/* 360GS_WEBNOTES - Shared dark UI (Tasks 5, 6d-6f)
 * Dark Bootstrap 5.3 styling for the workspace shell (/app), the public
 * sign-in page (/login) and the protected user guide (/help). Component
 * styling is scoped below the top-level page elements (body.app-shell-page,
 * body.login-page, .help-page) so the individual pages never clash. */

:root {
    color-scheme: dark;
    --wn-bg: #14141f;
    --wn-panel: #1b1b2a;
    --wn-panel-2: #212136;
    --wn-border: #2e2e48;
    --wn-text: #d6d6e4;
    --wn-muted: #8c8ca6;
    --wn-accent: #7aa2f7;
    --wn-accent-contrast: #0f1117;
    --wn-danger: #f7768e;
    --wn-success: #9ece6a;
    --wn-warn: #e0af68;
    --wn-font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

html, body {
    height: 100%;
}

body.app-shell-page {
    margin: 0;
    overflow: hidden;
    background: var(--wn-bg);
    color: var(--wn-text);
    font-size: 0.925rem;
}

/* ------------------------------------------------------------------ layout */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

.app-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--wn-bg);
}

.editor-host {
    flex: 1 1 auto;
    position: relative;
    min-height: 0;
}

/* ------------------------------------------------------------------ topbar */
.app-topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0 0.6rem;
    height: 3rem;
    background: var(--wn-panel-2);
    border-bottom: 1px solid var(--wn-border);
    z-index: 30;
}

