/* Studio: streamer control room. Tokens come from ../site.css. */

[hidden] { display: none !important; }

:root {
  --input: #0f0f14;
  --raise: #22222b;
  --danger: #ff9b9b;
  --danger-soft: rgba(255, 90, 90, 0.14);
  --side: 232px;
  --tabbar: 64px;
}

body { min-height: 100dvh; }

button, input { font: inherit; color: inherit; }
.ic { display: inline-grid; place-items: center; flex: none; }
.ic svg, .btn svg { width: 18px; height: 18px; }
.num, .hero-num, .row-time, .hl-clock, output { font-variant-numeric: tabular-nums; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--raise); }
.btn:focus-visible, .nav-item:focus-visible, .seg button:focus-visible, .pill:focus-visible, .switch:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1206; }
.btn.primary:hover { background: #ffc04d; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { background: var(--danger-soft); border-color: rgba(255, 90, 90, 0.35); color: var(--danger); }
.btn.small { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.big { width: 100%; height: 54px; font-size: 16px; border-radius: 14px; }
.btn:disabled { opacity: 0.45; cursor: default; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

/* segmented control */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--input);
  border: 1px solid var(--line);
}
.seg button {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.seg button[aria-pressed='true'] { background: var(--raise); color: var(--text); }

/* ------------------------------------------------------------ login */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 360px; display: grid; gap: 12px; }
.login-brand { justify-content: center; font-size: 26px; margin-bottom: 28px; }
.login-brand svg { width: 32px; height: 32px; }
.login-msg { margin: 0 0 4px; text-align: center; color: var(--danger); font-size: 15px; }
.code-form { display: grid; gap: 12px; }
.code-form input {
  height: 58px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--input);
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.4em;
  padding-left: 0.4em;
}
.code-form input::placeholder { color: #3a3a46; }
.code-form input:focus { outline: none; border-color: var(--accent); }
.login-demo { margin-top: 16px; text-align: center; color: var(--muted); font-size: 14px; }
.login-demo:hover { color: var(--text); }

/* ------------------------------------------------------------ shell */

.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); align-content: start; min-height: 100dvh; }

.offline {
  grid-column: 1 / -1;
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  background: #3a1a1d;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 90, 90, 0.3);
}
.offline svg { width: 18px; height: 18px; }
body.is-offline .panels { opacity: 0.45; filter: grayscale(0.5); transition: opacity 0.3s; }

