/* ===================================================================== tokens */
:root {
  --accent: #e95420; --accent-2: #f5a03d; --accent-rgb: 233,84,32;
  --now: #ff3b30; --now-rgb: 255,59,48; --ok: #30d158;
  --bg: #ffffff; --side: #f7f7f5; --surface: #ffffff; --elev: #ffffff; --glass: rgba(255,255,255,.82); --sunk: #f6f6f4;
  --hover: rgba(55,53,47,.06); --active: rgba(55,53,47,.1);
  --fg: #1f1f1d; --fg2: #55534e; --muted: #91918e; --line: #ebebea; --line-soft: #f3f3f2;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 24px 60px -16px rgba(15,15,15,.28), 0 8px 20px -10px rgba(15,15,15,.14), 0 0 0 1px rgba(15,15,15,.06);
  --spring: cubic-bezier(.2, 1.35, .35, 1); --ease: cubic-bezier(.2, .8, .2, 1);
  --side-w: 264px; --doc-w: 760px;
  --serif: "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919; --side: #202020; --surface: #191919; --elev: #252525; --glass: rgba(37,37,37,.86); --sunk: #222222;
    --hover: rgba(255,255,255,.055); --active: rgba(255,255,255,.1);
    --fg: #ebebea; --fg2: #b4b4b0; --muted: #7f7f7c; --line: #2f2f2f; --line-soft: #262626;
    --shadow: 0 24px 60px -16px rgba(0,0,0,.8), 0 8px 20px -10px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.07);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font: 15px/1.5 "Inter", "Ubuntu Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--muted); }
.ic { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; }
.ic svg { width: 100%; height: 100%; }
kbd { font-family: inherit; font-size: 10.5px; font-weight: 600; padding: 2px 6px; border-radius: 5px; background: var(--hover); border: 1px solid var(--line); color: var(--muted); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border: 3px solid transparent; background-clip: content-box; border-radius: 10px; }
::selection { background: rgba(var(--accent-rgb), .22); }

/* ===================================================================== buttons */
.btn { height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--elev); font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; text-decoration: none; color: var(--fg);
  transition: transform .2s var(--spring), background .15s, box-shadow .2s, filter .2s; }
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.96); }
.btn.primary { border: 0; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 20px -10px rgba(var(--accent-rgb), .85), inset 0 1px 0 rgba(255,255,255,.25); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { height: 48px; width: 100%; font-size: 15px; border-radius: 14px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: default; transform: none; filter: none; }
.icon-btn { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--fg2); display: inline-grid; place-items: center; cursor: pointer; flex: none; transition: background .12s, transform .2s var(--spring), color .12s; }
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.sm { width: 28px; height: 28px; } .icon-btn.sm .ic { width: 16px; height: 16px; }
.icon-btn.xs { width: 22px; height: 22px; border-radius: 6px; } .icon-btn.xs .ic { width: 14px; height: 14px; }
.only-mobile { display: none; }

