/* ============ Theme tokens ============ */

:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --radius-sm: 7px;
  --topbar-h: 52px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12142b;
  --bg-glow-1: rgba(139, 92, 246, 0.28);
  --bg-glow-2: rgba(236, 72, 153, 0.18);
  --bg-glow-3: rgba(14, 165, 233, 0.16);
  --surface: #1b1e3a;
  --raised: #222647;
  --hover: #2a2f55;
  --border: #2f345e;
  --border-strong: #3d4373;
  --text: #f1f2fb;
  --text-2: #c2c5e3;
  --muted: #9095bf;
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.2);
  --accent-text: #c4b5fd;
  --on-accent: #ffffff;
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.16);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.16);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.16);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.16);
  --teal: #2dd4bf;
  --teal-soft: rgba(45, 212, 191, 0.16);
  --pink: #f472b6;
  --pink-soft: rgba(244, 114, 182, 0.16);
  --phone-frame: #2b2f57;
  --shadow: 0 12px 32px rgba(5, 6, 20, 0.5);
  --log-bg: #0f1126;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f1ff;
  --bg-glow-1: rgba(139, 92, 246, 0.16);
  --bg-glow-2: rgba(236, 72, 153, 0.12);
  --bg-glow-3: rgba(14, 165, 233, 0.12);
  --surface: #ffffff;
  --raised: #faf9ff;
  --hover: #f0edff;
  --border: #e5e0fa;
  --border-strong: #d3cbf3;
  --text: #1e1b3a;
  --text-2: #463f6e;
  --muted: #7a739f;
  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.1);
  --accent-text: #6d28d9;
  --on-accent: #ffffff;
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.1);
  --danger: #e11d48;
  --danger-soft: rgba(225, 29, 72, 0.08);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.1);
  --info: #0284c7;
  --info-soft: rgba(2, 132, 199, 0.1);
  --teal: #0d9488;
  --teal-soft: rgba(13, 148, 136, 0.1);
  --pink: #db2777;
  --pink-soft: rgba(219, 39, 119, 0.1);
  --phone-frame: #2a2550;
  --shadow: 0 12px 32px rgba(76, 52, 160, 0.14);
  --log-bg: #fbfaff;
}

