:root {
  --bg: #f7f3ee;
  --surface: #ffffff;
  --text: #2a2522;
  --muted: #7a706a;
  --border: #e4ddd5;
  --accent: #c2553f;
  --accent-text: #ffffff;
  --error: #b3261e;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a19;
    --surface: #262321;
    --text: #efe9e3;
    --muted: #a59b94;
    --border: #3a3532;
    --accent: #e07a62;
    --accent-text: #1c1a19;
    --error: #f2b8b5;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
main { max-width: 34rem; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0.5rem 0 1rem; }
code { font-size: 0.85em; word-break: break-all; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); margin: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 34rem; margin: 0 auto; padding: 12px 16px 0;
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.topbar form { margin: 0; }

.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
input, textarea {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  width: 100%;
}
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

button { font: inherit; cursor: pointer; }
button.primary {
  background: var(--accent); color: var(--accent-text); border: 0;
  border-radius: 10px; padding: 12px 16px; font-weight: 600; min-height: 48px;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--muted); padding: 8px; }

.login { text-align: center; padding-top: 10vh; }
.login form { text-align: left; margin-top: 1.5rem; }
.login-logo { display: block; margin: 0 auto 0.5rem; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.card p { margin: 0; }
.card-title { font-weight: 600; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 14px; text-align: center;
  font-weight: 500; text-decoration: none; color: inherit;
}
.tile.disabled { color: var(--muted); }

a { color: var(--accent); }
.brand { color: inherit; text-decoration: none; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.flash {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 10px 12px; margin: 0 0 16px;
}
.badge {
  display: inline-block; min-width: 1.5em; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; background: var(--accent); color: var(--accent-text);
  font-size: 0.8rem; line-height: 1.5em;
}
select {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; width: 100%;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 10rem; }
button.secondary {
  background: none; color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; min-height: 48px;
}
.notes { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.notes li {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.note-text { overflow-wrap: anywhere; }
.proposal-action {
  font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent);
}
.old-text { border-left: 3px solid var(--border); padding-left: 10px; color: var(--muted); }
fieldset.carddraft {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 12px; margin: 0;
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
legend { font-size: 0.85rem; color: var(--muted); padding: 0 4px; }
.source summary { cursor: pointer; }
.source p { white-space: pre-wrap; overflow-wrap: anywhere; }

.tile-main { grid-column: 1 / -1; order: -1; background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.tile-main .badge { background: var(--accent-text); color: var(--accent); }
.progress { margin: 0.5rem 0; }
.review-card { gap: 16px; padding: 20px 16px; }
.review-card hr { border: 0; border-top: 1px solid var(--border); margin: 0; width: 100%; }
.question { font-size: 1.2rem; font-weight: 600; line-height: 1.4; }
.answer { font-size: 1.1rem; white-space: pre-wrap; }
button.wide { width: 100%; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
button.rating {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 56px; padding: 8px 4px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font-weight: 600;
}
button.rating .small { font-weight: 400; color: var(--muted); }
button.rating-3 { border-color: var(--accent); }
.card-actions { text-align: center; }
.done { text-align: center; padding-top: 10vh; }
