﻿/* ── APP SHELL ───────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

body:not(.auth-ok) #app { display: none; }
body.auth-ok #authGate { display: none; }

/* Auth gate - checking state (Firebase not yet resolved) */
#authGate.is-checking .auth-shell { display: none; }
#authGate:not(.is-checking) .auth-checking-screen { display: none; }
.auth-checking-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
}
.auth-checking-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--line2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: authCheckSpin .7s linear infinite;
}
@keyframes authCheckSpin { to { transform: rotate(360deg); } }
.auth-checking-msg { font-size: 13px; color: var(--muted); }

.auth-gate {
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.82), rgba(255,255,255,.38) 280px),
    linear-gradient(90deg, rgba(23,114,109,.045) 0 1px, transparent 1px),
    linear-gradient(0deg, rgba(23,114,109,.035) 0 1px, transparent 1px),
    var(--bg);
  background-size: auto, 42px 42px, 42px 42px;
}
.auth-shell {
  width: min(1080px, 100%);
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.auth-topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.auth-topbar-brand,
.auth-back-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--text);
}
.auth-topbar-brand {
  gap: 9px;
  font-size: 18px;
  font-weight: 800;
}
.auth-topbar-logo {
  width: 26px;
  height: 26px;
  object-fit: cover;
  object-position: center;
}
.auth-back-link {
  gap: 7px;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--rs);
  background: rgba(255,255,255,.68);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.auth-back-link:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-rgb),.26);
  background: #fff;
  color: var(--accent);
}
.auth-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(320px, 1fr);
  align-items: center;
  gap: 28px;
  padding: 24px 0 44px;
}
.auth-panel {
  width: 100%;
  border: 1px solid var(--line2);
  border-radius: 8px;
  background: var(--bg1);
  box-shadow: 0 22px 60px rgba(26,31,46,.14);
  padding: 30px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.auth-panel .auth-brand {
  gap: 0;
}
.auth-logo {
  display: none;
}
.auth-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.auth-brand h1 {
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
  color: var(--text);
}
.auth-copy {
  margin: 22px 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}
.auth-google-btn {
  width: 100%;
  min-height: 48px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, background .12s, opacity .12s;
}
.auth-google-btn:hover:not(:disabled) {
  background: var(--accent-btn);
  transform: translateY(-1px);
}
.auth-google-btn:focus-visible,
.auth-back-link:focus-visible {
  outline: 3px solid rgba(var(--gold-rgb),.36);
  outline-offset: 2px;
}
.auth-google-btn:disabled {
  opacity: .55;
  cursor: wait;
}
.auth-google-btn.is-loading {
  opacity: 1;
  background: var(--accent-btn);
  border-color: var(--accent-btn);
  cursor: wait;
}
.auth-google-btn.is-loading .google-mark {
  color: transparent;
  position: relative;
}
.auth-google-btn.is-loading .google-mark::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(var(--accent-rgb),.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: authBtnSpin .75s linear infinite;
}
@keyframes authBtnSpin {
  to { transform: rotate(360deg); }
}
.google-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  color: #2563eb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}
.auth-status {
  margin-top: 16px;
  min-height: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.auth-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 0 rgba(217,119,6,.45);
  animation: setupPulse 1.2s ease-in-out infinite;
}
.auth-status.ready .auth-status-dot {
  background: var(--ok);
  box-shadow: none;
  animation: none;
}
.auth-status.error .auth-status-dot {
  background: var(--danger);
  box-shadow: none;
  animation: none;
}
.auth-trust-row {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 12px;
}
.auth-trust-row span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.auth-trust-row svg {
  color: var(--accent);
}
/* ── AUTH TIPS CAROUSEL ──────────────────────── */
.auth-tips-aside {
  border: 1px solid var(--line2);
  border-radius: 12px;
  background: var(--bg1);
  box-shadow: 0 20px 50px rgba(26,31,46,.11);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 260px;
  overflow: hidden;
  position: relative;
}
.auth-tips-aside::after {
  content: '';
  position: absolute;
  top: -48px; right: -48px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(var(--accent-rgb),.06);
  pointer-events: none;
}
.auth-tips-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.auth-tips-eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
}
.auth-tips-count {
  font-size: 11px;
  color: var(--muted2);
  font-family: var(--mono);
}
.auth-tips-stage {
  position: relative;
  flex: 1;
  min-height: 140px;
}
.auth-tip-card {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .38s ease, transform .38s ease;
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-tip-card.active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.auth-tip-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 4px 11px;
  border-radius: 20px;
  text-transform: uppercase;
  width: fit-content;
  line-height: 1.4;
}
.auth-tip-badge--feature { background: rgba(var(--accent-rgb),.12); color: var(--accent); }
.auth-tip-badge--tip     { background: rgba(var(--gold-rgb),.14);   color: #8a6c0d; }
.auth-tip-badge--update  { background: rgba(37,99,235,.1);          color: #1d4ed8; }
.auth-tip-text {
  font-size: 16px;
  line-height: 1.65;
  font-weight: 500;
  color: var(--text);
}
.auth-tips-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
}
.auth-tips-dots {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.auth-tip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: none;
  background: var(--line2);
  cursor: pointer;
  padding: 0;
  transition: background .2s, width .2s, border-radius .2s;
  flex-shrink: 0;
}
.auth-tip-dot.active {
  background: var(--accent);
  width: 18px;
  border-radius: 3px;
}
.auth-tips-arrow {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line2);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
  padding: 0;
}
.auth-tips-arrow:hover {
  background: var(--bg2);
  border-color: var(--accent);
  color: var(--accent);
}
/* ── AUTH RIGHT COLUMN ───────────────────────── */
.auth-right-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* ── AUTH PRIVACY CARD ───────────────────────── */
.auth-privacy-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--line2);
  border-radius: 10px;
  background: var(--bg1);
  padding: 14px 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}