/* ===================================================================== login */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; overflow: hidden; background: #111; }
.login-bg { position: absolute; inset: 0; overflow: hidden; }
.login-bg i { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(80px); opacity: .55; animation: drift 18s ease-in-out infinite alternate; }
.login-bg i:nth-child(1) { background: #ff6a3d; left: -20vmax; top: -25vmax; }
.login-bg i:nth-child(2) { background: #7a5cff; right: -25vmax; top: 10vmax; animation-delay: -6s; opacity: .4; }
.login-bg i:nth-child(3) { background: #f7a541; left: 10vmax; bottom: -35vmax; animation-delay: -12s; opacity: .45; }
@keyframes drift { to { transform: translate(6vmax, 4vmax) scale(1.1); } }
.login-card { position: relative; width: 100%; max-width: 380px; padding: 34px 30px 26px; border-radius: 26px; background: rgba(30,30,34,.78); color: #f3f3f5; backdrop-filter: blur(30px) saturate(1.6); -webkit-backdrop-filter: blur(30px) saturate(1.6);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.08); text-align: center; animation: rise .6s var(--spring) both; }
.login-card.shake { animation: shake .45s; }
.login-logo { filter: drop-shadow(0 10px 18px rgba(var(--accent-rgb), .35)); animation: float 5s ease-in-out infinite alternate; }
@keyframes float { to { transform: translateY(-5px) rotate(-2deg); } }
.login-card h1 { margin: 10px 0 2px; font-size: 28px; letter-spacing: -.03em; }
.login-card .muted { margin: 0 0 22px; color: #9a9aa3; }
.field-wrap { display: block; text-align: left; margin-bottom: 14px; }
.field-wrap > span { display: block; font-size: 12px; font-weight: 700; color: #b9b9c2; margin: 0 0 6px 2px; }
.field-wrap input, .pw { width: 100%; height: 48px; border-radius: 14px; border: 1px solid rgba(255,255,255,.1); background: rgba(0,0,0,.25); color: #fff; padding: 0 14px; outline: none; font-size: 16px; transition: border-color .15s, box-shadow .2s; }
.field-wrap input:focus, .pw:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .2); }
#code { letter-spacing: .35em; font-weight: 700; text-align: center; font-size: 20px; }
.pw { display: flex; align-items: center; padding: 0 6px 0 0; }
.pw input { flex: 1; min-width: 0; border: 0; height: 100%; background: transparent; padding: 0 14px; box-shadow: none !important; }
.pw-toggle { border: 0; background: rgba(255,255,255,.08); color: #ccc; border-radius: 9px; height: 34px; padding: 0 11px; font-size: 12px; font-weight: 700; cursor: pointer; }
.login-err { min-height: 20px; margin: 2px 0 12px; color: #ff6b61; font-weight: 650; font-size: 13px; }
.fine { margin: 16px 0 0; font-size: 11.5px; color: #8a8a93; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }

/* ===================================================================== shell */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; font-size: 14px; }
.side-scrim { display: none; }
.ws { display: flex; align-items: center; gap: 9px; padding: 14px 12px 8px 16px; }
.ws b { flex: 1; font-size: 15px; letter-spacing: -.01em; }
.side-search { margin: 4px 10px 6px; height: 34px; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--muted); cursor: pointer; }
.side-search span:nth-child(2) { flex: 1; text-align: left; }
.side-search:hover { border-color: rgba(var(--accent-rgb), .4); }
.side-links, .side-foot { padding: 2px 8px; }
.side-links a, .side-foot a { display: flex; align-items: center; gap: 9px; height: 32px; padding: 0 9px; border-radius: 7px; text-decoration: none; color: var(--fg2); font-weight: 550; }
.side-links a:hover, .side-foot a:hover { background: var(--hover); color: var(--fg); }
.side-links a.on, .side-foot a.on { background: var(--active); color: var(--fg); }
.side-links .ic, .side-foot .ic { width: 17px; height: 17px; }
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 10px; min-height: 0; }
.side-h { display: flex; align-items: center; justify-content: space-between; margin: 14px 8px 4px 10px; font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.side-foot { border-top: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.new-page { width: 100%; }
.tree .row { position: relative; display: flex; align-items: center; height: 30px; padding-right: 4px; border-radius: 7px; cursor: pointer; color: var(--fg2); text-decoration: none; }
.tree .row:hover { background: var(--hover); color: var(--fg); }
.tree .row.on { background: var(--active); color: var(--fg); font-weight: 600; }
.tree .tw { width: 22px; height: 22px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); border-radius: 5px; cursor: pointer; flex: none; transition: transform .2s var(--ease); }
.tree .tw:hover { background: var(--active); }
.tree .tw.open { transform: rotate(90deg); }
.tree .tw.leaf { visibility: hidden; }
.tree .tw .ic { width: 12px; height: 12px; }
.tree .em { width: 20px; text-align: center; flex: none; font-size: 14px; }
.tree .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: 4px; }
.tree .acts { display: none; gap: 1px; }
.tree .row:hover .acts { display: flex; }
.tree .kids { overflow: hidden; }
.tree .empty-kids { padding: 4px 0 4px 0; font-size: 12.5px; color: var(--muted); }
.main { position: relative; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }
.view { flex: 1; min-height: 0; overflow-y: auto; animation: fadeUp .3s var(--ease); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px; height: 46px; padding: 0 12px; background: var(--bg); }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; font-size: 13.5px; color: var(--fg2); overflow: hidden; white-space: nowrap; }
.crumbs a { padding: 3px 6px; border-radius: 6px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.crumbs a:hover { background: var(--hover); }
.crumbs .sep { color: var(--muted); }
.save-state { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; margin-right: 4px; white-space: nowrap; }
.save-state.busy::before { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.save-state.err { color: var(--now); }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn.on { color: var(--accent); }
.hamburger { display: none; }

/* ===================================================================== page */
.page { max-width: calc(var(--doc-w) + 96px); margin: 0 auto; padding: 0 48px 120px; }
.page.wide { --doc-w: 1100px; }
.p-cover { height: 140px; margin: 0 -48px 0; border-radius: 0 0 4px 4px; background: linear-gradient(120deg, rgba(var(--accent-rgb), .16), rgba(122, 92, 255, .12) 50%, rgba(245, 160, 61, .16)); background-size: 200% 200%; animation: cover 16s ease-in-out infinite alternate; }
@keyframes cover { to { background-position: 100% 100%; } }
.p-icon { font-size: 64px; line-height: 1; margin-top: -40px; width: 78px; height: 78px; display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; border-radius: 12px; transition: transform .25s var(--spring), background .15s; }
.p-icon:hover { background: var(--hover); transform: scale(1.05); }
.p-icon.empty { font-size: 14px; color: var(--muted); width: auto; height: 30px; margin-top: 14px; padding: 0 8px; gap: 6px; display: inline-flex; align-items: center; }
.p-title { width: 100%; border: 0; outline: none; background: transparent; resize: none; overflow: hidden; font-size: 40px; font-weight: 750; letter-spacing: -.025em; line-height: 1.2; padding: 6px 0 2px; margin: 4px 0 2px; color: var(--fg); }
.p-title::placeholder { color: var(--muted); opacity: .55; }
.p-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 10px; font-size: 13px; color: var(--muted); }
.ev-chip { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px; border-radius: 999px; font-weight: 600; font-size: 12.5px; text-decoration: none;
  background: hsla(var(--h, 20), var(--s, 80%), 56%, .14); color: hsl(var(--h, 20), var(--s, 80%), 36%); cursor: pointer; border: 0; }
@media (prefers-color-scheme: dark) { .ev-chip { color: hsl(var(--h, 20), var(--s, 80%), 74%); } }
.ev-chip .ic { width: 14px; height: 14px; }

/* toolbar (Word-style) */
.toolbar { position: sticky; top: 46px; z-index: 15; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 8px; margin: 8px -8px 18px; background: var(--glass); backdrop-filter: blur(16px) saturate(1.5); -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px -16px rgba(0,0,0,.25); }
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; flex: none; }
.tb { height: 30px; min-width: 30px; padding: 0 6px; border: 0; border-radius: 7px; background: transparent; color: var(--fg2); display: inline-grid; place-items: center; cursor: pointer; transition: background .12s, color .12s; font-weight: 700; font-size: 13.5px; }
.tb:hover { background: var(--hover); color: var(--fg); }
.tb.on { background: rgba(var(--accent-rgb), .13); color: var(--accent); }
.tb:disabled { opacity: .35; cursor: default; background: transparent; }
.tb .ic { width: 17px; height: 17px; }
.tb-select { height: 30px; border: 0; border-radius: 7px; background: transparent; padding: 0 22px 0 8px; font-size: 13px; font-weight: 600; color: var(--fg2); cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2391918e' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 5px center; background-size: 12px; }
.tb-select:hover { background-color: var(--hover); }
.tb-select option { background: var(--elev); color: var(--fg); }
.swatch-btn { position: relative; }
.swatch-btn::after { content: ""; position: absolute; left: 7px; right: 7px; bottom: 4px; height: 3px; border-radius: 2px; background: var(--sw, currentColor); }
.ctx-bar { display: flex; flex-wrap: wrap; gap: 2px; width: 100%; padding-top: 6px; margin-top: 4px; border-top: 1px solid var(--line); animation: fadeUp .2s var(--ease); }
.ctx-bar .lbl { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; align-self: center; margin: 0 6px 0 4px; }

/* ===================================================================== document */
.doc { outline: none; font-size: 16px; line-height: 1.7; color: var(--fg); min-height: 50vh; caret-color: var(--accent); word-wrap: break-word; }
.doc > * + * { margin-top: .55em; }
.doc p { margin: 0; }
.doc h1, .doc h2, .doc h3 { line-height: 1.25; letter-spacing: -.015em; margin: 1.4em 0 .3em; }
.doc h1 { font-size: 1.9em; font-weight: 750; }
.doc h2 { font-size: 1.45em; font-weight: 700; }
.doc h3 { font-size: 1.2em; font-weight: 700; }
.doc > :first-child { margin-top: 0; }
.doc a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.doc ul, .doc ol { padding-left: 1.6em; margin: .3em 0; }
.doc li > p { margin: 0; }
.doc li::marker { color: var(--muted); }
.doc blockquote { margin: .8em 0; padding: 2px 0 2px 16px; border-left: 3px solid var(--fg); }
.doc code { font-family: var(--mono); font-size: .88em; padding: .15em .4em; border-radius: 5px; background: var(--hover); color: #eb5757; }
.doc pre { font-family: var(--mono); font-size: 13.5px; line-height: 1.6; padding: 16px 18px; border-radius: 10px; background: var(--sunk); border: 1px solid var(--line); overflow-x: auto; }
.doc pre code { padding: 0; background: none; color: var(--fg); font-size: inherit; }
.doc hr { border: 0; height: 1px; background: var(--line); margin: 1.6em 0; }
.doc mark { border-radius: 3px; padding: 0 .1em; color: inherit; }
.doc img { display: block; max-width: 100%; height: auto; border-radius: 8px; margin: .8em auto; transition: box-shadow .2s; }
.doc img[data-align="left"] { margin-left: 0; }
.doc img[data-align="right"] { margin-right: 0; }
.doc img.ProseMirror-selectednode { box-shadow: 0 0 0 3px var(--accent); }
.doc ul[data-type="taskList"] { list-style: none; padding-left: .2em; }
.doc ul[data-type="taskList"] li { display: flex; gap: 10px; align-items: flex-start; }
.doc ul[data-type="taskList"] li > label { flex: none; margin-top: .25em; user-select: none; }
.doc ul[data-type="taskList"] li > div { flex: 1; min-width: 0; }
.doc ul[data-type="taskList"] input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--muted); margin: 0; cursor: pointer; display: grid; place-items: center; transition: background .15s, border-color .15s, transform .2s var(--spring); }
.doc ul[data-type="taskList"] input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); transform: scale(1.05); }
.doc ul[data-type="taskList"] input[type="checkbox"]:checked::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }
.doc ul[data-type="taskList"] li[data-checked="true"] > div { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--muted); }
.doc .tableWrapper { overflow-x: auto; margin: 1em 0; }
.doc table { border-collapse: collapse; table-layout: fixed; width: 100%; margin: 0; overflow: hidden; }
.doc td, .doc th { position: relative; min-width: 60px; border: 1px solid var(--line); padding: 7px 10px; vertical-align: top; }
.doc th { background: var(--sunk); font-weight: 650; text-align: left; }
.doc td > p, .doc th > p { margin: 0; }
.doc .selectedCell::after { content: ""; position: absolute; inset: 0; background: rgba(var(--accent-rgb), .12); pointer-events: none; }
.doc .column-resize-handle { position: absolute; right: -2px; top: 0; bottom: -2px; width: 4px; background: var(--accent); pointer-events: none; }
.doc.resize-cursor, .resize-cursor { cursor: col-resize; }
.doc .is-empty::before { content: attr(data-placeholder); float: left; height: 0; color: var(--muted); opacity: .7; pointer-events: none; }
.doc .drop-cursor { background: var(--accent) !important; }
.doc .ProseMirror-gapcursor::after { border-top-color: var(--fg); }
.doc-foot { display: flex; justify-content: space-between; margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }

