:root {
  color-scheme: light;
  --ink: #17332e;
  --ink-soft: #58706b;
  --paper: #f4f6f1;
  --card: rgba(255, 255, 255, 0.93);
  --emerald-950: #062b25;
  --emerald-900: #0b3b32;
  --emerald-800: #145043;
  --emerald-700: #1d6655;
  --emerald-100: #deeee8;
  --gold: #d9a64e;
  --gold-soft: #f4e6c1;
  --line: rgba(17, 67, 58, 0.14);
  --danger: #a84740;
  --shadow: 0 18px 50px rgba(10, 48, 41, 0.13);
  --radius-xl: 28px;
  --radius-lg: 22px;
  font-family: ui-rounded, "SF Pro Rounded", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% -5%, rgba(217, 166, 78, 0.18), transparent 26rem),
    linear-gradient(180deg, #edf3ee 0, var(--paper) 32rem);
}

button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.capture-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: calc(26px + env(safe-area-inset-bottom));
  background: #f5f8f6;
  box-shadow: 0 0 0 1px rgba(8, 42, 37, 0.04), 0 0 60px rgba(8, 42, 37, 0.10);
  overflow: hidden;
}

.capture-hero {
  position: relative;
  min-height: 206px;
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 16px;
  padding: calc(28px + env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 30px max(22px, env(safe-area-inset-left));
  color: white;
  overflow: hidden;
  background:
    radial-gradient(circle at 90% 10%, rgba(217, 166, 78, 0.2), transparent 16rem),
    linear-gradient(145deg, var(--emerald-950), var(--emerald-800));
  border-radius: 0 0 34px 34px;
}

.hero-orbit {
  position: absolute;
  width: 270px;
  height: 270px;
  right: -96px;
  bottom: -160px;
  border: 1px solid rgba(217, 166, 78, 0.38);
  border-radius: 50%;
}

.hero-orbit::before {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  top: 31px;
  left: 38px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 18px rgba(217, 166, 78, 0.8);
}

.chapi-avatar {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border: 2px solid rgba(235, 195, 104, 0.75);
  border-radius: 50%;
  box-shadow: 0 13px 28px rgba(0, 0, 0, 0.25);
  z-index: 1;
}

.hero-copy { z-index: 1; min-width: 0; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.hero-copy h1 { margin: 0; font-size: clamp(32px, 9vw, 40px); line-height: 1.08; letter-spacing: -0.04em; }
.summary { margin: 8px 0 0; color: rgba(255,255,255,.74); font-size: 14px; }

.runtime-badge {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top));
  right: 20px;
  z-index: 2;
  padding: 7px 11px;
  color: rgba(255,255,255,.8);
  background: rgba(4, 31, 27, .42);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  font-size: .72rem;
}

main { padding: 0 18px calc(60px + env(safe-area-inset-bottom)); }
.capture-toolbar { margin-top: -18px; position: relative; z-index: 3; }