.auth-privacy-card svg {
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 1px;
}
.auth-privacy-card strong { color: var(--text); }

@media (max-width: 820px) {
  .auth-gate { padding: 18px; }
  .auth-shell { min-height: calc(100vh - 36px); }
  .auth-layout {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 14px 0 30px;
  }
  .auth-right-col { order: -1; }
}

@media (max-width: 560px) {
  .auth-gate { padding: 14px; }
  .auth-topbar { height: 50px; }
  .auth-topbar-brand span { display: none; }
  .auth-back-link {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 12px;
  }
  .auth-panel { padding: 22px; }
  .auth-brand {
    align-items: flex-start;
    gap: 12px;
  }
  .auth-brand h1 { font-size: 24px; }
  .auth-tips-aside { min-height: 180px; }
}

/* ── HEADER ──────────────────────────────────── */
.header {
  height: 60px;
  background: #17726d;
  border-bottom: 2px solid rgba(205,170,54,.45);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 200;
}
.logo { display: flex; align-items: center; margin-right: 8px; text-decoration: none; }
.logo-mark {
   height: 60px; border-radius: 0;
  object-fit: contain; flex-shrink: 0; background: none;
}
.header-sep { width: 1px; height: 24px; background: rgba(255,255,255,.2); flex-shrink: 0; }
.header-space { flex: 1; }