/* sub-pages */
.subpages { margin-top: 34px; }
.subpages h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.subpage { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: var(--fg2); font-weight: 550; }
.subpage:hover { background: var(--hover); color: var(--fg); }

/* ===================================================================== floating UI */
.pop, .bubble, .slash { position: fixed; z-index: 80; background: var(--elev); border-radius: 12px; box-shadow: var(--shadow); animation: popIn .22s var(--spring); }
@keyframes popIn { from { opacity: 0; transform: translateY(4px) scale(.97); } }
.pop { padding: 8px; max-width: 340px; }
.bubble { display: flex; align-items: center; gap: 1px; padding: 4px; }
.bubble .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.palette { display: grid; grid-template-columns: repeat(5, 30px); gap: 6px; padding: 4px; }
.palette-h { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 4px 4px 2px; }
.sw { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; display: grid; place-items: center; font-weight: 750; font-size: 14px; background: var(--bg); transition: transform .2s var(--spring); }
.sw:hover { transform: scale(1.12); }
.grid-pick { display: grid; grid-template-columns: repeat(8, 20px); gap: 3px; padding: 4px; }
.grid-pick i { width: 20px; height: 20px; border-radius: 4px; border: 1px solid var(--line); background: var(--bg); }
.grid-pick i.on { background: rgba(var(--accent-rgb), .3); border-color: var(--accent); }
.grid-lbl { text-align: center; font-size: 12px; font-weight: 650; color: var(--fg2); padding: 4px 0 2px; }
.link-form { display: flex; gap: 6px; }
.link-form input { width: 240px; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--bg); outline: none; }
.link-form input:focus { border-color: var(--accent); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 36px); gap: 2px; max-height: 260px; overflow-y: auto; }
.emoji-grid button { width: 36px; height: 36px; border: 0; background: transparent; border-radius: 8px; font-size: 20px; cursor: pointer; transition: transform .15s var(--spring), background .12s; }
.emoji-grid button:hover { background: var(--hover); transform: scale(1.15); }
.menu { display: flex; flex-direction: column; min-width: 200px; }
.menu button { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; background: transparent; border-radius: 8px; text-align: left; cursor: pointer; color: var(--fg2); font-size: 13.5px; }
.menu button:hover, .menu button.on { background: var(--hover); color: var(--fg); }
.menu button.danger { color: var(--now); }
.menu .ic { width: 16px; height: 16px; }
.slash { width: 300px; max-height: 360px; overflow-y: auto; padding: 6px; }
.slash .h { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin: 6px 8px 4px; }
.slash button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px 8px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; text-align: left; }
.slash button.on { background: var(--hover); }
.slash .si { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); display: grid; place-items: center; flex: none; font-weight: 750; color: var(--fg2); }
.slash .si .ic { width: 20px; height: 20px; }
.slash b { display: block; font-size: 14px; font-weight: 600; }
.slash small { color: var(--muted); font-size: 12px; }
.slash .none { padding: 10px; color: var(--muted); font-size: 13px; }