:root {
  --grad: linear-gradient(135deg, #8b5cf6 0%, #d946ef 55%, #ec4899 100%);
  --grad-cool: linear-gradient(135deg, #6366f1 0%, #0ea5e9 100%);
  --grad-success: linear-gradient(135deg, #10b981 0%, #22d3ee 100%);
  --grad-danger: linear-gradient(135deg, #f43f5e 0%, #f97316 100%);
}

/* ============ Base ============ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  background:
    radial-gradient(900px 600px at 85% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(700px 500px at 30% 110%, var(--bg-glow-2), transparent 60%),
    radial-gradient(600px 400px at 0% 20%, var(--bg-glow-3), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

h2 {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.2px;
}

h3 {
  font-size: 15px;
  font-weight: 650;
}

code,
.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

.muted {
  color: var(--muted);
  font-size: 12.5px;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============ Controls ============ */

.control {
  height: 34px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font: inherit;
  font-size: 13.5px;
  min-width: 0;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.control:disabled {
  opacity: 0.6;
}

.control-lg {
  height: 40px;
  font-size: 14px;
}

.control-sub {
  height: 30px;
  font-size: 12.5px;
  background: var(--raised);
}

.btn {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) {
  background: var(--hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-lg {
  height: 40px;
  padding: 0 18px;
  font-size: 14px;
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn-primary {
  background: var(--grad);
  border-color: transparent;
  color: var(--on-accent);
  box-shadow: 0 4px 14px rgba(217, 70, 239, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--grad);
  filter: brightness(1.1);
  box-shadow: 0 6px 18px rgba(217, 70, 239, 0.4);
}

.btn-danger {
  background: var(--grad-danger);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: var(--grad-danger);
  filter: brightness(1.1);
}

.btn-ghost {
  border-style: dashed;
  background: transparent;
  color: var(--text-2);
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
}

.lang-select {
  height: 32px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.lang-select option {
  background: var(--surface, #fff);
  color: var(--text, #111);
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.icon-btn-sm {
  width: 26px;
  height: 26px;
  font-size: 12px;
}

.icon-btn-danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent-text);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.text-btn:hover {
  text-decoration: underline;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.segment {
  height: 28px;
  padding: 0 12px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}

.segment:hover:not(:disabled) {
  color: var(--text);
}

.segment.is-active {
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15), 0 0 0 1px var(--accent-soft);
}

.segment[data-thinking="false"].is-active {
  color: var(--info);
  background: var(--info-soft);
  box-shadow: 0 0 0 1px var(--info-soft);
}

.segment[data-thinking="true"].is-active {
  color: var(--pink);
  background: var(--pink-soft);
  box-shadow: 0 0 0 1px var(--pink-soft);
}

.segment:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.segmented-small .segment {
  height: 24px;
  padding: 0 10px;
  font-size: 12px;
}

.chip-toggle {
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
}

.chip-toggle.is-on {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-text);
}

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

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  font-size: 13px;
  cursor: pointer;
}

/* ============ Top bar ============ */

.topbar {
  position: relative;
  height: var(--topbar-h);
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

/* colourful hairline under the top bar */
.topbar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, #8b5cf6, #d946ef, #ec4899, #f59e0b, #10b981, #0ea5e9);
  opacity: 0.8;
}

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

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(217, 70, 239, 0.4);
  flex-shrink: 0;
}

.brand-name {
  font-weight: 800;
  font-size: 16px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--hover);
  border-radius: 9px;
}

.nav-item {
  height: 30px;
  padding: 0 14px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-item:hover {
  color: var(--text);
}

.nav-item.is-active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 12px rgba(217, 70, 239, 0.35);
}

.nav-count {
  font-size: 11px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.nav-item.is-active .nav-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.topbar-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--hover);
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.dot.is-online {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.dot.is-offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

/* ============ Layout ============ */

.layout {
  flex: 1;
  min-height: 0;
  display: flex;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px;
  overflow-y: auto;
}

.view.is-active {
  display: flex;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.view-tools {
  display: flex;
  gap: 8px;
}

/* ============ Device column ============ */

.device {
  width: 400px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.device-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px 0;
}

.device-bar #deviceSelect {
  flex: 1;
}

/* WebUSB: connect the phone plugged into this computer straight from the browser. */
.webusb-btn {
  flex: 1;
  min-height: 34px;
  padding: 6px 12px;
  border: none;
  border-radius: 10px;
  background: var(--grad);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(217, 70, 239, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.webusb-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(217, 70, 239, 0.35);
}

.webusb-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.webusb-btn.is-connected {
  background: var(--grad-success);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}

.webusb-status {
  margin: 6px 16px 0;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  background: var(--accent-soft);
  color: var(--text);
}

.webusb-status.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.device-bar-secondary {
  padding-top: 8px;
  justify-content: space-between;
}

.phone-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
}

.phone-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Two phones side by side while a run has a second device (B). */
.device.has-second {
  width: 600px;
}

.phone-area.is-dual {
  flex-direction: row;
  align-items: flex-start;
}

.phone-area.is-dual .phone {
  width: 260px;
  height: 520px;
}

.phone {
  position: relative;
  width: 320px;
  height: 640px;
  flex-shrink: 0;
  background: #000;
  border: 8px solid var(--phone-frame);
  border-radius: 34px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.35), 0 20px 50px rgba(139, 92, 246, 0.25), var(--shadow);
}

.phone img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  cursor: crosshair;
  user-select: none;
}

.phone iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: #000;
}

.screen-badge {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.92), rgba(236, 72, 153, 0.92));
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

.phone-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #6b6f78;
  font-size: 13px;
  pointer-events: none;
}

.crosshair {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: rgba(124, 127, 245, 0.15);
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
  z-index: 10;
  animation: target-pulse 1.4s ease-in-out infinite;
}

.crosshair.is-visible {
  display: block;
}

.crosshair::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
}

.crosshair-label {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--accent);
  color: var(--on-accent);
  font: 600 11px var(--mono);
  white-space: nowrap;
}

@keyframes target-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.15); }
}

.touch-ripple {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  z-index: 9;
}

.touch-ripple.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.4);
}

.bounds-box {
  position: absolute;
  border: 2px solid var(--warning);
  background: var(--warning-soft);
  border-radius: 3px;
  pointer-events: none;
  display: none;
  z-index: 8;
}

.bounds-box.is-visible {
  display: block;
}

/* ---------- Model action overlays (tap ripple, type bubble, swipe, back) ---------- */

.action-tap,
.action-swipe,
.action-chip {
  position: absolute;
  pointer-events: none;
  z-index: 11;
}

.action-tap {
  width: 0;
  height: 0;
}

.action-ring,
.action-dot {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.action-ring {
  width: 56px;
  height: 56px;
  border: 2px solid var(--pink);
  box-shadow: 0 0 12px var(--accent), inset 0 0 8px var(--pink-soft);
  opacity: 0;
  animation: action-ring 1.2s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.action-ring:nth-child(2) { animation-delay: 0.18s; border-color: var(--accent); }
.action-ring:nth-child(3) { animation-delay: 0.36s; }

.action-dot {
  width: 12px;
  height: 12px;
  background: radial-gradient(circle, #fff 0 30%, var(--pink) 70%);
  box-shadow: 0 0 0 3px var(--pink-soft), 0 0 14px var(--pink);
  animation: action-dot 1.5s ease-out forwards;
}

.action-label,
.action-chip {
  padding: 3px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--pink));
  color: var(--on-accent);
  font: 600 11px var(--mono);
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.action-label {
  position: absolute;
  left: 18px;
  top: -30px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: action-badge 1.5s ease-out forwards;
}

.action-tap.is-flip-x .action-label { left: auto; right: 18px; }
.action-tap.is-flip-y .action-label { top: 12px; }

/* Typed text bubble: speech-bubble look above the tapped field. */
.action-tap.is-type .action-label {
  left: 50%;
  right: auto;
  top: -46px;
  max-width: 220px;
  padding: 5px 11px;
  border-radius: 10px;
  font: 600 12px var(--font);
  translate: -50% 0;
}

.action-tap.is-type .action-label::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  border: 6px solid transparent;
  border-top-color: var(--pink);
  translate: -50% 0;
}

.action-tap.is-type.is-flip-y .action-label { top: 22px; }
.action-tap.is-type.is-flip-y .action-label::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--accent);
}

