:root {
  color-scheme: light;
  --bg: #eef0f3;
  --sidebar: #e5e8ec;
  --list: #f4f5f7;
  --paper: #ffffff;
  --paper-muted: #fafafa;
  --ink: #282b31;
  --muted: #7c818a;
  --faint: #aeb2b9;
  --line: rgba(36, 40, 48, .09);
  --line-strong: rgba(36, 40, 48, .15);
  --ruby: #9b111e;
  --ruby-strong: #7d0d17;
  --ruby-soft: rgba(155, 17, 30, .10);
  --shadow: 0 24px 70px rgba(26, 29, 35, .16), 0 4px 18px rgba(26, 29, 35, .07);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Iowan Old Style, "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, monospace;
  --ease: cubic-bezier(.22, .8, .2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16181c;
  --sidebar: #1d2025;
  --list: #202328;
  --paper: #181a1e;
  --paper-muted: #1c1f24;
  --ink: #eff0f2;
  --muted: #999ea7;
  --faint: #666c76;
  --line: rgba(255, 255, 255, .075);
  --line-strong: rgba(255, 255, 255, .14);
  --ruby: #d94a5f;
  --ruby-strong: #be3048;
  --ruby-soft: rgba(217, 74, 95, .15);
  --shadow: 0 28px 80px rgba(0, 0, 0, .34), 0 4px 18px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; -webkit-font-smoothing: antialiased; }
button, input, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
kbd { font: 500 .67rem var(--mono); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--ruby) 34%, transparent); outline-offset: 2px; }
.hidden { display: none !important; }
.svg-sprite { position: fixed; width: 0; height: 0; overflow: hidden; }

.app-shell { display: grid; grid-template-columns: 236px 344px minmax(440px, 1fr); height: 100dvh; min-width: 0; overflow: hidden; background: var(--paper); }
.sidebar, .note-browser, .editor { min-width: 0; min-height: 0; }

.sidebar { position: relative; display: flex; flex-direction: column; padding: 18px 12px 13px; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--sidebar) 95%, transparent); }
.brand-row { display: flex; align-items: center; height: 34px; padding: 0 7px; gap: 10px; }
.brand-row strong { font-size: .88rem; font-weight: 680; letter-spacing: -.012em; }
.sidebar-close { margin-left: auto; }
.brand-icon { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px 8px 8px 3px; background: var(--ruby); color: white; box-shadow: 0 5px 12px rgba(155,17,30,.18); }
.brand-icon svg { width: 16px; height: 16px; stroke-width: 2; }

.new-note-button { display: flex; align-items: center; width: 100%; height: 40px; margin: 18px 0 11px; padding: 0 10px; gap: 8px; border: 0; border-radius: 9px; background: var(--ruby); color: #fff; font-size: .88rem; font-weight: 680; box-shadow: 0 6px 16px rgba(155,17,30,.19); }
.new-note-button svg { width: 17px; height: 17px; stroke-width: 2.2; }
.new-note-button kbd { margin-left: auto; color: rgba(255,255,255,.7); }
.new-note-button:hover { background: var(--ruby-strong); transform: translateY(-1px); }

.nav-list { display: grid; gap: 2px; }
.nav-item, .folder-item { display: grid; grid-template-columns: 22px minmax(0,1fr) auto; align-items: center; width: 100%; min-height: 36px; padding: 5px 8px; gap: 7px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); text-align: left; font-size: .87rem; }
.nav-item svg, .folder-item svg { width: 17px; height: 17px; }
.nav-item b, .folder-item b { color: var(--faint); font-size: .7rem; font-weight: 600; }
.nav-item:hover, .folder-item:hover { background: color-mix(in srgb, var(--paper) 58%, transparent); color: var(--ink); }
.nav-item.active, .folder-item.active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 5px rgba(25,29,36,.05); }
.nav-item.active svg { color: var(--ruby); }

.sidebar-section { margin-top: 20px; min-height: 0; }
.section-label { display: flex; align-items: center; justify-content: space-between; height: 28px; padding: 0 8px; color: var(--faint); font-size: .69rem; font-weight: 720; letter-spacing: .055em; text-transform: uppercase; }
.section-label button { display: grid; place-items: center; width: 25px; height: 25px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); }
.section-label button:hover { background: var(--paper); }
.section-label svg { width: 14px; height: 14px; }
.folder-nav { display: grid; gap: 1px; }
.folder-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item i { width: 9px; height: 9px; margin-left: 3px; border-radius: 3px 3px 3px 1px; background: color-mix(in srgb, var(--ruby) 74%, var(--paper)); }
.tags-section { overflow: hidden; }
.tag-cloud { display: flex; flex-wrap: wrap; padding: 3px 7px; gap: 5px; }
.tag-cloud button { max-width: 100%; padding: 4px 7px; overflow: hidden; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: .7rem; text-overflow: ellipsis; white-space: nowrap; }
.tag-cloud button:hover, .tag-cloud button.active { border-color: color-mix(in srgb, var(--ruby) 25%, var(--line)); background: var(--ruby-soft); color: var(--ruby); }