.app-topbar-start,
.app-topbar-end {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.app-logo {
    color: var(--wn-accent);
    font-size: 1.35rem;
}

.app-brand-name {
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.app-brand-version {
    color: var(--wn-muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

.app-topbar-btn {
    --bs-btn-color: var(--wn-text);
    --bs-btn-border-color: var(--wn-border);
    --bs-btn-hover-bg: var(--wn-panel);
    --bs-btn-hover-border-color: var(--wn-accent);
    --bs-btn-hover-color: var(--wn-text);
    white-space: nowrap;
}

.app-logout-form {
    display: inline-flex;
}

/* Task 7: export dropdown in the top bar. */
.app-export-dropdown .dropdown-menu {
    min-width: 15rem;
    font-size: 0.82rem;
    background: var(--wn-panel-2);
    border-color: var(--wn-border);
}

.app-export-menu .dropdown-header {
    color: var(--wn-muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.app-export-menu .dropdown-item {
    color: var(--wn-text);
    padding: 0.4rem 0.9rem;
}

.app-export-menu .dropdown-item:hover,
.app-export-menu .dropdown-item:focus {
    background: var(--wn-panel);
    color: var(--wn-text);
}

.app-export-menu .dropdown-item:disabled {
    opacity: 0.45;
    background: transparent;
    color: var(--wn-text);
}

.app-export-menu .app-export-context {
    display: block;
    padding: 0.1rem 0.9rem 0.35rem;
    font-size: 0.72rem;
    color: var(--wn-muted);
    white-space: normal;
}

.app-export-dropdown .dropdown-divider {
    border-color: var(--wn-border);
}

/* Task 7b: settings (dictation language) dropdown in the top bar. */
.app-settings-dropdown .dropdown-menu {
    min-width: 17rem;
    font-size: 0.82rem;
    background: var(--wn-panel-2);
    border-color: var(--wn-border);
}

.app-settings-menu .dropdown-header {
    color: var(--wn-muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.app-settings-menu .form-label {
    color: var(--wn-text);
}

.app-settings-menu .form-select {
    background-color: var(--wn-panel);
    border-color: var(--wn-border);
    color: var(--wn-text);
}

.app-settings-menu .form-select:focus {
    border-color: var(--wn-accent);
    box-shadow: 0 0 0 0.2rem rgba(122, 162, 247, 0.25);
}

.save-status {
    font-size: 0.78rem;
    color: var(--wn-muted);
    white-space: nowrap;
}

.save-status.is-dirty {
    color: var(--wn-warn);
}

.save-status.is-saved {
    color: var(--wn-success);
}

.save-status.is-error {
    color: var(--wn-danger);
}

/* ----------------------------------------------------------- login page (Task 6d)
 * Public /login page restyled to the dark app theme (qa-login-style): the app
 * top bar is reused as-is and the Bootstrap sign-in form sits centered on a
 * floating panel. */
body.login-page {
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--wn-bg);
    color: var(--wn-text);
    font-size: 0.925rem;
}

.login-main {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem 1rem;
}

.login-card {
    width: 100%;
    max-width: 24rem;
    background: var(--wn-panel);
    border: 1px solid var(--wn-border);
    border-radius: 12px;
    padding: 1.7rem 1.9rem;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.login-brand {
    text-align: center;
    margin-bottom: 1.1rem;
}

.login-brand-icon {
    font-size: 2.1rem;
    color: var(--wn-accent);
}

.login-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0.4rem 0 0;
    color: var(--wn-text);
}

.login-subtitle {
    font-size: 0.82rem;
    color: var(--wn-muted);
    margin: 0.2rem 0 0;
}

.login-card .form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--wn-muted);
}

.login-card .alert {
    font-size: 0.86rem;
}

.login-backlink {
    text-align: center;
    margin: 1.15rem 0 0;
    font-size: 0.84rem;
}

.login-backlink a {
    color: var(--wn-accent);
    text-decoration: none;
}

.login-backlink a:hover {
    text-decoration: underline;
}

.login-footer {
    flex: 0 0 auto;
    text-align: center;
    color: var(--wn-muted);
    font-size: 0.76rem;
    padding: 0.4rem 1rem 0.9rem;
}

/* -------------------------------------------------------------- help page (Task 6e)
 * Protected /help page reuses the full workspace shell (qa-help-style): the
 * guide scrolls inside its own pane and the rendered Markdown reuses the
 * shared .markdown-body typography, capped at a comfortable reading width. */
.help-page .qa-user-guide {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.5rem 2rem 4rem;
}

.help-page .qa-user-guide article {
    max-width: 54rem;
    margin: 0 auto;
}

.help-user {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--wn-muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

/* ------------------------------------------------------------------ sidebar */
.app-sidebar {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--wn-panel);
    border-right: 1px solid var(--wn-border);
}

/* ------------------------------------------------------- sidebar view tabs */
.sidebar-view-tabs {
    flex: 0 0 auto;
    display: flex;
    border-bottom: 1px solid var(--wn-border);
    background: var(--wn-panel-2);
}

.sidebar-view-tab {
    flex: 1 1 0;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    border: 0;
    background: transparent;
    color: var(--wn-muted);
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.5rem 0.2rem;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
}

.sidebar-view-tab .bi {
    font-size: 0.9rem;
}

.sidebar-view-tab:hover {
    color: var(--wn-text);
    background: var(--wn-panel);
}

.sidebar-view-tab.is-active {
    color: var(--wn-accent);
}

.sidebar-view-tab.is-active::after {
    content: "";
    position: absolute;
    left: 0.4rem;
    right: 0.4rem;
    bottom: 0;
    height: 2px;
    background: var(--wn-accent);
    border-radius: 2px 2px 0 0;
}

/* ---------------------------------------------------------- sidebar panes */
.sidebar-pane {
    display: none;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.sidebar-pane.is-active {
    display: flex;
}

.sidebar-toolbar {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.5rem 0.55rem;
    border-bottom: 1px solid var(--wn-border);
}

.sidebar-toolbar-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--wn-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* -------------------------------------------------------------- search box */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--wn-border);
    border-radius: 6px;
    background: var(--wn-bg);
    padding: 0.3rem 0.45rem;
}

.search-box:focus-within {
    border-color: var(--wn-accent);
    box-shadow: 0 0 0 1px rgba(122, 162, 247, 0.35);
}

.search-box-icon {
    color: var(--wn-muted);
    font-size: 0.8rem;
}

.search-box input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--wn-text);
    outline: none;
    font-size: 0.84rem;
    padding: 0;
}

.search-box input::-webkit-search-cancel-button {
    display: none;
}

.search-clear-btn {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    color: var(--wn-muted);
    line-height: 1;
    padding: 0.1rem 0.15rem;
}

.search-clear-btn:hover {
    color: var(--wn-text);
}

.search-case-label {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    color: var(--wn-muted);
    cursor: pointer;
    user-select: none;
}

.search-case-label input {
    accent-color: var(--wn-accent);
    margin: 0;
}

.sidebar-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid var(--wn-border);
}

.sidebar-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--wn-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.sidebar-actions {
    display: inline-flex;
    gap: 0.15rem;
}

.sidebar-icon-btn {
    --bs-btn-color: var(--wn-muted);
    --bs-btn-hover-color: var(--wn-text);
    --bs-btn-hover-bg: var(--wn-panel-2);
    line-height: 1;
    padding: 0.2rem 0.45rem;
}

.sidebar-foot {
    flex: 0 0 auto;
    padding: 0.4rem 0.7rem;
    border-top: 1px solid var(--wn-border);
}

.folder-tree {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.3rem 0 0.6rem;
}

/* ------------------------------------------------------- folder tree rows */
.tree-group,
.tree-group-inner {
    display: flex;
    flex-direction: column;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    height: 1.85rem;
    padding: 0 0.5rem;
    margin: 1px 0.4rem;
    border-radius: 6px;
    cursor: pointer;
    color: var(--wn-text);
    user-select: none;
    white-space: nowrap;
    position: relative;
}

.tree-row:hover {
    background: var(--wn-panel-2);
}

.tree-row.is-active {
    background: var(--wn-accent-soft, rgba(122, 162, 247, 0.16));
    color: var(--wn-accent);
}

.tree-row.is-folder > .tree-caret {
    color: var(--wn-muted);
    transition: transform 0.12s ease;
}

.tree-row.is-folder.is-open > .tree-caret {
    transform: rotate(90deg);
}

.tree-caret {
    flex: 0 0 auto;
    width: 1rem;
    text-align: center;
    font-size: 0.7rem;
}

.tree-icon {
    flex: 0 0 auto;
    width: 1.05rem;
    text-align: center;
    color: var(--wn-muted);
    font-size: 0.85rem;
}

.tree-row.is-folder .tree-icon {
    color: var(--wn-warn);
}

.tree-row.is-note .tree-icon {
    color: var(--wn-accent);
}

.tree-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.86rem;
}

