:root {
  color-scheme: light;
  --bg: #f4f5f5;
  --paper: #fff;
  --ink: #292d30;
  --muted: #6f777b;
  --soft: #7d8589;
  --line: #e7e9ea;
  --line-strong: #dcdfdf;
  --accent: #555d62;
  --accent-hover: #454c51;
  --accent-wash: #eef0f1;
  --warning: #946a32;
  --warning-bg: #fbf5e9;
  --danger: #a14c45;
  --danger-bg: #fbefed;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, [contenteditable="true"]:focus-visible, [tabindex]:focus-visible { outline: 2px solid #707b81; outline-offset: 3px; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 276px minmax(0, 1fr); gap: 16px; padding: 16px; }
.sidebar, .main-panel { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 15px; }
.sidebar { min-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.brand { height: 75px; padding: 0 21px; display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: white; background: var(--accent); font-size: 16px; font-weight: 600; }
.brand strong { display: block; font-size: 15px; letter-spacing: .02em; }
.brand small { display: block; margin-top: 3px; color: var(--soft); font-size: 9px; letter-spacing: .13em; }
.primary-button { min-height: 40px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s ease, border-color .15s ease; }
.primary-button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.new-note { margin: 0 14px 17px; }
.new-note span { font-size: 18px; line-height: 1; font-weight: 400; }
.search-box { height: 37px; margin: 0 14px 21px; padding: 0 10px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: #f8f9f9; color: #969da0; }
.search-box > span { font-size: 20px; line-height: 1; transform: rotate(-15deg); }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.search-box input::placeholder { color: #737b7f; }
.search-box:focus-within { border-color: #aeb5b8; }
.section-label, .list-heading { padding: 0 18px; color: #737b7f; font-size: 9px; font-weight: 650; letter-spacing: .13em; text-transform: uppercase; }
.nav-item { min-height: 35px; margin: 8px 10px 18px; padding: 0 10px; display: flex; align-items: center; gap: 9px; border-radius: 7px; color: #737b7f; font-size: 11px; cursor: pointer; }
.nav-item.active { background: var(--accent-wash); color: #495156; font-weight: 600; }
.nav-item > span:first-child { font-size: 15px; }
.count { margin-left: auto; color: #737b7f; font-size: 10px; font-weight: 500; }
.list-heading { display: flex; align-items: center; justify-content: space-between; padding-bottom: 8px; letter-spacing: .11em; }
.list-heading span:last-child { letter-spacing: 0; font-weight: 500; }
.note-list { flex: 1; padding: 0 8px 12px; overflow: auto; }
.note-card { width: 100%; margin: 0 0 3px; padding: 10px 10px 9px; display: block; border: 1px solid transparent; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; }
.note-card:hover { background: #f8f9f9; }
.note-card.selected { border-color: #e2e5e6; background: #f2f3f3; }
.note-card-title, .note-card-snippet { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card-title { font-size: 11px; font-weight: 620; line-height: 1.45; }
.note-card-snippet { margin-top: 4px; color: #737b7f; font-size: 10px; line-height: 1.5; }
.note-card-date { margin-top: 7px; color: #70787c; font-size: 9px; }
.empty-list { padding: 20px 12px; color: #6f777b; text-align: center; font-size: 10px; line-height: 1.7; }
.sidebar-foot { min-height: 44px; padding: 0 17px; display: flex; align-items: center; gap: 8px; border-top: 1px solid #eff0f0; color: #6f777b; font-size: 9px; }
.logout-button { margin-left: auto; padding: 6px 0 6px 8px; border: 0; background: transparent; color: #697277; font-size: 9px; cursor: pointer; }
.logout-button:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.status-dot { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: #899194; }

.main-panel { min-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 32px rgba(35, 39, 41, .035); }
.topbar { min-height: 61px; padding: 0 25px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid #eff0f0; }
.breadcrumbs { min-width: 0; display: flex; align-items: center; gap: 9px; color: #70797d; font-size: 10px; }
.breadcrumbs strong { max-width: min(38vw, 350px); overflow: hidden; color: #4d555a; font-weight: 560; text-overflow: ellipsis; white-space: nowrap; }
.slash { color: #c2c6c8; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.quiet-button { min-height: 31px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #6f777b; font-size: 10px; text-decoration: none; cursor: pointer; }
.quiet-button:hover { border-color: var(--line); background: #f8f9f9; color: #424a4e; }
.link-button { border-color: var(--line); }
.save-status { max-width: 210px; margin-left: 2px; display: flex; align-items: center; gap: 7px; color: #6e767a; font-size: 9px; white-space: nowrap; }
.save-status[data-state="error"] { color: var(--danger); }
.save-status[data-state="saving"] .status-dot { background: #b08a55; }
.save-status[data-state="error"] .status-dot { background: var(--danger); }
.icon-button { width: 31px; height: 31px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: #697277; cursor: pointer; font-size: 15px; }
.icon-button:hover { background: #f7f8f8; }
.menu-button { display: none; }
.retry-button { border-color: #ead1ce; color: var(--danger); }
.delete-button { color: #8a6a67; }
.delete-button:hover { border-color: #ead1ce; background: var(--danger-bg); color: var(--danger); }
.editor-wrap { flex: 1; min-height: 0; display: flex; justify-content: center; }
.editor-column { width: min(100%, 880px); min-height: 0; padding: 47px 66px 32px; display: flex; flex-direction: column; }
.eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 11px; color: #737b7f; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.eyebrow span { width: 17px; height: 1px; background: #b8bec0; }
.title-input { width: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: #292e31; font-size: clamp(28px, 3.4vw, 38px); font-weight: 620; letter-spacing: -.045em; line-height: 1.24; }
.title-input::placeholder { color: #7e888c; }
.note-meta { min-height: 34px; margin: 8px 0 13px; display: flex; align-items: center; gap: 9px; color: #737b7f; font-size: 9px; }
.format-pill { padding: 4px 7px; border-radius: 4px; background: #f2f3f3; color: #737c80; font-size: 8px; letter-spacing: .03em; }
.meta-divider { width: 3px; height: 3px; border-radius: 50%; background: #c5cacc; }
.word-count { margin-left: auto; }
.draft-banner { margin: 0 0 14px; padding: 11px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid #eadfca; border-radius: 8px; background: var(--warning-bg); color: #80623a; font-size: 10px; line-height: 1.6; }
.draft-message { min-width: 0; }
.draft-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.draft-actions button { padding: 5px 7px; border: 1px solid rgba(120, 92, 47, .2); border-radius: 5px; background: #fffdfa; color: #765c37; font-size: 9px; cursor: pointer; white-space: nowrap; }
.draft-actions button:hover { background: #f7eddc; }
.draft-actions button[data-danger="true"] { color: var(--danger); }
.toolbar { min-height: 45px; margin-bottom: 14px; padding: 6px 0; display: flex; align-items: center; flex-wrap: wrap; gap: 3px; border-top: 1px solid #eff0f0; border-bottom: 1px solid #eff0f0; }
.tool-button { min-width: 29px; height: 28px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 5px; background: transparent; color: #727a7e; font-size: 10px; font-weight: 560; cursor: pointer; }
.tool-button:hover { background: #f0f2f2; color: #394247; }
.tool-button strong { font-size: 12px; }
.tool-button.italic { font-family: Georgia, serif; font-size: 15px; font-style: italic; }
.wide-tool { padding: 0 8px; }
.tool-divider { width: 1px; height: 15px; margin: 0 4px; background: #e4e7e8; }
.editor-label { margin: 0 0 9px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #737b7f; font-size: 8px; letter-spacing: .1em; text-transform: uppercase; }
.editor-label span:last-child { font-size: 9px; letter-spacing: 0; text-transform: none; }
.body-editor { flex: 1; min-height: 320px; padding: 4px 0; overflow: auto; color: #434a4e; font-size: 14px; line-height: 1.9; outline: 0; overflow-wrap: anywhere; }
.body-editor:empty::before { content: attr(data-placeholder); color: #778185; pointer-events: none; }
.body-editor h1, .body-editor h2, .body-editor h3 { color: #333a3e; line-height: 1.35; }
.body-editor h1 { margin: .75em 0 .35em; font-size: 1.55em; }
.body-editor h2 { margin: .8em 0 .35em; font-size: 1.3em; }
.body-editor h3 { margin: .8em 0 .3em; font-size: 1.1em; }
.body-editor p { margin: .45em 0; }
.body-editor ul, .body-editor ol { padding-left: 1.55em; }
.body-editor blockquote { margin: .8em 0; padding: .2em 0 .2em 1em; border-left: 2px solid #c5cbcd; color: #727c81; }
.body-editor pre { padding: 12px 14px; overflow: auto; border-radius: 7px; background: #f1f3f3; white-space: pre-wrap; font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.body-editor code { padding: 1px 4px; border-radius: 4px; background: #f0f2f2; font: .9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.body-editor pre code { padding: 0; background: none; }
.body-editor a { color: #535f65; text-decoration: underline; text-underline-offset: 2px; }
.editor-footer { min-height: 35px; margin-top: 15px; padding-top: 11px; display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid #f0f1f1; color: #6e767a; font-size: 9px; }
.empty-state { max-width: 400px; margin: auto; padding: 32px 22px; text-align: center; }
.empty-icon { width: 46px; height: 46px; margin: 0 auto 17px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; color: #838c90; background: #fafbfb; font-size: 20px; }
.empty-state h1 { margin: 0; color: #343b3f; font-size: 20px; font-weight: 580; letter-spacing: -.03em; }
.empty-state p { margin: 9px 0 18px; color: #6e777b; font-size: 11px; line-height: 1.7; }
.scrim { position: fixed; inset: 0; z-index: 4; background: rgba(28, 32, 34, .22); }

.auth-dialog { width: min(390px, calc(100vw - 30px)); padding: 30px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); box-shadow: 0 20px 70px rgba(22, 28, 31, .16); }
.auth-dialog::backdrop { background: rgba(31, 36, 39, .32); }
.auth-dialog h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.035em; }
.auth-dialog .dialog-copy { margin-bottom: 21px; }
.auth-field { margin: 0 0 13px; display: grid; gap: 6px; color: #636d71; font-size: 10px; }
.auth-field input { width: 100%; height: 40px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fbfcfc; color: var(--ink); font-size: 13px; }
.auth-field input:focus { border-color: #aeb5b8; outline: 0; }
.auth-error { margin: 0 0 12px; color: var(--danger); font-size: 10px; line-height: 1.6; }
.auth-submit { width: 100%; margin-top: 5px; }
.auth-switch { width: 100%; margin-top: 14px; padding: 5px; border: 0; background: transparent; color: #697277; font-size: 10px; cursor: pointer; }
.auth-switch:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.import-dialog { width: min(520px, calc(100vw - 30px)); padding: 25px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); box-shadow: 0 20px 70px rgba(22, 28, 31, .16); }
.import-dialog::backdrop { background: rgba(31, 36, 39, .25); }
.dialog-close-row { display: flex; justify-content: flex-end; }
.dialog-close-row button { margin: -10px -10px 5px 0; font-size: 18px; }
.import-dialog h2 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -.03em; }
.dialog-copy { margin: 9px 0 17px; color: #6c7579; font-size: 11px; line-height: 1.7; }
.file-picker { min-height: 39px; padding: 0 12px; display: flex; align-items: center; border: 1px dashed #cdd2d4; border-radius: 8px; color: #697277; font-size: 10px; cursor: pointer; }
.file-picker input { max-width: 74%; margin-left: auto; font-size: 9px; }
.import-preview { min-height: 68px; max-height: 180px; margin-top: 12px; padding: 10px; overflow: auto; border: 1px solid #edf0f0; border-radius: 7px; background: #fafbfb; color: #6b7478; font-size: 10px; line-height: 1.65; }
.preview-list { margin: 5px 0 0; padding-left: 19px; color: #626c70; }
.preview-error { color: var(--danger); }
.dialog-actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions .primary-button { min-height: 34px; }

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 246px minmax(0, 1fr); gap: 11px; padding: 11px; }
  .sidebar, .main-panel { min-height: calc(100vh - 22px); }
  .editor-column { padding: 39px 35px 27px; }
  .topbar { padding: 0 17px; }
}
@media (max-width: 680px) {
  .app-shell { display: block; min-height: 100vh; padding: 0; }
  .sidebar { position: fixed; z-index: 5; top: 0; bottom: 0; left: 0; width: min(84vw, 300px); min-height: 0; border-radius: 0 14px 14px 0; box-shadow: 0 15px 40px rgba(20, 24, 26, .13); transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-panel { min-height: 100vh; border: 0; border-radius: 0; box-shadow: none; }
  .topbar { min-height: 57px; padding: 0 13px; gap: 8px; }
  .menu-button { display: inline-grid; flex: 0 0 31px; }
  .breadcrumbs { flex: 1; gap: 6px; }
  .breadcrumbs strong { max-width: 30vw; }
  .top-actions { gap: 2px; }
  .top-actions .quiet-button { padding: 0 7px; font-size: 9px; }
  .save-status { max-width: 72px; margin-left: 0; gap: 5px; overflow: hidden; font-size: 8px; text-overflow: ellipsis; }
  .editor-column { min-height: calc(100vh - 57px); padding: 31px 22px 22px; }
  .title-input { font-size: 30px; }
  .body-editor { min-height: 42vh; font-size: 13px; }
  .draft-banner { align-items: flex-start; flex-direction: column; }
  .draft-actions { justify-content: flex-start; }
}
@media (max-width: 390px) {
  .top-actions .quiet-button { padding: 0 5px; }
  .breadcrumbs > span, .breadcrumbs .slash { display: none; }
  .top-actions .link-button { padding: 0 5px; font-size: 8px; }
  .save-status { max-width: 64px; display: flex; font-size: 8px; }
  .editor-column { padding-right: 18px; padding-left: 18px; }
  .toolbar { gap: 1px; }
  .tool-button { min-width: 26px; padding: 0 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