.sidebar-footer { display: grid; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); gap: 2px; }
.sidebar-footer button { display: flex; align-items: center; min-height: 35px; padding: 5px 8px; gap: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .79rem; text-align: left; }
.sidebar-footer button:hover { background: var(--paper); color: var(--ink); }
.sidebar-footer svg { width: 16px; height: 16px; }

.note-browser { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--list); }
.browser-head { display: flex; align-items: flex-end; min-height: 112px; padding: 28px 24px 15px; }
.browser-head > div { min-width: 0; }
.browser-head span { color: var(--ruby); font-size: .67rem; font-weight: 760; letter-spacing: .075em; text-transform: uppercase; }
.browser-head h1 { margin: 5px 0 0; overflow: hidden; font-size: 1.65rem; font-weight: 720; letter-spacing: -.04em; text-overflow: ellipsis; white-space: nowrap; }
.mobile-icon { display: none; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 9px; background: transparent; }
.mobile-icon:hover { background: var(--paper); }
.mobile-new { margin-left: auto; background: var(--ruby); color: white; }

.search-field { display: flex; align-items: center; height: 38px; margin: 0 16px 14px; padding: 0 10px; gap: 8px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--paper) 78%, transparent); color: var(--faint); }
.search-field:focus-within { border-color: color-mix(in srgb, var(--ruby) 32%, var(--line)); box-shadow: 0 0 0 3px var(--ruby-soft); }
.search-field svg { width: 16px; height: 16px; }
.search-field input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: .82rem; }
.search-field input::placeholder { color: var(--faint); }
.search-field kbd { color: var(--faint); }
.list-summary { display: flex; align-items: center; justify-content: space-between; padding: 0 19px 8px; color: var(--faint); font-size: .69rem; }
.list-summary button { padding: 3px; border: 0; background: transparent; color: var(--muted); font-size: inherit; }