.tree-row-folder-new {
    flex: 0 0 auto;
    opacity: 0;
    border: 0;
    background: transparent;
    color: var(--wn-muted);
    padding: 0 0.25rem;
    line-height: 1;
}

.tree-row:hover .tree-row-folder-new {
    opacity: 1;
}

.tree-row-folder-new:hover {
    color: var(--wn-accent);
}

.tree-children {
    display: none;
    padding-left: 0.95rem;
}

.tree-group.is-open > .tree-children {
    display: block;
}

.tree-empty {
    color: var(--wn-muted);
    font-size: 0.82rem;
    padding: 0.5rem 0.9rem;
}

.tree-notes-hidden {
    color: var(--wn-muted);
    font-size: 0.78rem;
    padding: 0.1rem 0.9rem 0.35rem;
    font-style: italic;
}

/* ------------ explorer drag & drop / clipboard markers (Task 6g)
 * qa-explorer-dnd - note rows are draggable (drop onto a folder row, its
 * children area or the empty root area moves the note), Ctrl+X marks a note
 * .is-cut until it is pasted. HTML5 drag & drop is a mouse interaction -
 * touch devices use the Ctrl+C/X/V keyboard shortcuts. */
.tree-row.is-note[draggable="true"] {
    cursor: grab;
}

