:root {
  color-scheme: light;
  --ink: #17263a;
  --muted: #6d7a89;
  --line: #dfe5eb;
  --soft: #f3f6f8;
  --panel: #ffffff;
  --nav: #102438;
  --nav-soft: #183149;
  --cyan: #21a8d8;
  --coral: #f07f61;
  --good: #29a36a;
  --warning: #e3a62f;
  --bad: #cf4f55;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: #edf1f4; }
button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px 20px; color: #eef6fb; background: var(--nav); display: flex; flex-direction: column; }
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; padding: 0 8px 28px; border-bottom: 1px solid rgba(255,255,255,.11); }
.brand img { width: 88px; height: auto; }
.brand span { display: grid; gap: 2px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.18); }
.brand strong { font-size: 14px; }
.brand small { color: #91a8ba; font-size: 10px; }
.sidebar nav { display: grid; gap: 6px; margin-top: 28px; }
.nav-item { display: flex; gap: 12px; align-items: center; min-height: 42px; padding: 0 12px; color: #aebdca; border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 600; }
.nav-item:hover, .nav-item.is-active { color: white; background: var(--nav-soft); }
.nav-icon { width: 20px; color: #75c8e5; text-align: center; }
.sidebar-foot { margin-top: auto; display: grid; gap: 16px; }
.connection-mini { display: flex; gap: 10px; align-items: center; padding: 14px 12px; border: 1px solid rgba(255,255,255,.1); border-radius: 10px; }
.connection-mini span:last-child { display: grid; gap: 2px; }
.connection-mini strong { font-size: 12px; }
.connection-mini small { color: #8ea5b8; font-size: 10px; }
.status-dot, .status-light { display: inline-block; flex: 0 0 auto; border-radius: 50%; background: #82909c; }
.status-dot { width: 8px; height: 8px; }
.status-light { width: 10px; height: 10px; box-shadow: 0 0 0 4px rgba(130,144,156,.12); }
.is-good, .status-light.is-good { background: var(--good); box-shadow: 0 0 0 4px rgba(41,163,106,.13); }
.is-warning, .status-light.is-warning { background: var(--warning); box-shadow: 0 0 0 4px rgba(227,166,47,.13); }
.is-bad, .status-light.is-bad { background: var(--bad); box-shadow: 0 0 0 4px rgba(207,79,85,.13); }
.is-neutral, .status-light.is-neutral { background: #82909c; }
.quiet-button { min-height: 38px; border: 0; border-radius: 7px; color: #9eb0bf; background: transparent; cursor: pointer; text-align: left; padding: 0 12px; }
.quiet-button:hover { color: white; background: rgba(255,255,255,.06); }

.workspace { min-width: 0; padding: 30px clamp(22px, 3vw, 48px) 64px; }
.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 24px; }
.eyebrow { margin: 0 0 6px; color: #718092; font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 19px; letter-spacing: -.02em; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.save-state { color: #778391; font-size: 12px; margin-right: 4px; }
.save-state.has-changes { color: #a56614; }
.primary-button, .secondary-button { min-height: 40px; border-radius: 7px; padding: 0 16px; border: 1px solid transparent; font-size: 13px; font-weight: 750; cursor: pointer; }
.primary-button { color: white; background: var(--nav); }
.primary-button:hover:not(:disabled) { background: #193851; }
.secondary-button { color: #33475a; border-color: #cbd4dc; background: white; }
.secondary-button:hover:not(:disabled) { border-color: #91a2b1; }
button:disabled { opacity: .45; cursor: not-allowed; }

.status-strip { display: grid; grid-template-columns: 150px 170px 175px minmax(240px,1fr) 170px; min-height: 72px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); overflow: hidden; }
.status-item { display: flex; gap: 10px; align-items: center; padding: 14px 18px; border-right: 1px solid var(--line); }
.status-item:last-child { border-right: 0; }
.status-item span:last-child { min-width: 0; display: grid; gap: 3px; }
.status-item small { color: #7a8693; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.status-item strong { overflow: hidden; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.status-item-right { justify-content: flex-end; text-align: right; }

.studio-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.preview-panel { min-width: 0; padding: 24px; }
.settings-panel { padding: 24px; border-left: 1px solid var(--line); background: #fafbfc; }
.section-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 18px; }
.section-heading.compact { margin-bottom: 22px; }
.section-note { max-width: 430px; margin-bottom: 2px; color: var(--muted); font-size: 12px; }
.segmented { display: flex; padding: 3px; border: 1px solid #d7dee4; border-radius: 8px; background: var(--soft); }
.segmented button { min-height: 30px; padding: 0 11px; border: 0; border-radius: 5px; color: #6b7885; background: transparent; font-size: 11px; font-weight: 700; cursor: pointer; }
.segmented button.is-active { color: var(--ink); background: white; box-shadow: 0 1px 3px rgba(25,42,57,.12); }
.video-stage { position: relative; aspect-ratio: 16/9; overflow: hidden; border-radius: 8px; background: #0b111a; box-shadow: 0 10px 28px rgba(22,37,51,.16); }
.video-stage iframe { width: 100%; height: 100%; border: 0; display: block; }
.preview-foot { display: flex; justify-content: space-between; gap: 20px; margin-top: 14px; color: #7c8793; font-size: 11px; }
.preview-foot p { margin-bottom: 0; }
.preview-foot strong { color: #4f5d6a; }
.preview-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #e3a62f; }

.broadcast-switch { position: relative; display: grid; grid-template-columns: 1fr 42px; gap: 16px; align-items: center; cursor: pointer; }
.broadcast-switch > span:first-child, .check-row > span { display: grid; gap: 3px; }
.broadcast-switch strong, .check-row strong { font-size: 13px; }
.broadcast-switch small, .check-row small { color: #7b8792; font-size: 11px; line-height: 1.4; }
.broadcast-switch input { position: absolute; opacity: 0; }
.switch-track { width: 42px; height: 24px; padding: 3px; border-radius: 20px; background: #b8c2cb; transition: background .18s; }
.switch-track::after { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.broadcast-switch input:checked + .switch-track { background: var(--good); }
.broadcast-switch input:checked + .switch-track::after { transform: translateX(18px); }
.settings-divider { height: 1px; margin: 22px 0; background: var(--line); }
.field-stack { display: grid; gap: 7px; margin-bottom: 15px; }
.field-stack label { color: #566473; font-size: 11px; font-weight: 750; }
.field-stack input { width: 100%; min-height: 38px; padding: 0 11px; border: 1px solid #cfd8df; border-radius: 6px; color: var(--ink); background: white; font-size: 12px; outline: none; }
.field-stack input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(33,168,216,.13); }
.check-row { display: grid; grid-template-columns: 17px 1fr; gap: 10px; align-items: start; margin-bottom: 15px; cursor: pointer; }
.check-row input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--nav); }
.security-note { display: flex; gap: 10px; margin-top: 24px; padding: 13px; border-radius: 8px; color: #506273; background: #edf3f6; }
.security-note > span { color: var(--cyan); font-size: 9px; margin-top: 3px; }
.security-note p { margin-bottom: 0; font-size: 10px; line-height: 1.45; }

.visual-library { margin-top: 20px; padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.theme-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.theme-card { min-width: 0; padding: 0; overflow: hidden; border: 1px solid #d9e0e6; border-radius: 9px; background: white; cursor: pointer; text-align: left; transition: transform .16s, border-color .16s, box-shadow .16s; }
.theme-card:hover { transform: translateY(-2px); border-color: #aebdca; box-shadow: 0 7px 20px rgba(31,51,68,.09); }
.theme-card.is-selected { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(33,168,216,.16); }
.theme-preview { position: relative; display: block; aspect-ratio: 16/9; overflow: hidden; background: #dfe7ec; pointer-events: none; }
.theme-preview iframe { position: absolute; width: 1280px; height: 720px; border: 0; transform: scale(var(--thumbnail-scale, .2)); transform-origin: 0 0; }
.theme-meta { display: flex; gap: 12px; justify-content: space-between; align-items: center; padding: 13px; }
.theme-meta > span:first-child { min-width: 0; display: grid; gap: 3px; }
.theme-meta strong { font-size: 12px; }
.theme-meta small { overflow: hidden; color: #7b8793; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.selection-mark { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid #cdd6dd; border-radius: 50%; color: transparent; font-size: 11px; }
.theme-card.is-selected .selection-mark { color: white; border-color: var(--cyan); background: var(--cyan); }

.toast-region { position: fixed; right: 24px; bottom: 24px; z-index: 10; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: 380px; padding: 13px 16px; border-radius: 8px; color: white; background: var(--nav); box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: 12px; font-weight: 650; }
.toast.is-bad { background: #9d343c; }

.login-page { min-height: 100vh; background: #e9eef2; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, .9fr) minmax(480px, 1.1fr); }
.login-brand { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: clamp(50px, 8vw, 110px); color: white; background: #102438; }
.login-brand::after { content: ""; position: absolute; width: 520px; height: 520px; right: -240px; bottom: -260px; border: 82px solid rgba(33,168,216,.16); border-radius: 50%; }
.login-brand img { width: 135px; margin-bottom: 54px; }
.login-brand .eyebrow { color: #7ecae5; }
.login-brand h1 { max-width: 520px; margin-bottom: 18px; font-size: clamp(42px, 5vw, 72px); line-height: .98; letter-spacing: -.06em; }
.login-brand > p:not(.eyebrow) { max-width: 500px; color: #b7c6d2; line-height: 1.6; }
.login-signal { display: flex; align-items: center; gap: 5px; height: 44px; margin-top: 55px; }
.login-signal i { width: 4px; height: 16px; border-radius: 3px; background: #5ac5e9; }
.login-signal i:nth-child(3n) { height: 38px; }.login-signal i:nth-child(4n) { height: 26px; }.login-signal i:nth-child(5n) { height: 32px; }
.login-form-wrap { display: grid; place-items: center; padding: 48px; }
.login-form { width: min(400px, 100%); padding: 36px; border: 1px solid #d7dfe5; border-radius: 12px; background: white; box-shadow: 0 20px 50px rgba(32,51,68,.08); }
.login-form h2 { margin-bottom: 10px; font-size: 24px; }
.login-intro { margin-bottom: 28px; color: var(--muted); font-size: 13px; }
.login-form label { display: grid; gap: 8px; margin-bottom: 17px; color: #4f5d6b; font-size: 12px; font-weight: 700; }
.login-form input { min-height: 44px; padding: 0 12px; border: 1px solid #cbd5dc; border-radius: 7px; outline: none; }
.login-form input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(33,168,216,.13); }
.login-submit { width: 100%; min-height: 44px; margin-top: 4px; }
.form-error { min-height: 18px; margin-bottom: 7px; color: var(--bad); font-size: 11px; }
.login-security { margin: 20px 0 0; color: #87929d; font-size: 10px; text-align: center; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 210px minmax(0,1fr); }
  .status-strip { grid-template-columns: repeat(3, 1fr); }
  .status-item-wide, .status-item-right { display: none; }
  .studio-grid { grid-template-columns: 1fr; }
  .settings-panel { border-top: 1px solid var(--line); border-left: 0; }
  .theme-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; padding: 16px; flex-direction: row; align-items: center; gap: 16px; }
  .brand { padding: 0 16px 0 0; border: 0; }
  .brand img { width: 70px; }.brand span { display: none; }
  .sidebar nav { margin: 0; display: flex; }.nav-item { padding: 0 9px; }.nav-item:nth-child(n+2), .sidebar-foot { display: none; }
  .workspace { padding: 22px 14px 48px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; flex-wrap: wrap; }.save-state { width: 100%; }
  .status-strip { grid-template-columns: 1fr; }.status-item { border-right: 0; border-bottom: 1px solid var(--line); }.status-item:last-child { border-bottom: 0; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .segmented { max-width: 100%; }.segmented button { padding: 0 7px; }
  .preview-panel, .settings-panel, .visual-library { padding: 16px; }
  .preview-foot { display: none; }
  .theme-grid { grid-template-columns: 1fr; }
  .login-shell { display: block; }.login-brand { min-height: 44vh; padding: 40px 28px; }.login-brand img { margin-bottom: 34px; }.login-brand h1 { font-size: 43px; }.login-signal { display: none; }.login-form-wrap { padding: 28px 16px; }.login-form { padding: 26px; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
