:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --text: #17171a;
  --muted: #6b6b73;
  --border: #e3e3de;
  --accent: #e5484d;
  --accent-strong: #cf3a3f;
  --accent-soft: #fdeceb;
  --success: #2f9e5b;
  --success-soft: #e6f5ec;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 10px 30px rgb(0 0 0 / 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --surface: #19191c;
    --surface-2: #232327;
    --text: #ededef;
    --muted: #9b9ba4;
    --border: #2d2d32;
    --accent: #ff5a5f;
    --accent-strong: #ff7175;
    --accent-soft: #3a1c1e;
    --success: #4cc38a;
    --success-soft: #16301f;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 30px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
.topbar {
  max-width: 1040px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: radial-gradient(circle, var(--accent) 0 52%, transparent 54%);
}
main { max-width: 1040px; margin: 0 auto; padding: 0 20px 72px; }

h1 { font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 8px; }
h2 { font-size: 18px; letter-spacing: -0.01em; margin: 0 0 16px; }
.lede { color: var(--muted); margin: 0 0 28px; }
.hint { color: var(--muted); font-size: 13px; margin: 20px auto 0; max-width: 460px; }
.hint.left { text-align: left; margin: 0; max-width: none; }
.muted { color: var(--muted); }
.error { color: var(--accent); margin: 14px 0 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.center { justify-content: center; margin-top: 24px; }

/* ---------- studio card ---------- */
.studio {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 32px;
  text-align: center;
  box-shadow: var(--shadow);
}
.options { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 28px; }
.select, .toggle {
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
}
.select svg, .toggle svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.select select {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  max-width: 220px;
  padding-right: 18px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 6px center, right 1px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
}
.select select option { background: var(--surface); color: var(--text); }
.toggle { cursor: pointer; }
.toggle[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.btn-record {
  height: 58px;
  padding: 0 30px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform 0.12s ease, background 0.12s ease;
}
.btn-record:hover { background: var(--accent-strong); }
.btn-record:active { transform: scale(0.97); }
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; }

.rec-indicator { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.is-paused .rec-indicator { color: var(--muted); }
.is-paused .pulse { background: var(--muted); animation: none; }
@keyframes pulse { 50% { opacity: 0.25; } }
.timer {
  font-size: 56px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 4px 0 0;
}

.progress { height: 6px; max-width: 360px; margin: 24px auto 0; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }

.badge {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--success-soft);
  display: grid;
  place-items: center;
}
.badge svg { width: 28px; height: 28px; fill: var(--success); }

.linkbox { display: flex; gap: 8px; max-width: 580px; margin: 0 auto; }
.field {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.linkbox .btn { height: 44px; }
.title-field { display: flex; align-items: center; gap: 10px; max-width: 580px; margin: 12px auto 0; text-align: left; }
.title-field span { color: var(--muted); font-size: 13px; width: 40px; flex: none; }
.title-field .field { height: 40px; }

/* ---------- buttons ---------- */
.btn {
  height: 40px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 560;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--text); color: var(--bg); border-color: transparent; }
.btn.primary:hover { opacity: 0.88; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--accent); }
.btn.small { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 9px; }

/* ---------- library ---------- */
.library { margin-top: 44px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--surface-2) radial-gradient(circle, var(--border) 0 18%, transparent 19%);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dur {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgb(0 0 0 / 0.72);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.dur:empty { display: none; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-title { font-weight: 600; color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title:hover { text-decoration: underline; }
.card-meta { color: var(--muted); font-size: 13px; }
.card-actions { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- watch page ---------- */
.watch { max-width: 1100px; }
.player {
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: var(--shadow);
}
.player video { width: 100%; height: 100%; display: block; background: #000; object-fit: contain; }
.watch-info { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-top: 20px; }
.watch-meta { min-width: 0; }
.watch-meta h1 { font-size: 24px; margin: 0 0 2px; overflow-wrap: anywhere; }
.watch-meta p { margin: 0; }
.notice {
  max-width: 560px;
  margin: 60px auto 0;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 28px;
  box-shadow: var(--shadow);
}
.notice .lede { margin: 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 600px) {
  .topbar { padding: 14px 16px; }
  main { padding: 0 16px 56px; }
  .studio { padding: 32px 18px; border-radius: 16px; }
  h1 { font-size: 24px; }
  .timer { font-size: 44px; }
  .linkbox { flex-wrap: wrap; }
  .linkbox .field { flex-basis: 100%; }
  .linkbox .btn { flex: 1; }
  .watch-info .row { width: 100%; }
  .watch-info .btn { flex: 1; }
  .player { border-radius: 12px; }
}
