:root {
  --bg: #0b0f17;
  --panel: #121824;
  --panel-2: #171f2e;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f7fb;
  --muted: #8f9bad;
  --accent: #4f8cff;
  --accent-hover: #6a9dff;
  --success: #3ddc97;
  --danger: #ff6b78;
  --warning: #ffbf5b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(79, 140, 255, 0.14), transparent 34%),
    radial-gradient(circle at 92% 4%, rgba(61, 220, 151, 0.08), transparent 28%),
    var(--bg);
  color: var(--text);
}

button, input { font: inherit; }
button { cursor: pointer; }

.page-shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow, .section-label {
  color: #71809a;
  font-size: 11px;
  letter-spacing: 0.16em;
  font-weight: 700;
  margin: 0 0 8px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.04em; }
h2 { margin: 4px 0 0; font-size: 22px; letter-spacing: -0.02em; }

.topbar-actions, .live-main-row, .input-row, .list-heading, .list-tools, .card-title-row, .card-actions {
  display: flex;
  align-items: center;
}

.topbar-actions { gap: 12px; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 24, 36, 0.78);
  color: #cbd4e1;
  font-size: 13px;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 5px rgba(255, 191, 91, 0.1);
}

.live-pill.live .pulse { background: var(--success); box-shadow: 0 0 0 5px rgba(61, 220, 151, 0.1); }
.live-pill.error .pulse { background: var(--danger); box-shadow: 0 0 0 5px rgba(255, 107, 120, 0.1); }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 18px;
  margin-bottom: 36px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(23, 31, 46, 0.95), rgba(16, 22, 33, 0.96));
  box-shadow: var(--shadow);
}

.live-overview { padding: 25px; }
.add-panel { padding: 25px; }

.live-main-row { justify-content: space-between; gap: 20px; }
.live-title { font-size: 25px; font-weight: 750; letter-spacing: -0.025em; }
.live-meta { color: var(--muted); margin-top: 7px; font-size: 13px; }

.ticker-form {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 24px;
}

.metric {
  padding: 15px;
  border-radius: 13px;
  background: rgba(8, 12, 19, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.055);
}

.metric span, .detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 7px;
}

.metric strong { font-size: 14px; font-weight: 650; }

