/* Notes: warm paper, one red button. Light and dark. */
:root { --bg: #f7f5f0; --card: #fffdf7; --card-pin: #fff6d6; --text: #23211c; --muted: #6f6a5f; --line: #e7e1d3; --accent: #f5b400;
  --accent-ink: #7a5600; --red: #e5484d; --red-2: #c9373c; --ok: #1f8a5b; --bad: #c0392b; --shadow: 0 1px 2px rgba(60, 50, 20, .06), 0 6px 18px rgba(60, 50, 20, .07);
  --r: 14px; color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root { --bg: #16161a; --card: #222128; --card-pin: #2e2a1c; --text: #eceae4; --muted: #a29d92; --line: #34323a; --accent: #f5b400;
    --accent-ink: #f5c84a; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25); color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom, 0px); }
body.noscroll { overflow: hidden; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; }
p { margin: 0 0 .7em; }
.muted { color: var(--muted); } .faint { color: var(--muted); font-size: .85em; } .small { font-size: .88em; }
.err { color: var(--bad); background: color-mix(in srgb, var(--bad) 9%, transparent); border-radius: 10px; padding: 8px 12px; margin: 6px 0; }
.err.small { padding: 4px 8px; font-size: .82em; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }
.boot { min-height: 100vh; display: grid; place-items: center; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 32px; padding: 0 11px; font-size: .86em; border-radius: 9px; }
.btn.big { min-height: 52px; font-size: 1.05rem; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { width: 42px; height: 42px; display: inline-grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.icon-btn.on { color: var(--accent-ink); }
input, select, textarea { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); border-color: var(--accent); }
label { display: grid; gap: 5px; font-weight: 600; font-size: .92em; }
.spin { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.spin.inline { display: inline-block; width: 14px; height: 14px; border-width: 2px; margin-right: 7px; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* top bar + list */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; }
.brand img { width: 30px; height: 30px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px;
  font-weight: 400; max-width: 560px; margin: 0 auto; color: var(--muted); }
.search input { border: 0; background: none; padding: 9px 0; outline: none; min-width: 0; }
.list { padding: 6px 16px 130px; max-width: 1100px; margin: 0 auto; }
.label { font-size: .75em; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 14px 4px 8px; }
.grid { columns: 1; column-gap: 14px; }
@media (min-width: 640px) { .grid { columns: 2; } }
@media (min-width: 980px) { .grid { columns: 3; } }
.note { break-inside: avoid; position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 12px;
  margin-bottom: 14px; box-shadow: var(--shadow); cursor: pointer; display: grid; gap: 6px; }
.note:focus-visible { outline: 2px solid var(--accent); }
.note.pinned { background: var(--card-pin); }
.note.failed { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.note h3 { font-size: 1.02rem; margin: 0; padding-right: 22px; }
.note p { margin: 0; white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; color: color-mix(in srgb, var(--text) 85%, transparent); font-size: .95em; }
.note .meta { font-size: .78em; color: var(--muted); }
.note .stage { font-size: .88em; color: var(--accent-ink); font-weight: 600; }
.pin-mark { position: absolute; top: 12px; right: 12px; color: var(--accent-ink); }
.pin-mark svg { width: 17px; height: 17px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); max-width: 460px; margin: 0 auto; }
.empty h2 { color: var(--text); font-size: 1.25rem; }
.hello { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.hello svg { width: 34px; height: 34px; }
.pending { position: sticky; top: 62px; z-index: 4; margin: 0 16px; padding: 8px 12px; border-radius: 12px; display: flex; gap: 10px; align-items: center;
  justify-content: space-between; background: #fff3d1; color: #6b4e0f; border: 1px solid #f0d58a; font-size: .92em; }

/* the big buttons */
.fab-row { position: fixed; left: 0; right: 0; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); display: flex; justify-content: center; align-items: center;
  gap: 18px; pointer-events: none; z-index: 6; }
.fab-row > * { pointer-events: auto; }
.fab-gap { width: 52px; }
.fab { border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.fab.mic { width: 78px; height: 78px; background: var(--red); color: #fff; }
.fab.mic:active { transform: scale(.96); background: var(--red-2); }
.fab.mic svg { width: 36px; height: 36px; }
.fab.type { width: 52px; height: 52px; background: var(--card); color: var(--text); border: 1px solid var(--line); }

/* checklists */
.mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .94em; }
.mini li { display: flex; gap: 8px; align-items: flex-start; overflow: hidden; }
.mini li.done { color: var(--muted); text-decoration: line-through; }
.mini .box { flex: none; width: 15px; height: 15px; margin-top: 4px; border: 1.5px solid var(--muted); border-radius: 4px; font-size: 11px; line-height: 12px;
  text-align: center; color: var(--bg); }
.mini li.done .box { background: var(--muted); border-color: var(--muted); }
.checklist { display: grid; gap: 2px; padding-bottom: 8px; }
.item { display: flex; align-items: flex-start; gap: 10px; padding: 4px 0; border-radius: 8px; }
.item .tick { flex: none; width: 22px; height: 22px; margin: 6px 0 0; accent-color: var(--accent-ink); cursor: pointer; }
.item-text { flex: 1; border: 0; background: none; padding: 6px 0; resize: none; overflow: hidden; line-height: 1.45; font-size: 1.02rem; border-radius: 0; min-height: 34px; }
.item-text:focus { outline: none; border-bottom: 1px solid var(--line); }
.item .small-x { width: 34px; height: 34px; opacity: 0; }
.item:hover .small-x, .item:focus-within .small-x { opacity: 1; }
@media (hover: none) { .item .small-x { opacity: .55; } }
.item .small-x svg { width: 18px; height: 18px; }
.item.done .item-text { text-decoration: line-through; color: var(--muted); }
.item.add { font-weight: 400; color: var(--muted); padding: 4px 0; cursor: text; }
.item.add .plus { width: 22px; display: grid; place-items: center; margin-top: 6px; }
.item.add .plus svg { width: 20px; height: 20px; }
.item.add input { border: 0; background: none; padding: 6px 0; font-size: 1.02rem; outline: none; }
.done-box { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.done-box summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: .9em; padding: 4px 0; }
.fab-row .fab.type svg { width: 24px; height: 24px; }

/* summary, organized version, combining notes */
.ntabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 2px 0 4px; overflow-x: auto; }
.ntabs button { border: 0; background: none; padding: 8px 12px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.ntabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); vertical-align: 2px; margin-left: 3px; }
.ai-empty { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 36px 10px; }
.ai-empty .muted { max-width: 380px; }
.ai-out { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; line-height: 1.6; }
.ai-out h3 { font-size: 1.05rem; margin: 1em 0 .35em; }
.ai-out h3:first-child, .ai-out h4:first-child { margin-top: 0; }
.ai-out h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 1.1em 0 .4em; }
.ai-out ul { margin: 0 0 .6em; padding-left: 1.2em; }
.ai-out li { margin: .2em 0; }
.ai-out p { margin: 0 0 .6em; }
.sum-text { font-size: 1.04rem; }
.acts li::marker { content: '☐  '; }
.notice { background: #fff3d1; color: #6b4e0f; border: 1px solid #f0d58a; border-radius: 10px; padding: 8px 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .92em; }
.undo-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .9em; color: var(--muted); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-ink); font-size: .82em; font-weight: 700; }
.note.selecting { padding-left: 44px; }
.note.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.sel-mark { position: absolute; left: 14px; top: 15px; width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--muted); display: grid; place-items: center;
  font-size: 13px; font-weight: 800; color: #fff; }
.note.sel .sel-mark { background: var(--accent-ink); border-color: var(--accent-ink); }
.selbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); z-index: 6; display: flex; gap: 8px; align-items: center;
  flex-wrap: wrap; justify-content: center; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  width: max-content; max-width: calc(100vw - 24px); }