/* ── HEADER INTEGRATION CHIP ─────────────────── */
.int-chip-wrap { display: none; position: relative; }
.int-chip {
  display: flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px; border-radius: var(--rs);
  border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.08);
  cursor: pointer; color: rgba(255,255,255,.8); transition: all .15s;
}
.int-chip:hover, .int-chip.open { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.22); color: #fff; }
.int-chip-name { font-size: 11px; font-weight: 500; letter-spacing: .2px; }
.int-chip-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,.25); flex-shrink: 0; transition: background .3s;
}
.int-chip-dot.configured { background: #4ade80; }

/* Chip dropdown */
.int-chip-drop {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--bg1); border: 1px solid var(--line2);
  border-radius: var(--r); box-shadow: 0 8px 28px rgba(0,0,0,.18);
  min-width: 230px; z-index: 300; overflow: hidden;
  opacity: 0; pointer-events: none;
  transform: translateY(-6px); transition: opacity .15s, transform .15s;
}
.int-chip-drop.open { opacity: 1; pointer-events: all; transform: translateY(0); }
.int-chip-drop-label {
  font-size: 10px; font-weight: 600; letter-spacing: .5px;
  color: var(--muted); padding: 10px 14px 6px; text-transform: uppercase;
}
.int-chip-drop-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 14px; background: none; border: none;
  cursor: pointer; color: var(--text); font-size: 13px; text-align: left;
  transition: background .1s;
}
.int-chip-drop-item:hover { background: var(--bg2); }
.int-chip-drop-item.active { background: rgba(var(--accent-rgb),.06); }
.int-drop-radio {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--line2); transition: all .15s;
}
.int-chip-drop-item.active .int-drop-radio {
  border-color: var(--accent); background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--bg1);
}
.int-drop-status {
  margin-left: auto; font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px;
}
.int-drop-status.ok     { background: #dcfce7; color: #15803d; }
.int-drop-status.notset { background: var(--bg3); color: var(--muted); }
.int-chip-drop-divider { height: 1px; background: var(--line); margin: 4px 0; }
.int-chip-drop-cfg {
  display: block; width: 100%; padding: 8px 14px; background: none; border: none;
  cursor: pointer; color: var(--muted); font-size: 11px; text-align: left;
  transition: color .1s;
}
.int-chip-drop-cfg:hover { color: var(--text); }
.int-chip-drop-cfg:last-child { padding-bottom: 10px; }

.model-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 20px;
  border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.1);
  font-size: 12px; font-family: var(--font); color: rgba(255,255,255,.9);
  cursor: pointer; transition: all .2s; white-space: nowrap;
}
.model-btn:hover {
  border-color: #cdaa36; background: rgba(205,170,54,.15); color: #fff;
}
.agent-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px;
  border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.06);
  font-size: 12px; font-family: var(--font); color: rgba(255,255,255,.65);
  white-space: nowrap; pointer-events: none; user-select: none;
}
/* ── MODE PILL (header toggle) ───────────────── */
.mode-pill {
  display: flex; background: rgba(255,255,255,.1);
  border-radius: 8px; padding: 3px; gap: 2px;
}
.mode-pill .mode-tab {
  padding: 4px 14px; border-radius: 6px; border: none;
  background: transparent; color: rgba(255,255,255,.6);
  font-size: 12px; font-weight: 500; cursor: pointer;
  font-family: var(--font); transition: all .15s;
  white-space: nowrap; user-select: none;
  border-bottom: none; margin-bottom: 0;
}
.mode-pill .mode-tab:hover { color: rgba(255,255,255,.9); }
.mode-pill .mode-tab.active { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }
.model-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34,197,94,.5);
  animation: dotpulse 2s infinite;
}
.model-dot.unconfigured { background: #f59e0b; box-shadow: none; animation: none; }
.model-dot.error        { background: #ef4444; box-shadow: none; animation: none; }
.agent-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34,197,94,.5);
  animation: dotpulse 2s infinite;
}
.agent-dot.offline    { background: rgba(255,255,255,.3); box-shadow: none; animation: none; }
.agent-dot.setting-up { background: #f59e0b; animation: setupPulse 1s ease-in-out infinite; }
.agent-dot.setup-error { background: #ef4444; box-shadow: none; animation: none; }
@keyframes setupPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(245,158,11,.5); }
  50%     { box-shadow: 0 0 0 5px rgba(245,158,11,0); }
}
@keyframes dotpulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  70%  { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--rs);
  border: none; background: transparent; color: rgba(255,255,255,.75);
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 16px; transition: all .2s;
}
.icon-btn:hover { background: rgba(0,0,0,.2); color: #fff; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #cdaa36;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #17726d;
  cursor: pointer; margin-left: 2px; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,.35);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }

/* ── INPUT PANEL ─────────────────────────────── */
.input-panel {
  background: var(--bg1);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  flex-shrink: 0;
  display: flex;
  gap: 14px;
  align-items: stretch;
}
.input-left { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.input-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: .8px; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.fetch-jira-wrap { display: flex; align-items: center; gap: 6px; }
.fetch-story-input {
  width: 90px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--rs); padding: 4px 8px; color: var(--text);
  font-size: 11px; font-family: var(--mono); letter-spacing: .3px;
  text-transform: uppercase; outline: none;
}
.fetch-story-input:focus { border-color: rgba(var(--accent-rgb),.4); }
.fetch-story-input::placeholder { color: var(--muted); opacity: .5; text-transform: none; }
.input-div { width: 1px; background: var(--line); flex-shrink: 0; }