/* Centered chips (back, type without coordinates) and the swipe hint. */
.action-chip {
  animation: action-badge 1.5s ease-out forwards;
}

.action-chip.is-center,
.action-swipe {
  left: 50%;
  top: 50%;
  translate: -50% -50%;
}

.action-chip.is-bottom {
  left: 50%;
  bottom: 12%;
  translate: -50% 0;
  padding: 6px 16px;
  font-size: 13px;
}

.action-swipe {
  width: 64px;
  height: 180px;
}

.action-swipe .action-chip {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: 54px -50%;
}

.action-swipe-trail {
  position: absolute;
  left: 50%;
  top: 0;
  width: 6px;
  height: 100%;
  border-radius: 999px;
  translate: -50% 0;
  background: linear-gradient(to bottom, transparent, var(--accent) 45%, var(--pink));
  box-shadow: 0 0 14px var(--pink);
  transform-origin: top;
  animation: action-trail 1.5s ease-out forwards;
}

.action-swipe-arrow {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 22px;
  height: 22px;
  border-right: 4px solid var(--pink);
  border-bottom: 4px solid var(--pink);
  border-radius: 3px;
  filter: drop-shadow(0 0 6px var(--pink));
  translate: -50% 0;
  rotate: 45deg;
  animation: action-arrow 1.5s ease-out forwards;
}

.action-swipe[data-dir="up"] .action-swipe-trail {
  background: linear-gradient(to top, transparent, var(--accent) 45%, var(--pink));
  transform-origin: bottom;
}

.action-swipe[data-dir="up"] .action-swipe-arrow {
  top: 0;
  bottom: auto;
  rotate: -135deg;
}

@keyframes action-ring {
  0% { opacity: 0.95; transform: translate(-50%, -50%) scale(0.2); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); }
}

@keyframes action-dot {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  30%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
}

@keyframes action-badge {
  0% { opacity: 0; transform: translateY(6px) scale(0.92); }
  12%, 80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-4px); }
}

@keyframes action-trail {
  0% { opacity: 0; transform: scaleY(0); }
  40% { opacity: 1; transform: scaleY(1); }
  80% { opacity: 1; transform: scaleY(1); }
  100% { opacity: 0; transform: scaleY(1); }
}

@keyframes action-arrow {
  0% { opacity: 0; transform: translate(-6px, -6px); }
  40%, 80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translate(4px, 4px); }
}

@media (prefers-reduced-motion: reduce) {
  .action-ring { display: none; }
}

.hw-keys {
  display: flex;
  justify-content: center;
  gap: 28px;
  padding: 0 16px 18px;
}

.hw-key {
  width: 44px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text-2);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.hw-key:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ============ Runner ============ */

.run-setup {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.run-target {
  display: flex;
  gap: 8px;
}

/* A batch handed over from the test cases view, waiting for ▶ Başlat in the runner. */
.batch-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--accent-soft), rgba(236, 72, 153, 0.15));
  border: 1px solid var(--accent);
  color: var(--accent-text);
  flex-wrap: wrap;
}

.batch-banner-title {
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.batch-banner-count {
  font-size: 13px;
  opacity: 0.85;
}

.run-target #runTestSelect {
  flex: 1 1 300px;
}

.run-target #runGoalInput {
  flex: 2 1 300px;
}

.control-package {
  flex: 0 1 200px;
  font-family: var(--mono);
  font-size: 13px;
}

.run-device-b-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, var(--accent-soft), var(--pink-soft));
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}

.run-device-b-row .device-b-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-text);
  white-space: nowrap;
}

.run-device-b-row select {
  flex: 1 1 200px;
}

.run-device-b-row .control-package {
  flex: 1 1 160px;
}

.control-phone {
  width: 150px;
  flex: 0 0 auto;
  font-size: 13px;
}

.run-device-b-row .control-note {
  flex: 1.5 1 200px;
  font-size: 13px;
}

.run-options {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.control-language {
  width: auto;
  flex: 0 0 auto;
  cursor: pointer;
}

.control-verify {
  width: auto;
  min-width: 0;
  flex: 0 0 auto;
}

.run-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 12.5px;
}

