:root {
  --bg-outer: #e7e5de;
  --paper: #f3f2ee;
  --paper-subtle: #eceae3;
  --card: #ffffff;
  --card-elevated: #faf9f6;
  --ink: #111111;
  --ink-secondary: #4a4945;
  --ink-muted: #85837c;
  --line: #e2e0d8;
  --line-strong: #cbc8be;

  --accent: #111111;
  --accent-fg: #ffffff;
  --pill-bg: #f1efe9;

  --green: #15803d;
  --green-bg: #e8f5ee;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #b91c1c;
  --red-bg: #fee2e2;

  --header-glass: rgba(243, 242, 238, 0.88);
  --tabbar-glass: rgba(255, 255, 255, 0.92);
  --shadow-card: 0 2px 10px rgba(17, 17, 17, 0.04);
  --shadow-shell: 0 22px 60px rgba(17, 17, 17, 0.14);

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-pill: 999px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --bg-outer: #09090b;
  --paper: #111113;
  --paper-subtle: #19191d;
  --card: #18181c;
  --card-elevated: #202026;
  --ink: #f5f5f4;
  --ink-secondary: #b8b7b2;
  --ink-muted: #7c7b76;
  --line: #2a2a30;
  --line-strong: #3c3c45;

  --accent: #f5f5f4;
  --accent-fg: #111113;
  --pill-bg: #232329;

  --green: #4ade80;
  --green-bg: rgba(34, 197, 94, 0.16);
  --amber: #fbbf24;
  --amber-bg: rgba(245, 158, 11, 0.16);
  --red: #f87171;
  --red-bg: rgba(239, 68, 68, 0.16);

  --header-glass: rgba(17, 17, 19, 0.88);
  --tabbar-glass: rgba(24, 24, 28, 0.94);
  --shadow-card: 0 4px 18px rgba(0, 0, 0, 0.28);
  --shadow-shell: 0 24px 70px rgba(0, 0, 0, 0.65);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-outer);
  color: var(--ink);
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

code, pre, .mono, .mono-index, .mono-counter, .mono-label {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

button, input, textarea {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* ===== MOBILE SHELL FRAME ===== */
.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* On larger desktop screens, frame cleanly like a flagship mobile app */
@media (min-width: 540px) {
  body {
    padding: 16px 12px;
  }
  .app-shell {
    min-height: calc(100dvh - 32px);
    border-radius: 30px;
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-shell);
    overflow: clip;
  }
}

/* Optional wide split mode on desktop when user toggles layout */
@media (min-width: 960px) {
  .app-shell.wide-mode {
    max-width: 1060px;
  }
  .app-shell.wide-mode .mobile-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
    padding-bottom: 28px;
  }
  .app-shell.wide-mode #panel-create,
  .app-shell.wide-mode #panel-jobs {
    display: block !important;
  }
  .app-shell.wide-mode #panel-account.active {
    grid-column: 1 / -1;
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
  }
  .app-shell.wide-mode #panel-account.active ~ * {
    display: none;
  }
}

@media (max-width: 959px) {
  #layout-toggle-btn {
    display: none;
  }
}

/* ===== STICKY TOP HEADER ===== */
.mobile-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--header-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-sub {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink-muted);
  white-space: nowrap;
}

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

.live-dot.offline {
  background: var(--red);
}

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

.quota-chip {
  height: 32px;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--card);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  max-width: 158px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.quota-chip:active {
  transform: scale(0.96);
}

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

.quota-dot.ready {
  background: var(--green);
}

.quota-dot.error {
  background: var(--red);
}

.icon-pill {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  display: inline-grid;
  place-items: center;
  padding: 0;
  transition: transform 0.12s ease;
}

.icon-pill:active {
  transform: scale(0.93);
}

.icon-pill svg {
  width: 16px;
  height: 16px;
}

/* ===== MAIN CONTENT AREA ===== */
.mobile-main {
  flex: 1;
  padding: 14px 14px calc(86px + var(--safe-bottom));
}