/* User story textarea */
#usBox {
  width: 100%; height: 76px;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--rs); padding: 10px 12px;
  color: var(--text); font-size: 13px; line-height: 1.5;
  resize: vertical; outline: none; transition: border-color .2s; min-height: 52px; max-height: 320px;
}
#usBox::placeholder { color: var(--muted2); }
#usBox:focus { border-color: rgba(var(--accent-rgb),.4); }

/* Options checkboxes */
.options-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.opt-check {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--muted); cursor: pointer; user-select: none;
}
.opt-check input { accent-color: var(--accent); width: 13px; height: 13px; cursor: pointer; }
.opt-check:hover { color: var(--text); }

/* Upload drop zone */
.upload-col { width: 136px; flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; }
.drop-zone {
  flex: 1; background: var(--bg2); border: 1.5px dashed var(--line2);
  border-radius: var(--rs); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; transition: all .25s; padding: 8px; text-align: center;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent); background: rgba(var(--accent-rgb),.04);
}
.drop-zone.has-file { border-color: rgba(var(--accent-rgb),.4); border-style: solid; }
.dz-icon { font-size: 20px; color: var(--muted); }
.dz-label { font-size: 11px; color: var(--muted); line-height: 1.4; }
.dz-types { font-size: 10px; color: var(--muted2); font-family: var(--mono); }

/* Preview panel */
.preview-col {
  width: 196px; flex-shrink: 0; background: var(--bg2);
  border: 1px solid var(--line); border-radius: var(--rs);
  overflow: hidden; display: flex; flex-direction: column;
}
.preview-topbar {
  padding: 5px 10px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.preview-title {
  font-size: 10px; font-weight: 600; color: var(--muted);
  letter-spacing: .5px; text-transform: uppercase;
}
.preview-badge { font-size: 10px; color: var(--muted2); font-family: var(--mono); }
.preview-body { flex: 1; overflow: hidden; position: relative; }
.preview-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 10px;
}
.preview-empty-icon { font-size: 26px; opacity: .25; display: block; margin-bottom: 5px; }
.preview-empty-text { font-size: 11px; color: var(--muted2); line-height: 1.5; text-align: center; }
#previewImg {
  position: absolute; inset: 8px;
  width: calc(100% - 16px); height: calc(100% - 16px);
  object-fit: contain; display: none;
}
#previewFrame {
  border: none; display: none; background: #fff;
  position: absolute; top: 0; left: 0;
  transform-origin: top left;
}

