/* PEAR1M — palette taken from the PEAR1M artwork: deep green-black, ember orange, glacier teal. */
:root {
  --bg: #0f1716; --bg2: #141e1d; --card: #182322; --line: #26332f; --ink: #ecebe4; --muted: #96a39d;
  --orange: #f74f28; --orange2: #ff8a4c; --teal: #3f9bb7; --teal2: #8fd3e0;
  --ok: #7fd8a2; --ok-bg: #143224; --bad: #ff9a85; --bad-bg: #3a1a14; --warn: #ffcf7a; --warn-bg: #352a12;
  --radius: 18px; --nav-h: 66px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 var(--font); overflow-x: hidden; -webkit-text-size-adjust: 100%; }
h2 { font-size: 1.05rem; margin: 0 0 0.5rem; letter-spacing: 0.01em; }
p { margin: 0.4rem 0; }
code, .mono { font-family: var(--mono); font-size: 0.85em; }
.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.center { text-align: center; }

label { display: block; font-size: 0.88rem; font-weight: 600; margin: 0.85rem 0 0.35rem; }
label.inline { display: flex; flex-direction: column; flex: 1; margin-top: 0.4rem; }
input[type=text], input[type=search], input[type=password], input[type=number], textarea, select {
  width: 100%; font: inherit; font-size: 17px; color: var(--ink); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 14px; padding: 0.75rem 0.85rem; min-height: 52px; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 3px solid var(--teal); outline-offset: 1px; }