.tree-row.is-note.is-dragging {
    opacity: 0.45;
    cursor: grabbing;
}

.tree-row.is-note.is-cut {
    opacity: 0.55;
}

.tree-row.is-note.is-cut.is-active {
    opacity: 0.75;
}

.tree-row.is-drop-target,
.tree-row.is-drop-target:hover {
    background: var(--wn-accent-soft, rgba(122, 162, 247, 0.22));
    box-shadow: inset 0 0 0 2px var(--wn-accent);
}

.folder-tree.is-drop-root {
    outline: 2px dashed var(--wn-accent);
    outline-offset: -6px;
    border-radius: 8px;
}

/* ------------ image drag & drop into the editor (Task 6h)
 * qa-image-dnd - images dropped or pasted into the editor are uploaded
 * (POST /api/assets) and inserted as Markdown image links at the caret.
 * While an image file hovers the editor pane, the host carries
 * .is-image-drop and shows an overlay hint. */
.editor-host.is-image-drop::after {
    content: "Drop image to insert";
    position: absolute;
    z-index: 5;
    inset: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--wn-accent);
    border-radius: 10px;
    background: rgba(20, 20, 31, 0.85);
    color: var(--wn-accent);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    pointer-events: none;
}

.search-context {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding: 0.35rem 0.55rem;
    border-bottom: 1px solid var(--wn-border);
    background: rgba(122, 162, 247, 0.06);
}

.search-context-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(122, 162, 247, 0.18);
    border: 1px solid rgba(122, 162, 247, 0.4);
    color: var(--wn-accent);
    border-radius: 999px;
    padding: 0.05rem 0.55rem;
    font-size: 0.76rem;
}

.search-context-tag button {
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    line-height: 1;
    opacity: 0.75;
}

.search-context-tag button:hover {
    opacity: 1;
}

.search-context-hint {
    color: var(--wn-muted);
    font-size: 0.74rem;
    font-style: italic;
}

/* --------------------------------------------------------- search results */
.search-results {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.25rem 0 0.6rem;
}

.search-result-group {
    padding-top: 0.35rem;
}

.search-result-folder {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.7rem 0.2rem;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--wn-muted);
}

.search-result-folder .bi {
    font-size: 0.75rem;
    color: var(--wn-warn);
}

.search-result {
    display: block;
    width: auto;
    margin: 1px 0.4rem;
    padding: 0.35rem 0.5rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--wn-text);
    text-align: left;
    cursor: pointer;
}

.search-result:hover {
    background: var(--wn-panel-2);
}

.search-result.is-active {
    background: var(--wn-accent-soft, rgba(122, 162, 247, 0.16));
}

.search-result-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.86rem;
    font-weight: 600;
    min-width: 0;
}

.search-result-title .bi {
    color: var(--wn-accent);
    font-size: 0.8rem;
    flex: 0 0 auto;
}

.search-result-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-path {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.7rem;
    color: var(--wn-muted);
    margin: 0.1rem 0 0 1.2rem;
}

.search-result-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.76rem;
    color: var(--wn-muted);
    line-height: 1.45;
    margin: 0.15rem 0 0 1.2rem;
    overflow-wrap: anywhere;
}

.search-result-excerpt mark,
.search-result-title mark {
    background: rgba(224, 175, 104, 0.32);
    color: #ffe0a3;
    border-radius: 2px;
    padding: 0 0.05em;
}

.search-result-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0.25rem 0 0 1.2rem;
}

.search-result-tag {
    font-size: 0.68rem;
    color: var(--wn-accent);
    background: rgba(122, 162, 247, 0.12);
    border: 1px solid rgba(122, 162, 247, 0.3);
    border-radius: 999px;
    padding: 0 0.45rem;
}

