:root {
  --ground: #F4F1EA;
  --paper: #FFFDF8;
  --soft: #EDE8DD;
  --line: #DDD5C5;
  --line-strong: #C9C2B3;
  --ink: #1B2430;
  --ink-2: #3A4352;
  --muted: #5A6270;
  --accent: #1F6F6B;
  --accent-dark: #164F4C;
  --danger: #A3302A;
  --danger-dark: #8A2621;
  --danger-soft: #F6E3E1;
  --focus: #B7791F;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); }
body { font: 16px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
button, input { font: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.site-header { border-bottom: 1px solid var(--line); background: #FAF8F3; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 24px; }
.site-header .wrap { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding-top: 16px; padding-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand span { font-family: Fraunces, Georgia, serif; font-size: 24px; font-weight: 600; }
.tagline { font-size: 14px; color: var(--muted); }
main { flex: 1; }
main .wrap { padding-top: 40px; padding-bottom: 56px; }
.site-footer { border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 16px; padding-top: 16px; padding-bottom: 16px; }

h1, .serif { font-family: Fraunces, Georgia, serif; font-weight: 600; }
h1 { margin: 0; }
.hero h1 { font-size: clamp(34px, 6vw, 48px); line-height: 1.1; }
.dialogue-note { margin: 0; max-width: 680px; padding: 14px 18px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; color: var(--ink-2); }
.lead { margin: 0; font-size: 19px; color: var(--ink-2); max-width: 680px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 32px; }
.label { margin: 0; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
p { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); font-weight: 500; font-size: 15px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.card { padding: 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn { min-height: 48px; padding: 12px 20px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; cursor: pointer; }
.btn-lg { min-height: 56px; padding: 14px 24px; font-size: 17px; flex: 1 1 240px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-ghost { background: var(--paper); border-color: var(--line-strong); color: var(--ink); }
.btn-outline { background: #fff; border-color: var(--accent); color: var(--accent); }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-sm { min-height: 44px; padding: 10px 16px; font-size: 15px; border-radius: 8px; }
.btn:disabled { background: var(--soft); border-color: var(--line-strong); color: var(--muted); cursor: default; }
.btn-link { background: none; border: none; color: var(--accent); text-decoration: underline; padding: 10px 0; min-height: 44px; font-weight: 600; cursor: pointer; align-self: flex-start; }
.error { color: var(--danger); font-weight: 500; font-size: 15px; }

.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.rule { padding: 20px; background: var(--soft); border-radius: 12px; display: flex; flex-direction: column; gap: 6px; }
.rule h3 { margin: 0; font-size: 16px; }
.rule p { font-size: 15px; color: var(--ink-2); }

.code-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.input { min-height: 48px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--ink); }
.select { max-width: 420px; width: 100%; font-size: 16px; cursor: pointer; }
.saved-codes { display: flex; flex-wrap: wrap; gap: 8px; }

.center { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 72px 0; text-align: center; }
.dots { display: flex; gap: 8px; }
.dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.qotd { max-width: 560px; padding: 20px 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.qotd .q { font-family: Fraunces, Georgia, serif; font-size: 20px; margin-top: 6px; }

.chat-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.question { padding: 20px 24px; background: var(--accent); color: #fff; border-radius: 12px; }
.question .label { color: #D7EFEC; }
.question .q { font-family: Fraunces, Georgia, serif; font-size: 24px; line-height: 1.3; margin-top: 4px; }
.log-outer { display: flex; flex-direction: column-reverse; height: min(52vh, 440px); overflow-y: auto; padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.log { display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; }
.msg.mine { justify-content: flex-end; }
.msg.system { justify-content: center; }
.bubble { max-width: 75%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mine .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.theirs .bubble { background: var(--soft); border-bottom-left-radius: 4px; }
.who { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.system .bubble { max-width: 85%; text-align: center; font-size: 14px; font-style: italic; color: var(--muted); padding: 6px 12px; }
.codebox { margin: 4px auto; padding: 14px 18px; border: 1px dashed var(--accent); border-radius: 10px; background: #fff; text-align: center; font-style: normal; }
.codebox strong { display: block; font-size: 22px; letter-spacing: 2px; color: var(--accent-dark); margin: 4px 0 8px; }
.typing { font-size: 14px; color: var(--muted); font-style: italic; }
.notice { padding: 12px 16px; background: var(--danger-soft); color: var(--danger-dark); border-radius: 8px; font-size: 15px; font-weight: 500; }
.composer { display: flex; gap: 10px; }
.composer .input { flex: 1 1 auto; min-width: 0; min-height: 52px; }

.prose { max-width: 720px; }
.prose h1 { font-size: 36px; margin-bottom: 16px; }
.prose h2 { font-size: 20px; margin: 28px 0 8px; }
.prose p, .prose li { color: var(--ink-2); }
.prose p + p { margin-top: 12px; }

@media (max-width: 560px) {
  .question .q { font-size: 20px; }
  .bubble { max-width: 88%; }
}