.run-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.summary-text {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.summary-state {
  font-weight: 650;
  white-space: nowrap;
}

.summary-detail {
  color: var(--text-2);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-summary[data-state="idle"] { border-color: var(--accent-soft); background: linear-gradient(120deg, var(--accent-soft), var(--surface) 60%); }
.run-summary[data-state="running"] { border-color: var(--accent); background: linear-gradient(120deg, var(--accent-soft), var(--pink-soft)); }
.run-summary[data-state="running"] .summary-state { color: var(--accent-text); }
.run-summary[data-state="passed"] { border-color: var(--success); background: linear-gradient(120deg, var(--success-soft), var(--info-soft)); }
.run-summary[data-state="passed"] .summary-state { color: var(--success); }
.run-summary[data-state="failed"] { border-color: var(--danger); background: linear-gradient(120deg, var(--danger-soft), var(--warning-soft)); }
.run-summary[data-state="failed"] .summary-state { color: var(--danger); }

.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--grad);
  border-radius: inherit;
  transition: width 0.4s ease;
}

.run-summary[data-state="passed"] .progress-bar { background: var(--grad-success); }
.run-summary[data-state="failed"] .progress-bar { background: var(--grad-danger); }

/* Timeline */

.timeline {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.timeline-empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.tl-step {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  padding-bottom: 14px;
}

/* connector line */
.tl-step::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 30px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.tl-step:last-child::before {
  display: none;
}

.tl-step[data-status="completed"]::before {
  background: var(--success);
  opacity: 0.5;
}

.tl-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.tl-step[data-status="pending"] .tl-marker {
  border-color: var(--accent-soft);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.tl-step[data-status="active"] .tl-marker {
  border-color: transparent;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 0 0 4px var(--pink-soft), 0 4px 14px rgba(217, 70, 239, 0.45);
}

.tl-step[data-status="completed"] .tl-marker {
  border-color: transparent;
  background: var(--grad-success);
  color: #fff;
}

.tl-step[data-status="failed"] .tl-marker {
  border-color: transparent;
  background: var(--grad-danger);
  color: #fff;
}

.tl-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.tl-step[data-status="pending"] .tl-card {
  border-left-color: var(--accent-soft);
}

.tl-step[data-status="active"] .tl-card {
  border-color: var(--accent);
  border-left-color: #d946ef;
  background: linear-gradient(120deg, var(--accent-soft), var(--surface) 45%);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.18);
}

.tl-step[data-status="completed"] .tl-card {
  border-left-color: var(--success);
}

.tl-step[data-status="failed"] .tl-card {
  border-left-color: var(--danger);
  background: linear-gradient(120deg, var(--danger-soft), var(--surface) 45%);
}

.tl-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 24px;
}

.tl-title {
  font-weight: 600;
  flex: 1;
  min-width: 0;
}

.tl-step[data-status="pending"] .tl-title {
  color: var(--text-2);
}

.tl-state {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.tl-step[data-status="active"] .tl-state { color: var(--accent-text); }
.tl-step[data-status="completed"] .tl-state { color: var(--success); }
.tl-step[data-status="failed"] .tl-state { color: var(--danger); }

.tl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.tl-meta b {
  font-weight: 600;
  color: var(--text-2);
}

/* Attempts inside a step */

.attempts {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.attempt {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attempt-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.attempt-spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.decision {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.action-tag {
  font: 600 11.5px var(--mono);
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.action-tag[data-action="click"],
.action-tag[data-action="tap"] {
  background: var(--info-soft);
  color: var(--info);
}

.action-tag[data-action="type"] {
  background: var(--pink-soft);
  color: var(--pink);
}

.action-tag[data-action="scroll_down"],
.action-tag[data-action="scroll_up"] {
  background: var(--teal-soft);
  color: var(--teal);
}

.action-tag[data-action="back"] {
  background: var(--warning-soft);
  color: var(--warning);
}

.action-tag[data-action="done"],
.action-tag[data-action="verify"] {
  background: var(--success-soft);
  color: var(--success);
}

.action-tag[data-action="fail"] {
  background: var(--danger-soft);
  color: var(--danger);
}

.action-tag[data-action="skip"] {
  background: var(--hover);
  color: var(--muted);
}

.decision-args {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
}

.commentary {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
  padding: 7px 11px;
  border-left: 3px solid var(--accent);
  background: linear-gradient(90deg, var(--accent-soft), transparent);
  border-radius: 0 7px 7px 0;
  animation: fade-in 0.25s ease-out;
}

.thought {
  color: var(--text-2);
  font-style: italic;
  font-size: 13px;
  line-height: 1.5;
  padding: 6px 10px;
  border-left: 3px solid var(--pink);
  background: var(--pink-soft);
  border-radius: 0 6px 6px 0;
  animation: fade-in 0.25s ease-out;
}

/* Live commentary stream while the model is generating */

.live-stream {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-soft);
  background: linear-gradient(135deg, var(--accent-soft), var(--pink-soft));
}

.live-stream-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent-text);
}

.live-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: live-pulse 1.2s ease-out infinite;
}

.live-stream:not(.is-streaming) .live-pulse-dot {
  animation: none;
  background: var(--muted);
}

.live-commentary {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
}

.live-thought {
  color: var(--text-2);
  font-style: italic;
  font-size: 13px;
  line-height: 1.5;
  padding-left: 8px;
  border-left: 2px solid var(--pink);
}

.live-commentary:empty,
.live-thought:empty {
  display: none;
}

.live-stream .is-typing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--pink);
  animation: caret-blink 0.9s steps(1) infinite;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7); }
  70% { box-shadow: 0 0 0 7px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

.verdict {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.verdict.is-passed {
  background: var(--success-soft);
  color: var(--success);
}

.verdict.is-failed {
  background: var(--danger-soft);
  color: var(--danger);
}

/* A step that just passed: its verdict pops and the card glows green for the 0.5s the timeline holds. */
.verdict.is-just-passed {
  animation: verdict-pass 0.5s ease-out;
}

.tl-step.is-just-passed .tl-card {
  animation: step-pass-glow 0.6s ease-out;
}

.tl-step.is-just-passed .tl-marker {
  animation: step-pass-marker 0.5s ease-out;
}

@keyframes verdict-pass {
  0% { transform: scale(0.85); box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 60%, transparent); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); box-shadow: 0 0 0 10px transparent; }
}