/* --------------------------------------------------------------- tag list */
.tags-list {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.4rem 0.35rem 0.6rem;
}

.tag-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--wn-text);
    border-radius: 6px;
    padding: 0.32rem 0.5rem;
    text-align: left;
    cursor: pointer;
}

.tag-pill:hover {
    background: var(--wn-panel-2);
}

.tag-pill .bi {
    color: var(--wn-accent);
    font-size: 0.85rem;
}

.tag-pill-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.84rem;
}

.tag-pill-count {
    flex: 0 0 auto;
    font-size: 0.7rem;
    color: var(--wn-muted);
    background: var(--wn-panel-2);
    border: 1px solid var(--wn-border);
    border-radius: 999px;
    padding: 0 0.5rem;
}

.sidebar-empty {
    color: var(--wn-muted);
    font-size: 0.8rem;
    padding: 0.6rem 0.9rem;
    line-height: 1.5;
}

/* ------------------------------------------------------------------ tabs */
.tab-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    height: 2.35rem;
    background: var(--wn-panel);
    border-bottom: 1px solid var(--wn-border);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.tab-bar::-webkit-scrollbar {
    height: 4px;
}

.tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 220px;
    min-width: 100px;
    padding: 0 0.35rem 0 0.65rem;
    border: 0;
    border-right: 1px solid var(--wn-border);
    background: transparent;
    color: var(--wn-muted);
    font-size: 0.82rem;
    cursor: pointer;
    position: relative;
}

.tab:hover {
    color: var(--wn-text);
    background: var(--wn-panel-2);
}

.tab.is-active {
    color: var(--wn-text);
    background: var(--wn-bg);
}

.tab.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--wn-accent);
}

.tab-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-dirty {
    color: var(--wn-warn);
    font-size: 0.7rem;
}

.tab-close {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    color: inherit;
    opacity: 0.55;
    padding: 0 0.25rem;
    border-radius: 4px;
    line-height: 1;
}

.tab:hover .tab-close,
.tab.is-active .tab-close {
    opacity: 1;
}

.tab-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--wn-danger);
}

/* ----------------------------------------------------------- pane toolbar */
.pane-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.35rem 0.6rem;
    background: var(--wn-panel);
    border-bottom: 1px solid var(--wn-border);
    min-height: 2.5rem;
}

.pane-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--wn-muted);
    min-width: 0;
}

.pane-path {
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--wn-font-mono);
    color: var(--wn-text);
}

.pane-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.mode-switch .btn {
    --bs-btn-color: var(--wn-muted);
    --bs-btn-border-color: var(--wn-border);
    --bs-btn-hover-bg: var(--wn-panel-2);
    --bs-btn-hover-color: var(--wn-text);
    --bs-btn-active-bg: var(--wn-accent);
    --bs-btn-active-color: var(--wn-accent-contrast);
    --bs-btn-active-border-color: var(--wn-accent);
}

.pane-actions .btn-outline-secondary {
    --bs-btn-color: var(--wn-muted);
    --bs-btn-border-color: var(--wn-border);
    --bs-btn-hover-bg: var(--wn-panel-2);
    --bs-btn-hover-color: var(--wn-text);
    --bs-btn-hover-border-color: var(--wn-muted);
}

.pane-actions .btn-outline-danger {
    --bs-btn-color: var(--wn-danger);
    --bs-btn-border-color: var(--wn-border);
    --bs-btn-hover-bg: rgba(247, 118, 142, 0.12);
    --bs-btn-hover-color: var(--wn-danger);
    --bs-btn-hover-border-color: var(--wn-danger);
}

