:root {
  --bg: #14110e;
  --bg-2: #221c17;
  --bg-3: #2c241d;
  --line: #3d342b;
  --ink: #f6f0e6;
  --muted: #b5a898;
  --paper: #f4ead4;
  --paper-ink: #261c14;
  --red: #ff3b30;
  --amber: #f0b429;
  --green: #9dce78;
  --blue: #8eb6e8;
  color-scheme: dark;
  font-family: "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(1200px 500px at 10% -10%, #3a2418 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, monospace; }

.screen { min-height: 100%; }
.home-wrap { max-width: 980px; margin: 0 auto; padding: 42px 22px 80px; }
.brand {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--amber);
  font-size: 13px;
}
h1 { margin: 8px 0 10px; font-size: 40px; font-weight: 650; letter-spacing: -0.03em; }
.lead { margin: 0; max-width: 68ch; color: var(--muted); line-height: 1.5; }
.lead b { color: var(--ink); font-weight: 650; }
.steps { margin: 22px 0; padding-left: 22px; color: var(--ink); line-height: 1.55; }
.steps li { margin: 6px 0; }

.drops { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.drop {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 148px;
  padding: 16px;
  border: 1px dashed #6a5644;
  border-radius: 16px;
  background: rgba(255, 244, 230, 0.03);
  cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--amber); background: rgba(240, 180, 41, 0.08); }
