/* Layout: sticky toolbar, left label rail, masonry wall of paper slips */
:root {
  --bg: #f3f2ee;
  --surface: #ffffff;
  --fg: #23262b;
  --muted: #6b6f78;
  --line: #dcdad3;
  --accent: #2f6f6a;
  --accent-ink: #ffffff;
  --danger: #b3412f;
  --shadow: 0 1px 2px rgba(30,30,25,.08), 0 2px 8px rgba(30,30,25,.06);
  /* note paper colors */
  --n-default: #ffffff;
  --n-sand: #f6e7c1;
  --n-sage: #dbe8d4;
  --n-sky: #d6e6f0;
  --n-rose: #f3d9d6;
  --n-lilac: #e4dcef;
  --n-clay: #ecd9c6;
  --font-display: "LXGW WenKai TC", "Kaiti TC", "STKaiti", serif;
  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1d20; --surface: #24272b; --fg: #e8e6e1; --muted: #9a9ea6; --line: #383b41;
    --accent: #6fb5ad; --accent-ink: #10201e; --danger: #e08a7a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.3);
    --n-default: #24272b; --n-sand: #4a4129; --n-sage: #2f3d2d; --n-sky: #263846;
    --n-rose: #47302e; --n-lilac: #3a3247; --n-clay: #46372a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.55; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }

header.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  padding-bottom: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--font-display); font-size: 22px; font-weight: 700; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 22px; height: 26px; border-radius: 3px 3px 3px 10px; background: var(--n-sand); border: 1.5px solid var(--fg); transform: rotate(-6deg); flex: none; }
.search { flex: 1; min-width: 0; max-width: 640px; margin-inline: auto; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; }
.search input { border: 0; background: transparent; outline: none; flex: 1; min-width: 0; }
.icon-btn { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); color: var(--fg); }
.icon-btn[aria-pressed="true"] { color: var(--accent); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sync-pill { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sync-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync-pill[data-state="ok"] .dot { background: var(--accent); }
.sync-pill[data-state="syncing"] .dot { background: var(--accent); animation: pulse 1s infinite alternate; }
.sync-pill[data-state="error"] { color: var(--danger); border-color: var(--danger); }
.sync-pill[data-state="error"] .dot { background: var(--danger); }
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }

.shell { display: grid; grid-template-columns: 210px 1fr; gap: 24px;
  padding-top: 20px; padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px)); }