.pane-actions .btn-primary {
    --bs-btn-bg: var(--wn-accent);
    --bs-btn-border-color: var(--wn-accent);
    --bs-btn-color: var(--wn-accent-contrast);
    --bs-btn-hover-bg: #93b0fa;
    --bs-btn-hover-border-color: #93b0fa;
    --bs-btn-hover-color: var(--wn-accent-contrast);
    --bs-btn-disabled-bg: var(--wn-border);
    --bs-btn-disabled-border-color: var(--wn-border);
    --bs-btn-disabled-color: var(--wn-muted);
}
/* --------------------------------------------------------- format toolbar */
.format-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0.3rem 0.6rem;
    background: var(--wn-panel);
    border-bottom: 1px solid var(--wn-border);
    overflow-x: auto;
}

.format-toolbar .btn {
    --bs-btn-color: var(--wn-muted);
    --bs-btn-hover-color: var(--wn-text);
    --bs-btn-hover-bg: var(--wn-panel-2);
    padding: 0.15rem 0.45rem;
    font-size: 0.8rem;
    line-height: 1;
}

.format-toolbar .btn .bi {
    font-size: 0.95rem;
}

.format-sep {
    width: 1px;
    height: 1.1rem;
    background: var(--wn-border);
    margin: 0 0.3rem;
    flex: 0 0 auto;
}

/* Task 7: speech-to-text toggle inside the format toolbar. */
.format-toolbar #btn-dictate.is-listening {
    color: var(--wn-danger);
    background: rgba(247, 118, 142, 0.14);
}

.format-toolbar #btn-dictate.is-listening .bi {
    animation: wn-mic-pulse 1.2s ease-in-out infinite;
}

.format-toolbar #btn-dictate:disabled {
    opacity: 0.45;
}

@keyframes wn-mic-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: 0.75; }
}

/* ------------------------------------------------------- editor / reader */
.note-editor,
.note-reader {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.note-editor {
    display: block;
    border: 0;
    outline: none;
    resize: none;
    padding: 1.1rem 1.4rem 4rem;
    background: var(--wn-bg);
    color: var(--wn-text);
    font-family: var(--wn-font-mono);
    font-size: 0.9rem;
    line-height: 1.65;
    tab-size: 4;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.note-editor:focus {
    box-shadow: inset 0 0 0 1px rgba(122, 162, 247, 0.35);
}

.note-editor::selection {
    background: rgba(122, 162, 247, 0.3);
}

.note-reader {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.4rem 1.8rem 4rem;
}

/* ----------------------------------------------------------- markdown body */
.markdown-body {
    font-size: 0.96rem;
    line-height: 1.7;
    color: var(--wn-text);
    /* qa-reader-fullwidth (Task 6c): rendered notes use the full available
       editor area - the former 46rem column cap was removed. */
}

.markdown-body > *:first-child {
    margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    color: var(--wn-text);
    font-weight: 600;
    line-height: 1.3;
    margin: 1.6em 0 0.5em;
}

.markdown-body h1 {
    font-size: 1.7rem;
    border-bottom: 1px solid var(--wn-border);
    padding-bottom: 0.3rem;
}

.markdown-body h2 {
    font-size: 1.3rem;
    border-bottom: 1px solid var(--wn-border);
    padding-bottom: 0.25rem;
}

.markdown-body h3 {
    font-size: 1.1rem;
}

.markdown-body a {
    color: var(--wn-accent);
}

.markdown-body blockquote {
    border-left: 3px solid var(--wn-accent);
    background: var(--wn-panel);
    margin: 1rem 0;
    padding: 0.05rem 1rem;
    color: var(--wn-muted);
    border-radius: 0 6px 6px 0;
}

.markdown-body code {
    background: var(--wn-panel-2);
    border: 1px solid var(--wn-border);
    border-radius: 4px;
    padding: 0.1em 0.35em;
    font-family: var(--wn-font-mono);
    font-size: 0.85em;
}

.markdown-body pre {
    background: var(--wn-panel-2);
    border: 1px solid var(--wn-border);
    border-radius: 6px;
    padding: 0.8rem 1rem;
    overflow: auto;
}

.markdown-body pre code {
    background: transparent;
    border: 0;
    padding: 0;
    font-size: 0.85rem;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.5rem;
}

.markdown-body li + li {
    margin-top: 0.2rem;
}

.markdown-body table {
    border-collapse: collapse;
    margin: 1rem 0;
    display: block;
    max-width: 100%;
    overflow-x: auto;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--wn-border);
    padding: 0.35rem 0.7rem;
}

.markdown-body th {
    background: var(--wn-panel);
}

.markdown-body hr {
    border-color: var(--wn-border);
    margin: 1.6rem 0;
}

.markdown-body img {
    max-width: 100%;
    border-radius: 6px;
}

.markdown-body .footnote-ref,
.markdown-body .footnote-backref {
    color: var(--wn-accent);
    text-decoration: none;
}

.markdown-body kbd {
    background: var(--wn-panel-2);
    border: 1px solid var(--wn-border);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: var(--wn-font-mono);
    padding: 0.1em 0.4em;
}
/* --------------------------------------------------------- empty state */
.empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.empty-state-inner {
    text-align: center;
    padding: 2rem;
    max-width: 30rem;
}

.empty-icon {
    font-size: 3rem;
    color: var(--wn-accent);
    opacity: 0.7;
}

.empty-state h1 {
    font-size: 1.3rem;
    margin-top: 0.8rem;
}

/* ------------------------------------------------------------- properties */
.app-properties {
    flex: 0 0 300px;
    overflow-y: auto;
    background: var(--wn-panel);
    border-left: 1px solid var(--wn-border);
    padding: 0.8rem 0.9rem 2rem;
}

.properties-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.7rem;
}