.selbar span { font-weight: 600; padding: 0 6px; }

/* recorder */
.recorder { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: grid; place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
.rec-box { width: min(440px, 100%); display: grid; gap: 18px; justify-items: center; text-align: center; }
.rec-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--red); animation: pulse 1.2s ease-in-out infinite; }
.recorder.paused .rec-dot { animation: none; background: var(--muted); }
@keyframes pulse { 50% { opacity: .25; transform: scale(.8); } }
.rec-time { font-size: 3.2rem; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.rec-hint { color: var(--muted); max-width: 320px; }
.meter { display: flex; align-items: center; gap: 4px; height: 70px; width: 100%; max-width: 340px; }
.meter i { flex: 1; height: 8%; min-height: 4px; border-radius: 4px; background: var(--red); transition: height .08s linear; }
.recorder.paused .meter i { background: var(--muted); }
.rec-actions { display: flex; align-items: center; gap: 28px; margin-top: 6px; }
.round { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.round.stop { width: 86px; height: 86px; background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 8px 24px rgba(229, 72, 77, .35); }
.round.stop svg { width: 34px; height: 34px; }
.rec-small { font-size: .82em; color: var(--muted); }

/* one note */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(20, 18, 10, .35); display: flex; justify-content: center; align-items: flex-end; }
.sheet-card { width: 100%; max-width: 760px; height: 100%; background: var(--bg); display: flex; flex-direction: column; }
@media (min-width: 800px) { .sheet { align-items: center; } .sheet-card { height: min(92vh, 900px); border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); overflow: hidden; } }
.sheet-top { display: flex; align-items: center; gap: 2px; padding: calc(6px + env(safe-area-inset-top, 0px)) 8px 6px; border-bottom: 1px solid var(--line); }
.sheet-top .sp { flex: 1; }
.sheet-top .faint { margin-right: 6px; }
.sheet-body { flex: 1; overflow: auto; padding: 14px 18px 20px; display: grid; gap: 10px; align-content: start; }
.title-in { font-size: 1.35rem; font-weight: 700; border: 0; background: none; padding: 4px 0; border-radius: 0; }
.title-in:focus { outline: none; border-bottom: 2px solid var(--accent); }
.text-in { border: 0; background: none; padding: 4px 0; resize: none; min-height: 220px; line-height: 1.65; font-size: 1.02rem; border-radius: 0; }
.text-in:focus { outline: none; }
.stage.big { color: var(--accent-ink); font-weight: 600; padding: 6px 0; }
.raw { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--card); }
.raw summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.raw p { color: var(--muted); font-size: .93em; margin-top: 10px; }
.clip { display: grid; gap: 4px; margin-top: 8px; }
.clip audio { width: 100%; height: 38px; }
.sheet-bottom { display: flex; gap: 10px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--bg); }
.sheet-bottom .btn { flex: 1; }