/* ── GENERATE BAR ────────────────────────────── */
.gen-bar {
  padding: 9px 20px; background: var(--bg1);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.progress-track { flex: 1; height: 3px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0; border-radius: 2px;
  background: var(--accent); transition: width .3s;
}
.progress-fill.anim { animation: pfill 2s ease-in-out infinite; }
@keyframes pfill {
  0%   { width:0%;  margin-left:0%; }
  50%  { width:55%; margin-left:22%; }
  100% { width:0%;  margin-left:100%; }
}

/* ── TABS ────────────────────────────────────── */
.tabs-bar {
  display: flex; align-items: center; gap: 2px;
  padding: 0 20px; background: var(--bg1);
  border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.tab {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 14px; font-size: 13px; font-weight: 500;
  color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .18s; white-space: nowrap; margin-bottom: -1px;
  user-select: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-icon { font-size: 14px; }
.tab-badge {
  font-size: 10px; font-family: var(--mono);
  padding: 1px 5px; border-radius: 8px;
  background: var(--bg3); color: var(--muted);
}
.tab.active .tab-badge {
  background: rgba(var(--accent-rgb),.12); color: var(--accent);
}
.tabs-end { margin-left: auto; display: flex; align-items: center; gap: 6px; padding-bottom: 2px; }

/* ── MODE NAV ────────────────────────────────── */
.mode-nav {
  position: relative; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  padding: 0 20px; background: var(--bg0);
  border-bottom: 2px solid var(--line); flex-shrink: 0;
}
.mode-tab {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 18px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all .18s; white-space: nowrap; margin-bottom: -2px;
  user-select: none;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── MODE PAGES ──────────────────────────────── */
.mode-page { display: none; flex: 1; flex-direction: column; overflow: hidden; min-height: 0; }
.mode-page.active { display: flex; }

/* ── CONTENT AREA ────────────────────────────── */
.content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.tab-panel { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.tab-panel.active { display: flex; }

/* APK mode fills all remaining height */
#apkMode { background: var(--bg0); }
#apkModeInner { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; }

/* Table toolbar */
.tbl-toolbar {
  padding: 10px 20px; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--line); background: var(--bg); flex-shrink: 0;
}
.story-link-wrap {
  display: flex; align-items: center; gap: 5px;
  border: 1px solid var(--line2); border-radius: var(--rs);
  padding: 0 8px; background: var(--bg2); margin-left: auto;
}
.story-link-label {
  font-size: 11px; color: var(--muted); font-weight: 500; white-space: nowrap;
}
.story-link-input {
  width: 80px; background: none; border: none; outline: none;
  font-size: 12px; color: var(--text); padding: 5px 0;
  font-family: var(--mono); letter-spacing: .3px;
}
.story-link-input::placeholder { color: var(--muted); opacity: .6; }
.search-wrap {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--rs); padding: 6px 10px; flex: 1; max-width: 300px;
}
.search-wrap input {
  background: none; border: none; outline: none;
  color: var(--text); font-size: 13px; width: 100%;
}
.search-wrap input::placeholder { color: var(--muted2); }
.search-icon { color: var(--muted); font-size: 12px; }
.search-wrap:focus-within { border-color: rgba(var(--accent-rgb),.35); }

/* Scrollable table wrapper */
.tbl-wrap { flex: 1; overflow-y: auto; }

/* Empty state */
.empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; padding: 48px; color: var(--muted);
}
.empty-ico { font-size: 40px; opacity: .22; }
.empty-txt { font-size: 13px; text-align: center; line-height: 1.7; max-width: 300px; }
.empty-txt strong { color: var(--text); }


/* ── ONBOARDING BANNER ───────────────────────── */
#setupBanner {
  background: rgba(var(--accent-rgb),.06);
  border-bottom: 1px solid rgba(var(--accent-rgb),.15);
  padding: 10px 20px; display: flex; align-items: center; gap: 12px;
  font-size: 13px; flex-shrink: 0;
}
#setupBanner.hidden { display: none; }
#setupBanner .banner-icon { font-size: 16px; }
#setupBanner strong {
  background: var(--accent); color: #fff;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
}
#setupBanner button {
  margin-left: auto; padding: 5px 12px; border-radius: var(--rs);
  border: 1px solid var(--accent); background: var(--accent);
  color: #fff; font-size: 12px; font-weight: 600; cursor: pointer;
}

/* ══ MOBILE WIZARD - 3-COLUMN LAYOUT ═══════════ */

/* Device section (in sidebar) */
.apk-device-bar { display: flex; flex-direction: column; gap: 6px; }
.apk-device-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.device-chip {
  font-size: 11px; color: var(--muted); background: var(--bg3);
  border: 1px solid var(--line2); border-radius: 20px;
  padding: 2px 8px; white-space: nowrap;
}

/* Main workspace */
.apk-workspace {
  display: flex; flex: 1; overflow: hidden;
  min-height: 0;
}

/* Left panel */
.apk-left {
  width: 220px; flex-shrink: 0; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 0;
  overflow-y: auto; overflow-x: hidden;
  min-height: 0;
  scrollbar-width: thin;
}

/* Sidebar section block */
.apk-sidebar-section {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 14px 9px;
  border-bottom: 1px solid var(--line);
}
.apk-sidebar-section--grow {
  flex: 0 0 auto;
  min-height: 170px;
  overflow: visible;
}
.apk-sidebar-label {
  font-size: 10px; font-weight: 600; letter-spacing: .6px;
  text-transform: uppercase; color: var(--muted);
}

/* Vertical drag handles */
.apk-drag-left {
  width: 5px; flex-shrink: 0; cursor: col-resize;
  background: transparent; position: relative; z-index: 10;
  transition: background .15s;
}
.apk-drag-left:hover, .apk-drag-left.dragging { background: var(--accent); }
.apk-drag-right {
  width: 5px; flex-shrink: 0; cursor: col-resize;
  background: transparent; position: relative; z-index: 10;
  transition: background .15s;
}
.apk-drag-right:hover, .apk-drag-right.dragging { background: var(--accent); }