@keyframes step-pass-glow {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 55%, transparent); border-color: var(--success); }
  100% { box-shadow: 0 0 0 14px transparent; }
}

@keyframes step-pass-marker {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .verdict.is-just-passed,
  .tl-step.is-just-passed .tl-card,
  .tl-step.is-just-passed .tl-marker {
    animation: none;
  }
}

.notes {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.note {
  font-size: 12.5px;
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--warning-soft);
  color: var(--warning);
}

.note.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.note.is-success {
  background: var(--success-soft);
  color: var(--success);
}

.raw-output summary {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  width: fit-content;
}

.raw-output pre {
  margin-top: 6px;
  padding: 8px 10px;
  max-height: 220px;
  overflow: auto;
  background: var(--log-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: 12px/1.5 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-2);
}


/* Log drawer */

.log-drawer {
  position: relative;
  margin-top: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

.log-drawer summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.log-drawer summary::-webkit-details-marker {
  display: none;
}

.log-drawer summary::before {
  content: '▸';
  color: var(--muted);
  transition: transform 0.15s;
}

.log-drawer[open] summary::before {
  transform: rotate(90deg);
}

.log-count {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
}

.log-tools {
  position: absolute;
  top: 8px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.log-autoscroll {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.log-body {
  height: 260px;
  overflow-y: auto;
  padding: 10px 14px;
  background: var(--log-bg);
  border-top: 1px solid var(--border);
  font: 12px/1.6 var(--mono);
}

.log-entry {
  display: flex;
  gap: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-time {
  color: var(--muted);
  opacity: 0.7;
  flex-shrink: 0;
  user-select: none;
}

.log-info { color: var(--text-2); }
.log-stdout { color: var(--text); }
.log-stderr { color: var(--danger); }
.log-warn { color: var(--warning); }
.log-success { color: var(--success); }
.log-tokens { color: var(--accent-text); }

/* ============ Test cases ============ */

.case-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.case-card {
  --card-color: #8b5cf6;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 16px 14px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--card-color) 12%, var(--surface)), var(--surface) 55%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

/* colour stripe; colour rotates per card */
.case-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--card-color), color-mix(in srgb, var(--card-color) 40%, #ec4899));
}

.case-card:nth-child(6n + 2) { --card-color: #0ea5e9; }
.case-card:nth-child(6n + 3) { --card-color: #10b981; }
.case-card:nth-child(6n + 4) { --card-color: #f59e0b; }
.case-card:nth-child(6n + 5) { --card-color: #ec4899; }
.case-card:nth-child(6n + 6) { --card-color: #14b8a6; }

.case-card:hover {
  border-color: var(--card-color);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--card-color) 25%, transparent);
  transform: translateY(-2px);
}

.case-title {
  font-weight: 650;
  font-size: 14.5px;
}

.case-desc {
  color: var(--text-2);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--card-color, #8b5cf6) 16%, transparent);
  color: var(--text-2);
  white-space: nowrap;
}

.tag.mono {
  font-size: 11.5px;
}

.tag-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.chip-device {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.28), rgba(244, 114, 182, 0.28));
  color: var(--accent-text);
  border: 1px solid rgba(244, 114, 182, 0.35);
  line-height: 1.4;
  vertical-align: middle;
}

/* Folder header inside the case grid */
.case-folder {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
  font-size: 15px;
}

.case-folder:first-child {
  margin-top: 0;
}

.case-steps {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.case-steps li {
  counter-increment: step;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-steps li::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  margin-right: 7px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--card-color) 20%, transparent);
  color: var(--card-color);
  font-size: 10.5px;
  font-weight: 700;
}

.case-steps li.muted::before {
  content: none;
}

.case-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.case-date {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 40px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

/* ============ Inspector table ============ */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--raised);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tr.is-clickable {
  cursor: pointer;
}

.table tr.is-clickable:hover {
  background: var(--hover);
}

.table-empty {
  text-align: center;
  color: var(--muted);
  padding: 28px !important;
}

.table-error {
  color: var(--danger);
}

.empty-text {
  color: var(--muted);
  font-style: italic;
}

.source-badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
}

.source-badge.source-ocr {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.source-badge.source-icon {
  background: var(--warning-soft);
  color: var(--warning);
}

/* ============ Editor sheet ============ */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.45);
  animation: fade-in 0.15s ease-out;
}

.sheet-backdrop.is-center {
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.sheet {
  width: 640px;
  max-width: 100vw;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slide-in 0.2s ease-out;
}

.sheet.sheet-modal {
  width: 440px;
  max-width: 100%;
  height: auto;
  max-height: 90vh;
  border-radius: 14px;
  border: 1px solid var(--border);
  animation: pop-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pop-in {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes slide-in {
  from { transform: translateX(40px); opacity: 0; }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sheet-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.form-error {
  margin-right: auto;
  color: var(--danger);
  font-size: 12.5px;
}

.form-ok {
  color: var(--success);
  font-size: 12.5px;
  font-weight: 600;
}

/* ============ LLM provider modal ============ */

.status-btn {
  border: 1px solid transparent;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.status-btn:hover {
  color: var(--text);
  border-color: var(--accent-soft);
}

.provider-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.provider-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--hover);
  color: var(--text-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.provider-card:hover {
  border-color: var(--accent-soft);
}

.provider-card.is-active {
  border-color: transparent;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--grad-cool) border-box;
  border: 2px solid transparent;
  box-shadow: 0 4px 14px var(--accent-soft);
  color: var(--text);
}

.provider-card.provider-gemini.is-active {
  background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--grad) border-box;
}

.provider-name {
  font-weight: 650;
  font-size: 14px;
}

.provider-model {
  font-size: 12px;
}

.gemini-key-state {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
}

.gemini-key-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gemini-model-row {
  display: flex;
  gap: 8px;
}

.gemini-model-row .control {
  flex: 1;
  min-width: 0;
}

.key-badge {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--grad-success);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
}

.muted.small {
  font-size: 12px;
}

.steps-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.step-editor {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-edit {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--raised);
}

.step-edit-num {
  width: 26px;
  height: 26px;
  margin-top: 4px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
}

.step-edit-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.step-edit-main-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.step-edit-main-row input {
  flex: 1;
}

.control-step-device {
  width: auto;
  min-width: 65px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
}

.step-edit-tools {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ============ Runs history ============ */

.summary-links {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

a.btn {
  text-decoration: none;
}

.runs-table td {
  vertical-align: middle;
}

.run-date {
  white-space: nowrap;
  color: var(--text-2);
  font-size: 12.5px;
}

.run-title {
  font-weight: 600;
}

.run-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 999px;
  color: #fff;
  background: var(--grad-cool);
}

.run-status[data-status="passed"] { background: var(--grad-success); }
.run-status[data-status="failed"] { background: var(--grad-danger); }
.run-status[data-status="aborted"] { background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%); }
.run-status[data-status="running"] { background: var(--grad); animation: run-pulse 1.4s ease-in-out infinite; }

@keyframes run-pulse {
  50% { opacity: 0.6; }
}

.run-video {
  margin-left: 6px;
}

.run-steps-cell {
  font-family: var(--mono);
  white-space: nowrap;
}

.run-pass {
  color: var(--success);
  font-weight: 700;
}

.run-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

.run-noreport {
  font-size: 12px;
  align-self: center;
}

/* Timeline entries open the time travel view once the run is recorded. */
.timeline.is-replayable .tl-card,
.timeline.is-replayable .attempt {
  cursor: zoom-in;
}

.timeline.is-replayable .attempt:hover {
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ============ Time travel (step replay) ============ */

.sheet.replay {
  width: min(1240px, 100%);
  height: min(900px, 94vh);
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  animation: pop-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.replay-header {
  background: linear-gradient(120deg, var(--accent-soft), var(--pink-soft));
  gap: 12px;
}

.replay-heading {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.replay-heading h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.replay-sub {
  font-size: 12.5px;
  color: var(--text-2);
}

.replay-header-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.replay-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.replay-steps {
  list-style: none;
  overflow-y: auto;
  padding: 10px;
  border-right: 1px solid var(--border);
  background: var(--raised);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.replay-steps-empty {
  padding: 12px;
}

.replay-step {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.replay-step:hover {
  background: var(--hover);
}

.replay-step.is-active {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 4px 14px var(--accent-soft);
}

.replay-step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: var(--grad-success);
}

.replay-step[data-passed="false"] .replay-step-num {
  background: var(--grad-danger);
}

.replay-step-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
}

.replay-step-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.replay-main {
  overflow-y: auto;
  padding: 18px 22px;
}

.replay-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.replay-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.replay-step-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.replay-step-badge {
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--grad-success);
}

.replay-step-badge[data-passed="false"] {
  background: var(--grad-danger);
}

.replay-step-heading {
  font-size: 16px;
  font-weight: 700;
}

.replay-shots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.replay-arrow {
  font-size: 26px;
  font-weight: 800;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.replay-shot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.replay-shot figcaption {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.replay-frame {
  position: relative;
  display: inline-block;
  border: 6px solid var(--phone-frame);
  border-radius: 26px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.35), 0 16px 40px rgba(139, 92, 246, 0.22);
}

.replay-frame img {
  display: block;
  height: min(52vh, 520px);
  width: auto;
  cursor: zoom-in;
}

.replay-noshot {
  width: 220px;
  height: min(52vh, 520px);
  display: grid;
  place-items: center;
  border: 2px dashed var(--border-strong);
  border-radius: 26px;
  color: var(--muted);
  font-size: 12.5px;
}

.replay-target {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

.replay-target-ring {
  position: absolute;
  left: -20px;
  top: -20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid #f472b6;
  box-shadow: 0 0 16px 4px rgba(236, 72, 153, 0.7);
  animation: replay-ripple 1.6s ease-out infinite;
}

.replay-target-ring.is-delayed {
  border-color: #fff;
  box-shadow: none;
  animation-delay: 0.8s;
}

.replay-target-dot {
  position: absolute;
  left: -6px;
  top: -6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #ec4899;
  box-shadow: 0 0 10px #ec4899;
}

.replay-target-label {
  position: absolute;
  left: 14px;
  top: 12px;
  font: 700 11px var(--mono);
  color: #fff;
  background: rgba(124, 58, 237, 0.9);
  padding: 2px 6px;
  border-radius: 5px;
  white-space: nowrap;
}

@keyframes replay-ripple {
  from { transform: scale(0.5); opacity: 1; }
  to { transform: scale(2.1); opacity: 0; }
}

.replay-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.replay-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--raised);
}

.replay-block-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-text);
  cursor: default;
}

.replay-cot > summary {
  cursor: pointer;
}

.replay-cot .thought {
  margin-top: 6px;
  white-space: pre-wrap;
}

.replay-footer {
  gap: 10px;
}

.replay-position {
  margin-right: auto;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}

@media (max-width: 860px) {
  .replay-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .replay-steps {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .replay-step {
    width: auto;
    white-space: nowrap;
  }
}

/* ============ Responsive ============ */

@media (max-width: 1200px) {
  .brand-sub {
    display: none;
  }

  .device {
    width: 350px;
  }

  .phone {
    width: 290px;
    height: 580px;
  }
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
  }

  .status {
    display: none;
  }
}

/* ============ Admin Panel & User Management ============ */

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 14px);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.admin-card-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.field-full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.table-toolbar .control {
  max-width: 380px;
  flex: 1;
}

.admin-table td {
  vertical-align: middle;
}

.user-row.is-disabled {
  opacity: 0.65;
  background: rgba(0, 0, 0, 0.02);
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name {
  font-weight: 600;
  color: var(--text);
}

.user-email,
.user-note {
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.badge-admin {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge-runner {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.token-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.04);
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

[data-theme="dark"] .token-cell {
  background: rgba(255, 255, 255, 0.05);
}

.token-code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

.icon-btn-small {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 13px;
  opacity: 0.7;
}

.icon-btn-small:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

.btn-xs {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn-xs:hover {
  background: var(--surface-hover, rgba(0, 0, 0, 0.05));
  border-color: var(--accent);
}

.btn-xs.btn-warn {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.08);
}
.btn-xs.btn-warn:hover {
  background: rgba(245, 158, 11, 0.18);
}

.btn-xs.btn-success {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
}
.btn-xs.btn-success:hover {
  background: rgba(16, 185, 129, 0.18);
}

.btn-xs.btn-danger {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
}
.btn-xs.btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
}

.dates-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
}

.actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}


/* ---------- Xray import ---------- */

.dot.is-warning {
  background: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-soft);
}

.xray-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  margin-top: 16px;
}

.sheet.jira-popup {
  width: min(1320px, 100%);
  max-height: 96vh;
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  animation: pop-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.jira-popup-body {
  flex: 1;
  min-height: 0;
  padding: 16px;
  display: flex;
  justify-content: center;
  overflow: auto;
}

.jira-popup-footer {
  justify-content: space-between;
  flex-wrap: wrap;
}

.jira-screen {
  width: min(100%, calc((96vh - 150px) * 1.6));
  border-radius: 10px;
  overflow: hidden;
  background: var(--hover);
  aspect-ratio: 1280 / 800;
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.18);
  outline: none;
  transition: box-shadow 0.15s ease;
}

.jira-screen:focus-within {
  box-shadow: 0 0 0 3px var(--accent), 0 8px 30px rgba(139, 92, 246, 0.3);
}

.jira-screen iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.xray-fetch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.xray-fetch .control {
  flex: 1 1 200px;
  min-width: 0;
}

.xray-summary {
  display: grid;
  gap: 6px;
  margin: 14px 0 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(236, 72, 153, 0.1));
}

