:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efeeea;
  --text: #1c1b19;
  --muted: #6b6862;
  --line: #e2e0da;
  --accent: #c8102e;
  --accent-ink: #ffffff;
  --star: #e3a008;
  --ok: #1a7f37;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1d1d1b;
    --surface-2: #262624;
    --text: #f1efe9;
    --muted: #a19e96;
    --line: #34332f;
    --accent: #ff4d5e;
    --accent-ink: #1a0004;
    --ok: #4ade80;
    --danger: #ff7a70;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: inherit; }
img { display: block; max-width: 100%; height: auto; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; gap: 24px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.brand-mark { width: 28px; height: 18px; border-radius: 4px; background: linear-gradient(135deg, var(--accent), #2b4c7e); }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { text-decoration: none; padding: 6px 10px; border-radius: 8px; color: var(--muted); }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.account { display: flex; gap: 8px; align-items: center; }
.account form { margin: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 15px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--danger); }
.btn:disabled { opacity: 0.6; cursor: progress; }

main { padding: 32px 0 64px; }

.hero { display: grid; gap: 8px; margin-bottom: 28px; }
.hero h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.1; margin: 0; letter-spacing: -0.02em; }
.hero p { margin: 0; color: var(--muted); max-width: 60ch; }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.tabs a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 600; }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--muted); background: var(--surface); }
.chip:hover { color: var(--text); }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-decoration: none; display: flex; flex-direction: column; }
.card img { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; background: var(--surface-2); }
.card-body { padding: 12px 14px 14px; display: grid; gap: 2px; }
.card-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }

.stars { color: var(--star); letter-spacing: 1px; white-space: nowrap; }
.stars .count { color: var(--muted); letter-spacing: 0; margin-left: 4px; }

.empty { text-align: center; padding: 64px 16px; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); }

/* Detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; align-items: start; }
.detail > * { min-width: 0; }
@media (max-width: 900px) { .detail { grid-template-columns: minmax(0, 1fr); } }
.detail-image { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--surface-2); }
.detail-image img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: grid; gap: 14px; }
.panel h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.panel h2 { margin: 0; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.rate { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; }
.rate button { font-size: 26px; line-height: 1; border: 0; background: none; cursor: pointer; color: var(--line); padding: 0 2px; }
.rate button.on, .rate button:hover, .rate button:hover ~ button { color: var(--star); }

/* Add to Teams */
.teams { display: grid; gap: 10px; }
.os-tabs { display: flex; gap: 4px; }
.os-tabs button { font: inherit; font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.os-tabs button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.command { display: flex; gap: 6px; align-items: stretch; }
.command code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 10px; border-radius: 8px; }
.command .btn { font-size: 13px; padding: 6px 10px; }

/* Forms */
.form { display: grid; gap: 16px; max-width: 520px; }
.form-narrow { max-width: 380px; margin: 0 auto; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 14px; }
.field input, .field textarea {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); width: 100%;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field .hint { font-size: 13px; color: var(--muted); }
.field .error, .alert { color: var(--danger); font-size: 14px; }
.alert { background: color-mix(in srgb, var(--danger) 10%, transparent); padding: 10px 12px; border-radius: 10px; }
.notice { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

.prose { max-width: 72ch; }
.prose h2 { margin-top: 32px; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

.site-footer { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); font-size: 13px; }

/* Grid children default to min-width: auto, so the long one-line command
   would otherwise stretch its panel past a phone's width. */
.panel, .teams, .stack, .hero { grid-template-columns: minmax(0, 1fr); }

.badge {
  display: inline-block; vertical-align: middle; margin-right: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink);
}
.panel h1 .badge { font-size: 12px; position: relative; top: -2px; }

.prose pre { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; }
.prose h3 { margin: 20px 0 4px; font-size: 17px; }
.field .hint a { color: inherit; }

.tips { font-size: 14px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.tips summary { cursor: pointer; font-weight: 600; color: var(--text); }
.tips p { margin: 8px 0; }
.tips ul { margin: 8px 0; padding-left: 20px; display: grid; gap: 6px; }

.link-button { font: inherit; color: inherit; background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

/* Admin */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users th, table.users td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.users th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
table.users tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.actions form { margin: 0; }
.btn-small { font-size: 13px; padding: 5px 10px; border-radius: 8px; white-space: nowrap; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.pill-warn { background: color-mix(in srgb, var(--star) 18%, transparent); color: color-mix(in srgb, var(--star) 70%, var(--text)); }
.pill-bad { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.search { font: inherit; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); flex: 1; min-width: 0; max-width: 360px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* On phones the users table becomes one card per account. */
@media (max-width: 760px) {
  .table-wrap { background: none; box-shadow: none; overflow: visible; }
  table.users, table.users tbody, table.users tr, table.users td { display: block; }
  table.users thead { display: none; }
  table.users tr { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 12px; }
  table.users td { border: 0; padding: 3px 0; display: flex; gap: 12px; }
  table.users td[data-label]::before { content: attr(data-label); color: var(--muted); min-width: 84px; font-size: 13px; }
  table.users td.cell-name { display: block; padding-bottom: 8px; }
  table.users td.cell-actions { padding-top: 10px; }
  .actions { justify-content: flex-start; }
}

/* Moderation */
.badge-muted { background: var(--surface-2); color: var(--muted); }
.status-panel { border-left: 4px solid var(--star); }
.status-rejected { border-left-color: var(--danger); }
.hint.rules { margin: 0; padding-left: 20px; display: grid; gap: 2px; }
.review-list { display: grid; gap: 14px; }
.review-item { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.review-thumb { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.review-item .row form { margin: 0; }
@media (max-width: 640px) { .review-item { grid-template-columns: minmax(0, 1fr); } }

.field .checkbox { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 14px; cursor: pointer; }
.field .checkbox input { width: 18px; height: 18px; padding: 0; margin: 0; flex: none; accent-color: var(--accent); }
.admin-tabs { margin-bottom: 20px; }
