/* Interface 1.3 — surfaces are independent so navigation never blends together. */
:root {
  --bg: #101722;
  --bar: #172c48;
  --sidebar: #202c3d;
  --footer: #29384b;
  --bg-elevated: #263448;
  --bg-card: #263448;
  --bg-card-hover: #31425a;
  --border: #53657e;
  --border-soft: #3b4c63;
  --text: #f1f5fb;
  --text-dim: #c0cdde;
  --text-faint: #a8b9cf;
  --bar-text: #f5f8ff;
  --bar-text-dim: #c4d5eb;
  --accent: #8bc9ff;
  --accent-fill: #91cdff;
  --accent-ink: #102944;
  --selected: #324b65;
  --brass: #a6d6ff;
  --brass-bright: #b8dfff;
  --brass-dim: #55738d;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f2f5fa;
  --bar: #193b62;
  --sidebar: #e3ebf5;
  --footer: #d5e2f0;
  --bg-elevated: #f7f9fc;
  --bg-card: #ffffff;
  --bg-card-hover: #edf4fc;
  --border: #95a9c2;
  --border-soft: #c5d1e1;
  --text: #192e49;
  --text-dim: #415b79;
  --text-faint: #526a86;
  --accent: #174f87;
  --accent-fill: #205f9f;
  --accent-ink: #ffffff;
  --selected: #cadcf1;
  --brass: #24598a;
  --brass-bright: #174f87;
  --brass-dim: #7795b4;
  color-scheme: light;
}
html, body { width: 100%; }
body { -webkit-text-size-adjust: 100%; }
/* Existing fixed inset:0 fills the viewport correctly even with app text zoom. */
.screen { height: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
button:focus-visible, [role="button"]:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 3px;
}
.topbar :focus-visible, .editor-topbar :focus-visible { outline-color: #b8dfff; }
.topbar, .editor-topbar {
  background: var(--bar);
  border-bottom: 1px solid #7090b6;
  box-shadow: 0 2px 8px #09152524;
  padding: max(12px, env(safe-area-inset-top)) 20px 12px !important;
  gap: 18px;
  z-index: 5;
}
.topbar-brand { min-height: 44px; gap: 10px; flex-shrink: 0; }
.brand-logo-sm { width: 34px; height: 34px; object-fit: contain; }
[data-brand="nexgen"] .brand-name { color: #f5f9ff; -webkit-text-fill-color: #f5f9ff; background: none; text-shadow: none; font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.topbar-search { max-width: 650px; margin-left: auto; }
.topbar-search #search-input { min-height: 44px; font-size: 15px; border: 1px solid #7792b2; border-radius: 10px; background: #ffffff12; color: #fff; }
.topbar-search #search-input::placeholder { color: #c5d6eb; opacity: 1; }
.topbar-actions { margin-left: 0; gap: 8px; }
.topbar-actions .btn-icon, .editor-actions .btn-icon, .btn-icon, .btn-clear { min-width: 44px; min-height: 44px; }
.topbar-actions .btn-new-note {
  width: auto !important; height: 44px !important; padding: 0 14px; gap: 8px;
  color: #143555 !important; background: #b9dfff; border-radius: 10px; font-size: 24px !important;
}
.new-note-label { font-size: 14px; font-weight: 700; white-space: nowrap; }
.layout { overflow: hidden; }
.sidebar { width: 228px; background: var(--sidebar); border-right: 1px solid var(--border); padding: 22px 12px; }
.sidebar::before { content: "LIBRARY"; display: block; margin: 0 12px 14px; color: var(--text-dim); font-size: 11px; font-weight: 750; letter-spacing: 1.6px; }
.sidebar .category-item { color: var(--text-dim); min-height: 46px; padding: 10px 12px; margin-bottom: 4px; border: 1px solid transparent; border-radius: 9px; font-size: 14px; }
.sidebar .category-item:hover { color: var(--text); background: var(--bg-card-hover); }
.sidebar .category-item.active { color: var(--accent); background: var(--selected); border-color: var(--border); font-weight: 700; }
.category-item .count { color: var(--text-dim); border-radius: 5px; padding: 2px 5px; font-size: 12px; }
.sidebar-toggle { width: 20px; background: var(--sidebar); color: var(--text-dim); border-right: 1px solid var(--border); }
.sidebar-toggle:hover { background: var(--selected); }
.notes-panel { min-width: 0; padding: 0 26px 30px !important; background: var(--bg); scrollbar-gutter: stable; }
.notes-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; padding: 24px 0 20px; }
.view-context { display: flex !important; flex-direction: column; align-items: flex-start; gap: 5px; margin: 0; min-width: 0; color: var(--text); }
#view-context-title { font-size: 25px; font-weight: 700; letter-spacing: -.7px; margin: 0; overflow-wrap: anywhere; }
#view-context-count { color: var(--text-dim); font-size: 13px; }
.notes-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.toolbar-button, .sort-control select { min-height: 44px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-card); color: var(--text); font-size: 13px; font-weight: 550; }
.toolbar-button:hover { background: var(--bg-card-hover); }
.toolbar-button span { margin-right: 5px; }
.sort-control select { max-width: 170px; }
.view-switch { display: flex; padding: 3px; background: var(--sidebar); border: 1px solid var(--border); border-radius: 10px; }
.view-switch .view-opt { width: 42px; min-height: 38px; border-radius: 6px; font-size: 20px; color: var(--text-dim); }
.view-switch .view-opt.active { background: var(--bg-card); color: var(--accent); box-shadow: 0 1px 4px #09152520; }
.notes-list.view-list { gap: 7px !important; }
.notes-list.view-grid, .notes-list.view-tile { gap: 14px !important; align-content: start; }
.notes-list.view-grid { grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr)); }
.notes-list.view-tile { grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)) !important; }
.note-card { border: 1px solid var(--border-soft); border-left: 4px solid var(--cat-color) !important; border-radius: 9px !important; background: var(--bg-card); box-shadow: 0 2px 3px #09152509; transition: background .14s, border-color .14s, box-shadow .14s; }
.note-card[data-color]:not([data-color="default"]) { background: color-mix(in srgb, var(--cat-color) 18%, var(--bg-card)); }
.note-card:hover { background: var(--bg-card-hover); border-color: var(--border); box-shadow: 0 3px 10px #09152514; }
.note-card[data-color]:not([data-color="default"]):hover { background: color-mix(in srgb, var(--cat-color) 25%, var(--bg-card)); }
.notes-list.view-list .note-card { min-height: 60px; padding: 12px 16px; }
.note-row-title { font-size: 15px; font-weight: 600; }
.note-row-date { font-size: 12px; color: var(--text-dim); }
.note-row-category { color: var(--text-dim); }
.notes-list.view-grid .note-card { min-height: 174px; padding: 18px; }
.notes-list.view-tile .note-card { padding: 16px; }
.note-card-title { font-size: 17px; line-height: 1.4; font-weight: 650; }
.note-card-preview { color: var(--text-dim); font-family: var(--font-ui); line-height: 1.65; }
.note-card-meta { color: var(--text-dim); font-size: 12px; padding-top: 12px; }
.note-card.entering { animation: none; }
.note-card.selected { outline: 3px solid var(--accent); outline-offset: -2px; }
.home-footer { position: static; flex-shrink: 0; background: var(--footer); color: var(--text); border-top: 1px solid var(--border); box-shadow: 0 -2px 8px #0915250a; padding: 5px max(16px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); gap: 12px; }
.home-footer .hf-btn { min-height: 52px; min-width: 64px; max-width: 180px; border-radius: 9px; color: var(--text-dim); gap: 5px; }
.home-footer .hf-btn:hover, .home-footer .hf-btn.active { background: var(--selected); color: var(--accent); }
.home-footer .hf-lb { font-size: 12px; font-weight: 600; }
.home-footer .hf-ic { font-size: 21px; }
.editor-topbar { flex-wrap: wrap; }
.editor-title-wrap { flex-basis: 180px; }
.editor-title-input { font-size: 20px; min-height: 38px; }
.editor-meta-top { font-size: 12px; }
.editor-content-wrap, .checklist-editor { border-left: 1px solid var(--border-soft); border-right: 1px solid var(--border-soft); width: min(100%, 980px); margin-inline: auto; }
.editor-textarea, .editor-highlight-overlay { padding-left: 24px !important; padding-right: 24px !important; }
.editor-footer { color: var(--text-dim); background: var(--footer); border-top: 1px solid var(--border); padding-bottom: max(10px, env(safe-area-inset-bottom)); min-height: 62px; flex-wrap: wrap; }
.editor-footer .btn-text, .editor-footer .due-control { color: var(--text-dim); }
.editor-footer .btn-text:hover { color: var(--accent); }
.editor-footer button, .editor-footer input { min-height: 44px; }
.checklist-row { min-height: 52px; border-bottom-color: var(--border-soft); }
.checklist-row .chk-toggle, .checklist-row .chk-remove { min-width: 44px; min-height: 44px; }
.checklist-row .chk-text { font-size: 16px; }
.checklist-row .chk-box { width: 24px; height: 24px; margin: 10px; flex-shrink: 0; }
.checklist-row .chk-view { min-height: 44px; display: flex; align-items: center; }
.checklist-row.editing .chk-view { display: none; }
.ui-icon { width: 21px; height: 21px; display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dropdown, .note-context-menu { border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 35px #09152545; max-height: calc(100dvh - 150px); overflow-y: auto; }
.dropdown button, .note-context-menu button { min-height: 44px; }
.dropdown { top: 72px; }
.modal { padding: 18px; }
.modal-card { max-width: 460px; border-color: var(--border); border-radius: 16px; padding: 26px; max-height: calc(100dvh - 36px); overflow-y: auto; }
.modal-card h2 { font-size: 22px; letter-spacing: -.3px; }
.modal-card button, .modal-card select, .modal-card input:not([type="checkbox"]), .side-sheet button { min-height: 44px; }
.modal-sub { font-size: 14px; line-height: 1.6; }
.setting-row { gap: 12px; flex-wrap: wrap; padding-block: 14px; }
.setting-row select { max-width: 100%; }
.side-sheet { background: var(--sidebar); border-right: 1px solid var(--border); }
.drawer-item { min-height: 46px; }
.auth-card { background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: 20px; box-shadow: 0 16px 60px #0915251a; }
.auth-choice { border: 1px solid var(--border-soft); border-radius: 12px; padding: 18px; }
.auth-heading { letter-spacing: -.7px; }
.auth-sub { color: var(--text-dim); }
.btn-primary { background: var(--accent-fill); color: var(--accent-ink); border-radius: 9px; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent-fill); }
.empty-state { text-align: center; padding: 60px 16px; max-width: 460px; margin: auto; color: var(--text-dim); }
.empty-symbol { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 20px; border: 1px solid var(--border); background: var(--sidebar); color: var(--accent); border-radius: 18px; font-size: 32px; }
.empty-state h2 { color: var(--text); font-size: 22px; letter-spacing: -.5px; }
.empty-state p { line-height: 1.6; font-size: 14px; }
.empty-state .toolbar-button { margin-top: 12px; color: var(--accent); }
@media (min-width: 721px) and (max-width: 1100px) {
  .sidebar { width: 190px; padding-inline: 8px; }
  .topbar { gap: 12px; }
  .new-note-label { display: none; }
  .notes-panel { padding-inline: 18px !important; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 14px 12px !important; }
  .topbar-brand .brand-name { display: inline !important; font-size: 17px; }
  .topbar-brand .brand-caret { display: none; }
  .topbar-actions { margin-left: auto; gap: 2px; }
  .new-note-label { display: none; }
  .topbar-actions .btn-new-note { width: 44px !important; padding: 0; }
  .topbar-search { order: 3; flex: 1 0 100%; max-width: none; }
  .topbar-search #search-input { font-size: 16px; }
  .notes-panel { padding: 0 14px 18px !important; scrollbar-gutter: auto; }
  .notes-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 20px 0 16px; gap: 14px; }
  #view-context-title { font-size: 24px; }
  .notes-tools { display: contents; }
  .notes-tools .toolbar-button { grid-column: 1; grid-row: 2; justify-self: start; }
  .toolbar-button, .sort-control select { padding-inline: 10px; font-size: 12px; }
  .sort-control { grid-column: 2; grid-row: 2; width: 158px; min-width: 0; }
  .sort-control select { width: 100%; max-width: none; }
  .view-switch { grid-column: 2; grid-row: 1; justify-self: end; }
  .view-switch .view-opt { width: 44px; min-height: 44px; }
  .notes-list.view-tile { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .notes-list.view-grid, .notes-list.view-tile { gap: 10px !important; }
  .notes-list.view-tile .note-card { padding: 12px; }
  .notes-list.view-tile .note-card-title { font-size: 15px; }
  .notes-list.view-tile .note-card-preview { -webkit-line-clamp: 3; font-size: 13px; }
  .notes-list.view-tile .note-card-meta { margin-top: auto; font-size: 11px; }
  .notes-list.view-list .note-card { padding: 13px 12px; min-height: 58px; }
  .note-row-category { display: none; }
  .home-footer { gap: 0; padding-inline: 4px; }
  .home-footer .hf-btn { min-width: 58px; }
  .sel-footer .hf-btn { flex: 0 0 66px; }
  .editor-topbar { gap: 4px; padding: max(8px, env(safe-area-inset-top)) 10px 8px !important; }
  .editor-title-wrap { flex: 1 1 calc(100% - 52px); }
  .editor-actions { width: 100%; justify-content: flex-end; border-top: 1px solid #7090b670; padding-top: 5px; }
  .editor-title-input { font-size: 18px; }
  .editor-footer { padding-inline: 12px; gap: 5px !important; }
  .editor-textarea, .editor-highlight-overlay { padding-left: 16px !important; padding-right: 16px !important; }
  .dropdown { top: 66px; right: 12px; max-width: calc(100vw - 24px); }
  .modal { padding: 12px; align-items: center; }
  .modal-card { padding: 22px; max-height: calc(100dvh - 24px); }
  .auth-card { padding: 24px 18px; }
  .empty-state { padding-top: 36px; }
}
@media (max-width: 380px) {
  .topbar-brand .brand-name { font-size: 15px; }
  .brand-logo-sm { width: 28px; height: 28px; }
  .topbar { gap: 5px; padding-inline: 10px !important; }
  .view-switch .view-opt { width: 44px; }
  .notes-tools { gap: 5px; }
  .toolbar-button, .sort-control select { padding-inline: 7px; }
  .notes-list.view-tile .note-card-preview { -webkit-line-clamp: 2; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .note-card, .sidebar, .topbar, .home-footer, .toolbar-button, .view-switch { border: 1px solid CanvasText; }
  .category-item.active, .view-opt.active { outline: 2px solid Highlight; }
}

.editor-stats { display: block; font-size: 12px; line-height: 1.4; color: #d4e5f6; font-variant-numeric: tabular-nums; white-space: normal; }