label { display: block; font-size: 13px; margin-bottom: 10px; color: #d9e0ea; }
.input-row { gap: 10px; }
input {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(7, 11, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus { border-color: rgba(79, 140, 255, .7); box-shadow: 0 0 0 4px rgba(79, 140, 255, .1); }
input::placeholder { color: #596477; }
.helper { margin: 12px 0 0; color: var(--muted); font-size: 12px; }

.button, .icon-button, .menu-button {
  border: 0;
  border-radius: 10px;
  color: var(--text);
  transition: transform .15s, background .15s, opacity .15s;
}
.button:active, .icon-button:active { transform: translateY(1px); }
.button:disabled { opacity: .42; cursor: not-allowed; }
.button { min-height: 42px; padding: 0 15px; font-size: 13px; font-weight: 680; white-space: nowrap; }
.button.primary { background: var(--accent); box-shadow: 0 8px 22px rgba(79, 140, 255, 0.2); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.secondary { background: rgba(255,255,255,.09); border: 1px solid var(--line); }
.button.ghost { background: rgba(255,255,255,.05); border: 1px solid var(--line); }
.button.full { width: 100%; margin-top: 12px; }

.list-heading { justify-content: space-between; margin-bottom: 16px; }
.list-tools { gap: 10px; }
.sync-text { color: var(--muted); font-size: 12px; }
.icon-button {
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line);
  font-size: 20px;
}

.stream-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.stream-card {
  overflow: hidden;
  border-radius: 17px;
  border: 1px solid var(--line);
  background: rgba(18, 24, 36, 0.9);
  box-shadow: 0 14px 34px rgba(0,0,0,.18);
  transition: transform .2s, border-color .2s;
}
.stream-card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.14); }
.stream-card.is-current { border-color: rgba(79, 140, 255, .58); box-shadow: 0 16px 40px rgba(42, 98, 208, .15); }

.preview-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #090d14;
}
.preview-wrap.can-switch { cursor: pointer; }
.preview-wrap.can-switch:focus-visible { outline: 3px solid rgba(79, 140, 255, .8); outline-offset: -3px; }
.preview-wrap.can-switch::after {
  content: "点击切换";
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(9, 13, 20, .72);
  color: #fff;
  font-size: 11px;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity .15s, transform .15s;
  pointer-events: none;
}
.preview-wrap.can-switch:hover::after,
.preview-wrap.can-switch:focus-visible::after { opacity: 1; transform: translateY(0); }
.preview-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-shade { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.34), transparent 36%, rgba(0,0,0,.16)); pointer-events: none; }
.preview-topline { position: absolute; inset: 12px 12px auto; display: flex; align-items: center; justify-content: space-between; }
.status-badge, .current-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  backdrop-filter: blur(12px);
  font-size: 11px;
  font-weight: 720;
}
.status-badge.online { color: #bff8df; background: rgba(22, 97, 67, .68); border: 1px solid rgba(61,220,151,.34); }
.status-badge.offline { color: #ffd0d4; background: rgba(112, 29, 40, .68); border: 1px solid rgba(255,107,120,.3); }
.status-badge.checking { color: #ffe5b7; background: rgba(104, 72, 21, .68); border: 1px solid rgba(255,191,91,.3); }
.status-badge.disabled { color: #c5cedb; background: rgba(60, 69, 82, .74); border: 1px solid rgba(255,255,255,.12); }
.current-badge { color: white; background: rgba(46, 102, 219, .78); border: 1px solid rgba(140,180,255,.34); }

.offline-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: rgba(7, 10, 16, .58);
  backdrop-filter: grayscale(1);
}
.offline-overlay span { font-size: 18px; font-weight: 760; }
.offline-overlay small { color: #c5cedb; margin-top: 4px; }

.card-body { padding: 17px; }
.card-title-row { justify-content: space-between; align-items: flex-start; gap: 10px; }
.stream-name { font-size: 17px; font-weight: 740; }
.stream-number { color: var(--muted); font-size: 11px; margin-top: 5px; }
.menu-button { width: 30px; height: 30px; background: rgba(255,255,255,.04); color: #8c98aa; font-size: 20px; }
.menu-button:hover { color: var(--danger); background: rgba(255,107,120,.1); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 17px 0; }
.detail-grid strong { font-size: 12px; font-weight: 600; color: #dce3ed; }
.error-line { color: #ff9da6; background: rgba(255,107,120,.08); border: 1px solid rgba(255,107,120,.12); border-radius: 8px; padding: 8px 10px; font-size: 11px; margin: -4px 0 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { gap: 9px; }
.card-actions .button { flex: 1; }

.empty-state { text-align: center; padding: 60px 20px; border: 1px dashed rgba(255,255,255,.12); border-radius: 18px; color: var(--muted); }
.empty-state h3 { color: var(--text); margin-bottom: 8px; }
.empty-state p { margin: 0; }
.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 14px; background: rgba(79,140,255,.1); color: #8db2ff; font-size: 26px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 7, 11, .82);
  backdrop-filter: blur(18px);
}
.modal-card {
  width: min(410px, 100%);
  padding: 28px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.1);
  background: #121824;
  box-shadow: 0 32px 80px rgba(0,0,0,.46);
}
.modal-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; margin-bottom: 20px; background: var(--accent); font-weight: 800; }
.modal-card h2 { font-size: 24px; }
.modal-card p { color: var(--muted); font-size: 13px; }
.form-error { color: var(--danger); font-size: 12px; min-height: 18px; margin-top: 10px; }

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 10px; }
.toast { min-width: 260px; max-width: 380px; padding: 13px 15px; border-radius: 11px; background: #1b2433; border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 13px; animation: toast-in .2s ease; }
.toast.error { border-color: rgba(255,107,120,.35); }
.toast.success { border-color: rgba(61,220,151,.3); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.hidden { display: none !important; }

@media (max-width: 1000px) {
  .hero-grid { grid-template-columns: 1fr; }
  .stream-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .page-shell { width: min(100% - 24px, 1440px); padding-top: 22px; }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-direction: column; align-items: flex-end; }
  .hero-grid { margin-bottom: 28px; }
  .live-main-row, .input-row { align-items: stretch; flex-direction: column; }
  .metric-row { grid-template-columns: 1fr; }
  .stream-grid { grid-template-columns: 1fr; }
  .live-overview, .add-panel { padding: 19px; }
  .button { min-height: 44px; }
}