nav.rail { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); align-self: start; }
.rail button { display: flex; align-items: center; gap: 12px; border: 0; background: transparent; padding: 8px 14px; border-radius: 0 999px 999px 0; text-align: left; color: var(--fg); }
.rail button:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); }
.rail button[aria-current="true"] { background: color-mix(in srgb, var(--accent) 18%, transparent); font-weight: 700; }
.rail .count { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.rail-label { font-size: 11px; letter-spacing: .08em; color: var(--muted); padding: 14px 14px 4px; }

main { min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.status { font-size: 12.5px; color: var(--muted); text-align: center; }

/* composer */
.composer { max-width: 600px; width: 100%; margin-inline: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.composer .collapsed { display: flex; align-items: center; padding: 4px 6px 4px 16px; gap: 4px; }
.composer .collapsed input { flex: 1; border: 0; background: transparent; outline: none; padding: 8px 0; min-width: 0; }
.composer .expanded { padding: 12px 16px 8px; display: flex; flex-direction: column; gap: 6px; }
.composer .body-input { max-height: 45vh; overflow-y: auto; }

.title-input { border: 0; background: transparent; outline: none; font-family: var(--font-display); font-size: 19px; font-weight: 700; width: 100%; }
.body-input { border: 0; background: transparent; outline: none; resize: none; width: 100%; min-height: 60px; }
.check-list { display: flex; flex-direction: column; gap: 2px; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input[type=text] { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 3px 0; }
.check-row.done input[type=text] { text-decoration: line-through; color: var(--muted); }
.check-row .icon-btn { width: 28px; height: 28px; }
.tools { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.tools .spacer { flex: 1; }
.text-btn { border: 0; background: transparent; padding: 7px 16px; border-radius: 6px; font-weight: 500; }
.text-btn:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.text-btn.primary { background: var(--accent); color: var(--accent-ink); }
.text-btn.primary:disabled { opacity: .6; cursor: wait; }
.saved { font-size: 11.5px; color: var(--muted); }

/* wall */
.section-title { font-size: 11px; letter-spacing: .1em; color: var(--muted); margin: 0 0 8px 4px; }
.wall { columns: 240px; column-gap: 14px; }
.wall.list { columns: 1; max-width: 600px; margin-inline: auto; }
.note { break-inside: avoid; margin-bottom: 14px; border-radius: var(--radius); border: 1px solid var(--line); padding: 12px 14px 6px; position: relative; cursor: default; transition: box-shadow .15s; display: flex; flex-direction: column; gap: 6px; }
.note:hover { box-shadow: var(--shadow); }
.note:hover .note-tools, .note:focus-within .note-tools { opacity: 1; }
.note h3 { margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 700; padding-right: 30px; overflow-wrap: anywhere; }
.note .body { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 340px; overflow: hidden; }
.note .items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.note .items li { display: flex; gap: 8px; align-items: flex-start; overflow-wrap: anywhere; }
.note .items li.done span { text-decoration: line-through; color: var(--muted); }
.note .items .box { flex: none; width: 15px; height: 15px; margin-top: 4px; border: 1.5px solid var(--muted); border-radius: 3px; }
.note .items li.done .box { background: var(--muted); }
.note .pin { position: absolute; top: 6px; right: 6px; opacity: 0; }
.note .pin[aria-pressed="true"], .note:hover .pin { opacity: 1; }
.note-tools { display: flex; opacity: 0; transition: opacity .15s; margin-left: -8px; }
.note-tools .icon-btn { width: 32px; height: 32px; }
.note-tools svg { width: 17px; height: 17px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11.5px; padding: 1px 9px; border-radius: 999px; background: color-mix(in srgb, var(--fg) 9%, transparent); display: inline-flex; align-items: center; gap: 2px; }

.empty { text-align: center; color: var(--muted); padding: 60px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty svg { width: 64px; height: 64px; stroke-width: 1.2; opacity: .5; }

/* popovers */
.palette, .menu { position: absolute; z-index: 30; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 8px; }
.palette { display: flex; gap: 6px; flex-wrap: wrap; max-width: 240px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line); }
.swatch[aria-pressed="true"] { border: 2px solid var(--accent); }
.menu { display: flex; flex-direction: column; min-width: 200px; padding: 6px; }
.menu button { border: 0; background: transparent; text-align: left; padding: 9px 12px; border-radius: 6px; display: flex; gap: 10px; align-items: center; }
.menu button:hover { background: color-mix(in srgb, var(--fg) 7%, transparent); }
.menu .who { font-size: 12px; color: var(--muted); padding: 6px 12px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-wrap: anywhere; }
.menu .danger { color: var(--danger); }

/* editor dialog: fixed size, the writing area scrolls inside so nothing jumps while typing */
.scrim { position: fixed; inset: 0; z-index: 20; background: color-mix(in srgb, #000 45%, transparent); display: grid; place-items: center;
  padding-top: max(16px, env(safe-area-inset-top, 0px)); padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.dialog { width: 100%; max-width: 780px; height: min(86vh, 860px); max-height: 100%; overflow: hidden; border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.3); padding: 18px 20px 10px; display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); }
.dialog .title-input { font-size: 21px; flex: none; }
.dialog .body-input { flex: 1; min-height: 0; overflow-y: auto; font-size: 16px; line-height: 1.7; }
.dialog .check-list { flex: 1; min-height: 0; overflow-y: auto; }
.dialog .label-row, .dialog .tools { flex: none; }
.label-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.label-row input { border: 1px dashed var(--line); background: transparent; border-radius: 999px; padding: 2px 10px; font-size: 12.5px; width: 130px; outline: none; }

.toast { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 10px 14px 10px 18px; border-radius: 8px; display: flex; gap: 14px; align-items: center; font-size: 14px; max-width: calc(100% - 32px); }
.toast button { border: 0; background: transparent; color: var(--bg); font-weight: 700; text-decoration: underline; }

/* sign-in and unlock screens */
.gate { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding-top: max(24px, env(safe-area-inset-top, 0px)); padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.gate-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.gate-card h1 { font-family: var(--font-display); font-size: 26px; margin: 0; display: flex; align-items: center; gap: 10px; text-wrap: balance; }
.gate-card p { margin: 0; }
.dialog-h { font-family: var(--font-display); font-size: 22px; margin: 0; }
.gate-card form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input { font-size: 16px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; outline: none; }
.field input:focus { border-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; }
.check input { margin-top: 4px; }
.notice { font-size: 13px; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.notice.warn { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.error { color: var(--danger); font-size: 13.5px; }
.link-btn { border: 0; background: transparent; color: var(--accent); padding: 0; text-decoration: underline; font-size: 13.5px; align-self: flex-start; }
.gate-card .text-btn.primary { padding: 11px 16px; font-size: 16px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; gap: 14px; }
  nav.rail { position: static; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .rail button { border-radius: 999px; white-space: nowrap; padding: 6px 12px; border: 1px solid var(--line); }
  .rail .count, .rail-label { display: none; }
  .brand span.word, .sync-pill .label { display: none; }
  .note-tools, .note .pin { opacity: 1; }
  .wall { columns: 2 150px; column-gap: 10px; }
  /* 16px inputs stop iPhone from zooming in when you tap a field */
  input, textarea { font-size: 16px; }
  .scrim { padding: 0; }
  .dialog { height: 100%; max-width: none; border-radius: 0; border: 0;
    padding-top: max(14px, env(safe-area-inset-top, 0px)); padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