button { font: inherit; font-weight: 650; min-height: 52px; padding: 0 1.1rem; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg2); color: var(--ink); }
button.primary { border: 0; color: #fff; background: linear-gradient(100deg, var(--orange) 0%, #e2603a 48%, var(--teal) 100%); }
button.ghost { background: transparent; }
button.wide { width: 100%; margin-top: 0.8rem; }
button.big { min-height: 64px; font-size: 1.1rem; }
button.small-btn { min-height: 40px; padding: 0 0.9rem; }
button:disabled { opacity: 0.55; }
.row { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.6rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.file-btn { display: flex; align-items: center; justify-content: center; min-height: 52px; border: 1px dashed #3a4a45; border-radius: 14px; font-weight: 600; cursor: pointer; margin: 0.6rem 0 0; }
.file-btn input { display: none; }
.check { display: flex; gap: 0.6rem; align-items: center; font-weight: 500; }
.check input { width: 24px; height: 24px; }

/* ---------- gate ---------- */
.gate { min-height: 100vh; min-height: 100dvh; position: relative; display: flex; flex-direction: column; justify-content: flex-end; }
.gate-art { position: absolute; inset: 0; background: url("/art-pear.jpg") center 18% / cover no-repeat; }
.gate-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(15,23,22,0) 0%, rgba(15,23,22,0.15) 35%, rgba(15,23,22,0.92) 62%, var(--bg) 78%); }
.gate-body { position: relative; padding: 1.5rem 1.4rem calc(1.8rem + env(safe-area-inset-bottom)); max-width: 460px; width: 100%; margin: 0 auto; }
.wordmark { text-align: center; letter-spacing: 0.55em; text-indent: 0.55em; font-weight: 500; font-size: 1.15rem; }
.tagline { text-align: center; color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }
.gate-step h2 { text-align: center; }

/* ---------- app ---------- */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  padding: calc(0.6rem + env(safe-area-inset-top)) 1rem 0.6rem; background: rgba(15,23,22,0.92); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top-left { display: flex; gap: 0.6rem; align-items: center; min-width: 0; }
.top-icon { border-radius: 9px; }
.title { font-size: 1.15rem; font-weight: 700; }
.fp { font-size: 0.66rem; color: var(--muted); max-width: 58vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { max-width: 640px; margin: 0 auto; padding: 0.9rem 0.85rem calc(var(--nav-h) + 1.6rem + env(safe-area-inset-bottom)); }
.panel { display: grid; gap: 0.85rem; grid-template-columns: minmax(0, 1fr); }
.panel > * { min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.hero-card { background: radial-gradient(120% 140% at 0% 0%, rgba(247,79,40,0.22), transparent 55%), radial-gradient(120% 140% at 100% 100%, rgba(63,155,183,0.25), transparent 55%), var(--card); }
.section-h { margin: 0.6rem 0.2rem 0; }
.sticky-search { position: sticky; top: 70px; z-index: 4; padding: 0.55rem; }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(20,30,29,0.96); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav button { border: 0; border-radius: 0; background: none; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 0.1rem; font-size: 0.72rem; font-weight: 600; color: var(--muted); padding: 0.3rem; }
.bottom-nav .ico { font-size: 1.35rem; line-height: 1; }
.bottom-nav button[aria-selected="true"] { color: var(--orange2); }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3rem; background: var(--bg2); padding: 0.3rem; border-radius: 14px; }
.seg button { min-height: 42px; padding: 0; border: 0; background: transparent; font-size: 0.85rem; color: var(--muted); border-radius: 10px; }
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

.stat-row { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.stat { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.74rem; font-weight: 700; padding: 0.3rem 0.6rem; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.voice, .badge.cloud { background: #15303a; color: var(--teal2); }
.cloud-warning { margin-top: 0.8rem; padding: 0.85rem; border-radius: 14px; background: #15303a; color: var(--teal2); }
.msg { margin-top: 0.8rem; padding: 0.75rem 0.85rem; border-radius: 14px; background: var(--bg2); overflow-wrap: anywhere; }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.bad { background: var(--bad-bg); color: var(--bad); }
.verdict { margin-top: 0.8rem; font-weight: 700; padding: 0.85rem; border-radius: 14px; overflow-wrap: anywhere; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.bad { background: var(--bad-bg); color: var(--bad); }
.verdict .detail { display: block; font-weight: 400; font-size: 0.88rem; margin-top: 0.25rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list button { min-height: 42px; font-size: 0.82rem; padding: 0 0.8rem; }

.year h3 { font-size: 1.7rem; margin: 0.2rem 0 0.4rem; display: flex; align-items: center; gap: 0.5rem; font-weight: 750; }
.entry { padding: 0.75rem 0; border-top: 1px solid var(--line); }
.entry .meta { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.entry .when { color: var(--muted); font-size: 0.8rem; }
.entry .content { margin-top: 0.3rem; overflow-wrap: anywhere; white-space: pre-wrap; }
mark { background: rgba(247,79,40,0.3); color: inherit; border-radius: 4px; padding: 0 0.1em; }

.out { margin-top: 0.8rem; padding: 0.85rem; border-radius: 14px; border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.sources { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.draft { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.85rem; }
.draft .head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.draft textarea { margin-top: 0.6rem; }
.draft pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; background: var(--bg2); padding: 0.8rem; border-radius: 12px; }
.checks { list-style: none; padding: 0; margin: 0.8rem 0 0; }
.checks li { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.6rem; padding: 0.55rem 0; border-top: 1px solid var(--line); }
.checks li .badge { grid-row: span 2; align-self: start; }

.rec-btn { width: 100%; min-height: 86px; margin-top: 0.4rem; border-radius: 22px; font-size: 1.12rem; display: flex; align-items: center; justify-content: center; gap: 0.8rem; }
.rec-dot { width: 26px; height: 26px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 7px rgba(247,79,40,0.2); }
.rec-btn[aria-pressed="true"] { background: var(--orange); color: #fff; border-color: var(--orange); }
.rec-btn[aria-pressed="true"] .rec-dot { background: #fff; border-radius: 6px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 13px rgba(255,255,255,0.22); } }
audio { width: 100%; margin-top: 0.8rem; }
.file-list { list-style: none; padding: 0; margin: 0.6rem 0 0; }
.file-list li { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0; border-top: 1px solid var(--line); }
.file-list li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list button { min-height: 42px; }
