:root {
  --bg: #F3F6F4; --card: #FFFFFF; --ink: #16222B; --muted: #54656F; --line: #D8E1DD;
  --teal: #0B7A75; --teal-ink: #FFFFFF; --marker: #FFD84D; --ok: #1F7A4A; --ok-bg: #E4F4EA;
  --bad: #B5352A; --bad-bg: #FBE7E4; --warn-bg: #FFF4CC; --focus: #1B5FD1;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0F171C; --card: #17232A; --ink: #E8EFEC; --muted: #9FB1B9; --line: #2A3B44;
    --teal: #3FC0B8; --teal-ink: #08201F; --ok: #66D19A; --ok-bg: #12301F; --bad: #FF8F82; --bad-bg: #3A1B18; --warn-bg: #3A3210; --focus: #8DB8FF; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; max-width: 68ch; }
a { color: var(--teal); }
mark { background: linear-gradient(transparent 55%, var(--marker) 55%); color: inherit; padding: 0 .1em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 99; background: var(--card); padding: 8px 12px; }

.app { max-width: 880px; margin: 0 auto; }
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font: 700 1.35rem var(--serif); text-decoration: none; color: var(--ink); }
.top-right { display: flex; align-items: center; gap: 8px; }
.pill { font-size: .78rem; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--muted); white-space: nowrap; }
.pill.on { color: var(--ok); border-color: var(--ok); } .pill.off { color: var(--bad); border-color: var(--bad); }
select, input, textarea, button { font: inherit; color: inherit; }
select { padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
main { padding: 16px; min-height: 70vh; outline: none; }
.side { display: none; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
.tabs a { text-align: center; padding: 10px 4px; font-size: .78rem; text-decoration: none; color: var(--muted); min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.tabs a b { font: 700 1.05rem var(--serif); }
.tabs a[aria-current="page"] { color: var(--teal); box-shadow: inset 0 3px 0 var(--teal); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card.flat { border-radius: 10px; }
.hero { padding: 6px 0 14px; } .hero p { color: var(--muted); }
.grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.tile { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; min-height: 112px; }
.tile .sample { font: 700 1.25rem var(--serif); color: var(--teal); display: block; margin-bottom: 4px; }
.tile strong { display: block; } .tile small { color: var(--muted); display: block; line-height: 1.35; margin-top: 2px; }
.tile:hover { border-color: var(--teal); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--teal); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; min-height: 46px; border-radius: 12px; border: 1px solid var(--teal); background: var(--teal); color: var(--teal-ink); font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--teal); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.muted { color: var(--muted); } .small { font-size: .88rem; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.back { display: inline-block; margin-bottom: 10px; }

.ex-ex { margin: 6px 0; padding: 10px 12px; border-left: 4px solid var(--marker); background: color-mix(in srgb, var(--marker) 16%, transparent); border-radius: 0 8px 8px 0; }
.ex-ex small { display: block; color: var(--muted); }
.opt { display: block; width: 100%; text-align: left; padding: 12px 14px; margin: 8px 0; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); cursor: pointer; min-height: 48px; }
.opt:hover { border-color: var(--teal); }
.opt.ok { border-color: var(--ok); background: var(--ok-bg); } .opt.bad { border-color: var(--bad); background: var(--bad-bg); }
.inp { width: 100%; padding: 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); }
textarea.inp { min-height: 150px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { padding: 9px 14px; border-radius: 99px; border: 1.5px solid var(--teal); background: var(--card); cursor: pointer; min-height: 42px; }
.chip.used { opacity: .35; }
.answer-line { min-height: 48px; padding: 10px; border: 1.5px dashed var(--line); border-radius: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.feedback { margin-top: 10px; padding: 10px 12px; border-radius: 10px; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); } .feedback.bad { background: var(--bad-bg); color: var(--bad); }
.notice { padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); margin: 10px 0; font-size: .92rem; }
.card-flash { text-align: center; padding: 30px 16px; }
.card-flash .w { font: 700 2rem var(--serif); }
.ai-out { white-space: normal; } .ai-out h4 { margin: 1em 0 .3em; font-family: var(--serif); } .ai-out ul { padding-left: 1.2em; }
.bubble { padding: 10px 12px; border-radius: 12px; margin: 8px 0; max-width: 90%; }
.bubble.me { background: var(--teal); color: var(--teal-ink); margin-left: auto; }
.bubble.bot { background: var(--card); border: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: 90vw; }
.toast.show { opacity: 1; }
[data-layout="wide"] body { padding-bottom: 0; }
[data-layout="wide"] .app { display: grid; grid-template-columns: 220px 1fr; grid-template-areas: "top top" "side main"; max-width: 1100px; }
[data-layout="wide"] .top { grid-area: top; }
[data-layout="wide"] .side { grid-area: side; display: block; padding: 16px 8px; position: sticky; top: 64px; align-self: start; }
[data-layout="wide"] main { grid-area: main; }
[data-layout="wide"] .tabs { display: none; }
[data-layout="wide"] .side a { display: block; padding: 9px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); }
[data-layout="wide"] .side a[aria-current="page"] { background: var(--card); border: 1px solid var(--line); color: var(--teal); font-weight: 600; }
[data-layout="wide"] .grid { grid-template-columns: repeat(3, 1fr); }
[data-layout="wide"] .toast { bottom: 24px; }
[data-device="phone"] .btn, [data-device="tablet"] .btn { min-height: 48px; }
.install-tip { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
a.chip { text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; }
a.chip[aria-current="true"] { color: var(--teal-ink); }
