:root {
  color-scheme: light;

  --bg: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-preview: #0f172a;
  --bg-header: #ffffff;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: rgba(37, 99, 235, 0.45);

  --text: #1e293b;
  --text-dim: #475569;
  --text-muted: #94a3b8;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --accent-text: #1e40af;

  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
  --red-glow: rgba(220, 38, 38, 0.22);

  --green: #16a34a;
  --green-bg: #f0fdf4;
  --green-border: #bbf7d0;
  --green-glow: rgba(22, 163, 74, 0.22);

  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.09), 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.05);

  --r: 8px;
  --r-lg: 12px;
}

* { box-sizing: border-box; }

html {
  font-size: 13px;
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Be Vietnam Pro", "Segoe UI", Arial, sans-serif;
}

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

/* ── App Layout ─────────────────────────────────────────────── */

#app {
  display: grid;
  grid-template-columns: 1fr 344px;
  grid-template-rows: 56px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

#preview-area {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

/* ── Top Bar ────────────────────────────────────────────────── */

.top-bar {
  grid-column: 1 / -1;
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 5;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(250px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 56px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-copy {
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  object-fit: cover;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-subtitle {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-top: 1px;
}

.brand-credit {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.63rem;
  line-height: 1.15;
  margin-top: 1px;
  max-width: 270px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-credit a {
  color: inherit;
  text-decoration: none;
}

.brand-credit a:hover {
  color: var(--accent);
}

.top-bar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.top-bar-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
  max-width: 560px;
  min-width: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.79rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-live {
  border-color: var(--red-border);
  background: var(--red-bg);
  color: var(--red);
}
.status-live .status-dot {
  background: var(--red);
  animation: blink 1.6s infinite;
}

.status-error {
  border-color: var(--amber-border);
  background: var(--amber-bg);
  color: var(--amber);
}
.status-error .status-dot {
  background: var(--amber);
}

.stream-timer {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.82rem;
}

.stream-timer.active {
  border-color: var(--red-border);
  background: var(--red-bg);
  color: var(--red);
}

.stat-item {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.stat-item.active {
  border-color: var(--green-border);
  background: var(--green-bg);
  color: var(--green);
}

.live-link-box {
  flex: 1 1 250px;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 280px;
  padding: 5px 9px;
  border: 1px solid var(--red-border);
  border-radius: 999px;
  background: var(--red-bg);
}

.live-link-label {
  color: var(--red);
  font-size: 0.68rem;
  font-weight: 800;
  flex-shrink: 0;
  letter-spacing: 0.05em;
}

.live-link-url {
  overflow: hidden;
  color: var(--accent);
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
  font-size: 0.77rem;
}

/* ── Preview Stage ──────────────────────────────────────────── */

.preview-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  flex: 1;
  min-height: 0;
  padding: 16px;
}

.preview-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-preview);
  box-shadow: var(--shadow-md);
  isolation: isolate;
}

.preview-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 64px 64px;
  z-index: -2;
}

.signal-grid {
  position: absolute;
  inset: 14%;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.12), transparent 68%);
  filter: blur(22px);
  z-index: -1;
}

.preview-image {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #020206;
}

.local-preview-video {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #020206;
}

.local-preview-logo {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 24px;
  width: 120px;
  height: auto;
  pointer-events: none;
}

.local-preview-patient {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 14px;
  max-width: calc(100% - 44px);
  transform: translateX(-50%);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.52);
  color: white;
  padding: 4px 10px;
  font-size: 1.62rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.preview-frame.has-preview .preview-content,
.preview-frame.has-local-preview .preview-content,
.preview-frame.has-preview .signal-grid,
.preview-frame.has-local-preview .signal-grid {
  opacity: 0;
  pointer-events: none;
}

.preview-badge {
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 2;
  border-radius: 999px;
  padding: 4px 9px;
  border: 1px solid rgba(22, 163, 74, 0.28);
  background: rgba(22, 163, 74, 0.12);
  color: #86efac;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.preview-badge.is-live {
  border-color: rgba(220, 38, 38, 0.36);
  background: rgba(220, 38, 38, 0.16);
  color: #fca5a5;
}