.tab-panel {
  display: none;
  animation: fadeSlideUp 0.18s ease-out;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeSlideUp {
  from {
    opacity: 0.4;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== MISSING KEY ALERT BANNER ===== */
.key-alert-banner {
  width: 100%;
  margin-bottom: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(180, 83, 9, 0.35);
  background: var(--amber-bg);
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.key-alert-icon {
  font-size: 18px;
}

.key-alert-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  font-size: 12px;
}

.key-alert-copy strong {
  font-size: 13px;
  color: var(--amber);
}

.key-alert-copy span {
  color: var(--ink-secondary);
}

.key-alert-arrow {
  font-weight: 700;
  color: var(--amber);
}

/* ===== STUDIO CARD ===== */
.studio-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.card-eyebrow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mono-index {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  text-transform: uppercase;
}

.cost-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--ink-secondary);
  border: 1px solid var(--line);
}

/* ===== FORM FIELDS ===== */
.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.field-label {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}

.req-star {
  color: var(--red);
}

.optional-tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  margin-left: 6px;
}

.prompt-meta-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.text-action-btn {
  border: none;
  background: none;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
}

.mono-counter {
  font-size: 12px;
  color: var(--ink-muted);
}

.prompt-box-wrap {
  background: var(--card-elevated);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.prompt-box-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.07);
}

#prompt-input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 12px 13px 8px;
  /* 16px prevents iOS Safari from auto-zooming on focus */
  font-size: 16px;
  line-height: 1.48;
  resize: vertical;
  min-height: 104px;
  outline: none;
}

#prompt-input::placeholder {
  color: var(--ink-muted);
  font-size: 14.5px;
}

.prompt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 8px;
  border-top: 1px dashed var(--line);
  background: var(--paper);
}

.mini-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-secondary);
  cursor: pointer;
  user-select: none;
}

.mini-switch input {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  margin: 0;
}

.char-hint {
  font-size: 11px;
  color: var(--ink-muted);
}

/* Sample Prompt Chips */
.sample-chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 0 2px;
  scrollbar-width: none;
}

.sample-chips::-webkit-scrollbar {
  display: none;
}

.sample-chip {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-secondary);
  border-radius: var(--radius-pill);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease;
}

.sample-chip:active {
  transform: scale(0.96);
  background: var(--paper-subtle);
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

/* ===== SEGMENTED CONTROLS (Matches Screenshot 1) ===== */
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.control-row:last-of-type {
  margin-bottom: 0;
}

.control-row-wrap {
  flex-wrap: wrap;
}

.control-label {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.25;
  color: var(--ink);
  flex-shrink: 0;
}

.label-sub {
  font-size: 13px;
  font-weight: 700;
}

.segmented-pill {
  display: inline-flex;
  align-items: center;
  background: var(--pill-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
  max-width: 100%;
}

.ratio-scroll {
  overflow-x: auto;
  scrollbar-width: none;
}

.ratio-scroll::-webkit-scrollbar {
  display: none;
}

.duration-pill {
  flex: 1;
  max-width: 268px;
  justify-content: space-between;
}

.duration-pill .seg-btn {
  flex: 1;
  padding: 7px 8px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-weight: 600;
  font-size: 13.5px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, transform 0.1s ease;
}

.seg-btn:active {
  transform: scale(0.96);
}

.seg-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}

.seg-emoji {
  font-size: 14px;
  line-height: 1;
}

/* Aspect Ratio Frame Glyphs */
.frame-glyph {
  display: inline-block;
  border: 1.6px solid currentColor;
  border-radius: 2px;
  flex-shrink: 0;
}

.frame-glyph.landscape {
  width: 14px;
  height: 9px;
}

.frame-glyph.portrait {
  width: 9px;
  height: 14px;
}

.frame-glyph.square {
  width: 11px;
  height: 11px;
}

.frame-glyph.r43 {
  width: 13px;
  height: 10px;
}

.frame-glyph.r34 {
  width: 10px;
  height: 13px;
}

/* ===== REFERENCE IMAGE UPLOAD ===== */
.ref-header {
  margin-bottom: 9px;
}

.upload-dropzone {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--paper);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-dropzone.dragover {
  border-color: var(--accent);
  background: var(--paper-subtle);
}

.upload-dropzone input[type="file"] {
  display: none;
}

.upload-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.upload-icon-box svg {
  width: 18px;
  height: 18px;
}

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

.upload-text strong {
  font-size: 13.5px;
  font-weight: 700;
}

.upload-text span {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.browse-pill {
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  background: var(--card);
  border: 1px solid var(--line-strong);
  font-size: 12.5px;
  font-weight: 600;
  flex-shrink: 0;
}

.autocrop-bar {
  margin-top: 9px;
  padding: 8px 11px;
  border-radius: var(--radius-md);
  background: var(--paper);
  border: 1px solid var(--line);
}

.ref-image-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.ref-image-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line-strong);
}

