:root {
  color-scheme: light;
  --paper: #f6f4ee; --surface: #fffef9; --ink: #20211d; --muted: #77776f;
  --line: #dfded6; --accent: #b34b30; --accent-dark: #8f3823; --green: #38845a;
  --shadow: 0 18px 60px rgba(49, 43, 32, .13);
  font-family: ui-rounded, "SF Pro Rounded", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: #e8e4db; color: var(--ink); }
body { overscroll-behavior: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0; color: var(--accent); font-size: .68rem; font-weight: 800; letter-spacing: .16em; }
.app, .login-view { width: 100%; min-height: 100dvh; background: var(--paper); }
.panel { min-height: 100dvh; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.topbar { min-height: 78px; padding: 17px 20px 10px; display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { margin: 2px 0 0; font-family: Georgia, serif; font-size: 2.2rem; line-height: 1; letter-spacing: -.04em; }
.topbar h2 { margin: 0; font-family: Georgia, serif; font-size: 1.2rem; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: #ebe8df; font-size: 1.25rem; font-weight: 700; }
.primary-icon { background: var(--accent); color: white; box-shadow: 0 7px 16px rgba(179,75,48,.25); font-size: 1.65rem; font-weight: 400; }
.text-button { border: 0; background: none; padding: 8px 0; color: var(--accent); font-weight: 700; font-size: 1rem; }
.primary { border: 0; padding: 13px 18px; border-radius: 14px; background: var(--accent); color: white; font-weight: 750; box-shadow: 0 7px 16px rgba(179,75,48,.2); }
.wide { width: 100%; }
.login-link { display: block; text-decoration: none; }

.login-view { display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); }
.login-card { width: min(100%, 390px); background: var(--surface); padding: 34px 26px; border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); text-align: center; }
.brand-mark { width: 66px; height: 66px; margin: 0 auto 22px; display: grid; place-items: center; background: var(--accent); color: #fff8e7; border-radius: 21px; font: 700 2.2rem Georgia, serif; transform: rotate(-3deg); box-shadow: 0 9px 22px rgba(179,75,48,.25); }
.brand-mark.small { width: 52px; height: 52px; border-radius: 17px; font-size: 1.7rem; margin-bottom: 14px; }
.login-card h1 { margin: 5px 0 4px; font: 700 2.35rem Georgia, serif; letter-spacing: -.04em; }
.login-card .muted { margin: 0 0 28px; }
.login-card label { display: block; margin: 0 0 7px; text-align: left; color: var(--muted); font-size: .82rem; font-weight: 700; }
.login-card input { width: 100%; margin-bottom: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); outline: none; }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(179,75,48,.12); }
.error { min-height: 1.2em; color: #a92f28; font-size: .83rem; }
.version-label { margin: 22px 0 0; color: #aaa79d; font-size: .72rem; }

.search-wrap { margin: 4px 20px 9px; display: flex; gap: 9px; align-items: center; padding: 11px 13px; border-radius: 13px; background: #eae7df; color: var(--muted); }
.search-wrap input { width: 100%; padding: 0; border: 0; outline: 0; background: none; font-size: .95rem; }
.library-meta { padding: 2px 21px 8px; display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; font-weight: 700; }
.connection-pill { display: flex; align-items: center; gap: 5px; }
.connection-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.connection-pill.offline i { background: #d08a2e; }
.note-list { padding: 0 12px 98px; }
.note-card { width: 100%; padding: 17px 10px; display: grid; grid-template-columns: 1fr auto; gap: 7px 10px; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; }
.note-card:active { background: rgba(255,255,255,.65); border-radius: 12px; }
.note-card h2 { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 1.04rem Georgia, serif; }
.note-card .pin { color: var(--accent); font-size: .8rem; }
.note-card p { margin: 0; grid-column: 1 / -1; color: var(--muted); font-size: .84rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card footer { grid-column: 1 / -1; display: flex; gap: 8px; color: #aaa79d; font-size: .69rem; }
.empty-state { padding: 70px 34px; text-align: center; }
.empty-glyph { color: var(--accent); font-size: 2.6rem; }
.empty-state h2 { font: 700 1.5rem Georgia, serif; }
.empty-state p { color: var(--muted); line-height: 1.5; }
.tabbar { position: fixed; z-index: 5; bottom: 0; left: 0; right: 0; height: calc(69px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: rgba(249,247,241,.93); border-top: 1px solid var(--line); backdrop-filter: blur(18px); }
.tab { flex: 1; border: 0; background: none; color: #97958c; font-size: .68rem; font-weight: 700; }
.tab span { display: block; margin-bottom: 2px; font-size: 1.2rem; }
.tab.active { color: var(--accent); }

.editor { background: var(--surface); }
.editor-topbar { min-height: 62px; padding-bottom: 7px; }
.save-state { color: var(--muted); font-size: .75rem; font-weight: 700; }
.reading-progress { height: 2px; background: #eeeae1; }
.reading-progress i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .15s; }
.editor-scroll { height: calc(100dvh - 119px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 24px 22px 85px; overflow-y: auto; }
.note-title { width: 100%; border: 0; outline: 0; background: none; font: 700 2rem/1.1 Georgia, serif; letter-spacing: -.035em; }
.note-details { margin: 12px 0 22px; display: flex; flex-wrap: wrap; gap: 6px; color: #99968d; font-size: .7rem; }
.note-body { display: block; width: 100%; height: calc(100dvh - 245px); min-height: 360px; padding: 0 0 40px; resize: none; overflow: auto; border: 0; outline: 0; background: none; font: 400 1rem/1.72 Georgia, serif; caret-color: var(--accent); }
.editor-toolbar { position: fixed; z-index: 5; bottom: 0; left: 0; right: 0; height: calc(56px + env(safe-area-inset-bottom)); padding: 0 12px env(safe-area-inset-bottom); display: flex; align-items: center; justify-content: space-around; background: rgba(249,247,241,.95); border-top: 1px solid var(--line); backdrop-filter: blur(18px); }
.editor-toolbar button, .find-bar button { width: 39px; height: 38px; border: 0; background: none; color: #5f5f59; font-weight: 800; }
.find-bar { padding: 8px 12px; display: flex; align-items: center; gap: 4px; background: #f0ede6; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.find-bar input { min-width: 0; flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: white; outline: 0; }
.find-bar span { min-width: 28px; text-align: center; color: var(--muted); font-size: .7rem; }

.settings-content { padding: 10px 18px 60px; }
.settings-hero { padding: 22px; text-align: center; }
.settings-hero h1 { margin: 0; font: 700 1.6rem Georgia, serif; }
.settings-hero p { margin: 5px; color: var(--muted); font-size: .78rem; }
.settings-content > h3 { margin: 22px 5px 8px; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.settings-group { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.settings-group button { width: 100%; padding: 15px; display: flex; justify-content: space-between; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.settings-group button:last-child { border-bottom: 0; }
.settings-group b { color: #aaa79d; }.danger { color: #b1322c !important; }
.settings-footnote { padding: 10px 5px; color: var(--muted); font-size: .76rem; line-height: 1.5; }

.sheet { width: min(calc(100% - 20px), 500px); max-height: 83dvh; margin: auto auto 10px; padding: 9px 16px calc(15px + env(safe-area-inset-bottom)); border: 0; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.sheet::backdrop { background: rgba(22,22,19,.35); backdrop-filter: blur(3px); }
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 16px; border-radius: 3px; background: #cbc7bd; }
.sheet h2 { margin: 0 4px 13px; font: 700 1.35rem Georgia, serif; }
.sheet > button { width: 100%; padding: 14px 6px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font-weight: 650; }
.sheet > button.cancel { margin-top: 10px; border: 0; border-radius: 12px; background: #ebe8e0; text-align: center; }
.sheet.tall { overflow: auto; }
.outline-list { max-height: 55dvh; overflow: auto; }
.outline-list button { width: 100%; padding: 11px 8px; overflow: hidden; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.outline-list .level-2 { padding-left: 25px; }.outline-list .level-3 { padding-left: 42px; color: var(--muted); }
.changelog { padding: 0 5px; color: #55554f; line-height: 1.5; }.changelog h3 { margin-bottom: 0; }.changelog p { margin-top: 2px; color: var(--muted); font-size: .8rem; }
.toast { position: fixed; z-index: 30; left: 50%; top: calc(14px + env(safe-area-inset-top)); max-width: calc(100% - 32px); padding: 10px 15px; transform: translate(-50%,-80px); border-radius: 12px; background: #282923; color: white; font-size: .8rem; box-shadow: var(--shadow); opacity: 0; transition: .25s; }
.toast.show { transform: translate(-50%,0); opacity: 1; }

@media (min-width: 760px) {
  body { padding: 30px; }.app, .login-view { width: 430px; min-height: min(880px, calc(100dvh - 60px)); margin: auto; overflow: hidden; border-radius: 38px; box-shadow: var(--shadow); }
  .login-view { display: grid; }.panel { position: relative; min-height: min(880px, calc(100dvh - 60px)); }
  .tabbar, .editor-toolbar { position: absolute; }.editor-scroll { height: calc(min(880px, 100dvh - 60px) - 119px); }
}

@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --paper: #191a17; --surface: #20211e; --ink: #eeeade; --muted: #aaa99f; --line: #363732; --accent: #e17859; }
  html, body { background: #10110f; }.search-wrap, .editor-toolbar, .tabbar, .find-bar, .icon-button { background-color: #292a26; }
  .tabbar, .editor-toolbar { background: rgba(31,32,29,.94); }.find-bar input { background: #191a17; }.sheet { background: var(--surface); }
}
