:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d7dce5;
  --accent: #0b7f8c;
  --accent-strong: #075f68;
  --danger: #b42318;
  --warning: #b54708;
  --ok: #067647;
  --shadow: 0 18px 60px rgba(18, 28, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(11, 127, 140, 0.14), rgba(255, 255, 255, 0) 45%),
    #f7f8fb;
}

.login-shell {
  width: min(100%, 430px);
}

.login-panel,
.settings-panel,
.obs-link-band {
  background: var(--panel);
  border: 1px solid rgba(215, 220, 229, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  padding: 34px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 22px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 26px;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.login-copy,
.hint,
.form-message {
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.form-message {
  min-height: 24px;
  margin: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px min(5vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.signed-user {
  color: var(--muted);
  font-size: 14px;
}

.studio-layout {
  display: grid;
  gap: 22px;
  padding: 24px min(5vw, 48px) 42px;
}

.obs-link-band {
  display: grid;
  gap: 16px;
  padding: 22px;
  border-color: rgba(11, 127, 140, 0.35);
  background: linear-gradient(180deg, #ffffff, #eefafb);
}

.obs-link-band h2 {
  font-size: clamp(24px, 3vw, 34px);
}

.obs-url-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

#obs-url {
  min-height: 58px;
  border: 2px solid var(--accent);
  font-size: 18px;
  font-weight: 800;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 390px);
  gap: 22px;
  align-items: start;
}

.preview-area {
  display: grid;
  gap: 14px;
}

.preview-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-height: 260px;
  border-radius: 8px;
  background: #111827;
  box-shadow: var(--shadow);
}

.preview-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111827;
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  color: #d8dee9;
  text-align: center;
  padding: 24px;
}

.preview-placeholder strong {
  color: #fff;
  font-size: 22px;
}

.preview-status {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: #fff;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-weight: 800;
}

.status-pill.live {
  background: var(--ok);
}

.status-pill.waiting {
  background: rgba(255, 255, 255, 0.18);
}

.status-pill.warn {
  background: var(--warning);
}

.control-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  padding: 0 16px;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.danger-button {
  background: #fff1f0;
  color: var(--danger);
  border: 1px solid #fecdca;
}

.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.full {
  width: 100%;
}

.panel-stack {
  display: grid;
  gap: 16px;
}

.settings-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  box-shadow: none;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 96px auto;
  align-items: center;
  gap: 10px;
}

.range-row input[type="range"] {
  padding: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.stats-grid div {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.stats-grid dt {
  color: var(--muted);
  font-size: 13px;
}

.stats-grid dd {
  margin: 6px 0 0;
  font-size: 18px;
  font-weight: 800;
}

.engine-frame {
  position: fixed;
  left: -20px;
  bottom: -20px;
  width: 10px;
  height: 10px;
  border: 0;
  opacity: 0.01;
  pointer-events: none;
}

.obs-page {
  margin: 0;
  overflow: hidden;
  background: #000;
}

.obs-page iframe {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  border: 0;
  background: #000;
}

.obs-fallback {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: #d0d5dd;
  background: #000;
  z-index: 0;
}

@media (max-width: 920px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .obs-url-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar,
  .top-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .studio-layout {
    padding: 16px;
  }

  .login-panel {
    padding: 24px;
  }

  .range-row {
    grid-template-columns: 1fr;
  }

  .control-strip > button {
    flex: 1 1 150px;
  }
}
