:root {
  --ground: #F3F4F6; --surface: #FFFFFF; --ink: #111827; --muted: #4B5563; --line: #E5E7EB; --line-soft: #F0F1F3;
  --accent: #0B5D4B; --accent-ink: #FFFFFF; --accent-soft: #E3F1EC;
  --blue-soft: #E4ECFB; --blue: #1E40AF; --amber-soft: #FBEEDD; --amber: #8A4308; --red-soft: #FBE4E4; --red: #A61B1B;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: 'Manrope', system-ui, -apple-system, sans-serif; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; padding-bottom: calc(96px + var(--safe-b)); }
body.has-bar { padding-bottom: calc(160px + var(--safe-b)); }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
.wrap { max-width: 560px; margin: 0 auto; }
h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
h2 { margin: 22px 20px 10px; font-size: 17px; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* Header */
.top { padding: calc(20px + env(safe-area-inset-top, 0px)) 20px 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.top .date { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; display: block; margin-bottom: 4px; }
.bar-top { padding: calc(10px + env(safe-area-inset-top, 0px)) 8px 4px; display: flex; align-items: center; gap: 4px; justify-content: space-between; }
.bar-top h1 { font-size: 20px; flex: 1; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: none; background: none; color: var(--ink); border-radius: 12px; text-decoration: none; cursor: pointer; }
.avatar { width: 44px; height: 44px; border-radius: 22px; border: none; background: var(--ink); color: #fff; font-weight: 700; font-size: 14px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* Tiles */
.tiles { padding: 8px 20px 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; }
.tile b { font-size: 28px; font-weight: 800; line-height: 1; }
.tile span { font-size: 12px; font-weight: 600; color: var(--muted); }
.tile.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.tile.primary span { color: #fff; }

.assistant { margin: 0 20px 6px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); display: flex; gap: 10px; align-items: center; font-size: 13px; line-height: 1.4; }
.assistant .spark { flex: none; width: 32px; height: 32px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }

.section-head { padding: 0 20px; margin-top: 18px; display: flex; justify-content: space-between; align-items: baseline; }
.section-head h2 { margin: 0; }
.section-head a, .section-head button { font-size: 14px; font-weight: 700; text-decoration: none; background: none; border: none; color: var(--accent); padding: 10px 0; cursor: pointer; }

/* Cards */
.list { padding: 12px 20px 0; display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
a.card { text-decoration: none; color: inherit; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .title { font-size: 15px; font-weight: 700; line-height: 1.35; }
.card .sub { font-size: 13px; color: var(--muted); line-height: 1.4; }
.card .btns { display: flex; gap: 8px; margin-top: 2px; }
.tag { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; padding: 4px 8px; border-radius: 6px; background: var(--line); color: var(--ink); white-space: nowrap; }
.tag.green { background: var(--accent-soft); color: var(--accent); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.red { background: var(--red-soft); color: var(--red); }
.pill { font-size: 12px; font-weight: 800; padding: 5px 10px; border-radius: 999px; background: var(--ink); color: #fff; white-space: nowrap; }
.pill.soft { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.pill.warn { background: var(--amber-soft); color: var(--amber); font-weight: 700; }
.time { font-size: 12px; color: var(--muted); font-weight: 600; }

.btn { flex: 1; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid #D1D5DB; background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.go { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 800; }
.btn.slim { flex: none; }
.btn:disabled { opacity: 0.55; cursor: default; }

.empty { margin: 12px 20px; padding: 28px 20px; text-align: center; border: 1px dashed #D1D5DB; border-radius: var(--radius); color: var(--muted); font-size: 14px; line-height: 1.5; }

/* Panels */
.panel { margin: 0 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.panel .line { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); display: flex; gap: 10px; font-size: 14px; align-items: baseline; }
.panel .line:last-child { border-bottom: none; }
.panel .line .k { color: var(--muted); font-weight: 700; width: 62px; flex: none; }
.panel .line input { flex: 1; min-width: 0; border: none; padding: 0; font-weight: 600; background: transparent; outline: none; }
.panel textarea { display: block; width: 100%; border: none; resize: vertical; padding: 14px 16px; min-height: 300px; font-size: 14px; line-height: 1.55; background: transparent; outline: none; }
.panel .pad { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; line-height: 1.45; }
.panel:focus-within { border-color: #9CA3AF; }

.head-block { padding: 4px 20px 16px; display: flex; flex-direction: column; gap: 8px; }
.head-block .chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.head-block .facts { font-size: 14px; color: var(--muted); font-weight: 600; }

.scores { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.scores div { display: flex; flex-direction: column; gap: 4px; }
.scores span { font-size: 12px; font-weight: 700; color: var(--muted); }
.scores b { font-size: 32px; font-weight: 800; line-height: 1; }
.scores b.accent { color: var(--accent); }
.verdict { border-radius: 12px; padding: 12px; font-size: 14px; font-weight: 700; line-height: 1.4; background: var(--accent-soft); color: var(--accent); }
.verdict.maybe { background: var(--amber-soft); color: var(--amber); }
.verdict.reject { background: var(--red-soft); color: var(--red); }

.check { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); align-items: flex-start; }
.check:last-child { border-bottom: none; }
.check .dot { flex: none; width: 28px; height: 28px; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.check .dot.ok { background: var(--accent-soft); color: var(--accent); }
.check .dot.warn { background: var(--amber-soft); color: var(--amber); }
.check .dot.fail { background: var(--red-soft); color: var(--red); }
.check b { font-size: 15px; display: block; margin-bottom: 3px; }
.check span { font-size: 13px; color: var(--muted); line-height: 1.4; }

.seg { margin: 12px 20px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--line); border-radius: 12px; }
.seg button { min-height: 40px; border-radius: 9px; border: none; background: transparent; color: #374151; font-size: 13px; font-weight: 700; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 800; }

.chips-row { padding: 14px 20px 6px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid #D1D5DB; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 700; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Bottom action bar and tab bar */
.actionbar { position: fixed; left: 0; right: 0; bottom: calc(72px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--line); padding: 12px 16px; z-index: 5; }
.actionbar .inner { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(72px + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--line); z-index: 6; }
.tabbar .inner { max-width: 560px; margin: 0 auto; height: 72px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 700; text-decoration: none; color: var(--muted); position: relative; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar .badge { position: absolute; top: 10px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted); }
.field input, .field select, .field textarea { min-height: 44px; padding: 10px 12px; border: 1px solid #D1D5DB; border-radius: 12px; background: var(--surface); font-size: 15px; }
.field textarea { min-height: 120px; line-height: 1.5; }
.login { max-width: 380px; margin: 0 auto; padding: calc(80px + env(safe-area-inset-top, 0px)) 24px 24px; }
.login .mark { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: #fff; font-weight: 800; font-size: 24px; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; }
.error { color: var(--red); font-size: 14px; font-weight: 600; min-height: 20px; }

.status-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.status-row:last-child { border-bottom: none; }
.status-row span:first-child { font-weight: 700; }
.status-row span:last-child { color: var(--muted); text-align: right; }

.timeline { padding: 4px 16px; }
.timeline div { padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; line-height: 1.45; }
.timeline div:last-child { border-bottom: none; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(160px + var(--safe-b)); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 20; max-width: calc(100% - 40px); box-shadow: 0 6px 24px rgba(0,0,0,0.18); }
.reply-body { white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
details.why summary { cursor: pointer; font-weight: 700; padding: 12px 16px; list-style: none; display: flex; justify-content: space-between; }
details.why summary::-webkit-details-marker { display: none; }
details.why[open] summary { border-bottom: 1px solid var(--line-soft); }
.mt { margin-top: 12px; }
.note { margin: 12px 20px 0; }
.note-top { margin: 0 20px 10px; }
.link-row { margin: 16px 20px; font-size: 14px; font-weight: 600; }
.btns-row { display: flex; gap: 8px; }
details.card > summary { list-style: none; cursor: pointer; min-height: 28px; }
details.card > summary::-webkit-details-marker { display: none; }
.cmd { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--ground); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; word-break: break-all; user-select: all; }
.mt-x { margin: 12px 20px 0; }
