:root {
  color-scheme: light;
  --bg: #f4f5f9;
  --panel: #ffffff;
  --border: #e7e9f0;
  --text: #1b1e27;
  --muted: #667085;
  --muted-2: #8a8f9e;
  --accent: #6366f1;
  --accent-text: #4f46e5;
  --amber: #d4a544;
  --amber-text: #92660a;
  --danger: #dc2626;
  --input-bg: #f5f6fa;
  --input-border: #dde0ea;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

input, select, textarea, button { font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

input[type="text"], input[type="url"], input[type="password"], select {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 7px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
}

h1 { margin: 0 0 6px; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
h3 { margin: 0; }
.muted { color: var(--muted); margin: 0; }
.muted.small { font-size: 11.5px; }

#login-gate {
  max-width: 420px;
  margin: 15vh auto 0;
  text-align: center;
  padding: 24px;
}
#login-gate h2 { margin-top: 0; }
#google-sign-in-btn { margin: 12px auto 0; }

/* ===== shell ===== */
#app-shell {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}
#app-shell[hidden] { display: none; }

.sidebar {
  width: 268px;
  min-width: 268px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px 16px;
  gap: 26px;
  transition: width .16s ease, min-width .16s ease;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; }
.brand-logo { display: block; flex: none; object-fit: contain; }
.brand-text { flex: 1; min-width: 0; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; line-height: 1.1; }
.brand-sub { font-size: 10px; color: var(--muted-2); letter-spacing: .14em; text-transform: uppercase; margin-top: 2px; }

.sidebar-toggle-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 7px;
  color: var(--muted-2); cursor: pointer; padding: 5px; display: flex; flex-shrink: 0;
}
.sidebar-toggle-btn:hover { color: var(--text); border-color: var(--muted-2); }
.sidebar-toggle-btn svg { transition: transform .16s ease; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-btn {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 9px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; text-align: left; width: 100%;
  background: transparent; color: var(--muted);
}
.nav-btn.active { background: rgba(99,102,241,0.1); color: var(--text); }
.nav-btn:hover:not(.active) { background: #f6f7fb; }

/* ===== collapsed sidebar ===== */
.sidebar.collapsed { width: 76px; min-width: 76px; padding-left: 12px; padding-right: 12px; }
.sidebar.collapsed .brand { justify-content: center; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-btn span,
.sidebar.collapsed .usage-widget,
.sidebar.collapsed .profile-card-text,
.sidebar.collapsed .profile-card > svg {
  display: none;
}
.sidebar.collapsed .brand-logo { display: none; }
.sidebar.collapsed .sidebar-toggle-btn svg { transform: rotate(180deg); }
.sidebar.collapsed .nav-btn { justify-content: center; padding: 10px; }
.sidebar.collapsed .profile-card { justify-content: center; padding: 9px; }

.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.usage-widget { background: #f6f7fb; border: 1px solid var(--border); border-radius: 10px; padding: 12px 13px; }
.usage-widget-row {
  display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted-2);
  letter-spacing: .08em; text-transform: uppercase; margin-bottom: 7px;
}
.bar-track { height: 5px; border-radius: 4px; background: var(--border); overflow: hidden; }
.bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--amber)); transition: width .3s ease; }
.bar-fill.usage-at-limit { background: #ef4444; }
.bar-fill.usage-near-limit { background: var(--amber); }
.bar-fill.bar-indeterminate {
  width: 40%;
  background: var(--accent);
  animation: bar-slide 1.2s ease-in-out infinite;
}
@keyframes bar-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

.profile-card {
  display: flex; align-items: center; gap: 10px; background: #f6f7fb; border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 10px; cursor: pointer; color: var(--text); text-align: left; width: 100%;
}
.profile-card-text { flex: 1; min-width: 0; }
.profile-card-name { font-size: 13px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-card-role { font-size: 11px; color: var(--muted-2); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
}
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }

/* ===== main content ===== */
.content { flex: 1; overflow-y: auto; min-width: 0; }
.content-inner { max-width: 1180px; margin: 0 auto; padding: 36px 44px 60px; }

section[data-tab-panel][hidden] { display: none; }
div[data-view][hidden], div[data-profile-view][hidden] { display: none; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }

.mobile-menu-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); cursor: pointer;
  margin: 14px 0 0 16px;
}
.sidebar-backdrop { display: none; }