.properties-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--wn-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.properties-body {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.property-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.property-row label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--wn-muted);
    margin: 0;
}

.property-row .form-control,
.property-row .input-group {
    font-size: 0.86rem;
}

.tags-editor {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    border: 1px solid var(--wn-border);
    border-radius: 6px;
    background: var(--wn-panel-2);
    padding: 0.35rem 0.45rem;
    min-height: 2.2rem;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(122, 162, 247, 0.18);
    border: 1px solid rgba(122, 162, 247, 0.4);
    color: var(--wn-accent);
    border-radius: 999px;
    padding: 0.05rem 0.6rem;
    font-size: 0.78rem;
}

.tag-chip button {
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
}

.tag-chip button:hover {
    opacity: 1;
}

.tags-editor input {
    flex: 1 1 90px;
    border: 0;
    background: transparent;
    color: var(--wn-text);
    outline: none;
    font-size: 0.84rem;
    min-width: 60px;
}

.properties-divider {
    border-color: var(--wn-border);
    margin: 0.4rem 0;
}

.extra-prop-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    padding: 0.2rem 0;
}

.extra-prop-row .form-control {
    font-family: var(--wn-font-mono);
    font-size: 0.8rem;
}

.extra-prop-row .remove-extra {
    border: 0;
    background: transparent;
    color: var(--wn-muted);
    line-height: 1;
    padding: 0.2rem;
}

.extra-prop-row .remove-extra:hover {
    color: var(--wn-danger);
}

.extra-readonly {
    color: var(--wn-muted);
    font-size: 0.78rem;
    font-family: var(--wn-font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
}

.datalist-hint {
    color: var(--wn-muted);
    font-size: 0.7rem;
}
/* ------------------------------------------------------------------ toasts */
.toast-stack {
    position: fixed;
    right: 0.9rem;
    bottom: 0.9rem;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 26rem;
}

.wn-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: var(--wn-panel-2);
    border: 1px solid var(--wn-border);
    border-left: 3px solid var(--wn-accent);
    color: var(--wn-text);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    font-size: 0.86rem;
    animation: toast-in 0.16s ease-out;
}

.wn-toast.is-success {
    border-left-color: var(--wn-success);
}