.preview-content {
  width: min(600px, calc(100% - 48px));
  text-align: center;
}

.preview-kicker {
  margin: 0 0 10px;
  color: #4ade80;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.preview-content h1 {
  margin: 0;
  color: #f1f5f9;
  font-size: clamp(2rem, 4.5vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.preview-content p {
  max-width: 500px;
  margin: 14px auto 0;
  color: #64748b;
  line-height: 1.65;
}

.preview-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
}

.preview-metrics div {
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255,255,255,0.04);
}

.preview-metrics span,
.stats-grid span {
  display: block;
  margin-bottom: 4px;
  color: #475569;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.preview-metrics strong {
  display: block;
  overflow: hidden;
  color: #cbd5e1;
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Log Dock ───────────────────────────────────────────────── */

.log-dock {
  min-height: 112px;
  max-height: 170px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 7px 12px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

pre {
  height: 120px;
  margin: 0;
  overflow: auto;
  padding: 10px 12px;
  color: #64748b;
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ── Sidebar ────────────────────────────────────────────────── */

#sidebar {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--bg-sidebar);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  margin: 0 0 2px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.section-title-row .section-title { margin: 0; }

.key-corner-btn {
  min-width: 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  font-size: 0.85rem;
  line-height: 1;
}

.key-corner-btn.active {
  border-color: var(--amber-border);
  background: var(--amber-bg);
  color: var(--amber);
}

/* Source row */
.source-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 9px;
  align-items: center;
  gap: 8px;
}

.source-name {
  overflow: hidden;
  color: var(--text-dim);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-select,
.field-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r);
  outline: none;
  background: var(--bg-input);
  color: var(--text);
  padding: 7px 10px;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.source-select:hover,
.field-input:hover {
  border-color: var(--border-strong);
}

.source-select:focus,
.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.field-input::placeholder { color: var(--text-muted); }

.source-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}

.source-indicator.active {
  background: var(--green);
  box-shadow: 0 0 7px rgba(22, 163, 74, 0.55);
}

/* Audio meter */
.audio-level-wrap {
  overflow: hidden;
  height: 6px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.audio-level-fill {
  width: 18%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green) 0%, #eab308 70%, var(--red) 100%);
  transition: width 0.1s linear;
}

.hint-text,
.oauth-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

/* Fields */
.field-group {
  display: grid;
  gap: 5px;
}

.field-label {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.field-textarea {
  min-height: 70px;
  resize: vertical;
}

/* Auth panel */
.auth-panel { display: grid; gap: 8px; }

.top-auth-panel {
  flex: 0 1 270px;
  min-width: 220px;
}

.manual-key-panel {
  margin-top: 0;
}

.key-input-wrapper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

/* Buttons */
.btn-icon {
  min-width: 34px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text-dim);
  padding: 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.btn-icon:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--bg-sidebar);
}

.btn-sm-icon {
  min-width: 28px;
  height: 28px;
  padding: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--r);
  padding: 9px 14px;
  font-weight: 700;
  font-size: 0.83rem;
  transition: filter 0.12s, box-shadow 0.12s, background 0.12s;
}

.btn-block { width: 100%; }

.btn-ghost {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.btn-google {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: #374151;
  box-shadow: var(--shadow-xs);
}

.btn-google:hover {
  background: #f9fafb;
  box-shadow: var(--shadow-sm);
}

/* OAuth user area */
.oauth-user-area {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  height: 40px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 5px 4px 6px;
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
}

.oauth-user-details {
  min-width: 0;
}

.oauth-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--border);
}