.note-list { flex: 1; overflow-y: auto; padding: 0 10px 22px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.note-card { position: relative; width: 100%; min-height: 112px; padding: 14px 14px 13px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.note-card:first-child { border-radius: 11px 11px 0 0; }
.note-card:hover { background: color-mix(in srgb, var(--paper) 58%, transparent); }
.note-card.active { z-index: 1; border-bottom-color: transparent; border-radius: 11px; background: var(--paper); box-shadow: 0 4px 18px rgba(31,35,43,.08); }
.note-card .card-top { display: flex; align-items: center; gap: 6px; }
.note-card h2 { margin: 0; overflow: hidden; flex: 1; font: 700 .93rem/1.25 var(--sans); letter-spacing: -.012em; text-overflow: ellipsis; white-space: nowrap; }
.note-card .pin { width: 13px; height: 13px; color: var(--ruby); }
.note-card p { display: -webkit-box; min-height: 2.75em; margin: 7px 0 9px; overflow: hidden; color: var(--muted); font: 400 .79rem/1.38 var(--serif); -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.note-card footer { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: .65rem; }
.note-card footer .folder-chip { overflow: hidden; color: var(--ruby); text-overflow: ellipsis; white-space: nowrap; }
.note-card footer time { margin-left: auto; white-space: nowrap; }
.list-empty { display: grid; place-items: center; padding: 70px 30px; color: var(--muted); text-align: center; }
.list-empty svg { width: 28px; height: 28px; margin-bottom: 12px; color: var(--faint); }
.list-empty strong { color: var(--ink); font-size: .9rem; }
.list-empty p { max-width: 220px; margin: 6px 0 0; font: .83rem/1.5 var(--serif); }

.editor { position: relative; background: var(--paper); }
.editor-empty { display: grid; place-content: center; justify-items: center; height: 100%; padding: 30px; text-align: center; }
.empty-mark { position: relative; display: grid; place-items: center; width: 72px; height: 82px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 8px 18px 8px 8px; background: var(--paper-muted); color: var(--ruby); transform: rotate(-2deg); box-shadow: 10px 12px 0 color-mix(in srgb, var(--ruby-soft) 48%, transparent); }
.empty-mark::after { content: ""; position: absolute; top: 17px; bottom: 17px; left: 13px; width: 2px; border-radius: 2px; background: var(--ruby); opacity: .55; }
.empty-mark svg { width: 30px; height: 30px; margin-left: 8px; }
.editor-empty h2 { margin: 0; font: 600 1.35rem/1.25 var(--serif); }
.editor-empty p { max-width: 320px; margin: 8px 0 18px; color: var(--muted); font: .9rem/1.5 var(--serif); }
.editor-empty button, .primary-button { min-height: 39px; padding: 0 15px; border: 0; border-radius: 9px; background: var(--ruby); color: #fff; font-size: .82rem; font-weight: 700; }

.editor-document { display: flex; flex-direction: column; height: 100%; }
.editor-bar { display: flex; align-items: center; min-height: 54px; padding: 8px 18px; border-bottom: 1px solid var(--line); }
.save-status { display: inline-flex; align-items: center; margin-left: 8px; gap: 6px; color: var(--faint); font-size: .69rem; }
.save-status i { width: 6px; height: 6px; border-radius: 50%; background: #32a873; }
.save-status.saving i { background: #d6a23d; }
.editor-actions { display: flex; margin-left: auto; gap: 2px; }
.editor-actions button, .format-bar button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.editor-actions button:hover, .format-bar button:hover { background: var(--paper-muted); color: var(--ink); }
.editor-actions button.active { background: var(--ruby-soft); color: var(--ruby); }
.editor-actions svg { width: 17px; height: 17px; }

.paper { position: relative; display: flex; flex-direction: column; width: min(820px, calc(100% - 64px)); height: calc(100% - 100px); margin: 0 auto; padding: 62px 64px 34px 79px; }
.paper-thread { position: absolute; top: 56px; bottom: 36px; left: 47px; width: 1px; background: color-mix(in srgb, var(--ruby) 36%, transparent); }
.paper-thread span { position: absolute; top: 9px; left: -4px; width: 9px; height: 9px; border-radius: 50%; background: var(--ruby); box-shadow: 0 0 0 5px var(--ruby-soft); }
.note-title { width: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: 600 clamp(1.85rem, 4vw, 2.55rem)/1.15 var(--serif); letter-spacing: -.035em; }
.note-title::placeholder { color: var(--faint); }
.note-meta-row { display: flex; align-items: center; min-height: 36px; margin-top: 14px; gap: 4px; }
.note-meta-row button, .tag-editor { display: flex; align-items: center; min-width: 0; height: 30px; padding: 0 7px; gap: 5px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: .72rem; }
.note-meta-row button:hover { background: var(--paper-muted); color: var(--ink); }
.note-meta-row svg { width: 14px; height: 14px; }
.tag-editor { flex: 1; }
.tag-editor input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: inherit; }
.tag-editor input::placeholder { color: var(--faint); }
.format-bar { display: flex; align-items: center; height: 40px; margin: 7px 0 12px; padding: 0 2px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); gap: 1px; }
.format-bar button { width: 31px; height: 30px; }
.format-bar button span { font: 700 .8rem var(--serif); }
.format-bar svg { width: 15px; height: 15px; }
.format-bar > span { margin-left: auto; color: var(--faint); font-size: .64rem; }
.note-body { width: 100%; min-height: 0; flex: 1; padding: 2px 0 80px; resize: none; border: 0; outline: 0; background: transparent; color: var(--ink); font: 400 1.04rem/1.75 var(--serif); caret-color: var(--ruby); }
.note-body::placeholder { color: var(--faint); }
.editor-footer { position: absolute; right: 0; bottom: 0; left: 0; display: flex; align-items: center; justify-content: space-between; min-height: 42px; padding: 0 25px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 93%, transparent); color: var(--faint); font-size: .65rem; backdrop-filter: blur(14px); }

.app-dialog { width: min(440px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.app-dialog::backdrop { background: rgba(18,20,24,.30); backdrop-filter: blur(4px); }
.app-dialog > header, .app-dialog form > header { display: flex; align-items: center; padding: 19px 20px 14px; border-bottom: 1px solid var(--line); }
.app-dialog header div { display: grid; gap: 3px; }
.app-dialog header span { color: var(--ruby); font-size: .65rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.app-dialog header strong { font: 600 1.1rem var(--serif); }
.dialog-close { display: grid; place-items: center; width: 34px; height: 34px; margin-left: auto; padding: 0; border: 0; border-radius: 8px; background: transparent; }
.dialog-close:hover { background: var(--paper-muted); }
.dialog-close svg { width: 17px; height: 17px; }
.app-dialog form > label { display: grid; padding: 20px; gap: 7px; color: var(--muted); font-size: .72rem; font-weight: 650; }
.app-dialog input { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px; outline: 0; background: var(--paper-muted); }
.app-dialog input:focus { border-color: color-mix(in srgb, var(--ruby) 40%, var(--line)); box-shadow: 0 0 0 3px var(--ruby-soft); }
.app-dialog form > footer { display: flex; justify-content: flex-end; padding: 0 20px 20px; gap: 7px; }
.secondary-button { min-height: 39px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 9px; background: transparent; color: var(--muted); font-size: .82rem; font-weight: 650; }
.picker-list { display: grid; max-height: 340px; padding: 9px; overflow-y: auto; gap: 2px; }
.picker-list button { display: flex; align-items: center; min-height: 40px; padding: 0 10px; gap: 9px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
.picker-list button:hover, .picker-list button.active { background: var(--ruby-soft); color: var(--ruby); }
.picker-list svg { width: 16px; height: 16px; }
.settings-dialog section { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.settings-dialog h3 { margin: 0 0 10px; font-size: .74rem; }
.settings-dialog p { margin: 0 0 12px; color: var(--muted); font: .82rem/1.5 var(--serif); }
.theme-options { display: grid; grid-template-columns: repeat(3,1fr); padding: 3px; border-radius: 10px; background: var(--paper-muted); }
.theme-options button { min-height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .73rem; }
.theme-options button.active { background: var(--paper); color: var(--ruby); box-shadow: 0 1px 5px rgba(20,24,30,.08); }
.settings-actions { display: grid; gap: 7px; }
.settings-actions button, .settings-actions label { display: flex; align-items: center; min-height: 57px; padding: 8px 10px; gap: 10px; border: 1px solid var(--line); border-radius: 10px; background: transparent; cursor: pointer; }
.settings-actions button:hover, .settings-actions label:hover { background: var(--paper-muted); }
.settings-actions svg { color: var(--ruby); }
.settings-actions span { display: grid; gap: 2px; text-align: left; }
.settings-actions strong { font-size: .77rem; }
.settings-actions small { color: var(--muted); font-size: .67rem; }
.settings-actions input { display: none; }
.install-button { width: calc(100% - 40px); min-height: 40px; margin: 16px 20px 20px; border: 0; border-radius: 9px; background: var(--ruby); color: white; font-size: .78rem; font-weight: 700; }

.toast-region { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow); font-size: .75rem; animation: toast-in .25s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 220px 300px minmax(0, 1fr); }
  .paper { width: calc(100% - 28px); padding-right: 35px; padding-left: 68px; }
}

@media (max-width: 800px) {
  .app-shell { position: relative; display: block; }
  .sidebar, .note-browser, .editor { position: absolute; inset: 0; width: 100%; transition: opacity .18s ease, transform .28s var(--ease); }
  .sidebar { z-index: 3; max-width: none; }
  .note-browser { z-index: 2; }
  .editor { z-index: 4; }
  .mobile-icon { display: grid; }
  .sidebar .mobile-icon { display: grid; }
  .browser-head { align-items: center; min-height: 92px; padding: 24px 16px 12px; gap: 11px; }
  .browser-head h1 { font-size: 1.45rem; }
  .app-shell[data-mobile-pane="menu"] .note-browser, .app-shell[data-mobile-pane="menu"] .editor { opacity: 0; pointer-events: none; transform: translateX(34px); }
  .app-shell[data-mobile-pane="list"] .sidebar { opacity: 0; pointer-events: none; transform: translateX(-34px); }
  .app-shell[data-mobile-pane="list"] .editor { opacity: 0; pointer-events: none; transform: translateX(34px); }
  .app-shell[data-mobile-pane="editor"] .sidebar, .app-shell[data-mobile-pane="editor"] .note-browser { opacity: 0; pointer-events: none; transform: translateX(-34px); }
  .paper { width: 100%; height: calc(100% - 96px); padding: 38px 25px 25px 42px; }
  .paper-thread { top: 36px; bottom: 28px; left: 24px; }
  .note-title { font-size: 1.85rem; }
  .format-bar > span { display: none; }
  .editor-bar { min-height: 54px; padding-inline: 9px; }
  .save-status { margin-left: 4px; }
  .editor-footer { padding-inline: 15px; }
  .note-card { min-height: 105px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