/* modal, toasts, sign-in */
dialog.modal { border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px)); background: var(--bg); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog.modal::backdrop { background: rgba(20, 18, 10, .45); }
.modal .mh { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 0 20px; }
.modal .mh h2 { margin: 0; font-size: 1.2rem; }
.modal .mb { padding: 14px 20px; display: grid; gap: 16px; max-height: 70vh; overflow: auto; }
.modal .mf { padding: 0 20px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.paircode { font-size: 2.6rem; font-weight: 800; letter-spacing: .12em; text-align: center; padding: 10px; border-radius: 14px; background: var(--card-pin); font-variant-numeric: tabular-nums; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(120px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 60;
  width: min(420px, calc(100vw - 32px)); }
.toast { background: #2b2822; color: #fff; padding: 11px 14px; border-radius: 12px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.toast.ok { background: var(--ok); }
.toast button { background: rgba(255, 255, 255, .18); color: #fff; border: 0; border-radius: 8px; padding: 6px 10px; font: inherit; font-weight: 700; cursor: pointer; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(400px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 26px; box-shadow: var(--shadow); display: grid; gap: 10px; text-align: center; }
.logo-big { width: 64px; height: 64px; margin: 0 auto; }
.login input { text-align: center; font-size: 1.5rem; letter-spacing: .2em; }
.login form { text-align: left; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