.ref-image-item img {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--paper);
}

.ref-image-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ref-image-name {
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ref-image-size {
  font-size: 12px;
  color: var(--ink-muted);
}

.ref-remove-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 19px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.ref-remove-btn:active {
  background: var(--paper);
}

/* ===== ERROR BOX & SUBMIT BUTTON ===== */
.form-error-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--red-bg);
  color: var(--red);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid rgba(185, 28, 28, 0.25);
}

.primary-cta {
  width: 100%;
  margin-top: 14px;
  height: 52px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(17, 17, 17, 0.16);
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.primary-cta:active:not(:disabled) {
  transform: scale(0.98);
}

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

.compact-cta {
  margin-top: 0;
  height: 42px;
  font-size: 13.5px;
  padding: 0 18px;
}

.secondary-pill-btn {
  height: 42px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.secondary-pill-btn:active {
  transform: scale(0.97);
}

/* Policy Accordion */
.policy-details {
  margin-top: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 11px 14px;
  font-size: 12px;
  color: var(--ink-secondary);
}

.policy-details summary {
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.policy-details summary::after {
  content: '▾';
  font-size: 13px;
  color: var(--ink-muted);
}

.policy-details[open] summary::after {
  content: '▴';
}

.policy-list {
  margin: 10px 0 2px;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  line-height: 1.45;
}

/* ===== TAB 2: OUTPUT / JOBS (Matches Screenshot 2) ===== */
.output-card {
  display: flex;
  flex-direction: column;
}

.output-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.output-heading {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.output-right-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.sync-pill {
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--paper);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.sync-pill svg {
  width: 13px;
  height: 13px;
}

.sync-pill.spinning svg {
  animation: spin 0.8s linear infinite;
}

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

.filter-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 12px 0 10px;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 600;
}

.filter-chip.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.empty-jobs {
  text-align: center;
  padding: 36px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-icon-circle {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.empty-icon-circle svg {
  width: 24px;
  height: 24px;
}

.empty-jobs p {
  margin: 0 0 6px;
  font-size: 12.5px;
  color: var(--ink-muted);
  max-width: 280px;
}

/* Job Card (Matches Screenshot 2 closely) */
.jobs-feed {
  display: grid;
  gap: 12px;
  margin-top: 2px;
}

.job-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.job-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.job-title-line {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  flex: 1;
}

.job-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.job-prompt-text {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.status-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-pill.done {
  background: var(--green-bg);
  color: var(--green);
}

.status-pill.queued,
.status-pill.generating,
.status-pill.sending,
.status-pill.checking {
  background: var(--amber-bg);
  color: var(--amber);
}

.status-pill.queued .dot,
.status-pill.generating .dot,
.status-pill.sending .dot {
  animation: pulseDot 1.2s ease-in-out infinite;
}

.status-pill.failed,
.status-pill.connection {
  background: var(--red-bg);
  color: var(--red);
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.job-metrics-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: var(--ink-secondary);
}

.job-metrics-row strong {
  color: var(--ink);
  font-weight: 700;
}

/* Media Stage */
.job-media-stage {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000000;
  max-height: 440px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.job-media-stage video {
  width: 100%;
  max-height: 440px;
  display: block;
  background: #000000;
}

.job-media-stage img {
  width: 100%;
  max-height: 440px;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
}

/* Rendering Shimmer Placeholder */
.job-rendering-box {
  padding: 22px 14px;
  border-radius: 12px;
  background: var(--card);
  border: 1px dashed var(--line-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.shimmer-bar {
  width: 100%;
  max-width: 220px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--line);
  overflow: hidden;
  position: relative;
}

.shimmer-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  width: 45%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  animation: slideBar 1.4s ease-in-out infinite;
}

@keyframes slideBar {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(230%); }
}

.job-rendering-box span {
  font-size: 12px;
  color: var(--ink-muted);
}

.job-id-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.job-uuid {
  font-size: 11.5px;
  color: var(--ink-muted);
  word-break: break-all;
  line-height: 1.35;
}

.copy-uuid-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.copy-uuid-btn:active {
  background: var(--card);
  border-color: var(--line);
}

.copy-uuid-btn svg {
  width: 16px;
  height: 16px;
}

.job-error-msg {
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--red-bg);
  color: var(--red);
  font-size: 12px;
  font-weight: 500;
}

.job-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.action-btn {
  height: 36px;
  padding: 0 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.action-btn.icon-only {
  padding: 0 11px;
}

.action-btn svg {
  width: 15px;
  height: 15px;
}

.action-btn:active {
  transform: scale(0.96);
}

.output-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-secondary);
}

.footer-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.footer-status-dot.busy {
  background: var(--amber);
  animation: pulseDot 1.2s infinite;
}

/* ===== TAB 3: ACCOUNT & API KEY ===== */
.card-desc {
  margin: 6px 0 14px;
  font-size: 13px;
  color: var(--ink-secondary);
}

.server-key-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: var(--green-bg);
  border: 1px solid rgba(21, 128, 61, 0.25);
  margin-bottom: 14px;
  font-size: 12.5px;
}

.status-dot-ok {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  margin-top: 5px;
  flex-shrink: 0;
}

.server-key-notice p {
  margin: 3px 0 0;
  color: var(--ink-secondary);
  font-size: 12px;
}

.key-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.key-input-group {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--card-elevated);
  padding-right: 6px;
}

.key-input-group:focus-within {
  border-color: var(--accent);
}

#api-key-input,
#passcode-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 11px 12px;
  font-size: 16px;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
}

.passcode-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.passcode-wrap input {
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--card-elevated);
}