.xray-title {
  font-weight: 600;
}

.xray-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.xray-steps td {
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
}

.xray-steps td:first-child {
  width: 36px;
}

/* ---------- Performance (perf.js) ---------- */

.perf-toggle {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--hover);
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}

.perf-toggle:hover:not(:disabled) {
  color: var(--text);
}

.perf-toggle.is-active {
  color: var(--teal);
  background: var(--teal-soft);
  border-color: var(--teal);
}

.perf-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.perf-strip,
.perf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.perf-strip {
  margin: 8px 0 2px;
}

.perf-chips {
  margin-top: 8px;
}

.perf-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--teal-soft);
  color: var(--teal);
  white-space: nowrap;
}

.perf-chip.is-warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.perf-chip.is-bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.perf-chip.is-muted {
  background: var(--hover);
  color: var(--muted);
}

.run-perf {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--teal);
}

.run-perf.is-bad {
  color: var(--danger);
  font-weight: 700;
}

/* ---------- Goal mode prompt editor ---------- */

.btn-prompts {
  border-color: var(--accent-soft);
  color: var(--accent-text);
}

.sheet.sheet-modal.sheet-prompts {
  width: 860px;
}

.prompt-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prompt-tab {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.prompt-tab:hover {
  border-color: var(--accent);
}

.prompt-tab.is-active {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
}

.prompt-tab.is-custom::after {
  content: " ●";
  color: #f59e0b;
}

.prompt-tab.is-active.is-custom::after {
  color: #fde68a;
}

.prompt-text {
  min-height: 46vh;
  resize: vertical;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.prompt-badge {
  margin-right: auto;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  font-size: 12px;
}

@media (max-width: 640px) {
  .prompt-text {
    min-height: 50vh;
  }
}

.goal-toggle.is-active {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.thinking-toggle {
  min-width: 38px;
  padding: 0 9px;
  font-size: 16px;
}

.thinking-toggle.is-active {
  color: #db2777;
  background: rgba(236, 72, 153, 0.14);
  border-color: #ec4899;
}

/* ---------- Batch runs (batches.js) ---------- */

.batch-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--accent-soft);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(236, 72, 153, 0.06));
}

