:root {
  color-scheme: light;
  --bg: #f2f4f1;
  --surface: #ffffff;
  --ink: #17201c;
  --muted: #69736e;
  --line: #dce2de;
  --accent: #166548;
  --accent-2: #dff1e9;
  --danger: #a23838;
  --shadow: 0 12px 35px rgba(27, 47, 38, .07);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
a { color: var(--accent); }
.topbar {
  height: 62px;
  padding: 0 max(20px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #153c2e;
}
.brand { color: #fff; text-decoration: none; font-weight: 800; letter-spacing: .02em; }
.link-button { background: none; color: #dceae4; padding: 8px; }
.container { width: min(1180px, calc(100% - 32px)); margin: 28px auto 70px; }
.hero {
  padding: 36px;
  border-radius: 24px;
  color: white;
  background: linear-gradient(125deg, #123d2e, #207052);
  display: flex;
  justify-content: space-between;
  align-items: end;
  box-shadow: var(--shadow);
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 5vw, 44px); line-height: 1.05; }
h2 { margin: 0; font-size: 24px; }
h3 { margin-bottom: 6px; }
.eyebrow { margin-bottom: 10px; text-transform: uppercase; letter-spacing: .14em; font-size: 12px; opacity: .7; }
.quick-nav { display: flex; flex-wrap: wrap; gap: 10px; }
.quick-nav a {
  color: white; text-decoration: none; border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px; padding: 8px 12px;
}
.panel {
  margin-top: 22px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.section-heading {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px;
}
.section-heading > div { display: flex; gap: 12px; align-items: center; }
.step, .counter, .position {
  display: inline-grid; place-items: center; min-width: 32px; height: 32px;
  padding: 0 9px; border-radius: 10px; background: var(--accent-2); color: var(--accent); font-weight: 800;
}
.counter { border-radius: 999px; }
.form-row, .schedule-form {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end;
  margin-bottom: 22px; padding: 18px; border-radius: 14px; background: #f7f9f7;
}
.form-row.compact { grid-template-columns: minmax(220px, 1fr) auto; }
.schedule-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
label { color: var(--muted); font-size: 13px; font-weight: 650; }
input, select {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px;
  color: var(--ink); background: white; border: 1px solid #cad2cd; border-radius: 9px;
}
input:focus, select:focus { outline: 3px solid rgba(22,101,72,.15); border-color: var(--accent); }
button, .button {
  border: 0; border-radius: 9px; padding: 11px 15px; color: white; background: var(--accent);
  font-weight: 750; cursor: pointer; text-decoration: none; text-align: center;
}
button.secondary, .button.secondary { color: var(--accent); background: var(--accent-2); }
button.danger { color: var(--danger); background: #f9e6e6; }
.full { width: 100%; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.item-card { border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.item-card-title { display: flex; justify-content: space-between; align-items: start; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #abb3ae; }
.status-dot.known { background: #37a973; box-shadow: 0 0 0 4px #e0f6eb; }
.copy-row { display: flex; gap: 8px; }
.copy-row button { margin-top: 6px; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.actions form { margin: 0; }
.item-card small, .list-row small { display: block; margin-top: 8px; color: var(--muted); }
.pairing-box {
  margin: 14px 0; padding: 14px; border-radius: 12px;
  color: var(--accent); background: var(--accent-2);
}
.pairing-box span { display: block; font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.pairing-box strong { display: block; margin: 3px 0; font-size: 32px; letter-spacing: .16em; }
.pairing-box small { color: #315f4e; overflow-wrap: anywhere; }
.media-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.media-card { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: white; }
.preview { height: 145px; position: relative; background: #121512; }
.preview img, .preview video { width: 100%; height: 100%; display: block; object-fit: contain; }
.video-badge { position: absolute; right: 8px; bottom: 8px; color: white; background: rgba(0,0,0,.7); padding: 3px 7px; border-radius: 5px; font-size: 10px; }
.media-meta { min-height: 70px; padding: 12px; }
.media-meta strong, .media-meta span, .list-row span { display: block; }
.media-meta span, .list-row span { color: var(--muted); }
.media-card form { padding: 0 12px 12px; }
.list { display: grid; gap: 10px; }
.list-row {
  padding: 14px 16px; display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--line); border-radius: 12px;
}
.list-row.disabled { opacity: .5; }
.playlist-item { display: flex; align-items: center; gap: 12px; }
.inline-form { display: flex; align-items: end; gap: 7px; }
.inline-form input { width: 85px; }
.weekdays { grid-column: 1 / -2; border: 0; padding: 0; margin: 0; }
.weekdays legend { margin-bottom: 7px; color: var(--muted); font-size: 13px; font-weight: 650; }
.weekdays label { display: inline-block; margin-right: 6px; }
.weekdays input { position: absolute; opacity: 0; width: 1px; }
.weekdays span { display: inline-block; padding: 8px 11px; border-radius: 8px; background: #e4e8e5; cursor: pointer; }
.weekdays input:checked + span { background: var(--accent); color: white; }
.empty, .hint { color: var(--muted); }
.page-title { margin: 24px 0; }
.page-title h1 { margin-top: 12px; }
.login-card { width: min(420px, 100%); margin: 10vh auto; padding: 30px; background: white; border-radius: 20px; box-shadow: var(--shadow); }
.connect-card {
  width: min(620px, 100%); margin: 8vh auto; padding: 42px;
  text-align: center; background: white; border-radius: 24px; box-shadow: var(--shadow);
}
.connect-card .stack { width: min(420px, 100%); margin: 28px auto 0; text-align: left; }
.pair-code-input {
  padding: 18px; text-align: center; font-size: 34px; font-weight: 800;
  letter-spacing: .2em; font-variant-numeric: tabular-nums;
}
.stack { display: grid; gap: 16px; }
.flash { margin: 0 0 12px; padding: 12px 16px; border-radius: 10px; background: #e7f5ed; color: #15563e; }
.flash.error { background: #fae8e8; color: #842d2d; }
details summary { cursor: pointer; font-weight: 800; }

@media (max-width: 850px) {
  .hero { align-items: start; flex-direction: column; gap: 20px; }
  .form-row, .schedule-form { grid-template-columns: 1fr 1fr; }
  .weekdays { grid-column: 1 / -1; }
  .card-grid { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .list-row { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 560px) {
  .container { width: min(100% - 20px, 1180px); }
  .hero, .panel { padding: 20px; border-radius: 16px; }
  .form-row, .form-row.compact, .schedule-form { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: 1fr; }
  .copy-row { align-items: stretch; flex-direction: column; }
  .inline-form { flex-wrap: wrap; }
}