.side {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
}
body.is-offline .side { height: calc(100dvh - 40px); top: 40px; }
.side .brand { padding: 6px 10px; margin-bottom: 24px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
}
.nav-item .ic svg { width: 20px; height: 20px; }
.nav-item:hover { color: var(--text); background: #15151b; }
.nav-item[aria-current='page'] { color: var(--text); background: var(--surface); }
.nav-item[aria-current='page'] .ic { color: var(--accent); }
.side .account { margin-top: auto; }
.side .account-btn { width: 100%; justify-content: flex-start; color: var(--muted); border-color: transparent; }
.side .account-btn:hover { color: var(--text); }

.topbar, .tabbar { display: none; }

.panels { padding: 28px 32px 64px; max-width: 1180px; width: 100%; }
/* site.css gives every <section> landing-page spacing */
.panel { padding: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; min-height: 40px; }
.panel-head h1 { margin: 0; font-size: 24px; letter-spacing: -0.02em; font-weight: 800; }
.panel-actions { display: flex; gap: 8px; align-items: center; }
.panel-actions:empty { display: none; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }

/* ------------------------------------------------------------ 오늘 방송 */

.hero-stat { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; margin-bottom: 14px; }
.hero-label { color: var(--muted); font-weight: 600; font-size: 15px; }
.hero-num { font-size: 60px; line-height: 1.05; font-weight: 800; letter-spacing: -0.03em; color: var(--accent); }
.hero-meta { display: flex; gap: 14px; color: var(--muted); font-size: 15px; font-weight: 600; padding-bottom: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { display: inline-flex; gap: 6px; align-items: baseline; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.chip-label { color: var(--muted); }

.timeline .bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  border-bottom: 1px solid var(--line);
}
.bar { flex: 1 1 0; min-width: 2px; background: #3b3b48; border-radius: 2px 2px 0 0; }
.bar.hot { background: var(--accent); }
.axis { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.rank, .rows, .hl-list { list-style: none; margin: 0; padding: 0; }
.rank li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.rank li:first-child, .rows li:first-child, .hl-list li:first-child { border-top: 0; }
.rank-no { color: var(--muted); font-weight: 700; font-size: 14px; text-align: center; }
.rank li.podium .rank-no { color: var(--accent); }
.rank .num { font-weight: 700; }
.nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.link-ext { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none; }
.link-ext:hover { color: var(--text); }
.link-ext .ic svg { width: 15px; height: 15px; }

.hl { display: grid; grid-template-columns: max-content minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.hl-when { display: flex; flex-direction: column; line-height: 1.3; }
.hl-clock { font-size: 18px; font-weight: 800; }
.hl.best .hl-clock { color: var(--accent); }
.hl-offset { color: var(--muted); font-size: 12px; white-space: nowrap; }
.hl-what { min-width: 0; line-height: 1.35; }
.hl-amount { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.hl-who { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }

.row { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.row-ic { color: var(--muted); }
.row-ic svg { width: 18px; height: 18px; }
.row-who { display: flex; align-items: center; gap: 4px; min-width: 0; font-weight: 600; }
.row-who .arrow { color: var(--muted); }
.row-who .arrow svg { width: 14px; height: 14px; }
.row-what { white-space: nowrap; }
.row.big .row-what { color: var(--accent); font-weight: 700; }
.row-time { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------ 리포트 */

.report { display: grid; grid-template-columns: minmax(0, 480px) 220px; gap: 24px; align-items: start; }
.report-canvas { display: block; width: 100%; height: auto; aspect-ratio: 1080 / 1350; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); }
.report-actions { display: grid; gap: 10px; }

/* ------------------------------------------------------------ 위젯 */

.widgets { display: grid; gap: 16px; }
.wcard { padding: 20px; }
.wcard-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(60% 80% at 20% 30%, #3b4a7a 0%, transparent 60%),
    radial-gradient(50% 70% at 85% 75%, #8a4f5f 0%, transparent 60%),
    linear-gradient(135deg, #1c2238, #2a1f33);
}
.stage iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1280px;
  height: 720px;
  border: 0;
  transform-origin: 0 0;
  pointer-events: none;
  /* must match the widget document, or Chrome paints the iframe opaque */
  color-scheme: normal;
}
.stage-missing { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; color: rgba(241, 241, 245, 0.7); font-size: 14px; }

.fields { display: grid; gap: 12px; align-content: start; }
.field { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; align-items: center; min-height: 38px; }
.field-label { color: var(--muted); font-size: 14px; font-weight: 600; }
.field-items, .field-end { grid-template-columns: minmax(0, 1fr); }
.field-end { justify-items: start; }

.fields input[type='text'], .fields input[type='number'] {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--input);
  font-size: 15px;
}
.fields input:focus { outline: none; border-color: var(--accent); }
.input-unit { display: flex; align-items: center; gap: 8px; }
.input-unit input { max-width: 130px; }
.unit { color: var(--muted); font-size: 14px; }

.color { display: flex; align-items: center; gap: 10px; }
.color input { width: 38px; height: 38px; padding: 3px; border-radius: 10px; border: 1px solid var(--line); background: var(--input); cursor: pointer; }
.color input::-webkit-color-swatch-wrapper { padding: 0; }
.color input::-webkit-color-swatch { border: 0; border-radius: 7px; }
.color input::-moz-color-swatch { border: 0; border-radius: 7px; }
.hex { color: var(--muted); font-size: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.range { display: flex; align-items: center; gap: 12px; }
.range input { flex: 1; min-width: 0; accent-color: var(--accent); }
.range output { width: 48px; text-align: right; color: var(--muted); font-size: 14px; }

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  border: 0;
  background: #33333f;
  cursor: pointer;
  transition: background 0.15s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch[aria-checked='true'] { background: var(--accent); }
.switch[aria-checked='true']::after { transform: translateX(18px); }

.kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.pill[aria-pressed='true'] { background: var(--accent-soft); color: var(--accent); border-color: rgba(255, 176, 32, 0.45); }

.items { display: grid; gap: 6px; }
.item-head, .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px 38px; gap: 8px; align-items: center; }
.item-head { color: var(--muted); font-size: 13px; font-weight: 600; }
.items .btn { justify-self: start; margin-top: 2px; }

.wcard-foot { display: flex; gap: 10px; align-items: center; margin-top: 18px; }
.addr {
  flex: 1;
  min-width: 0;
  height: 40px;
  line-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--muted);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------ dialog, toast */

.dialog { border: 0; padding: 0; background: transparent; color: var(--text); max-width: none; }
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-box { width: min(400px, calc(100vw - 32px)); padding: 24px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.dialog-box h2 { margin: 0 0 8px; font-size: 18px; letter-spacing: -0.01em; }
.dialog-box p { margin: 0 0 22px; color: var(--muted); font-size: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  transform: translate(-50%, 8px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--raise);
  border: 1px solid #33333f;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------ mid widths */

@media (max-width: 900px) {
  .wcard-body { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------ phone */

@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 8px 0 16px;
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(14, 14, 18, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
  }
  body.is-offline .topbar { top: 40px; }
  .topbar .account-label { display: none; }
  .topbar .account-btn { width: 44px; height: 44px; padding: 0; border-color: transparent; color: var(--muted); }
  .topbar .account-btn svg { width: 20px; height: 20px; }

  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(14, 14, 18, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  .tabbar .nav-item {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    height: var(--tabbar);
    padding: 0 2px;
    border-radius: 0;
    font-size: 11px;
    background: transparent;
  }
  .tabbar .nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar .nav-item[aria-current='page'] { color: var(--accent); background: transparent; }

  .panels { padding: 18px 16px calc(var(--tabbar) + 32px + env(safe-area-inset-bottom)); }
  .panel-head { margin-bottom: 16px; }
  .panel-head h1 { font-size: 21px; }
  .hero-num { font-size: 46px; }
  .card { padding: 16px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 12px; }
  .hl { gap: 10px; }
  .hl .btn span:last-child { display: none; }
  .hl .btn { width: 38px; padding: 0; }

  .report { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .report-actions { grid-template-columns: 1fr 1fr; }

  .wcard { padding: 16px; }
  .field { grid-template-columns: 72px minmax(0, 1fr); gap: 10px; }
  .toast { bottom: calc(var(--tabbar) + 20px + env(safe-area-inset-bottom)); }
}