/* search */
.overlay { position: fixed; inset: 0; z-index: 70; background: rgba(15,15,15,.35); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 0; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.search-box { width: 640px; max-width: 100%; background: var(--elev); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; animation: rise .35s var(--spring); }
.search-field { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.search-field input { flex: 1; border: 0; outline: none; background: transparent; font-size: 18px; }
.search-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.sr { display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 9px 12px; border: 0; background: transparent; border-radius: 10px; text-align: left; cursor: pointer; }
.sr.on, .sr:hover { background: var(--hover); }
.sr .em { font-size: 18px; width: 24px; text-align: center; }
.sr b { display: block; font-weight: 600; }
.sr small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 520px; }
.sr-empty { padding: 26px; text-align: center; color: var(--muted); }

/* ===================================================================== home */
.home { max-width: 1000px; margin: 0 auto; padding: 40px 40px 100px; }
.hello { font-size: 34px; font-weight: 800; letter-spacing: -.03em; margin: 10px 0 4px; }
.hello-sub { color: var(--muted); margin-bottom: 26px; }
.quick { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 34px; }
.sec-h { display: flex; align-items: center; gap: 8px; margin: 30px 0 12px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 16px; min-height: 120px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--fg);
  transition: transform .25s var(--spring), box-shadow .25s, border-color .2s; animation: fadeUp .4s var(--ease) backwards; overflow: hidden; }
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 46px; background: linear-gradient(120deg, rgba(var(--accent-rgb), .1), rgba(122, 92, 255, .08)); }
.card:hover { transform: translateY(-3px); box-shadow: 0 16px 32px -18px rgba(0,0,0,.35); border-color: transparent; }
.card .em { position: relative; font-size: 30px; line-height: 1; margin-top: 12px; }
.card b { font-size: 14.5px; font-weight: 650; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card small { margin-top: auto; color: var(--muted); font-size: 12px; }
.dl { display: flex; flex-direction: column; gap: 8px; }
.dl-item { display: grid; grid-template-columns: 4px 64px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 11px 14px 11px 12px; border-radius: 12px;
  background: linear-gradient(110deg, hsla(var(--h), var(--s), 58%, .12), hsla(calc(var(--h) + 24), var(--s), 58%, .03)); box-shadow: inset 0 0 0 1px hsla(var(--h), var(--s), 50%, .14); animation: fadeUp .4s var(--ease) backwards; }
.dl-item .bar { align-self: stretch; border-radius: 3px; background: hsl(var(--h), var(--s), 55%); }
.dl-item .date { font-size: 12px; font-weight: 700; color: var(--fg2); line-height: 1.2; }
.dl-item .date b { display: block; font-size: 20px; letter-spacing: -.02em; color: var(--fg); }
.dl-item .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-item .t small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; }
.empty { text-align: center; padding: 50px 10px; color: var(--muted); }
.empty .ic { width: 46px; height: 46px; opacity: .45; animation: float 4s ease-in-out infinite alternate; }
.empty b { display: block; color: var(--fg2); font-size: 15px; margin: 8px 0 4px; }