.surface-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  background: rgba(247, 250, 248, .96);
  border: 1px solid rgba(15, 64, 55, .11);
  border-radius: 16px;
  box-shadow: 0 9px 24px rgba(9, 54, 46, .11);
}
.surface-switcher-link {
  appearance: none;
  min-height: 42px;
  display: grid;
  place-items: center;
  color: var(--emerald-700);
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
}
.surface-switcher-link.is-active {
  color: white;
  background: var(--emerald-800);
}
.surface-switcher-link:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.surface-panel[hidden] { display: none !important; }

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 0 18px;
  background: #fff;
  border: 1px solid rgba(12, 58, 50, .08);
  border-radius: 19px;
  box-shadow: 0 12px 30px rgba(15, 61, 52, .1);
}
.search-box svg { width: 22px; fill: none; stroke: var(--emerald-700); stroke-width: 2; stroke-linecap: round; }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 1rem; }
.search-box input::placeholder { color: #8aa09b; }

.connection-notice {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin: 14px 0 16px;
  padding: 11px 14px;
  color: #6a5a30;
  background: rgba(250, 242, 218, .9);
  border: 1px solid rgba(194, 148, 55, .3);
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}
.connection-notice strong { white-space: nowrap; }
.connection-notice[data-kind="connected"] { color: #245c4e; background: #e7f3ee; border-color: #beddd2; }
.connection-notice[data-kind="error"] { color: #833b36; background: #f9e9e7; border-color: #e5bfbb; }

.add-capture-button {
  width: 100%;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: white;
  text-align: left;
  background: linear-gradient(135deg, var(--emerald-900), var(--emerald-700));
  border: 1px solid rgba(244, 230, 193, .42);
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(9, 54, 46, .16);
}
.add-capture-button:disabled { opacity: .5; }
.add-capture-button:not(:disabled):active { transform: translateY(1px); }
.add-capture-button img { width: 48px; height: 48px; object-fit: contain; border-radius: 16px; background: rgba(255,255,255,.08); }
.add-capture-button span { display: grid; gap: 4px; }
.add-capture-copy { flex: 1; min-width: 0; }
.add-capture-plus {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin-left: auto;
  color: var(--gold);
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  pointer-events: none;
}
.add-capture-button strong { font-size: 17px; font-weight:750; line-height:1.4; }
.add-capture-button small { color: rgba(255,255,255,.7); font-size: 12px; font-weight:550; line-height:1.4; }

.timeline-section { margin-top: 24px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 22px; line-height:1.4; letter-spacing: -.02em; }
.section-heading .eyebrow { color: var(--emerald-700); margin-bottom: 4px; }
.visible-count { color: var(--ink-soft); font-size: 13px; }

.capture-timeline { position: relative; display: grid; gap: 16px; padding-left: 20px; }

.capture-card {
  position: relative;
  padding: 19px;
  background: var(--card);
  border: 1px solid rgba(15, 64, 55, .08);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 28px rgba(13, 57, 49, .08);
}
.capture-card.is-favorite { border-color: rgba(218, 164, 54, .42); box-shadow: 0 12px 30px rgba(151, 108, 22, .12); }
.capture-card::before { content: ""; position: absolute; left: -18px; top: 25px; width: 10px; height: 10px; border: 3px solid var(--paper); border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 1px rgba(172,124,35,.3); }
.capture-meta { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin: -5px -5px 8px 0; }
.capture-time { color: #586b64; font-size: 13px; font-weight: 600; line-height: 1.5; }
.capture-source { margin: -4px 0 10px; color: var(--ink-soft); font-size: .8rem; line-height: 1.4; }
.capture-actions { display: flex; align-items: center; gap: 2px; }
.capture-action {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #586b64;
  background: transparent;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.capture-action:hover { color: #153f36; background: #eaf1ed; }
.capture-action:focus-visible { outline: 3px solid #a87722; outline-offset: 2px; }
.capture-action:disabled { cursor: wait; opacity: .55; }
.capture-action.archive:hover { color: #a84740; background: #fbefed; }
.capture-action.favorite.is-active { color: #a87722; }
.capture-action.favorite.is-active svg { fill: #f4d68b; }
.capture-action svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.capture-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; border-top: 1px solid #e5ece7; margin-top: 17px; padding-top: 10px; }
.capture-action.completion { display: inline-flex; gap: 6px; width: auto; min-width: 80px; padding: 0 10px; border-radius: 22px; color: #286c59; background: #edf4ef; font-size: 14px; font-weight: 600; white-space: nowrap; }
.capture-action.completion:hover { background: #e0ece4; }
.capture-action.completion.is-active { background: #dcebe1; color: #20583e; }
.capture-action.completion.is-active svg { fill: #286c59; stroke: white; }
.capture-card.is-completed { background: #e6f0e9; border-color: #b4cdbd; border-left:4px solid #27644f; box-shadow: 0 3px 12px rgba(13,57,49,.025); }
.capture-card.is-completed::before { background: #6b9980; box-shadow: 0 0 0 1px #c3d7cb; }
.capture-card.is-completed .capture-body { color: #314f43; }
.capture-completed-time { display: block; margin-top: 14px; color: #496552; font-size: 12px; line-height: 1.6; }
.capture-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; margin-bottom: 16px; padding: 4px; border: 1px solid #dbe5df; border-radius: 15px; background: #eaf1ed; }
.capture-filters button { min-width: 0; min-height: 44px; padding: 8px 3px; border: 0; border-radius: 11px; background: transparent; color: #586b64; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.capture-filters button[aria-pressed="true"] { color: #153f36; background: white; box-shadow: 0 2px 6px rgba(13,57,49,.07); }
.capture-filters button:focus-visible { outline: 3px solid #a87722; outline-offset: 2px; }
.capture-filters button:disabled { cursor: wait; }
.capture-filters span { margin-left: 3px; font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 500; }
@media (max-width: 360px) {
  main { padding-left:14px; padding-right:14px; }
  .capture-card { padding: 15px 13px; }
  .capture-footer { gap: 2px; }
  .capture-action.completion { min-width: 76px; padding: 0 8px; }
}
.capture-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.72; }
.capture-body:empty { display: none; }
.capture-heading { display:flex; flex-direction:column; gap:6px; min-width:0; }
.capture-action.completion { background:#27644f; color:white; font-weight:700; }
.capture-action.completion:hover { background:#20583e; color:white; }
.capture-action.completion.is-active { background:transparent; color:#27644f; }
.capture-action.completion.is-active svg { fill:none; stroke:currentColor; }

/* Shared reading/status contract: duplicated because each surface enables one stylesheet. */
.record-status { display:inline-flex; align-items:center; align-self:flex-start; gap:6px; padding:5px 10px; border-radius:8px; background:#fff2d4; color:#875816; font-size:14px; font-weight:700; line-height:1.5; white-space:nowrap; }
.record-status.is-completed { background:#27644f; color:#fff; }
.record-status-mark { font-size:16px; line-height:1; }
.reading-disclosure { min-width:0; scroll-margin-top:80px; }
.reading-disclosure [hidden] { display:none !important; }
.reading-preview { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:5; line-clamp:5; overflow:hidden; }
.reading-toggle { display:block; min-height:44px; padding:8px 0; border:0; background:transparent; color:#205f4d; font:inherit; font-size:14px; font-weight:700; cursor:pointer; }
.reading-toggle:focus-visible { outline:3px solid #a87722; outline-offset:2px; border-radius:4px; }
/* Quiet segmented rail; no line after the final card or on an empty list. */
.capture-card { --rail-left:-21px; }
.capture-card.is-completed { --rail-left:-24px; }
.capture-card::before {
  content:""; position:absolute; left:var(--rail-left); top:28px;
  width:12px; height:12px; box-sizing:border-box; border:1.5px solid #ae8a4d;
  border-radius:50%; background:#f6f9f7; box-shadow:none;
}
.capture-card.is-completed::before {
  content:"✓"; display:grid; place-items:center; border-color:#27644f;
  background:#27644f; color:white; font-size:9px; font-weight:800; line-height:1; box-shadow:none;
}
.capture-card:not(:last-child)::after {
  content:""; position:absolute; left:calc(var(--rail-left) + 5.5px);
  top:46px; bottom:-38px; width:1px; background:#ccd9d1; pointer-events:none;
}

.capture-images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 14px; }
.capture-images.is-one { grid-template-columns: 1fr; }
.capture-image { position: relative; padding: 0; overflow: hidden; border: 0; border-radius: 14px; background: #dbe5e1; aspect-ratio: 1; }
.capture-images.is-one .capture-image { aspect-ratio: 16 / 10; }
.capture-image img { width: 100%; height: 100%; object-fit: cover; display: block; }

.capture-audio { margin-top: 14px; padding: 13px; background: #edf4f1; border-radius: 15px; }
.capture-audio audio { width: 100%; min-height: 42px; }
.capture-transcript { margin-top: 10px; }
.capture-transcript summary { color: var(--emerald-700); cursor: pointer; font-weight: 700; font-size: .86rem; }
.capture-transcript p { margin: 9px 0 0; color: var(--ink-soft); white-space: pre-wrap; line-height: 1.65; }

.media-caption { margin: 9px 0 0; color: var(--ink-soft); font-size: .82rem; line-height: 1.5; }

.empty-state { padding: 38px 24px; text-align: center; background: rgba(255,255,255,.65); border: 1px dashed rgba(20,80,67,.22); border-radius: var(--radius-lg); }
.empty-state h3 { margin: 10px 0 6px; }
.empty-state p { margin: 0; color: var(--ink-soft); line-height: 1.6; }
.empty-orbit { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto; color: var(--gold); border: 1px solid var(--gold); border-radius: 50%; }

dialog { width: min(calc(100% - 16px), 504px); max-width: none; margin: auto auto 0; padding: 0; color: var(--ink); background: #fbfcfa; border: 0; border-radius: 24px 24px 0 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(2, 24, 20, .58); backdrop-filter: blur(3px); }
.capture-dialog form { max-height: min(88dvh, 820px); overflow-y: auto; overscroll-behavior: contain; padding: 11px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet-handle {
  width: 76px;
  height: 28px;
  margin: -7px auto 7px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  touch-action: none;
  cursor: grab;
}
.sheet-handle::before { content: ""; width: 42px; height: 5px; background: #c5d2cd; border-radius: 99px; }
.sheet-handle:active { cursor: grabbing; }
dialog.is-dragging { transition: none !important; }
dialog.is-snap-back { transition: transform 200ms cubic-bezier(.22, .8, .3, 1); }
.dialog-heading { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 18px; }
.dialog-heading h2 { margin: 0; font-size: 1.45rem; }
.dialog-heading .eyebrow { color: var(--emerald-700); }
.icon-button { width: 40px; height: 40px; border: 0; border-radius: 50%; color: var(--ink-soft); background: #edf2ef; font-size: 1.5rem; }

.field { display: grid; gap: 9px; margin: 18px 0; }
.field > span, .transcript-field > span { font-weight: 800; }
.field textarea, .transcript-field textarea, .image-description {
  width: 100%;
  padding: 13px 14px;
  resize: vertical;
  color: var(--ink);
  background: white;
  border: 1px solid #cad7d2;
  border-radius: 14px;
  outline: 0;
  line-height: 1.55;
}
.field textarea:focus, .transcript-field textarea:focus, .image-description:focus { border-color: var(--emerald-700); box-shadow: 0 0 0 3px rgba(29,102,85,.12); }
.field-hint, .transcript-field small { color: var(--ink-soft); font-size: .78rem; line-height: 1.5; }

.media-picker { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; color: var(--emerald-800); background: var(--emerald-100); border: 1px dashed #8cb8aa; border-radius: 14px; font-weight: 800; cursor: pointer; }
.media-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.media-picker > span { font-size: 1.25rem; }
.media-picker-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.media-picker-camera { color: #fff; background: var(--emerald-800); border-color: var(--emerald-800); border-style: solid; }
.capture-dialog.is-photo-mode .image-field { margin-top: 10px; }

.media-drafts { display: grid; gap: 12px; }
.image-draft { display: grid; grid-template-columns: 88px 1fr auto; gap: 10px; align-items: center; padding: 9px; background: #eef3f0; border-radius: 15px; }
.image-draft img { width: 88px; height: 78px; object-fit: cover; border-radius: 11px; }
.image-draft textarea { min-height: 66px; resize: vertical; }
.remove-media { width: 34px; height: 34px; align-self: start; border: 0; border-radius: 10px; color: var(--danger); background: #fae6e3; }

.audio-draft { padding: 12px; background: #eef3f0; border-radius: 14px; }
.audio-draft audio { width: 100%; }
.audio-draft-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.audio-draft-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; color: var(--ink-soft); }
.transcript-field { display: grid; gap: 8px; margin-top: 12px; }

.form-note { margin: 18px 0 0; padding: 11px 13px; color: #6b5a30; background: #f8efda; border-radius: 13px; font-size: .79rem; line-height: 1.5; }
.draft-favorite { display: flex; position: relative; align-items: center; gap: 9px; width: fit-content; min-height: 44px; margin: 0 0 10px; color: #746954; cursor: pointer; font-size: 14px; }
.draft-favorite[hidden] { display: none !important; }
.draft-favorite input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.draft-favorite svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; flex-shrink: 0; }
.draft-favorite input:checked ~ svg { color: #a87722; fill: #f4d68b; }
.draft-favorite input:checked ~ span { color: #806026; }
.draft-favorite input:focus-visible ~ svg { outline: 2px solid #8b6637; outline-offset: 4px; border-radius: 3px; }
.draft-favorite:has(input:disabled) { opacity: .6; cursor: default; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; margin-top: 18px; }
.button { min-height: 48px; border: 0; border-radius: 14px; font-weight: 800; }
.button:disabled { opacity: .45; }
.button-primary { color: white; background: var(--emerald-800); }
.button-secondary { color: var(--emerald-800); background: #e8f0ed; }
.button-danger { color: white; background: var(--danger); }

.confirm-dialog {
  width: min(calc(100% - 32px), 420px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border-radius: 24px;
  text-align: center;
}
.confirm-dialog form {
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 28px 24px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.confirm-dialog h2 { margin: 12px 0 8px; }
.confirm-dialog p { margin: 0; color: var(--ink-soft); }
.confirm-symbol { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto; color: var(--danger); background: #f8e9e7; border-radius: 50%; }
.confirm-symbol svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.content-link {
  color: var(--emerald-700);
  font-weight: 650;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.image-lightbox { width: min(100% - 20px, 900px); background: #071c19; }
.image-lightbox form { position: relative; display: grid; place-items: center; min-height: 260px; padding: 48px 12px 18px; }
.image-lightbox img { max-width: 100%; max-height: 75dvh; object-fit: contain; border-radius: 12px; }
.image-lightbox p { margin: 12px 8px 0; color: rgba(255,255,255,.78); text-align: center; white-space: pre-wrap; }
.lightbox-close { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; color: white; background: rgba(255,255,255,.12); border: 0; border-radius: 50%; font-size: 1.4rem; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 30; max-width: calc(100% - 32px); padding: 11px 16px; color: white; background: rgba(4,35,29,.94); border-radius: 999px; box-shadow: 0 12px 28px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  .capture-hero { min-height: 206px; grid-template-columns: 84px 1fr; }
  .chapi-avatar { width: 84px; height: 84px; }
  main { padding-left: 18px; padding-right: 18px; }
  .capture-images { grid-template-columns: repeat(2, 1fr); }
  .image-draft { grid-template-columns: 74px 1fr auto; }
  .image-draft img { width: 74px; height: 72px; }
  dialog {
    box-sizing: border-box;
  }
  .capture-dialog form {
    width: 100%;
    box-sizing: border-box;
    padding-right: max(20px, env(safe-area-inset-right));
    padding-left: max(20px, env(safe-area-inset-left));
  }
}

@media (min-width: 521px) {
  body {
    padding: 20px 0;
  }
  .capture-shell {
    min-height: calc(100vh - 40px);
    border-radius: 28px;
  }
  .capture-hero {
    border-radius: 28px 28px 0 0;
  }
  dialog {
    margin-bottom: 20px;
    border-radius: 24px;
  }
}

@media (min-width: 700px) and (max-width: 999px) {
  .capture-shell {
    width: min(720px, calc(100% - 40px));
  }
  main {
    padding-right: 28px;
    padding-left: 28px;
  }
}

@media (min-width: 1000px) {
  body {
    padding: 24px;
  }
  .capture-shell {
    width: min(1180px, calc(100% - 16px));
    min-height: calc(100vh - 48px);
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    align-items: stretch;
    padding-bottom: 0;
    border-radius: 28px;
    overflow: clip;
  }
  .capture-hero {
    grid-column: 1;
    grid-row: 1;
    min-height: calc(100vh - 48px);
    padding: 52px 34px 40px;
    grid-template-columns: 1fr;
    align-content: start;
    align-items: start;
    gap: 26px;
    border-radius: 28px 0 0 28px;
  }
  .capture-hero .hero-orbit {
    right: -110px;
    bottom: -80px;
  }
  .capture-hero .chapi-avatar {
    width: 126px;
    height: 126px;
  }
  .capture-hero .hero-copy h1 {
    max-width: 4em;
    font-size: 44px;
    line-height: 1.1;
  }
  .capture-hero .summary {
    max-width: 15em;
    margin-top: 12px;
    line-height: 1.65;
  }
  .runtime-badge {
    top: 22px;
    right: 22px;
  }
  main {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    margin-top: 0;
    padding: 34px;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    align-items: start;
    gap: 28px;
  }
  .capture-toolbar {
    position: sticky;
    top: 58px;
    margin-top: 0;
  }
  .timeline-section {
    margin-top: 0;
  }
  dialog {
    margin: auto;
    border-radius: 24px;
  }
}

/* Capture focus keeps the existing form, but gives camera and microphone launches one clear job. */
.capture-dialog.is-focus-mode {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  overflow: hidden;
  border-radius: 0;
  background: #f4faf7;
  box-shadow: none;
}

.capture-dialog.is-focus-mode form {
  width: min(100%, 620px);
  height: 100%;
  max-height: none;
  margin: 0 auto;
  padding:
    calc(18px + env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    calc(20px + env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.capture-dialog.is-focus-mode .sheet-handle {
  display: none;
}

.capture-dialog.is-focus-mode .dialog-heading {
  margin-bottom: 8px;
}

.capture-dialog .capture-body-field[hidden],
.capture-dialog .image-field[hidden],
.capture-dialog .audio-field[hidden],
.capture-dialog .transcript-field[hidden] {
  display: none !important;
}

.capture-dialog.is-photo-mode .image-field,
.capture-dialog.is-voice-mode .audio-field {
  margin: 10px 0 0;
}

.capture-dialog.is-focus-mode .dialog-actions {
  margin-top: 14px;
}

.audio-recorder {
  padding: 18px;
  border: 1px solid rgba(16, 92, 76, 0.14);
  border-radius: 22px;
  background:
    radial-gradient(circle at 88% 12%, rgba(242, 186, 79, 0.18), transparent 7.5rem),
    linear-gradient(145deg, #f7fcf9, #e6f2ed);
}

.audio-recorder-heading,
.audio-recorder-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.audio-recorder-heading strong {
  color: var(--emerald-800);
  font-size: 0.92rem;
}

.audio-recorder-heading output {
  min-width: 5.2ch;
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  letter-spacing: 0.04em;
  text-align: right;
}

.audio-recorder-actions {
  margin-top: 18px;
}

.record-button,
.stop-recording-button {
  min-height: 58px;
  border: 0;
  border-radius: 18px;
  font-weight: 820;
  cursor: pointer;
}

.record-button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  background: var(--emerald-800);
  box-shadow: 0 11px 24px rgba(8, 71, 58, 0.18);
}

.record-dot {
  width: 14px;
  height: 14px;
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: #e4564b;
}

.stop-recording-button {
  flex: 0 0 86px;
  color: #8d2d27;
  background: #f8dfdc;
}

.record-button:disabled,
.stop-recording-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.audio-recorder.is-recording .record-dot {
  animation: recording-pulse 1.15s ease-out infinite;
}

.recording-status {
  min-height: 1.5em;
  margin: 13px 0 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.5;
}

.audio-recorder[data-state="recording"] .recording-status {
  color: #a23831;
  font-weight: 720;
}

.audio-recorder[data-state="error"] .recording-status,
.audio-recorder[data-state="unavailable"] .recording-status {
  color: #8d2d27;
}

.audio-file-fallback {
  margin-top: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.audio-file-fallback > span {
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.capture-dialog.is-voice-mode .audio-recorder {
  min-height: min(34dvh, 300px);
  display: grid;
  align-content: center;
}

@keyframes recording-pulse {
  0% { box-shadow: 0 0 0 0 rgba(228, 86, 75, 0.5); }
  70%, 100% { box-shadow: 0 0 0 10px rgba(228, 86, 75, 0); }
}

/* The picture is the lightbox: the dialog itself is a transparent, centered stage. */
.image-lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  overflow: hidden;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.image-lightbox::backdrop {
  background: rgba(1, 13, 11, 0.88);
  backdrop-filter: blur(5px);
}

.image-lightbox form {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding:
    max(54px, calc(20px + env(safe-area-inset-top)))
    max(14px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  place-items: center;
  touch-action: none;
}

.image-lightbox img {
  width: auto;
  max-width: 100%;
  max-height: 100%;
  align-self: center;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
}

.image-lightbox p {
  max-width: min(720px, calc(100vw - 40px));
  margin: 10px 8px 0;
  color: rgba(255, 255, 255, 0.82);
}

.image-lightbox .lightbox-close {
  position: fixed;
  z-index: 2;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(2, 28, 23, 0.66);
  backdrop-filter: blur(8px);
}

.image-lightbox .lightbox-footer {
  width: min(220px, calc(100vw - 40px));
  min-height: 44px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.78rem;
  font-weight: 750;
  text-align: center;
}

.image-lightbox .lightbox-footer button {
  width: 40px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  font-size: 1.15rem;
}

@media (prefers-reduced-motion: reduce) {
  .audio-recorder.is-recording .record-dot { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* 2026-08-27 paired visual system: quick capture in motion */
body {
  background-color: #eef7f2;
  background-image:
    radial-gradient(circle at 88% 4%, rgba(95, 209, 171, 0.17), transparent 17rem),
    radial-gradient(circle at 8% 18%, rgba(242, 186, 79, 0.14), transparent 20rem);
}

.capture-hero {
  min-height: 218px;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 14px;
  background-color: #0a4c42;
  background-image:
    radial-gradient(circle at 84% 18%, rgba(242, 186, 79, 0.24), transparent 9rem),
    linear-gradient(118deg, rgba(21, 117, 99, 0.78), rgba(6, 51, 47, 0.94));
  isolation: isolate;
}

.capture-hero::after {
  content: "";
  position: absolute;
  right: -34px;
  top: 50px;
  width: 190px;
  height: 106px;
  border: 2px solid rgba(221, 244, 232, 0.17);
  border-left-color: transparent;
  border-radius: 50%;
  box-shadow: 0 0 0 12px rgba(242, 186, 79, 0.035), 0 0 0 28px rgba(95, 209, 171, 0.025);
  transform: rotate(-13deg);
  z-index: -1;
}

.capture-hero .hero-orbit {
  width: 224px;
  height: 224px;
  right: -88px;
  bottom: -128px;
  border-color: rgba(242, 186, 79, 0.34);
}

.hero-character {
  position: relative;
  z-index: 1;
  width: 112px;
  height: 112px;
  display: block;
}

.capture-hero .chapi-avatar {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(0 9px 15px rgba(0, 0, 0, 0.25));
}

.capture-hero .hero-copy {
  position: relative;
  z-index: 1;
}

.capture-hero .eyebrow {
  margin-bottom: 4px;
  color: #f6d287;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.capture-hero .hero-copy h1 {
  font-family: "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  font-weight: 820;
  letter-spacing: -0.045em;
}

.add-capture-mascot {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.add-capture-button .add-capture-mascot img {
  width: 48px;
  height: 48px;
  border-radius: 0;
  background: transparent;
}

@media (max-width: 560px) {
  .capture-hero {
    min-height: 218px;
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .hero-character {
    width: 112px;
    height: 112px;
  }
}

@media (max-width: 360px) {
  .capture-hero {
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 10px;
    padding-right: 18px;
    padding-left: 18px;
  }

  .hero-character {
    width: 100px;
    height: 100px;
  }

  .capture-hero .hero-copy h1 {
    font-size: 32px;
  }
}

@media (min-width: 1000px) {
  .capture-hero {
    grid-template-columns: 1fr;
  }

  .hero-character {
    width: 154px;
    height: 154px;
  }

  .capture-hero .hero-orbit {
    right: -110px;
    bottom: -80px;
  }
}

/* Quick Capture editor only: the note stays central; attachments are a quiet tool rail. */
#captureDialog {
  --capture-editor-ideal-height: 490px;
  --capture-editor-height: min(var(--capture-editor-ideal-height), calc(var(--capture-viewport-height, 100dvh) - 12px));
  position: fixed;
  inset: auto 0 auto;
  top: calc(var(--capture-viewport-top, 0px) + var(--capture-viewport-height, 100dvh) - var(--capture-editor-height));
  width: min(calc(100% - 16px), 504px);
  height: var(--capture-editor-height);
  max-height: none;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 24px 24px 0 0;
}
#captureDialog.is-focus-mode { width: 100%; border-radius: 20px 20px 0 0; }
#captureDialog.is-voice-mode { --capture-editor-ideal-height: 360px; }
#captureDialog:not(.is-voice-mode):has(.audio-recorder:not([hidden])) { --capture-editor-ideal-height: 590px; }
#captureDialog:has(.image-field.has-drafts),
#captureDialog:has(.audio-draft:not([hidden])) { --capture-editor-ideal-height: 680px; }
#captureDialog #captureForm {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%; height: 100%; max-height: none;
  padding: 0; margin: 0; overflow: hidden;
}
#captureDialog .capture-editor-header { padding: 8px 20px 12px; }
#captureDialog .sheet-handle { margin: -5px auto 1px; }
#captureDialog .dialog-heading { align-items: center; margin: 0; }
#captureDialog .dialog-heading .eyebrow { font-size: 11px; margin: 0 0 4px; }
#captureDialog .dialog-heading h2 { font-size: 21px; line-height: 1.35; letter-spacing: -.025em; }
#captureDialog .icon-button { width: 44px; height: 44px; flex: 0 0 44px; }
#captureDialog .capture-editor-scroll {
  min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 2px max(20px, env(safe-area-inset-right)) 18px max(20px, env(safe-area-inset-left));
  scroll-padding: 12px;
}
#captureDialog .capture-body-field { margin: 0 0 14px; gap: 8px; }
#captureDialog .capture-body-field > span { font-size: 13px; color: var(--ink-soft); font-weight: 650; }
#captureDialog .capture-body-field textarea { min-height: 150px; font-size: 16px; line-height: 1.6; padding: 12px 14px; }
#captureDialog .capture-media-toolbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-bottom: 14px; }
#captureDialog .capture-media-tool {
  min-height: 48px; min-width: 0; padding: 6px 4px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid #d9e5df; border-radius: 12px;
  color: var(--emerald-800); background: #edf4f0;
  font-size: 13px; font-weight: 650;
}
#captureDialog .capture-media-tool svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#captureDialog .capture-media-tool:disabled { opacity: .45; cursor: default; }
#captureDialog .capture-media-tool:active:not(:disabled) { background: var(--emerald-100); }
#captureDialog .capture-media-tool.is-recording { color:#fff; background:var(--emerald-800); border-color:var(--emerald-800); }
#captureDialog .capture-media-tool.is-recording:active:not(:disabled) { background:var(--emerald-900); }
#captureDialog.is-photo-mode .capture-audio-tool,
#captureDialog.is-voice-mode .capture-image-tool { display: none; }
#captureDialog.is-focus-mode .capture-media-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#captureDialog .image-field { margin: 0 0 14px; }
#captureDialog .image-field:not(.has-drafts) { display: none; }
#captureDialog .audio-field { margin: 0; gap: 12px; }
#captureDialog .audio-recorder { min-height: 0; margin:0 0 8px; padding:0 0 8px; border:0; border-bottom:1px solid var(--line); border-radius:0; background:transparent; }
#captureDialog .audio-recorder[hidden], #captureDialog .audio-draft[hidden], #captureDialog .transcript-field[hidden] { display: none; }
#captureDialog .audio-recorder-heading { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; min-height:44px; }
#captureDialog .audio-recorder-heading output { font-size: 19px; min-width: 5ch; }
#captureDialog .stop-recording-button { min-height: 44px; min-width: 64px; padding: 8px 14px; border-radius: 10px; }
#captureDialog .recording-status { min-height: 0; margin: 3px 0 0; font-size: 12px; line-height:1.5; overflow-wrap:anywhere; }
#captureDialog .remove-media { width: 44px; height: 44px; }
#captureDialog .image-draft { grid-template-columns: 64px minmax(0, 1fr) 44px; gap: 8px; }
#captureDialog .image-draft img { width: 64px; height: 64px; }
#captureDialog .image-description { min-width: 0; padding: 8px; font-size: 16px; }
#captureDialog .capture-editor-footer { padding: 10px max(20px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: #fbfcfa; }
#captureDialog .form-note { margin: 0 0 9px; padding: 0; color: var(--ink-soft); background: transparent; border-radius: 0; font-size: 12px; line-height: 1.5; }
#captureDialog .dialog-actions { margin: 0; grid-template-columns: 1fr 1.65fr; }
#captureDialog .button { min-height: 48px; border-radius: 13px; }
#captureDialog :is(button, input):focus-visible,
#quickArchiveDialog button:focus-visible,
#quickImageLightbox button:focus-visible { outline: 3px solid #a87722; outline-offset: 2px; }
#captureDialog .capture-neutral-focus[tabindex="-1"]:focus,
#quickArchiveDialog .capture-neutral-focus[tabindex="-1"]:focus,
#quickImageLightbox .capture-neutral-focus[tabindex="-1"]:focus { outline: none; }
@media (max-width: 360px) {
  #captureDialog .capture-editor-header { padding-left: 14px; padding-right: 14px; }
  #captureDialog .capture-editor-scroll, #captureDialog .capture-editor-footer { padding-left: 14px; padding-right: 14px; }
  #captureDialog .capture-media-tool { gap: 3px; font-size: 12px; }
}
@media (max-height: 520px) {
  #captureDialog .capture-editor-header { padding-top: 8px; padding-bottom: 8px; }
  #captureDialog .capture-editor-header .sheet-handle, #captureDialog .capture-editor-header .eyebrow { display: none; }
  #captureDialog .capture-editor-footer { padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}
