:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --text: #2a2420;
  --muted: #7a6f66;
  --line: #e8dfd3;
  --accent: #c8501e;
  --accent-dark: #a63f14;
  --ok: #2f7d4f;
  --warn-bg: #fff4e0;
  --warn-text: #8a5a00;
  --err-bg: #fde8e6;
  --err-text: #a12a20;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1714;
    --surface: #26211d;
    --text: #f3ece4;
    --muted: #b0a498;
    --line: #3b332c;
    --accent: #ef7a47;
    --accent-dark: #ff9366;
    --ok: #62c58a;
    --warn-bg: #3a2d12;
    --warn-text: #f2c26b;
    --err-bg: #3d1f1c;
    --err-text: #ff9d92;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 96px;
}
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

header.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
header.top .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); margin-right: auto; }
.brand span { color: var(--accent); }
.chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: .85rem; cursor: pointer;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip.needs-setup { border-color: var(--accent); color: var(--accent); font-weight: 600; }

h1 { font-size: 1.6rem; margin: 28px 0 4px; }
p.sub { color: var(--muted); margin: 0 0 20px; }

.notice { border-radius: 10px; padding: 10px 14px; margin: 0 0 16px; font-size: .92rem; }
.notice.warn { background: var(--warn-bg); color: var(--warn-text); }
.notice.err { background: var(--err-bg); color: var(--err-text); }
.notice.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.notice[hidden] { display: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 6px; position: relative;
}
.card .icon { font-size: 2.4rem; line-height: 1; }
.card h2 { margin: 6px 0 0; font-size: 1.1rem; }
.card p { margin: 0; color: var(--muted); font-size: .9rem; flex: 1; }
.card.unavailable { opacity: .55; }
.badge {
  position: absolute; top: 14px; right: 14px; background: var(--err-bg); color: var(--err-text);
  font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
}

.stepper { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; }
.stepper button {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 1.2rem; cursor: pointer; line-height: 1;
}
.stepper button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.stepper button:disabled { cursor: not-allowed; opacity: .4; }
.stepper .qty { min-width: 32px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-block; border: 0; border-radius: 10px; padding: 12px 20px; font: inherit;
  font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--accent); color: #fff;
}
.btn:hover:not(:disabled) { background: var(--accent-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.secondary:hover:not(:disabled) { background: var(--bg); border-color: var(--accent); }

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface);
  border-top: 1px solid var(--line); padding: 14px 0; z-index: 5;
}
.bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bar .summary { color: var(--muted); }

.lines { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.line { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line .icon { font-size: 1.8rem; }
.line .name { flex: 1; font-weight: 600; }
.line .name small { display: block; color: var(--err-text); font-weight: 600; }
.line .stepper { margin: 0; }
.empty { padding: 32px 18px; text-align: center; color: var(--muted); }

label.field { display: block; margin: 20px 0 6px; font-weight: 600; font-size: .92rem; }
input[type=text], input[type=url] {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { color: var(--muted); font-size: .82rem; margin: 4px 0 0; }

.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }

.confirm { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-top: 8px; }
.confirm h2 { margin-top: 0; }
pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  overflow: auto; font-size: .82rem; margin: 8px 0 0;
}
details { margin-top: 14px; }
summary { cursor: pointer; font-weight: 600; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin: 0 0 4px; }
dialog p.lead { margin: 0; color: var(--muted); font-size: .92rem; }
dialog .actions { justify-content: flex-end; }
.overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.overlay-box {
  background: var(--surface); color: var(--text); border-radius: var(--radius);
  padding: 28px 32px; text-align: center; max-width: 340px; border: 1px solid var(--line);
}
.overlay-title { font-weight: 700; margin: 14px 0 2px; }
.overlay-sub { color: var(--muted); font-size: .92rem; margin: 0; }
.spinner {
  width: 40px; height: 40px; margin: 0 auto; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

dialog.alert { text-align: center; }
dialog.alert .alert-icon {
  width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 700;
  background: var(--line); color: var(--text);
}
dialog.alert.success .alert-icon { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
dialog.alert.error .alert-icon { background: var(--err-bg); color: var(--err-text); }
dialog.alert .alert-msg { font-size: 1.1rem; font-weight: 600; margin: 0 0 4px; }
dialog.alert .actions { justify-content: center; }

.field-err { color: var(--err-text); font-size: .85rem; margin-top: 10px; }