/* ===================================================================== calendar view */
.calv { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; flex: 1; min-height: 0; padding: 0 14px 14px; }
.cal-head { display: flex; align-items: center; gap: 6px; }
.cal-head h2 { margin: 0 8px; font-size: 20px; letter-spacing: -.02em; min-width: 170px; }
.event-dialog { width: min(520px, calc(100vw - 28px)); max-height: min(90vh, 760px); margin: auto; padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--elev); color: var(--fg); box-shadow: var(--shadow); }
.event-dialog::backdrop { background: rgba(15,15,15,.45); backdrop-filter: blur(4px); }
.event-form { display: grid; gap: 14px; max-height: min(90vh, 760px); overflow-y: auto; padding: 20px; }
.event-form header, .event-form footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.event-form header h2 { margin: 0; font-size: 20px; }
.event-form footer { justify-content: flex-end; padding-top: 4px; }
.event-error { margin: 0; color: var(--now); font-size: 13px; }
.event-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.event-field { display: grid; gap: 5px; min-width: 0; }
.event-field > span { font-size: 12px; font-weight: 650; color: var(--fg2); }
.event-field input, .event-field select, .event-field textarea { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); padding: 9px 10px; outline: none; }
.event-field input:focus, .event-field select:focus, .event-field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .14); }
.event-field textarea { resize: vertical; }
.event-check { display: flex; align-items: center; gap: 8px; color: var(--fg2); font-size: 13px; }
.event-check input { accent-color: var(--accent); }
.cal { display: flex; flex-direction: column; min-height: 0; border-radius: 14px; border: 1px solid var(--line); overflow: hidden; background: var(--surface); }
.dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.dow div { padding: 9px 0 7px; text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: repeat(6, minmax(0, 1fr)); }
.grid.anim { animation: slideIn .4s var(--ease); } .grid.anim.back { animation-name: slideInBack; }
@keyframes slideIn { from { opacity: 0; transform: translateX(26px); } }
@keyframes slideInBack { from { opacity: 0; transform: translateX(-26px); } }
.day { position: relative; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: transparent; padding: 5px 5px 3px; text-align: left; display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden; cursor: pointer; transition: background .15s; }
.day:nth-child(7n) { border-right: 0; } .day:nth-last-child(-n+7) { border-bottom: 0; }
.day:hover { background: rgba(var(--accent-rgb), .04); }
.day.out { color: var(--muted); } .day.out .chip { opacity: .5; }
.dnum { align-self: flex-start; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 9px; display: grid; place-items: center; font-weight: 650; font-size: 12.5px; }
.day.today .dnum { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 6px 14px -5px rgba(var(--accent-rgb), .8); }
.day.sel { background: rgba(var(--accent-rgb), .06); }
.day.sel::after { content: ""; position: absolute; inset: 3px; border-radius: 10px; box-shadow: inset 0 0 0 2px var(--accent); pointer-events: none; animation: popIn .3s var(--spring); }
.chip { display: flex; align-items: center; gap: 5px; min-width: 0; padding: 1px 6px; border-radius: 6px; font-size: 11.5px; flex: none; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: hsl(var(--h), var(--s), 55%); }
.chip .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.allday { background: linear-gradient(135deg, hsl(var(--h), var(--s), 52%), hsl(calc(var(--h) + 18), var(--s), 46%)); color: #fff; font-weight: 650; }
.chip.allday .dot { display: none; }
.chip.past { opacity: .5; }
.more { font-size: 11px; font-weight: 700; color: var(--fg2); padding: 0 6px; }
.mdots { display: none; }
.panel { min-height: 0; overflow-y: auto; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); padding: 20px 20px 26px; }
.view-in { animation: viewIn .35s var(--ease); } .view-in.back { animation-name: viewInBack; }
@keyframes viewIn { from { opacity: 0; transform: translateX(18px); } }
@keyframes viewInBack { from { opacity: 0; transform: translateX(-18px); } }
.p-head { display: flex; align-items: flex-end; gap: 14px; }
.p-big { font-size: 50px; font-weight: 800; line-height: .9; letter-spacing: -.05em; }
.p-big.today { background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.p-wd { font-size: 17px; font-weight: 750; }
.p-sub { color: var(--muted); font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: rgba(var(--accent-rgb), .12); color: var(--accent); margin: 14px 0; }
.items { display: flex; flex-direction: column; gap: 8px; }
.item { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; padding: 11px 13px 11px 11px; border: 0; border-radius: 12px; text-align: left; cursor: pointer;
  background: linear-gradient(110deg, hsla(var(--h), var(--s), 58%, .13), hsla(calc(var(--h) + 24), var(--s), 58%, .04)); box-shadow: inset 0 0 0 1px hsla(var(--h), var(--s), 50%, .14);
  transition: transform .22s var(--spring), box-shadow .22s; animation: fadeUp .4s var(--ease) backwards; }
.item:hover { transform: translateX(3px); }
.item .bar { align-self: stretch; border-radius: 3px; background: hsl(var(--h), var(--s), 55%); }
.item .ti { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 12.5px; color: var(--fg2); display: flex; gap: 10px; flex-wrap: wrap; }
.item .meta .ic { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
.item.past { opacity: .55; }
.due { font-size: 11px; font-weight: 750; padding: 4px 9px; border-radius: 999px; white-space: nowrap; background: hsla(var(--h), var(--s), 55%, .16); color: hsl(var(--h), var(--s), 34%); }
@media (prefers-color-scheme: dark) { .due { color: hsl(var(--h), var(--s), 78%); } }
.due.soon { background: rgba(var(--now-rgb), .14); color: var(--now); }
.due.done { background: var(--hover); color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 4px; margin: -4px 0 12px -8px; border: 0; background: transparent; color: var(--fg2); font-weight: 650; padding: 6px 10px 6px 6px; border-radius: 9px; cursor: pointer; }
.back:hover { background: var(--hover); }
.d-card { position: relative; border-radius: 16px; padding: 16px 16px 14px 22px; background: linear-gradient(135deg, hsla(var(--h), var(--s), 58%, .2), hsla(calc(var(--h) + 30), var(--s), 58%, .06)); }
.d-card::before { content: ""; position: absolute; left: 9px; top: 14px; bottom: 14px; width: 4px; border-radius: 4px; background: hsl(var(--h), var(--s), 55%); }
.d-title { font-size: 20px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; word-break: break-word; }
.d-cal { margin: 3px 0 10px; font-size: 12.5px; font-weight: 650; color: var(--fg2); }
.rows { margin: 16px 0 4px; display: flex; flex-direction: column; gap: 11px; }
.r { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 12px; color: var(--fg2); font-size: 14px; }
.r .ic { color: var(--muted); }
.desc { white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow-y: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }

/* trash */
.trash-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; }
.trash-row:hover { background: var(--hover); }
.trash-row .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* toast */
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 30px) scale(.92); opacity: 0; padding: 10px 18px; border-radius: 12px; font-weight: 650;
  background: #2b2b2b; color: #fff; box-shadow: var(--shadow); transition: opacity .25s, transform .45s var(--spring); pointer-events: none; z-index: 100; }