.drop strong { font-size: 18px; }
.drop span { color: var(--muted); line-height: 1.35; }
.drop-kicker { color: var(--amber) !important; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.drop input { display: none; }

.import-box {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(240, 180, 41, 0.14), rgba(255, 244, 230, 0.03));
  border: 1px solid #6a5644;
}
.import-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.import-head strong {
  font-size: 28px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  color: var(--amber);
}
.bar { height: 12px; border-radius: 99px; background: #3a3128; overflow: hidden; }
.bar div {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #c9842a, #f0b429 70%, #ffe08a);
  transition: width 0.12s linear;
}
.boot-meter { margin-top: 16px; }

.home-tools { display: flex; gap: 12px; align-items: center; margin: 18px 0; }
.lib-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.lib-head h2 { margin: 0; }
.lib-head input, .field input, .field textarea, .title-input, select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 12px; }
.pack {
  text-align: left;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-2);
  overflow: hidden;
}
.pack img { width: 100%; height: 120px; object-fit: cover; background: #000; display: block; }
.pack-body { padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.pack-body strong { font-size: 16px; }
.pack-meta { color: var(--muted); font-size: 13px; }
.pack-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
}

.btn {
  border: 1px solid var(--line);
  background: var(--bg-3);
  border-radius: 999px;
  padding: 8px 14px;
}
.btn:hover { border-color: #8a7360; }
.btn.primary { background: var(--amber); color: #24180c; border-color: transparent; font-weight: 650; }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: 14px; font-size: 18px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.file-btn { display: inline-flex; margin-top: 8px; }
.file-btn input { display: none; }

#studio { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.title-input { flex: 1; min-width: 0; font-size: 16px; }
.title-input[readonly] {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}
.modes { display: flex; padding: 3px; border-radius: 999px; background: #100e0c; }
.mode { border: 0; background: transparent; border-radius: 999px; padding: 7px 12px; color: var(--muted); }
.mode.on { background: var(--bg-3); color: var(--ink); }
.progress, .save-state { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.save-state.hot { color: var(--amber); }
.save-state.bad { color: var(--red); }

.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 340px;
}
.line-col, .side {
  min-height: 0;
  overflow: auto;
  padding: 10px;
  background: rgba(0, 0, 0, 0.18);
}
.line-col { border-right: 1px solid var(--line); }
.side { border-left: 1px solid var(--line); }
.line {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 2px 8px;
  text-align: left;
  margin: 0 0 6px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
}
.line.on { background: var(--bg-3); border-color: var(--line); }
.line.done .num { color: var(--green); }
.line.skip { opacity: 0.45; }
.num { grid-row: span 2; color: var(--amber); font-variant-numeric: tabular-nums; padding-top: 2px; }
.line .who-mini { font-size: 12px; color: var(--amber); }
.line .cap { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.center { min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 10px; gap: 8px; overflow: hidden; }
.video-wrap {
  position: relative;
  flex: 1;
  min-height: 180px;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
}
.video-wrap.rec { box-shadow: inset 0 0 0 4px var(--red); }
video, .poster { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.poster { position: absolute; inset: 0; }
.no-video {
  position: absolute;
  inset: 18% 12%;
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}
#overlay-caption {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 52px;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  line-height: 1.25;
  color: white;
  text-shadow: 0 2px 2px #000, 0 0 12px #000;
  pointer-events: none;
}
#countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 120px;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
body:has(#studio:not(.hidden)) #home {
  display: none !important;
  pointer-events: none !important;
}

.watch-choice { display: flex; align-items: center; gap: 8px; }
.watch-choice span { color: var(--muted); font-size: 12px; }
.watch-choice button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 4px 12px;
  color: var(--muted);
}
.watch-choice button.on { background: var(--bg-3); color: var(--ink); border-color: var(--amber); }
.slider span { font-variant-numeric: tabular-nums; color: var(--ink); }

.timeline {
  position: relative;
  height: 46px;
  border-radius: 10px;
  background: #0e0c0a;
  border: 1px solid var(--line);
  overflow: hidden;
  cursor: pointer;
}
.tl-line {
  position: absolute;
  top: 8px;
  height: 30px;
  border-radius: 6px;
  opacity: 0.9;
  min-width: 3px;
}
.tl-line.on { outline: 2px solid white; }
.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--amber);
  pointer-events: none;
  z-index: 2;
}
.wave-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
#wave { width: 100%; max-width: 100%; height: 148px; max-height: 148px; background: #0e0c0a; border-radius: 10px; border: 1px solid var(--line); display: block; }
.timecode { font-family: Consolas, monospace; color: var(--amber); font-size: 18px; }

.who { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber); }
.roles { display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin: 8px 0; }
.role {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}
.role.off { opacity: 0.4; text-decoration: line-through; }
.role-assign { display: flex; align-items: center; gap: 8px; }
.role-assign select { flex: 1; min-width: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.role-who { font-size: 12px; color: var(--muted, #b7aa9c); }
.record {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 16px;
  background: var(--red);
  color: white;
  font-size: 22px;
  font-weight: 700;
}
.record.live { background: #7a1410; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.4; }
#claim-note:empty { display: none; }
.row { display: flex; gap: 8px; margin: 8px 0; }
.row .btn { flex: 1; }
.slider, .field, .check { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; font-size: 13px; color: var(--muted); }
.slider input[type="range"] { width: 100%; }
.check { flex-direction: row; align-items: center; gap: 8px; }
.field textarea { resize: vertical; }
.settings { margin-top: 8px; }
.keys { color: #7d7268; font-size: 12px; }
.side section { display: flex; flex-direction: column; }

.auth-page { max-width: 420px; margin: 28px auto 0; }
.auth-page h1 { margin-bottom: 8px; }
.auth-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-2);
}
.auth-card input, .auth-card .btn { width: 100%; }
.auth-card .field input { width: 100%; }
.profile-card {
  max-width: 520px;
  margin-top: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(420px 180px at 0% 0%, rgba(240, 180, 41, 0.16), transparent 60%),
    var(--bg-2);
}
.profile-kicker {
  margin: 0 0 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
  font-size: 12px;
}
.profile-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.profile-head h2 { margin: 0; font-size: 28px; }
.profile-head .hint { margin: 4px 0 0; }
.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: #140e0b;
  color: var(--amber);
  font-size: 28px;
  font-weight: 700;
  flex: none;
}
.profile-card .field input, .profile-card .btn.primary { width: 100%; }
.profile-site {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.profile-site h3 { margin: 0 0 10px; }
.profile-card #auth-logout { margin-top: 8px; }
.home-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 4px; }
.home-nav button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
}
.home-nav button.on { background: var(--amber); color: #24180c; border-color: transparent; font-weight: 650; }
.lobby-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.lobby-columns h3 { margin: 12px 0 0; }
.home-block { margin-top: 28px; }
.home-block .lead { margin: 8px 0 12px; }
.net-box {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(240, 180, 41, 0.08);
  border: 1px solid #6a5644;
}
.net-box .lead { margin: 0 0 8px; }
.net-box .row { align-items: center; }
.lobby-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.lobby-form input, .lobby-form select { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
#room-code, #room-code-home { width: 7em; text-transform: uppercase; }
#profile-label { color: var(--amber); }
#profile-name { min-width: 12em; }
#hub-url { min-width: 16em; flex: 1; }
#room-title { min-width: 12em; }
.room-box { margin: 4px 0 8px; }
body.room-window #home .home-wrap > :not(#room-boot) { display: none; }
body.room-window #room-boot { display: block; }
body.room-window #room-join-row { display: none; }
#room-pack { min-width: 12em; }
.room-take { display: flex; flex-direction: column; gap: 4px; align-items: stretch; margin: 8px 0; font-size: 13px; }
.room-take audio { width: 100%; height: 36px; }
.lobby-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: #2a2114;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.lobby-bar strong { letter-spacing: 0.12em; color: var(--amber); }
.line.mine { box-shadow: inset 3px 0 0 var(--green); }
.line.taken { box-shadow: inset 3px 0 0 var(--blue); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: min(640px, calc(100% - 24px));
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff8ec;
  color: #24180c;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.web-back {
  display: block;
  padding: 10px 14px;
  background: #140e0b;
  color: #f6efe4;
  text-decoration: none;
  font-size: 14px;
}
body.web-app { display: flex; flex-direction: column; min-height: 100%; }
body.web-app .web-back { flex: none; }
body.web-app .screen { flex: 1; min-height: 0; }
body.web-app input,
body.web-app select,
body.web-app textarea { font-size: 16px; }

@media (max-width: 980px) {
  .drops, .stage, .lobby-columns { grid-template-columns: 1fr; }
  .stage { overflow: auto; }
  .line-col, .side { border: 0; max-height: none; }
  h1 { font-size: 32px; }
}

@media (max-width: 760px) {
  body.web-app { display: block; height: auto; min-height: 100dvh; }
  body.web-app .home-wrap { padding: 18px 14px 40px; }
  body.web-app .home-nav button,
  body.web-app .home-nav a { min-height: 44px; }
  body.web-app .drops { grid-template-columns: 1fr; }
  body.web-app #studio { height: auto; min-height: calc(100dvh - 42px); }
  body.web-app .top { flex-wrap: wrap; align-items: stretch; }
  body.web-app .title-input { flex: 1 1 140px; }
  body.web-app .stage {
    display: flex;
    flex-direction: column;
    overflow: visible;
    height: auto;
  }
  body.web-app .line-col { max-height: 42vh; border: 0; }
  body.web-app .center { overflow: visible; height: auto; }
  body.web-app .video-wrap { flex: none; height: 52vw; min-height: 190px; }
  body.web-app .side {
    overflow: visible;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  body.web-app #overlay-caption { font-size: 18px; left: 10px; right: 10px; bottom: 36px; }
  body.web-app .record { position: sticky; bottom: 8px; }
  body.web-app .wave-row { grid-template-columns: 1fr; }
  body.web-app #wave { height: 96px; }
  body.web-app .lobby-form input,
  body.web-app .lobby-form select { width: 100%; }
}

.line-meter, .clip-play, .mobile-dock { display: none; }
body.mobile-studio {
  height: auto;
  min-height: 100dvh;
}
body.mobile-studio #studio {
  height: auto;
  min-height: 100dvh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
body.mobile-studio .top { flex-wrap: wrap; align-items: stretch; }
body.mobile-studio .stage {
  display: flex;
  flex-direction: column;
  overflow: visible;
  height: auto;
}
body.mobile-studio #line-col { display: none; }
body.mobile-studio.show-lines #line-col {
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(60px + env(safe-area-inset-bottom));
  max-height: 58vh;
  z-index: 8;
  background: #221c17;
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
}
body.mobile-studio .toast { bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 12; }
body.mobile-studio .lib-head {
  flex-direction: column;
  align-items: stretch;
}
body.mobile-studio .lib-head input,
body.mobile-studio #shop-search {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
body.mobile-studio .home-wrap,
body.mobile-studio .home-block,
body.mobile-studio .profile-card { max-width: 100%; min-width: 0; }
body.mobile-studio #drop-folder,
body.mobile-studio .web-limit,
body.mobile-studio #open-folder { display: none !important; }
body.mobile-studio .modes,
body.mobile-studio #roles,
body.mobile-studio #who,
body.mobile-studio #room-box,
body.mobile-studio .watch-choice,
body.mobile-studio #timecode,
body.mobile-studio .mode[data-mode="play"],
body.mobile-studio #panel-dub .row:has(#prev-line) { display: none !important; }
body.mobile-studio .wave-row {
  display: block;
  width: 100%;
  min-width: 0;
}
body.mobile-studio #wave {
  width: 100%;
  max-width: 100%;
  height: 28vw;
  min-height: 84px;
  max-height: 140px;
}
body.mobile-studio .video-wrap { flex: none; height: 54vw; min-height: 200px; }
body.mobile-studio .center { overflow: visible; height: auto; }
body.mobile-studio .side { overflow: visible; }
body.mobile-studio .mobile-dock {
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: #140e0b;
  border-top: 1px solid var(--line);
}
body.mobile-studio .mobile-dock .btn { flex: 1; min-height: 46px; }
body.mobile-studio .mobile-dock .btn.on { background: var(--amber); color: #24180c; border-color: transparent; }
body.clip-player #timeline { display: none; }
body.clip-player .line-meter {
  display: block;
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.35);
  z-index: 3;
}
body.clip-player #line-meter-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--amber);
}
body.clip-player .clip-play {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: rgba(20, 14, 11, 0.82);
  color: white;
  font-size: 16px;
}
body.clip-player .clip-play.hidden { display: none !important; }