/* Center column - fluid, takes all remaining space */
.apk-center {
  flex: 1; min-width: min(100%, var(--apk-center-min, 520px)); display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  position: relative; overflow: hidden; align-self: stretch;
  background: var(--bg2);
}

/* Topbar above phone */
.apk-topbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; flex-shrink: 0;
  border-bottom: 1px solid var(--line); background: var(--bg1);
}
.apk-topbar-space { flex: 1; }
.apk-res-info {
  font-size: 11px; color: var(--muted); font-family: var(--mono);
  white-space: nowrap; letter-spacing: .2px;
  min-width: 16ch; text-align: right; font-variant-numeric: tabular-nums;
  flex: 0 0 16ch;
}

/* Phone pane */
.apk-phone-pane {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 12px; overflow: hidden; background: var(--bg2);
  position: relative;
}
.apk-phone-stage {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: auto; height: min(680px, calc(100% - 24px));
  max-width: calc(100% - 260px); max-height: calc(100% - 24px);
}
.apk-phone {
  position: relative; z-index: 2;
  --phone-pad-x: 8px;
  --phone-pad-y: 8px;
  --phone-radius: 24px;
  --screen-radius: 14px;
  --phone-notch-h: 6px;
  --phone-notch-gap: 5px;
  background: #111; border-radius: var(--phone-radius); padding: var(--phone-pad-y) var(--phone-pad-x);
  box-shadow: 0 12px 40px rgba(0,0,0,.4), inset 0 0 0 1px rgba(255,255,255,.08);
  display: flex; flex-direction: column; flex-shrink: 0;
  aspect-ratio: 9 / 19.5;
  width: auto;
  height: 100%;
  min-width: 60px;
  min-height: 120px;
  max-width: 100%;
  max-height: 100%;
}
.phone-notch {
  width: min(44px, 24%); height: var(--phone-notch-h); background: #111; border-radius: 8px;
  margin: 0 auto var(--phone-notch-gap); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.phone-notch-dot { width: 4px; height: 4px; border-radius: 50%; background: #333; }
.phone-screen {
  flex: 1; border-radius: var(--screen-radius); min-height: 0;
  background: var(--bg3); overflow: hidden; cursor: cell;
  background-size: cover; background-position: top center; position: relative;
}
.phone-screen > *:not(canvas):not(#inspectorEventLayer) { display: none; }
.tap-ripple {
  position: absolute; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(255,255,255,.5); transform: translate(-50%,-50%) scale(0);
  animation: tapRipple .5s ease-out forwards; pointer-events: none;
}
@keyframes tapRipple { to { transform: translate(-50%,-50%) scale(2.5); opacity: 0; } }

/* Inspector overlay elements */
#inspectorCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; display: none; border-radius: 16px;
  z-index: 10;
}
#inspectorEventLayer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; cursor: crosshair; border-radius: 16px; background: transparent;
  z-index: 11;
}
#inspectorEventLayer.active { pointer-events: auto; }
#inspectorTooltip {
  position: fixed; z-index: 9999; pointer-events: none;
  background: rgba(10,15,25,.92); border: 1px solid rgba(0,180,255,.5);
  border-radius: 6px; padding: 5px 9px; font-size: 11px;
  font-family: var(--mono); color: #e0f0ff; white-space: nowrap;
  display: none; line-height: 1.5; backdrop-filter: blur(4px);
}

/* Screenshots vertical list in sidebar */
.apk-screenshots-list {
  flex: 0 0 auto;
  max-height: 260px;
  overflow-y: auto;
  padding: 2px 0;
  min-height: 96px;
}
.apk-screenshots-list::-webkit-scrollbar { width: 3px; }
.apk-screenshots-list::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 2px; }

/* Right panel */
.apk-right {
  flex: 0 0 min(35%, var(--apk-right-max, 420px));
  min-width: 260px;
  max-width: var(--apk-right-max, 420px);
  display: flex; flex-direction: column; overflow: hidden;
}
.apk-panel-tabs { display: flex; align-items: center; border-bottom: 1px solid var(--line); flex-shrink: 0; overflow-x: auto; scrollbar-width: none; }
.apk-panel-tabs::-webkit-scrollbar { display: none; }