.batch-heading {
  margin: 0 0 4px;
  font-size: 15px;
}

.batch-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(80px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.batch-row:hover,
.batch-row.is-open {
  box-shadow: 0 0 0 1px var(--accent);
}

.batch-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--hover);
  overflow: hidden;
}

.batch-progress-bar {
  height: 100%;
  background: var(--grad);
  transition: width 0.4s ease;
}

.batch-counts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.batch-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--hover);
  color: var(--muted);
}

.batch-chip.is-passed { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.batch-chip.is-bug { background: rgba(244, 63, 94, 0.15); color: #f43f5e; }
.batch-chip.is-qpilot { background: rgba(139, 92, 246, 0.15); color: var(--accent-text); }
.batch-chip.is-skip { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.batch-chip.is-running { background: rgba(14, 165, 233, 0.15); color: #0ea5e9; }

.batch-detail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0 8px;
}

.batch-detail-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.case-folder .batch-start {
  margin-left: auto;
}

@media (max-width: 640px) {
  .batch-row {
    grid-template-columns: 1fr;
  }
}

.prompt-tab-add {
  border-style: dashed;
  color: var(--accent-text);
}

/* The start button pulses once when a test case is opened in the runner. */
#startRunBtn.is-attention {
  animation: start-attention 1.2s ease-out 2;
}

@keyframes start-attention {
  0% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.65); }
  100% { box-shadow: 0 0 0 14px rgba(236, 72, 153, 0); }
}