.wn-toast.is-error {
    border-left-color: var(--wn-danger);
}

.wn-toast.is-warning {
    border-left-color: var(--wn-warn);
}

.wn-toast .bi {
    margin-top: 0.1rem;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ------------------------------------------------------------------ modal */
.modal-content {
    background: var(--wn-panel);
    border: 1px solid var(--wn-border);
    color: var(--wn-text);
}

.modal-header,
.modal-footer {
    border-color: var(--wn-border);
}

.modal-title {
    font-size: 1rem;
}

.modal .form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--wn-muted);
}

.modal .form-text {
    color: var(--wn-muted);
}

/* ------------------------------------------------------- scrollbars */
.app-sidebar::-webkit-scrollbar,
.folder-tree::-webkit-scrollbar,
.note-reader::-webkit-scrollbar,
.app-properties::-webkit-scrollbar,
.format-toolbar::-webkit-scrollbar,
.help-page .qa-user-guide::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

.app-sidebar::-webkit-scrollbar-thumb,
.folder-tree::-webkit-scrollbar-thumb,
.note-reader::-webkit-scrollbar-thumb,
.app-properties::-webkit-scrollbar-thumb,
.format-toolbar::-webkit-scrollbar-thumb,
.help-page .qa-user-guide::-webkit-scrollbar-thumb {
    background: var(--wn-border);
    border-radius: 8px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover,
.folder-tree::-webkit-scrollbar-thumb:hover,
.note-reader::-webkit-scrollbar-thumb:hover,
.app-properties::-webkit-scrollbar-thumb:hover,
.help-page .qa-user-guide::-webkit-scrollbar-thumb:hover {
    background: var(--wn-muted);
}

/* --------------------------------------- mobile sidebar drawer (Task 6f)
 * qa-sidebar-drawer: below the Bootstrap lg breakpoint (< 992 px) the explorer
 * sidebar (.app-sidebar) turns into an off-canvas drawer. The hamburger button
 * in the top bar opens it as an overlay (the editor keeps its full width - no
 * push layout). The drawer is closed by default on mobile and remembers its
 * state in localStorage ("webnotes.sidebar.open"). From 992 px upwards the
 * static sidebar from the base rules above stays unchanged. */
.app-sidebar-toggle {
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.2rem 0.5rem;
    color: var(--wn-text);
}

#sidebar-scrim {
    position: fixed;
    top: 3rem;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 35;
    background: rgba(9, 9, 16, 0.62);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

#sidebar-scrim.is-open {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        top: 3rem;
        bottom: 0;
        left: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 40;
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.22s ease, visibility 0.22s;
        box-shadow: 0 0 28px rgba(0, 0, 0, 0.55);
    }

    .app-sidebar.is-sidebar-open {
        transform: translateX(0);
        visibility: visible;
    }
}

/* small usability extras */
.btn:focus-visible,
.form-control:focus-visible {
    outline: 2px solid var(--wn-accent);
    outline-offset: 1px;
}

.note-editor[hidden],
.note-reader[hidden],
#pane-toolbar[hidden],
#format-toolbar[hidden],
#empty-state[hidden],
#app-properties[hidden],
.app-properties[hidden] {
    display: none !important;
}
/* ------------------------------------------------------------------ print */
@media print {
    body.app-shell-page {
        overflow: visible;
    }

    .app-shell,
    .app-body {
        height: auto;
        display: block;
    }

    .app-topbar,
    .app-sidebar,
    #sidebar-scrim,
    .tab-bar,
    .pane-toolbar,
    .format-toolbar,
    .app-properties,
    .toast-stack,
    #modal-root {
        display: none !important;
    }

    .editor-host {
        position: static;
    }

    .note-reader {
        position: static;
        overflow: visible;
        padding: 0;
        max-width: none;
    }

    .help-page .qa-user-guide {
        overflow: visible;
        padding: 0;
    }
}