.icon-inline-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  display: grid;
  place-items: center;
}

.icon-inline-btn svg {
  width: 18px;
  height: 18px;
}

.paste-inline-btn {
  height: 30px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  font-size: 12px;
  font-weight: 700;
}

.key-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.key-btn-row .primary-cta {
  flex: 1;
}

/* Quota Dashboard */
.quota-dashboard {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.quota-hero {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--paper);
  border: 1px solid var(--line);
}

.quota-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mono-label {
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
}

.quota-big-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 6px;
}

.quota-sub-value {
  font-size: 12.5px;
  color: var(--ink-secondary);
  margin-bottom: 12px;
}

.quota-progress-track {
  width: 100%;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--line);
  overflow: hidden;
}

.quota-progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width 0.35s ease;
}

.quota-meta-foot {
  margin-top: 9px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-muted);
}

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

.stat-box {
  padding: 12px;
  border-radius: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.stat-val {
  font-size: 19px;
  font-weight: 800;
}

.green-text {
  color: var(--green);
}

.stat-hint {
  font-size: 11px;
  color: var(--ink-secondary);
}

/* ===== STICKY BOTTOM MOBILE TAB BAR ===== */
.bottom-tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  z-index: 60;
  padding: 6px 12px calc(8px + var(--safe-bottom));
  background: var(--tabbar-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

@media (min-width: 540px) {
  .bottom-tabbar {
    bottom: 16px;
    border-radius: 0 0 29px 29px;
    border-left: 1px solid var(--line-strong);
    border-right: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
  }
}

@media (min-width: 960px) {
  .app-shell.wide-mode .bottom-tabbar {
    max-width: 1060px;
  }
}

.tab-item {
  border: none;
  background: transparent;
  padding: 6px 4px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--ink-muted);
  transition: color 0.15s ease, background 0.15s ease;
}

.tab-item.active {
  color: var(--ink);
  background: var(--paper);
}

.tab-icon {
  position: relative;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
}

.tab-icon svg {
  width: 21px;
  height: 21px;
}

.tab-badge {
  position: absolute;
  top: -4px;
  right: -10px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.tab-badge.running {
  background: var(--amber);
  color: #ffffff;
}

.tab-label {
  font-size: 11px;
  font-weight: 700;
}

/* ===== LIGHTBOX MODAL ===== */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 540px) {
  .lightbox-backdrop {
    align-items: center;
    padding: 20px;
  }
}

.lightbox-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 16px 16px calc(18px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

@media (min-width: 540px) {
  .lightbox-sheet {
    border-radius: 24px;
    padding: 18px;
  }
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lightbox-title-wrap {
  display: flex;
  flex-direction: column;
}

.lightbox-title-wrap span {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.lightbox-body {
  border-radius: 14px;
  overflow: hidden;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-body video,
.lightbox-body img {
  width: 100%;
  max-height: 58dvh;
  object-fit: contain;
  display: block;
}

.lightbox-prompt {
  margin: 0;
  font-size: 13px;
  color: var(--ink-secondary);
  line-height: 1.45;
}

.lightbox-actions {
  display: flex;
  gap: 10px;
}

.lightbox-actions > * {
  flex: 1;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: calc(14px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--paper);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  animation: toastIn 0.2s ease-out;
  text-align: center;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