.toast.on { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ===================================================================== responsive */
@media (max-width: 1100px) { .calv { grid-template-columns: minmax(0, 1fr) 320px; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 84vw; max-width: 320px; z-index: 60; transform: translateX(-105%); transition: transform .4s var(--spring); box-shadow: var(--shadow); padding-top: env(safe-area-inset-top); }
  .side.open { transform: none; }
  .side-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .3s; }
  .side-scrim.on { opacity: 1; pointer-events: auto; }
  .only-mobile, .hamburger { display: inline-grid; }
  .page { padding: 0 18px 100px; }
  .p-cover { margin: 0 -18px; height: 100px; }
  .p-title { font-size: 30px; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; margin: 8px -18px 16px; border-radius: 0; border-left: 0; border-right: 0; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .ctx-bar { flex-wrap: nowrap; width: auto; border-top: 0; border-left: 1px solid var(--line); padding: 0 0 0 6px; margin: 0 0 0 4px; }
  .home { padding: 20px 18px 80px; }
  .hello { font-size: 28px; }
  .dl-item { grid-template-columns: 4px 52px minmax(0, 1fr) auto; }
  .dl-item .due { display: none; }
  .calv { grid-template-columns: 1fr; padding: 0 6px 8px; }
  .calv .panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: 76dvh; border-radius: 22px 22px 0 0; transform: translateY(105%); transition: transform .45s var(--spring); box-shadow: var(--shadow); border: 0; }
  .calv .panel.open { transform: none; }
  .chip, .more { display: none; }
  .mdots { display: flex; gap: 3px; margin-top: 3px; justify-content: center; }
  .mdots i { width: 6px; height: 6px; border-radius: 50%; background: hsl(var(--h), var(--s), 55%); }
  .day { align-items: center; }
  .dnum { align-self: center; }
  .cal-head h2 { min-width: 0; font-size: 17px; }
  .event-fields { grid-template-columns: 1fr; }
  .add-event { padding: 0 9px; }
  .add-event span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