/* Scenario folder tree: "QABR · More · Light" nests as QABR ▸ More ▸ Light. */
.case-tree {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tree-node {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tree-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tree-header .batch-start {
  margin-left: auto;
}

.tree-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-soft), var(--pink-soft));
  color: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tree-toggle:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.tree-toggle:disabled {
  cursor: default;
}

.tree-caret {
  width: 12px;
  color: var(--accent-text);
}

.tree-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 18px;
  border-left: 2px solid var(--accent-soft);
  margin-left: 10px;
}

.tree-more {
  align-self: flex-start;
}

/* Picking scenarios for a batch: a checkbox on every card and folder, and a bar above the tree. */
.case-select {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  accent-color: #ec4899;
  cursor: pointer;
}

.case-card > .case-select {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
}

.case-card.is-selected {
  outline: 2px solid #ec4899;
  outline-offset: -2px;
}

.selection-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(236, 72, 153, 0.35)), var(--surface);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.25);
}

.selection-bar[hidden] {
  display: none;
}

.selection-count {
  font-weight: 700;
  margin-right: auto;
}

.case-card .case-title {
  padding-right: 24px;
}

/* iPhone connection guide */
.ios-guide-btn {
  flex: 1;
  min-height: 32px;
}

.sheet-modal.ios-guide {
  width: min(760px, 100%);
}

.guide-section {
  margin: 4px 0 -4px;
  font-size: 15px;
}

.guide-step {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-step h4 {
  margin: 0;
  font-size: 13px;
}

.guide-phone {
  margin: 0;
  font-size: 13px;
}

.guide-cmd {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.guide-cmd pre {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2, rgba(127, 127, 127, 0.08));
  white-space: pre-wrap;
  word-break: break-all;
}