.btn-primary, .btn-outline, .btn-outline-accent, .btn-soft, .link-btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 14px; font-weight: 600; white-space: nowrap;
  border-radius: 9px; padding: 11px 16px;
}
.btn-primary { background: var(--accent); color: white; border: none; }
.btn-primary:hover { background: #4f46e5; }
.btn-outline { background: white; border: 1px solid var(--input-border); color: var(--text); padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-outline-accent { background: transparent; border: 1px solid #cfd0fb; color: var(--accent-text); padding: 8px 10px; font-size: 13px; border-radius: 8px; }
.btn-soft { background: #f2f3f8; border: 1px solid #e0e2eb; color: var(--text); padding: 8px 10px; font-size: 13px; border-radius: 8px; }
.btn-danger-text { color: var(--danger); }
.btn-block { width: 100%; justify-content: center; }
.link-btn { background: transparent; border: none; color: var(--muted-2); font-size: 12.5px; padding: 4px 2px; align-self: flex-start; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: 0 1px 2px rgba(20,24,40,0.04); }
.panel.narrow { max-width: 520px; }
.panel-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); margin-bottom: 12px; }
.row-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 1px 2px rgba(20,24,40,0.04);
}
.scenario-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.card-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-title-row h3 { font-size: 15.5px; font-weight: 650; line-height: 1.3; }
.card-desc { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; min-height: 36px; }
.icon-x { background: transparent; border: none; color: var(--muted-2); cursor: pointer; font-size: 16px; line-height: 1; padding: 0; }
.icon-x:hover { color: var(--danger); }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.chip-indigo { background: rgba(99,102,241,0.1); color: var(--accent-text); }
.chip-amber { background: rgba(212,165,68,0.16); color: var(--amber-text); }

.screenplay-card { overflow: hidden; display: flex; flex-direction: column; }
.cover-strip { height: 6px; }
.card-body { padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.meta-row { display: flex; gap: 14px; font-size: 12px; color: var(--muted-2); }

.pill { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.pill-completed, .pill-success { background: rgba(22,163,74,0.12); color: #15803d; }
.pill-failed { background: rgba(220,38,38,0.12); color: #b91c1c; }
.pill-draft { background: rgba(100,116,139,0.12); color: #64748b; }
.pill-running { background: rgba(202,138,4,0.14); color: #a16207; }

.empty-state { border: 1.5px dashed var(--input-border); border-radius: 12px; padding: 30px; text-align: center; color: var(--muted-2); font-size: 13.5px; }

.title-input { width: 100%; background: transparent; border: none; font-size: 25px; font-weight: 700; padding: 2px 0; margin-bottom: 6px; letter-spacing: -0.01em; }
.subtitle-input { width: 100%; background: transparent; border: none; font-size: 14px; color: var(--muted); padding: 2px 0; margin-bottom: 24px; }

.back-btn { display: flex; align-items: center; gap: 6px; background: transparent; border: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 0; margin-bottom: 16px; }

.editor-columns { display: flex; gap: 28px; align-items: flex-start; }
.editor-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.editor-rail { width: 320px; min-width: 320px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; }

/* While recording, lift the page's own reading-width cap and drop the rail
   below so the VNC viewer can use the full window width instead of being
   squeezed into a ~1100px reading column. */
.content-inner.recording-active { max-width: none; }
.content-inner.recording-active .editor-columns { flex-direction: column; }
.content-inner.recording-active .editor-rail { width: 100%; min-width: 0; position: static; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--muted-2); }
.field-grow { flex: 2; min-width: 220px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }

.steps-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.step-item {
  display: flex; flex-direction: column; gap: 6px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 10px;
}
.step-item.dragging { opacity: 0.4; }
.step-item-row { display: flex; align-items: center; gap: 8px; }
/* Resolved actions behind a "guided" step (see app.js's describeAction) -
   shows exactly what it does, since the step's own text is often the
   original vague instruction rather than a literal description. */
.step-actions {
  list-style: none; margin: 0; padding: 0 0 0 40px; display: flex; flex-direction: column; gap: 3px;
}
.step-actions li {
  font-size: 12px; color: var(--muted); position: relative; padding-left: 14px;
}
.step-actions li::before {
  content: ""; position: absolute; left: 0; top: 7px; width: 6px; height: 6px; border-radius: 50%;
  background: rgba(99,102,241,0.35);
}
/* Prior guided resolutions superseded by a text edit (see types.ts's
   GuidedHistoryEntry) - a hover-title carries the actual detail, this is
   just a quiet marker that history exists. */
.step-guided-history {
  margin: 0; padding: 0 0 0 40px; font-size: 11px; color: var(--muted-2); cursor: help;
}
.step-handle { color: #b7bbc7; letter-spacing: -2px; cursor: grab; font-size: 15px; user-select: none; }
.step-marker {
  width: 14px; height: 14px; min-width: 14px; border-radius: 50%;
  border: 2px solid #cbd0dc; background: transparent; padding: 0; flex-shrink: 0; cursor: pointer;
}
.step-marker:hover:not(:disabled) { border-color: var(--muted); }
.step-marker.selected { background: var(--danger); border-color: var(--danger); }
.step-marker:disabled { cursor: not-allowed; opacity: 0.5; }
.step-number { color: var(--muted-2); font-size: 12px; min-width: 18px; }
.step-badge {
  background: rgba(212,165,68,0.2); color: var(--amber-text); font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; padding: 2px 6px; border-radius: 4px;
}
.step-badge.step-badge-guided { background: rgba(99,102,241,0.12); color: var(--accent-text); }
.step-input { flex: 1; min-width: 0; background: transparent; border: none; color: var(--text); padding: 6px 4px; font-size: 13.5px; }
.step-remove { background: transparent; border: none; color: var(--muted-2); cursor: pointer; font-size: 17px; padding: 0 4px; line-height: 1; }
.step-remove:hover { color: var(--danger); }

.variables-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.variable-row {
  display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 10px; flex-wrap: wrap;
}
.variable-name-input {
  width: 140px; flex: none; background: transparent; border: none; color: var(--text); padding: 6px 4px;
  font-size: 13.5px; font-weight: 600;
}
.variable-mode-select {
  flex: none; background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 6px;
  color: var(--text); padding: 5px 6px; font-size: 12.5px;
}
.variable-value-input, .variable-instruction-input {
  flex: 1; min-width: 180px; background: transparent; border: none; color: var(--text); padding: 6px 4px; font-size: 13.5px;
}
.variable-instruction-input { resize: vertical; min-height: 32px; font-family: inherit; }
.variable-remove-btn { background: transparent; border: none; color: var(--muted-2); cursor: pointer; font-size: 17px; padding: 0 4px; line-height: 1; }
.variable-remove-btn:hover { color: var(--danger); }

#add-precursor-select {
  background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 7px;
  color: var(--text); padding: 6px 9px; font-size: 12.5px;
}
.precursors-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.precursor-row {
  display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 10px;
}
.precursor-index {
  width: 20px; height: 20px; border-radius: 50%; background: var(--input-bg); color: var(--muted-2);
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.precursor-name { flex: 1; min-width: 0; font-size: 13.5px; }
.precursor-remove-btn { background: transparent; border: none; color: var(--muted-2); cursor: pointer; font-size: 17px; padding: 0 4px; line-height: 1; }
.precursor-remove-btn:hover { color: var(--danger); }

.recording-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #a16207; margin: -4px 0 10px; }
.recording-status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; animation: recPulse 1.1s infinite;
}
@keyframes recPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* 16:9, matching both the recording browser's viewport (devices.ts
   DEVICE_PROFILES.desktop) and the actual Xvnc display's `-geometry`
   (recorder.ts's startVirtualDisplay) - keep these three in sync, or the
   viewer either letterboxes or clips despite vnc-embed.html's scaleViewport.
   Capped well above 1280x720 since the box can span the full editor width
   while recording (see .editor-columns.recording-active) - some upscaling
   reads better than a small window. */
#vnc-viewer-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: 100%; max-width: 1600px; aspect-ratio: 1280 / 720; height: auto; }
#vnc-frame { width: 100%; height: 100%; border: none; background: #000; }

.param-chips-block { margin-top: 4px; }
.hint { margin: 8px 0 0; font-size: 12px; color: var(--muted-2); }

.toggle-list { display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }
.toggle-list-row { flex-direction: row; gap: 16px; }
.device-toggle { display: flex; align-items: center; gap: 10px; background: transparent; border: none; padding: 2px 0; cursor: pointer; color: var(--text); text-align: left; font-size: 13.5px; }
.checkbox-box { width: 16px; height: 16px; border-radius: 5px; border: 1.6px solid #cbd0dc; display: inline-block; }
.device-toggle.checked .checkbox-box { border-color: var(--accent); background: var(--accent); }
/* Scenario test-run device selection is a radio group (one device at a time,
   see app.js's renderDeviceToggles `exclusive` mode) - round instead of
   square so it doesn't read as an independent checkbox. */
.device-toggle-radio .checkbox-box { border-radius: 50%; }
.device-toggle-radio.checked .checkbox-box { box-shadow: inset 0 0 0 3px var(--bg); }

.storyline-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.storyline-card { background: var(--panel); border: 1px solid var(--border); border-radius: 11px; }
.storyline-card.dragging { opacity: 0.4; }
.storyline-header { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid #eceef3; }
.storyline-order { color: var(--muted-2); font-size: 12px; min-width: 16px; }
.storyline-name { font-size: 14.5px; font-weight: 650; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-chevron { background: transparent; border: none; color: var(--muted-2); cursor: pointer; padding: 2px; display: flex; }
.icon-chevron.expanded svg { transform: rotate(90deg); transition: transform .12s; }
.storyline-params { padding: 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.storyline-resolved { padding: 0 14px 14px; }
.storyline-resolved-inner { background: #f7f8fb; border: 1px solid #eceef3; border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.storyline-resolved-step { font-size: 12.5px; color: #3f4453; display: flex; gap: 8px; }
.storyline-resolved-step span { color: #b7bbc7; min-width: 14px; }

.library-list { display: flex; flex-direction: column; gap: 8px; }
.library-row {
  display: flex; align-items: center; gap: 10px; text-align: left; background: #f7f8fb; border: 1px solid var(--border);
  border-radius: 9px; padding: 10px 11px; cursor: pointer; color: var(--text); width: 100%;
}
.library-row-text { flex: 1; min-width: 0; }
.library-row-name { font-size: 13px; font-weight: 600; }
.library-row-desc { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }

.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-row { padding: 12px 16px; }
.history-row-header { display: flex; align-items: center; gap: 10px; cursor: pointer; flex-wrap: wrap; }
.history-row-name { font-size: 14px; font-weight: 650; flex: 1; min-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-row-error { margin: 8px 0 0; font-size: 12.5px; color: var(--danger); }
.history-row-detail { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.history-step-line { font-size: 12.5px; display: flex; gap: 8px; align-items: baseline; }
.history-step-line .step-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 3px; }
.history-step-line.status-success .step-dot { background: #22c55e; }
.history-step-line.status-failed .step-dot { background: #ef4444; }
.history-step-line .step-error { color: var(--danger); margin-left: 4px; }

.matrix-wrap { margin-bottom: 24px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.run-matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
.run-matrix th { text-align: center; padding: 10px 14px; color: var(--muted-2); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
.run-matrix th:first-child { text-align: left; }
.run-matrix td { padding: 9px 14px; border-bottom: 1px solid #eceef3; text-align: center; position: relative; }
.run-matrix td:first-child { text-align: left; color: #3f4453; white-space: nowrap; }
.matrix-group-row td { padding: 9px 14px 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #7a8094; background: #f7f8fb; }
.matrix-box { display: inline-block; width: 13px; height: 13px; border-radius: 4px; background: #d7dae3; }
.matrix-box.status-success { background: #22c55e; }
.matrix-box.status-failed { background: #ef4444; }
.matrix-box.status-running { background: #eab308; }

.video-thumb-wrap { position: relative; height: 140px; border-radius: 9px; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #6366f1, #1a1d26); overflow: hidden; }
.video-thumb-wrap.media-thumb { height: 120px; margin-bottom: 0; }
.video-play-btn { position: absolute; inset: 0; background: transparent; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.duration-badge { position: absolute; bottom: 8px; right: 10px; font-size: 11px; color: white; background: rgba(0,0,0,0.5); padding: 2px 6px; border-radius: 4px; }
.device-badge { position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: white; background: rgba(0,0,0,0.5); padding: 3px 7px; border-radius: 5px; }
.run-card { padding: 16px; }
.run-video, .media-video { width: 100%; border-radius: 8px; background: black; }
.run-error { color: #dc2626; font-size: 13px; margin: 8px 0 0; }
.media-card-body { padding: 12px 14px 14px; }
.media-card-title { font-size: 13.5px; font-weight: 600; margin-bottom: 6px; line-height: 1.3; }

.tab-strip { display: flex; gap: 6px; margin-bottom: 24px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 4px; width: fit-content; }
.tab-strip-btn { padding: 8px 14px; border-radius: 7px; border: none; cursor: pointer; font-size: 13px; font-weight: 600; background: transparent; color: var(--muted); }
.tab-strip-btn.active { background: #eef0f7; color: var(--text); }

.account-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.account-name { font-size: 16px; font-weight: 650; }

.credential-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 10px; }
.cred-icon { width: 34px; height: 34px; border-radius: 8px; background: #f2f3f8; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.credential-text { flex: 1; min-width: 0; }
.credential-name { font-size: 14px; font-weight: 650; }
.credential-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-credential-form { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.add-credential-form .btn-outline { align-self: flex-start; }

.prefs-panel { display: flex; flex-direction: column; gap: 18px; padding: 22px 24px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; max-width: 340px; font-size: 13.5px; }
.switch { width: 38px; height: 22px; border-radius: 999px; border: none; cursor: pointer; padding: 2px; position: relative; background: var(--input-border); flex-shrink: 0; }
.switch.on { background: var(--accent); }
.switch-knob { display: block; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(20,24,40,0.25); transition: transform .15s; }
.switch.on .switch-knob { transform: translateX(16px); }

@media (max-width: 860px) {
  .editor-columns { flex-direction: column; }
  .editor-rail { width: 100%; min-width: 0; position: static; }
}

@media (max-width: 700px) {
  .mobile-menu-btn { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 60;
    width: 268px;
    min-width: 268px;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(20, 24, 40, 0.18);
  }
  /* On mobile "collapsed" means the drawer is off-canvas, not the icon-only
     rail used on desktop - the whole drawer is invisible either way, so the
     icon-rail width doesn't matter, but keep it at full width so there's no
     layout flash on the frame where it becomes visible again. */
  .sidebar.collapsed { width: 268px; min-width: 268px; }
  .sidebar:not(.collapsed) { transform: translateX(0); }

  .sidebar-backdrop.visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.4);
    z-index: 55;
  }

  .content-inner { padding: 20px 16px 40px; }
  .tab-strip { flex-wrap: wrap; width: auto; }
  .toggle-list-row { flex-wrap: wrap; }
  .editor-rail { position: static; }
}
