:root {
  color-scheme: light;
  --primary: #fcd535;
  --primary-active: #f0b90b;
  --on-primary: #181a20;
  --canvas: #f5f5f5;
  --surface: #ffffff;
  --surface-raised: #fafafa;
  --surface-pressed: #eaecef;
  --line: #eaecef;
  --line-strong: #cdd1d6;
  --text: #181a20;
  --text-soft: #474d57;
  --muted: #707a8a;
  --muted-strong: #5e6673;
  --danger: #f6465d;
  --focus: #3b82f6;
  --shadow: 0 12px 32px rgb(24 26 32 / 10%);
  --header-height: 64px;
  --nav-height: 72px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --markdown-canvas: #f7f8fa;
  --markdown-panel: #ffffff;
  --markdown-border: #d8dee9;
  --markdown-text: #2e3440;
  --markdown-muted: #687386;
  font-family: Inter, "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0b0e11;
  --surface: #1e2329;
  --surface-raised: #2b3139;
  --surface-pressed: #333b45;
  --line: #2b3139;
  --line-strong: #474d57;
  --text: #f5f5f5;
  --text-soft: #eaecef;
  --muted: #929aa5;
  --muted-strong: #b7bdc6;
  --shadow: 0 18px 48px rgb(0 0 0 / 30%);
  --markdown-canvas: #2e3440;
  --markdown-panel: #3b4252;
  --markdown-border: #4c566a;
  --markdown-text: #eceff4;
  --markdown-muted: #aab4c4;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--canvas); }
body { min-width: 320px; color: var(--text); overscroll-behavior-y: none; }
button, input, textarea { color: inherit; font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button, [role="button"] { touch-action: manipulation; }
input, textarea { appearance: none; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.svg-sprite { position: fixed; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }

.login-view {
  display: flex;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: calc(32px + var(--safe-top)) 20px calc(32px + var(--safe-bottom));
  background: var(--canvas);
}
.login-card { width: 100%; min-width: 0; max-width: 430px; border: 1px solid var(--line); border-radius: 12px; padding: 32px 24px 26px; background: var(--surface); box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.security-chip { display: inline-flex; min-height: 28px; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 99px; padding: 0 10px; color: var(--muted-strong); background: var(--surface-raised); font-size: 11px; font-weight: 650; white-space: nowrap; }
.security-chip svg { width: 14px; height: 14px; color: #0ecb81; stroke-width: 2; }
.brand-mark { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border-radius: 8px; color: var(--on-primary); background: var(--primary); }
.brand-mark svg { width: 23px; height: 23px; fill: currentColor; stroke: none; }
.brand-mark.large { width: 50px; height: 50px; margin-bottom: 28px; border-radius: 12px; }
.brand-mark.large svg { width: 31px; height: 31px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .04em; }
.login-card h1 { margin: 0; font-size: 34px; line-height: 1.15; letter-spacing: -.03em; }
.login-copy { margin: 14px 0 28px; color: var(--text-soft); font-size: 15px; line-height: 1.7; }
.login-form label { display: block; margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.login-form label ~ label { margin-top: 16px; }
.login-form input { width: 100%; height: 48px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 14px; outline: none; background: var(--surface); }
.login-form input:focus { border-color: var(--focus); box-shadow: 0 0 0 2px rgb(59 130 246 / 18%); }
.login-form input::placeholder { color: var(--muted); }
.primary-button { display: flex; width: 100%; min-height: 48px; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; border: 0; border-radius: 8px; padding: 0 18px; color: var(--on-primary); background: var(--primary); font-weight: 700; cursor: pointer; }
.primary-button:active { background: var(--primary-active); }
.primary-button:disabled { cursor: wait; opacity: .65; }
.primary-button svg { width: 18px; height: 18px; }
.login-hint { margin: 20px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.form-error { margin: 8px 0 0; color: var(--danger); font-size: 12px; }
.totp-input { font-family: "SF Mono", SFMono-Regular, ui-monospace, monospace !important; font-size: 21px !important; font-weight: 650; letter-spacing: .38em; text-align: center; }
.totp-input::placeholder { letter-spacing: .24em; }
.text-button { display: block; min-height: 38px; margin: 8px auto 0; border: 0; padding: 4px 8px; color: var(--muted-strong); background: transparent; font-size: 12px; cursor: pointer; }
.text-button:active { color: var(--text); }
.qr-frame { width: 184px; height: 184px; margin: 0 auto 14px; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.qr-frame img { display: block; width: 100%; height: 100%; border-radius: 4px; }
.enrollment-guide { margin: 0 0 14px; color: var(--text-soft); font-size: 12px; line-height: 1.65; text-align: center; }
.secret-box { display: grid; gap: 6px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface-raised); }
.secret-box span { color: var(--muted); font-size: 10px; }
.secret-box code { overflow-wrap: anywhere; color: var(--text); font-family: "SF Mono", SFMono-Regular, ui-monospace, monospace; font-size: 11px; letter-spacing: .04em; }

.app-view { width: min(100%, 760px); min-height: 100dvh; margin: 0 auto; border-right: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--canvas); }
.app-header { position: fixed; z-index: 20; top: 0; left: 50%; display: flex; width: min(100%, 760px); height: calc(var(--header-height) + var(--safe-top)); align-items: flex-end; justify-content: space-between; padding: var(--safe-top) 16px 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--canvas); transform: translateX(-50%); }
.brand-row { display: flex; min-width: 0; align-items: center; gap: 10px; }
.brand-row > div:last-child { display: flex; min-width: 0; flex-direction: column; }
.brand-row strong { font-size: 15px; line-height: 1.2; }
.brand-row span { overflow: hidden; max-width: 190px; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; gap: 5px; }
.icon-button { display: grid; width: 40px; height: 40px; place-items: center; border: 0; border-radius: 8px; padding: 0; color: var(--text-soft); background: transparent; cursor: pointer; }
.icon-button:active { background: var(--surface-pressed); }
.icon-button.syncing svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.main-content { min-height: 100dvh; padding: calc(var(--header-height) + var(--safe-top) + 22px) 16px calc(var(--nav-height) + var(--safe-bottom) + 28px); }
.workspace-loading { display: grid; min-height: calc(100dvh - var(--header-height) - var(--nav-height) - var(--safe-top) - var(--safe-bottom) - 50px); place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.workspace-loading > span { display: grid; width: 38px; height: 38px; margin-bottom: 12px; place-items: center; border-radius: 9px; color: var(--text-soft); background: var(--surface); }
.workspace-loading > span svg { animation: spin .9s linear infinite; }
.workspace-loading strong { color: var(--text-soft); font-size: 13px; }
.workspace-loading small { margin-top: 5px; font-size: 10px; }
.bottom-nav { position: fixed; z-index: 20; bottom: 0; left: 50%; display: grid; width: min(100%, 760px); height: calc(var(--nav-height) + var(--safe-bottom)); grid-template-columns: repeat(3, 1fr); padding: 7px 12px var(--safe-bottom); border: 1px solid var(--line); border-bottom: 0; background: var(--surface); transform: translateX(-50%); }
.nav-item { position: relative; display: flex; min-width: 0; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 600; cursor: pointer; }
.nav-item svg { width: 20px; height: 20px; }
.nav-item.active { color: var(--text); }
.nav-item.active::after { position: absolute; bottom: 2px; left: 50%; width: 20px; height: 3px; border-radius: 2px; background: var(--primary); content: ""; transform: translateX(-50%); }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 0 0 18px; }
.page-heading p { margin: 0 0 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
.page-heading h1 { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: -.025em; }
.page-heading .date-value { font-family: "SF Mono", "JetBrains Mono", ui-monospace, monospace; font-size: 12px; }
.section-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 16px; padding: 4px; border-radius: 8px; background: var(--surface-raised); }
.mode-tabs button { display: flex; min-height: 38px; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 600; }
.mode-tabs button.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgb(24 26 32 / 8%); }
.mode-tabs svg { width: 17px; height: 17px; }
.week-switcher { display: flex; align-items: center; margin-bottom: 12px; }
.week-switcher > button { display: grid; width: 38px; height: 38px; place-items: center; border: 0; border-radius: 7px; color: var(--muted); background: transparent; }
.week-switcher > button:active { background: var(--surface-pressed); }
.week-switcher > div { min-width: 0; flex: 1; text-align: center; }
.week-switcher strong { display: block; font-size: 14px; }
.week-switcher span { display: block; margin-top: 2px; color: var(--muted); font-family: "SF Mono", ui-monospace, monospace; font-size: 10px; }
.week-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 16px; }
.day-button { display: flex; min-width: 0; min-height: 58px; flex-direction: column; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 8px; color: var(--muted); background: transparent; }
.day-button span { font-size: 10px; }
.day-button strong { margin-top: 5px; font-family: "SF Mono", ui-monospace, monospace; font-size: 14px; font-weight: 600; }
.day-button.today strong { color: var(--primary-active); }
.day-button.selected { border-color: var(--line-strong); color: var(--text); background: var(--surface); }
.day-button.selected.today { border-color: var(--primary-active); }
.quick-add { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; padding: 8px 8px 8px 14px; }
.quick-add input { min-width: 0; height: 40px; flex: 1; border: 0; outline: 0; background: transparent; font-size: 14px; }
.quick-add input::placeholder { color: var(--muted); }
.quick-add button { display: grid; width: 40px; height: 40px; flex: 0 0 40px; place-items: center; border: 0; border-radius: 8px; color: var(--on-primary); background: var(--primary); }
.quick-add button:active { background: var(--primary-active); }
.quick-add button svg { width: 20px; height: 20px; stroke-width: 2.2; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 2px 10px; }
.section-title h2 { margin: 0; font-size: 15px; line-height: 1.3; }
.section-title span { color: var(--muted); font-family: "SF Mono", ui-monospace, monospace; font-size: 12px; }
.task-list { overflow: hidden; }
.task-row { position: relative; display: grid; min-height: 58px; grid-template-columns: 40px minmax(0, 1fr) 38px; align-items: center; border-bottom: 1px solid var(--line); padding: 7px 6px 7px 8px; }
.task-row:last-child { border-bottom: 0; }
.task-check { position: relative; display: grid; width: 40px; height: 40px; place-items: center; border: 0; padding: 0; background: transparent; }
.task-check::before { width: 19px; height: 19px; border: 1.5px solid var(--line-strong); border-radius: 50%; content: ""; }
.task-row.completed .task-check::before { border-color: var(--primary); background: var(--primary); }
.task-row.completed .task-check::after { position: absolute; top: 16px; left: 15px; width: 8px; height: 4px; border-bottom: 2px solid var(--on-primary); border-left: 2px solid var(--on-primary); content: ""; transform: rotate(-45deg); }
.task-main { min-width: 0; border: 0; padding: 5px 2px; color: var(--text); background: transparent; text-align: left; }
.task-main strong { display: block; overflow-wrap: anywhere; font-size: 14px; font-weight: 600; line-height: 1.45; }
.task-main small { display: flex; align-items: center; gap: 5px; margin-top: 4px; color: var(--muted); font-size: 10px; }
.task-main small svg { width: 11px; height: 11px; }
.task-row.completed .task-main strong { color: var(--muted); text-decoration: line-through; }
.task-color { position: absolute; top: 50%; left: 0; width: 3px; height: 28px; border-radius: 0 2px 2px 0; background: var(--task-color, var(--primary)); transform: translateY(-50%); }
.task-more { display: grid; width: 38px; height: 38px; place-items: center; border: 0; border-radius: 7px; color: var(--muted); background: transparent; }
.task-more:active { color: var(--text); background: var(--surface-pressed); }
.empty-state { display: flex; min-height: 180px; flex-direction: column; align-items: center; justify-content: center; padding: 28px; color: var(--muted); text-align: center; }
.empty-state svg { width: 30px; height: 30px; margin-bottom: 14px; }
.empty-state strong { color: var(--text-soft); font-size: 14px; }
.empty-state p { max-width: 260px; margin: 7px 0 0; font-size: 12px; line-height: 1.6; }

.search-box { display: flex; height: 46px; align-items: center; gap: 9px; margin-bottom: 18px; padding: 0 13px; }
.search-box svg { width: 18px; height: 18px; color: var(--muted); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: 14px; }
.search-box input::placeholder { color: var(--muted); }
.notes-grid { display: grid; gap: 10px; }
.note-card { position: relative; display: block; width: 100%; min-height: 116px; border: 1px solid var(--line); border-radius: 12px; padding: 17px; color: var(--text); background: var(--surface); text-align: left; }
.note-card::before { position: absolute; top: 18px; left: 0; width: 3px; height: 22px; border-radius: 0 2px 2px 0; background: var(--primary); content: ""; }
.note-card strong { display: block; overflow: hidden; padding-left: 3px; font-size: 15px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.note-card p { display: -webkit-box; overflow: hidden; margin: 9px 0 14px; color: var(--text-soft); font-size: 12px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.note-card time { color: var(--muted); font-family: "SF Mono", ui-monospace, monospace; font-size: 10px; }
.fab { position: fixed; z-index: 15; right: max(20px, calc((100vw - 760px) / 2 + 20px)); bottom: calc(var(--nav-height) + var(--safe-bottom) + 18px); display: grid; width: 52px; height: 52px; place-items: center; border: 0; border-radius: 12px; color: var(--on-primary); background: var(--primary); box-shadow: var(--shadow); }
.fab:active { background: var(--primary-active); }
.fab svg { width: 23px; height: 23px; stroke-width: 2.2; }
.note-editor-page { position: fixed; z-index: 25; inset: 0; display: flex; width: min(100%, 760px); margin: 0 auto; flex-direction: column; background: var(--canvas); }
.editor-header { display: flex; min-height: calc(60px + var(--safe-top)); align-items: flex-end; gap: 8px; padding: var(--safe-top) 10px 8px; border-bottom: 1px solid var(--line); background: var(--canvas); }
.editor-header .icon-button { flex: 0 0 40px; }
.editor-title { min-width: 0; flex: 1; padding: 0 4px 3px; }
.editor-title strong { display: block; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.editor-title span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.editor-toolbar { display: flex; align-items: center; gap: 4px; padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.editor-toolbar button { display: grid; width: 38px; height: 38px; place-items: center; border: 0; border-radius: 7px; color: var(--muted-strong); background: transparent; }
.editor-toolbar button:active { color: var(--text); background: var(--surface-pressed); }
.editor-toolbar span { flex: 1; }
.note-textarea { width: 100%; min-height: 0; flex: 1; resize: none; border: 0; padding: 18px 18px calc(22px + var(--safe-bottom)); outline: 0; color: var(--text); background: var(--canvas); font-family: "SF Mono", "Noto Sans SC", ui-monospace, monospace; font-size: 15px; line-height: 1.75; caret-color: var(--primary-active); tab-size: 2; }
.note-mode-bar { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding: 5px 10px; background: var(--surface); }
.editor-mode-switch { display: flex; border: 1px solid var(--line-strong); border-radius: 7px; padding: 2px; background: var(--surface-raised); }
.editor-mode-switch button { min-width: 54px; height: 29px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 650; }
.editor-mode-switch button.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgb(24 26 32 / 12%); }
.note-mode-bar > button { display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 7px; color: var(--muted-strong); background: transparent; }
.note-mode-bar > button:active { color: var(--text); background: var(--surface-pressed); }
.note-mode-bar > button svg { width: 18px; height: 18px; }
.markdown-actions { min-height: 48px; }
.markdown-actions span { color: var(--muted); font-size: 10px; text-align: right; }
.markdown-stage { min-width: 0; min-height: 0; flex: 1; overflow: hidden; color: var(--markdown-text); background: var(--markdown-canvas); }
.markdown-source-editor { position: relative; width: 100%; height: 100%; }
.markdown-source-editor .cm-editor { width: 100%; height: 100%; }
.markdown-source-editor .cm-scroller { min-width: 0; min-height: 0; overflow: auto !important; scrollbar-color: #5e81ac #242936; scrollbar-width: thin; }
.markdown-source-editor .cm-gutters { border-right: 1px solid color-mix(in srgb, var(--markdown-border) 65%, transparent) !important; }
.markdown-preview { width: 100%; height: 100%; overflow: auto; overscroll-behavior: contain; margin: 0; padding: 22px 20px calc(64px + var(--safe-bottom)); color: var(--markdown-text); background: var(--markdown-canvas); font-family: "LXGW WenKai", "LXGW WenKai Screen R", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 16px; font-weight: 400; line-height: 1.7; text-shadow: none; scrollbar-color: #5e81ac #242936; scrollbar-width: thin; }
.markdown-preview h1, .markdown-preview h2, .markdown-preview h3, .markdown-preview h4, .markdown-preview h5, .markdown-preview h6 { margin: 2rem 0 1rem; font-family: "霞鹜文楷 GB Medium", "LXGW WenKai", serif; line-height: 1.4; }
.markdown-preview h1 { margin-top: 0; border-bottom: 3px solid #bf616a; color: #bf616a; }
.markdown-preview h2 { border-bottom: 2px solid #d08770; color: #d08770; }
.markdown-preview h3 { border-bottom: 1px solid #ebcb8b; color: #ebcb8b; }
.markdown-preview h4 { color: #a3be8c; }
.markdown-preview h5 { color: #b48ead; }
.markdown-preview h6 { color: var(--markdown-muted); }
.markdown-preview p, .markdown-preview ul, .markdown-preview ol { margin: 0 0 1em; }
.markdown-preview a { color: #81a1c1; text-decoration: none; }
.markdown-preview strong { color: #e8b4b4; }
.markdown-preview em { color: #a3be8c; }
.markdown-preview code { border-radius: 4px; padding: 2px 6px; color: #88c0d0; background: #1d1f23; font-family: "SF Mono", SFMono-Regular, "JetBrains Mono", "Fira Code", "Source Code Pro", Consolas, monospace; font-size: .9em; }
.markdown-preview pre { max-width: 100%; overflow: auto; border-radius: 6px; padding: 16px; background: #1d1f23; box-shadow: 0 0 10px rgb(0 0 0 / 20%); }
.markdown-preview pre code { padding: 0; color: inherit; background: transparent; }
.markdown-preview pre code.hljs { color: #d8dee9; }
.markdown-preview .hljs-comment, .markdown-preview .hljs-quote { color: #76839b; font-family: "LXGW WenKai", "LXGW WenKai Screen R", "霞鹜文楷 GB Medium", "Noto Sans SC", serif; font-style: normal; }
.markdown-preview .hljs-keyword, .markdown-preview .hljs-selector-tag, .markdown-preview .hljs-literal { color: #b48ead; }
.markdown-preview .hljs-string, .markdown-preview .hljs-doctag, .markdown-preview .hljs-regexp { color: #a3be8c; }
.markdown-preview .hljs-number, .markdown-preview .hljs-symbol, .markdown-preview .hljs-bullet { color: #d08770; }
.markdown-preview .hljs-title, .markdown-preview .hljs-title.function_, .markdown-preview .hljs-section { color: #88c0d0; }
.markdown-preview .hljs-params, .markdown-preview .hljs-variable, .markdown-preview .hljs-template-variable { color: #eceff4; }
.markdown-preview .hljs-attr, .markdown-preview .hljs-attribute, .markdown-preview .hljs-meta, .markdown-preview .hljs-type { color: #ebcb8b; }
.markdown-preview .hljs-built_in, .markdown-preview .hljs-selector-class { color: #8fbcbb; }
.markdown-preview .hljs-tag, .markdown-preview .hljs-name { color: #bf616a; }
.markdown-preview .hljs-addition { color: #a3be8c; background: rgb(163 190 140 / 13%); }
.markdown-preview .hljs-deletion { color: #bf616a; background: rgb(191 97 106 / 13%); }
.markdown-preview blockquote { margin: 1.5rem 0; border-left: 4px solid #81a1c1; border-radius: 0 6px 6px 0; padding: 12px 18px; color: var(--markdown-text); background: rgb(94 129 172 / 10%); font-style: italic; }
.markdown-preview table { display: block; width: 100%; margin: 1.5rem 0; overflow-x: auto; border-collapse: collapse; background: var(--markdown-panel); }
.markdown-preview th, .markdown-preview td { border: 1px solid var(--markdown-border); padding: 9px 12px; text-align: left; white-space: nowrap; }
.markdown-preview th { background: color-mix(in srgb, var(--markdown-panel) 76%, #81a1c1); }
.markdown-preview hr { height: 2px; border: 0; margin: 2rem 0; background: #81a1c1; opacity: .72; }
.markdown-preview img { max-width: 100%; height: auto; border-radius: 6px; }
.markdown-preview input[type="checkbox"] { appearance: auto; accent-color: #5e81ac; }
.markdown-source-editor .cm-scroller::-webkit-scrollbar, .markdown-preview::-webkit-scrollbar { width: 7px; height: 7px; background: #242936; }
.markdown-source-editor .cm-scroller::-webkit-scrollbar-thumb, .markdown-preview::-webkit-scrollbar-thumb { border-radius: 99px; background: #5e81ac; }
.editor-loading { display: grid; height: 100%; place-items: center; padding: 20px; color: var(--markdown-muted); font-size: 12px; text-align: center; }
.editor-loading.error { color: var(--danger); }

.settings-stack { display: grid; gap: 14px; }
.settings-card { overflow: hidden; }
.settings-card > header { padding: 15px 16px 10px; }
.settings-card h2 { margin: 0; font-size: 14px; }
.settings-card header p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.setting-row { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); padding: 10px 16px; }
.setting-row > div:first-child { min-width: 0; }
.setting-row strong { display: block; font-size: 13px; }
.setting-row small { display: block; overflow: hidden; max-width: 280px; margin-top: 4px; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.secondary-button, .danger-button { min-height: 38px; flex: 0 0 auto; border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 13px; background: transparent; font-size: 12px; font-weight: 600; }
.secondary-button:active { background: var(--surface-pressed); }
.danger-button { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); color: var(--danger); }
.security-status { display: inline-flex; align-items: center; gap: 5px; color: #0ecb81; font-size: 11px; font-weight: 650; white-space: nowrap; }
.security-status svg { width: 15px; height: 15px; }
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 14px 14px; }
.theme-options button { min-height: 40px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: transparent; font-size: 12px; }
.theme-options button.active { border-color: var(--primary-active); color: var(--text); background: color-mix(in srgb, var(--primary) 13%, transparent); }
.version-line { color: var(--muted); font-family: "SF Mono", ui-monospace, monospace; font-size: 10px; text-align: center; }

.sheet-backdrop { position: fixed; z-index: 50; inset: 0; background: rgb(11 14 17 / 58%); }
.bottom-sheet { position: fixed; z-index: 51; right: 0; bottom: 0; left: 0; max-height: min(88dvh, 720px); overflow-y: auto; border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; padding: 10px 18px calc(18px + var(--safe-bottom)); background: var(--surface); box-shadow: var(--shadow); }
.sheet-handle { width: 36px; height: 4px; margin: 0 auto 14px; border-radius: 2px; background: var(--line-strong); }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.sheet-header h2 { margin: 0; font-size: 18px; }
.sheet-close { display: grid; width: 38px; height: 38px; place-items: center; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 23px; }
.sheet-form { display: grid; gap: 16px; }
.field label, .color-field > label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 600; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; padding: 11px 12px; outline: none; background: var(--surface); }
.field textarea { min-height: 88px; resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 2px rgb(59 130 246 / 16%); }
.switch-row { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 12px; }
.switch-row span { font-size: 13px; font-weight: 600; }
.switch { position: relative; width: 44px; height: 26px; border: 0; border-radius: 13px; background: var(--surface-pressed); }
.switch::after { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 4px rgb(0 0 0 / 18%); content: ""; transition: transform .15s ease; }
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(18px); }
.color-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.color-swatch { position: relative; aspect-ratio: 1; min-width: 0; border: 1px solid var(--line-strong); border-radius: 6px; padding: 3px; background: transparent; }
.color-swatch::before { display: block; width: 100%; height: 100%; border-radius: 3px; background: var(--swatch); content: ""; }
.color-swatch.active { border-color: var(--text); }
.color-swatch.active::after { position: absolute; inset: 50% auto auto 50%; width: 6px; height: 3px; border-bottom: 1.5px solid #fff; border-left: 1.5px solid #fff; content: ""; filter: drop-shadow(0 1px 1px #000); transform: translate(-50%, -65%) rotate(-45deg); }
.sheet-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding-top: 4px; }
.sheet-actions .primary-button { margin: 0; }
.delete-icon-button { display: grid; width: 48px; height: 48px; place-items: center; border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line)); border-radius: 8px; color: var(--danger); background: transparent; }

.toast-root { position: fixed; z-index: 80; bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px); left: 50%; display: grid; width: min(calc(100% - 32px), 420px); gap: 8px; pointer-events: none; transform: translateX(-50%); }
.toast { border: 1px solid var(--line-strong); border-radius: 8px; padding: 11px 14px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); font-size: 12px; line-height: 1.5; animation: toast-in .18s ease-out; }
.toast.error { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (min-width: 620px) {
  .main-content { padding-right: 26px; padding-left: 26px; }
  .notes-grid { grid-template-columns: 1fr 1fr; }
  .bottom-sheet { right: 50%; left: auto; width: min(560px, calc(100% - 32px)); border-bottom: 1px solid var(--line); border-radius: 12px; transform: translateX(50%); bottom: 18px; }
}

@media (max-width: 380px) {
  .main-content { padding-right: 12px; padding-left: 12px; }
  .app-header { padding-right: 10px; padding-left: 10px; }
  .day-button { min-height: 54px; }
  .brand-row span { max-width: 135px; }
  .color-grid { gap: 6px; }
}

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