.oauth-name,
.oauth-email {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.oauth-name {
  font-weight: 700;
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.2;
}

.oauth-email {
  color: var(--text-dim);
  font-size: 0.68rem;
  line-height: 1.2;
}

/* Quality grids */
.quality-grid,
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.bitrate-slider {
  width: 100%;
  accent-color: var(--accent);
}

.bitrate-labels {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.resolution-info {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.res-badge {
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--accent-light);
  border: 1px solid rgba(37, 99, 235, 0.14);
  color: var(--accent-text);
  font-size: 0.69rem;
  font-weight: 700;
}

.res-badge[data-latency="normal"] {
  background: var(--accent-light);
  border-color: rgba(37, 99, 235, 0.14);
  color: var(--accent-text);
}

.res-badge[data-latency="low"] {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: var(--green);
}

.res-badge[data-latency="ultraLow"] {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber);
}

/* Stats grid cells */
.stats-grid div {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 9px 10px;
  background: var(--bg);
}

.stats-grid strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 0.89rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

/* Message */
.message {
  border: 1px solid var(--red-border);
  border-radius: var(--r);
  padding: 10px 12px;
  background: var(--red-bg);
  color: var(--red);
  font-size: 0.79rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message.info {
  border-color: rgba(37, 99, 235, 0.2);
  background: var(--accent-light);
  color: var(--accent-text);
}

.message.success {
  border-color: var(--green-border);
  background: var(--green-bg);
  color: var(--green);
}

/* Sidebar footer */
.sidebar-footer {
  position: sticky;
  bottom: 0;
  display: grid;
  gap: 8px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 12px 16px 14px;
  background: var(--bg-sidebar);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
}

.btn-stream,
.btn-live {
  min-height: 42px;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--green-glow);
  font-size: 0.87rem;
  letter-spacing: 0.02em;
}

.btn-stream:not(:disabled):hover,
.btn-live:not(:disabled):hover {
  filter: brightness(1.07);
  box-shadow: 0 4px 14px var(--green-glow);
}

.btn-stop {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--red-glow);
}

.btn-stop:not(:disabled):hover {
  filter: brightness(1.07);
  box-shadow: 0 4px 14px var(--red-glow);
}

/* Modals */
.modal-overlay {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
}

.modal-card {
  width: min(440px, 100%);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.04);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
}

.modal-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.modal-footer {
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.modal-title {
  margin: 0;
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--text);
}

.modal-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.modal-close-btn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text-muted);
}

.modal-close-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-strong);
}

/* Privacy options */
.privacy-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.privacy-option input { display: none; }

.privacy-option span {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 9px 7px;
  background: var(--bg);
  color: var(--text-dim);
  text-align: center;
  font-size: 0.77rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.privacy-option span:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.privacy-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

/* Logo upload section */
.logo-upload-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.logo-preview-wrap {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.logo-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.logo-preview-placeholder {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
  padding: 4px;
}

.logo-actions {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Utils */
.hidden { display: none !important; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 1120px) and (min-width: 901px) {
  .top-bar {
    grid-template-columns: auto auto minmax(220px, 1fr);
    gap: 8px;
    padding: 0 12px;
  }

  .stat-item {
    display: none;
  }

  .top-auth-panel {
    min-width: 210px;
  }
}

@media (max-width: 900px) {
  body { overflow: auto; }

  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 60vh) auto;
    height: auto;
    min-height: 100vh;
  }

  #preview-area {
    grid-column: 1;
    grid-row: 2;
  }

  #sidebar {
    grid-column: 1;
    grid-row: 3;
    max-height: none;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .top-bar {
    grid-template-columns: 1fr;
    height: auto;
    padding: 12px 16px;
    gap: 8px;
  }

  .top-bar-center {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .top-bar-actions {
    justify-self: stretch;
    justify-content: flex-start;
    flex-wrap: wrap;
    max-width: none;
  }

  .top-auth-panel {
    flex: 1 1 230px;
    min-width: min(100%, 230px);
  }

  .live-link-box {
    flex: 1 1 100%;
    max-width: none;
  }

  .preview-metrics,
  .quality-grid,
  .stats-grid,
  .privacy-options {
    grid-template-columns: 1fr;
  }
}
