:root {
  --bg: #1c1a18;
  --bg-2: #262220;
  --bg-3: #302b28;
  --line: #3b3531;
  --ink: #efe6d6;
  --ink-2: #b8ad9c;
  --ink-3: #7f766b;
  --accent: #c8623f;
  --accent-2: #e07a52;
  --ok: #7fa66a;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent); color: #fff; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-2);
  color: var(--ink); font-size: 13px; font-weight: 500;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); background: var(--bg-2); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; }

/* ---------- gate ---------- */
.gate {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(200, 98, 63, .18), transparent 60%),
    var(--bg);
}
.gate form {
  width: 100%; max-width: 380px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 36px 32px 28px;
}
.gate h1 {
  font-family: var(--serif); font-weight: 500; font-size: 44px; letter-spacing: .04em;
  margin: 0; line-height: 1;
}
.gate .sub { color: var(--ink-2); margin: 10px 0 26px; font-size: 14px; }
.gate label { display: block; font-size: 12px; color: var(--ink-3); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .08em; }
.gate input {
  width: 100%; padding: 11px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg); outline: none;
}
.gate input:focus { border-color: var(--accent); }
.gate .btn { width: 100%; justify-content: center; margin-top: 22px; padding: 11px; font-size: 14px; }
.gate .err { color: var(--accent-2); font-size: 13px; min-height: 20px; margin-top: 10px; }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; min-height: 56px;
  background: rgba(28, 26, 24, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar .brand { font-family: var(--serif); font-size: 22px; letter-spacing: .05em; font-weight: 500; text-decoration: none; }
.bar .spacer { flex: 1; }
.bar .who { color: var(--ink-2); font-size: 13px; }
.bar .who b { color: var(--ink); font-weight: 500; }

/* ---------- gallery ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 16px 80px; }
.hero { padding: 28px 0 10px; }
.hero h1 { font-family: var(--serif); font-weight: 500; font-size: 48px; margin: 0; line-height: 1.05; }
.hero p { color: var(--ink-2); max-width: 640px; margin: 12px 0 0; font-size: 16px; }
.section { margin-top: 44px; }
.section h2 {
  font-family: var(--serif); font-weight: 500; font-size: 30px; margin: 0;
  display: flex; align-items: baseline; gap: 14px;
}
.section h2 small { font-family: var(--sans); font-size: 12px; color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; }
.section .blurb { color: var(--ink-2); margin: 6px 0 18px; max-width: 720px; }
.section .links { display: flex; gap: 10px; flex-wrap: wrap; margin: -6px 0 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.card {
  display: block; text-decoration: none;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: #574e47; }
.card .thumb { aspect-ratio: 17 / 22; background: var(--bg-3); overflow: hidden; position: relative; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.card .thumb .count {
  position: absolute; right: 10px; top: 10px;
  background: rgba(28, 26, 24, .85); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 9px; font-size: 12px; color: var(--ink-2);
}
.card .thumb .count.has { background: var(--accent); border-color: var(--accent); color: #fff; }
.card .body { padding: 14px 16px 16px; }
.card h3 { font-family: var(--serif); font-size: 24px; font-weight: 500; margin: 0; line-height: 1.1; }
.card p { color: var(--ink-2); font-size: 13px; margin: 6px 0 0; line-height: 1.45; }
.card .meta { color: var(--ink-3); font-size: 12px; margin-top: 10px; }

/* ---------- viewer ---------- */
.viewer { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.viewer .bar .title { font-family: var(--serif); font-size: 20px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer .bar .slide-label { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.viewer .bar .nav { display: flex; align-items: center; gap: 4px; }
.viewer .bar .nav .pos { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; min-width: 52px; text-align: center; }
.viewer .main { flex: 1; display: flex; min-height: 0; }
.stage {
  flex: 1; min-width: 0; overflow: auto; padding: 20px;
  display: flex; align-items: flex-start; justify-content: center;
  background: #121110;
}
.stage.drawing { cursor: crosshair; }
.page { position: relative; display: inline-block; line-height: 0; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.page img { display: block; max-width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.page img.fit { max-height: calc(100vh - 96px); max-height: calc(100dvh - 96px); width: auto; }
.overlay { position: absolute; inset: 0; touch-action: none; }
.stage.drawing .overlay { cursor: crosshair; }
.rect {
  position: absolute; border: 2px solid var(--accent); border-radius: 3px;
  background: rgba(200, 98, 63, .08); box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
  transition: background .12s;
}
.rect.hot, .rect:hover { background: rgba(200, 98, 63, .22); border-color: var(--accent-2); }
.rect .n {
  position: absolute; left: -2px; top: -2px; transform: translate(-50%, -50%);
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 600;
  display: grid; place-items: center; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.rect.temp { border-style: dashed; background: rgba(200, 98, 63, .12); pointer-events: none; }

.panel {
  width: 360px; flex: none; border-left: 1px solid var(--line); background: var(--bg);
  display: flex; flex-direction: column; min-height: 0;
}
.panel .head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.panel .head h4 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
.panel .head .hint { color: var(--ink-2); font-size: 13px; margin-top: 6px; }
.panel .list { flex: 1; overflow: auto; padding: 8px 12px; }
.panel .empty { color: var(--ink-3); font-size: 13px; padding: 24px 6px; text-align: center; }
.note {
  display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start;
  padding: 10px 8px; border-radius: 10px; margin-bottom: 2px;
}
.note:hover, .note.hot { background: var(--bg-2); }
.note .badge {
  width: 22px; height: 22px; border-radius: 999px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; margin-top: 2px;
}
.note .badge.none { background: var(--bg-3); color: var(--ink-3); }
.note .who { font-size: 12px; color: var(--ink-2); }
.note .who b { color: var(--ink); font-weight: 600; }
.note .who span { color: var(--ink-3); margin-left: 6px; }
.note .text { white-space: pre-wrap; word-break: break-word; margin-top: 3px; font-size: 14px; }
.note .acts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 6px; }
.note .act { color: var(--ink-2); background: none; border: 1px solid var(--line); padding: 3px 10px; border-radius: 6px; font: inherit; font-size: 12px; cursor: pointer; }
.note .act:hover { color: var(--ink); background: var(--bg-3); }
.note .act.danger:hover { color: var(--accent-2); border-color: var(--accent-2); }
.note .acts .ask { font-size: 12px; color: var(--ink); margin-right: 4px; }
.btn.danger { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger:hover { background: var(--accent-2); }
.note .edit-box { width: 100%; min-height: 72px; margin-top: 4px; resize: vertical; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--accent); background: var(--bg-2); color: var(--ink); outline: none; font: inherit; font-size: 14px; line-height: 1.45; }
.panel .compose { border-top: 1px solid var(--line); padding: 12px 12px 14px; }
.panel textarea, .popover textarea {
  width: 100%; min-height: 72px; resize: vertical; padding: 10px 12px;
  border-radius: 9px; border: 1px solid var(--line); background: var(--bg-2); outline: none;
  line-height: 1.45;
}
.panel textarea:focus, .popover textarea:focus { border-color: var(--accent); }
.panel .compose .row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.panel .compose .row .tip { color: var(--ink-3); font-size: 12px; flex: 1; }

.popover {
  position: absolute; z-index: 10; width: 300px;
  background: var(--bg-2); border: 1px solid #4a423c; border-radius: 12px;
  padding: 12px; box-shadow: 0 14px 40px rgba(0, 0, 0, .55);
  line-height: 1.4;
}
.popover .row { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }
.popover .lbl { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }

/* ---------- all notes ---------- */
.notes-page h1 { font-family: var(--serif); font-weight: 500; font-size: 40px; margin: 20px 0 4px; }
.notes-page .sub { color: var(--ink-2); margin-bottom: 28px; }
.notes-page .comp { margin-top: 30px; }
.notes-page .comp h2 { font-family: var(--serif); font-size: 28px; font-weight: 500; margin: 0 0 8px; }
.notes-page .slide-group { border-left: 2px solid var(--line); padding-left: 16px; margin: 12px 0 18px; }
.notes-page .slide-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 0 0 6px; font-weight: 600; }
.notes-page .slide-group h3 a { color: var(--ink-2); text-decoration: none; margin-left: 10px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.notes-page .slide-group h3 a:hover { color: var(--accent-2); }
.notes-page .note { grid-template-columns: 26px 1fr; padding: 8px 6px; }
.notes-page .export { margin-top: 36px; }
.notes-page pre {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; white-space: pre-wrap; font-size: 13px; color: var(--ink-2); line-height: 1.5;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 500; z-index: 50; box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  animation: toast 2.6s forwards;
}
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 8px);} 10%, 80% { opacity: 1; transform: translate(-50%, 0);} 100% { opacity: 0; } }

/* ---------- view modes ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg-2); }
.seg button { border: 0; background: transparent; color: var(--ink-2); padding: 5px 11px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--bg-3); color: var(--ink); }

.spread-wrap { display: flex; gap: 14px; justify-content: center; align-items: flex-start; max-width: 100%; }
.spread-wrap .page { max-width: calc(50% - 7px); }
.spread-wrap .page img.fit { max-width: 100%; }

.stage.all { display: block; }
.pages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 22px 18px; max-width: 1500px; margin: 0 auto; }
.gp { text-decoration: none; display: block; color: inherit; }
.gp .page { display: block; box-shadow: 0 6px 20px rgba(0, 0, 0, .45); border-radius: 2px; }
.gp .page img.fit { width: 100%; max-height: none; }
.gp .rect { border-width: 1.5px; pointer-events: none; }
.gp .rect .n { min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
.gp .cap { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--ink-2); margin-top: 9px; line-height: 1.3; }
.gp .cap .num { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.gp .cap .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp .cap .cnt { color: var(--accent-2); white-space: nowrap; }
.gp:hover .page { outline: 2px solid var(--accent); outline-offset: 2px; }

.pg-head { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 12px 8px 4px; font-weight: 600; }
.pg-head a { color: inherit; text-decoration: none; }
.pg-head a:hover { color: var(--accent-2); }
.panel .compose .pick { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); margin-bottom: 7px; }
.panel .compose select { background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 12px; color: var(--ink); max-width: 240px; }
.popover .lbl .pg { color: var(--ink-2); margin-left: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .viewer { height: auto; min-height: 100vh; }
  .viewer .main { flex-direction: column; }
  .stage { padding: 12px; overflow: visible; }
  .page img.fit { max-height: none; width: 100%; }
  .panel { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  .panel .list { max-height: 50vh; }
  .viewer .bar .slide-label { display: none; }
  .viewer .bar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .viewer .bar .title { flex: 1 1 100px; font-size: 18px; }
  .bar .who { display: none; }
  .hero h1 { font-size: 36px; }
  .spread-wrap { gap: 8px; }
  .pages-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px 10px; }
  .seg { order: 5; }
}

.walkthrough video{display:block;width:100%;max-width:1100px;aspect-ratio:16/9;background:#000;border-radius:6px;margin-top:12px}
.foot{margin:48px 0 24px;padding-top:16px;border-top:1px solid var(--line,#ddd);font-size:14px}
.foot a{color:var(--ink-3,#666)}
/* what changed page */
.changes .chg{border-top:1px solid var(--line);padding:28px 0}
.changes .chg h3{font-family:var(--serif);font-weight:500;font-size:24px;margin:0 0 14px}
.changes .chg h3 small{font-family:var(--sans);font-size:13px;color:var(--ink-3);margin-left:8px}
.changes .pair{display:grid;grid-template-columns:1fr 1fr;gap:20px;align-items:start}
.changes .lbl{font:600 11px/1 var(--sans);letter-spacing:.1em;text-transform:uppercase;color:var(--ink-3);margin-bottom:8px}
.changes .pg{position:relative;line-height:0;box-shadow:0 1px 6px rgba(0,0,0,.15)}
.changes .pg img,.changes .now img{width:100%;display:block}
.changes .pg.empty{line-height:1.4;padding:40px;background:var(--bg-2);color:var(--ink-3);text-align:center}
.changes .nowcol{display:grid;gap:14px}
.changes .now{display:block;color:var(--ink-2);text-decoration:none;font-size:13px}
.changes .now img{box-shadow:0 1px 6px rgba(0,0,0,.15);margin-bottom:6px}
.changes .rect.cl{position:absolute;border:2px solid #c0392b;background:rgba(192,57,43,.08);cursor:help}
.changes .rect.cl.st-done,.changes .rect.cl.st-kept{border-color:#2e7d4f;background:rgba(46,125,79,.08)}
.changes .rect.cl.st-new{border-color:#2f5d8a;background:rgba(47,93,138,.08)}
.changes .rect.cl .n{position:absolute;top:-11px;left:-11px;width:22px;height:22px;border-radius:50%;background:#222;color:#fff;font:600 12px/22px var(--sans);text-align:center}
.changes .rect.cl .tip{display:none;position:absolute;z-index:5;top:100%;left:0;margin-top:6px;width:min(360px,70vw);background:#fff;color:#222;line-height:1.45;font:14px/1.45 var(--sans);padding:12px 14px;border-radius:6px;box-shadow:0 6px 24px rgba(0,0,0,.25)}
.changes .rect.cl:hover .tip{display:block}
.changes .tip hr{border:0;border-top:1px solid #ddd;margin:8px 0}
.changes .res{list-style:none;padding:0;margin:16px 0 0;display:grid;gap:12px}
.changes .res li{display:flex;gap:10px;align-items:flex-start}
.changes .res .badge{flex:none;width:22px;height:22px;border-radius:50%;background:#222;color:#fff;font:600 12px/22px var(--sans);text-align:center}
.changes .res .q{font-style:italic;color:var(--ink-2)}
.changes .res .who{font-style:normal;font-size:12px;color:var(--ink-3);margin-left:6px}
.changes .res .a{margin-top:4px}
.st{display:inline-block;font:600 11px/1 var(--sans);letter-spacing:.04em;padding:4px 7px;border-radius:10px;color:#fff;vertical-align:1px}
.st-done{background:#2e7d4f}.st-kept{background:#5b7f3a}.st-new{background:#2f5d8a}.st-open{background:#c0392b}
@media (max-width:760px){.changes .pair{grid-template-columns:1fr}}
.front .grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
