:root {
  color-scheme: light;
  --canvas: #fbf7ef;
  --surface: #fffdfa;
  --surface-strong: #fff7eb;
  --ink: #1f2320;
  --muted: #6d7068;
  --line: #e8dfd0;
  --accent: #d95632;
  --accent-strong: #b93c24;
  --teal: #0b8f7a;
  --indigo: #4052a6;
  --shadow: 0 18px 54px rgba(67, 55, 34, .12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0;
  background:
    linear-gradient(135deg, rgba(217, 86, 50, .08), transparent 36%),
    linear-gradient(215deg, rgba(11, 143, 122, .08), transparent 42%),
    var(--canvas);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand-copy {
  display: grid;
  gap: 2px;
  line-height: 1.08;
}

.brand-byline {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 750;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 3px;
  padding: 8px;
  color: #fff;
  background: var(--ink);
  border-radius: var(--radius);
}

.brand-mark span {
  display: block;
  background: currentColor;
  border-radius: 999px;
}

.brand-mark span:nth-child(1) {
  height: 12px;
}

.brand-mark span:nth-child(2) {
  height: 20px;
  background: #f5b64a;
}

.brand-mark span:nth-child(3) {
  height: 16px;
  background: #37c5ac;
}

.top-actions,
.metric-row,
.status-strip,
.action-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill,
.status-badge,
.status-muted {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 253, 250, .76);
  font-size: .86rem;
  white-space: nowrap;
}

a.pill {
  text-decoration: none;
}

.logout-link {
  color: var(--accent-strong);
  font-weight: 800;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.dot-ready {
  color: var(--teal);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(430px, .95fr) minmax(420px, 1.05fr);
  gap: 22px;
  align-items: stretch;
}

.intro-panel,
.control-panel,
.transcript-panel,
.queue-panel,
.notes-panel {
  border: 1px solid rgba(232, 223, 208, .9);
  border-radius: var(--radius);
  background: rgba(255, 253, 250, .86);
  box-shadow: var(--shadow);
}

.intro-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 488px;
  padding: clamp(28px, 5vw, 48px);
  overflow: hidden;
  position: relative;
}

.intro-panel::after {
  content: "";
  position: absolute;
  right: 28px;
  bottom: 28px;
  width: 155px;
  height: 88px;
  border: 1px solid rgba(64, 82, 166, .22);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, transparent 12%, rgba(31, 35, 32, .08) 12% 14%, transparent 14% 28%, rgba(31, 35, 32, .08) 28% 30%, transparent 30% 44%, rgba(31, 35, 32, .08) 44% 46%, transparent 46%),
    linear-gradient(180deg, rgba(245, 182, 74, .48), rgba(11, 143, 122, .18));
  opacity: .8;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.03;
}

h1 {
  max-width: 11em;
  font-size: clamp(1.9rem, 2.6vw, 2.35rem);
}

h2 {
  font-size: clamp(1.18rem, 1.8vw, 1.55rem);
}

.intro-copy {
  max-width: 620px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .98rem;
  line-height: 1.38;
}

.metric-row {
  margin-top: auto;
  padding-top: 26px;
}

.metric-row > div {
  min-width: 108px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 247, 235, .68);
}

.metric-row strong,
.metric-row span {
  display: block;
}

.metric-row strong {
  font-size: 1.55rem;
  line-height: 1;
}

.metric-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: .83rem;
}

.control-panel,
.transcript-panel,
.queue-panel,
.notes-panel {
  padding: 18px;
}

.workspace-grid .transcript-panel {
  display: flex;
  flex-direction: column;
}

.workspace-grid > .control-panel,
.workspace-grid > .transcript-panel {
  max-height: calc(100vh - 120px);
  overflow: auto;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  padding: 0 13px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(217, 86, 50, .72);
  box-shadow: 0 0 0 4px rgba(217, 86, 50, .12);
}

.field textarea {
  min-height: 96px;
  padding: 11px 13px;
  resize: vertical;
  line-height: 1.35;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.key-row,
.secret-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: start;
}

.key-status,
.secret-status {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 650;
}

.health-panel {
  display: grid;
  gap: 10px;
  margin: 10px 0 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 244, .82);
}

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

.health-head strong,
.health-head span {
  display: block;
}

.health-head strong {
  font-size: .9rem;
}

.health-head span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 650;
}

.health-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.health-item {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: .76rem;
  font-weight: 780;
}

.health-item.is-ok {
  border-color: rgba(11, 143, 122, .22);
  color: #075f52;
  background: #f1fbf7;
}

.health-item.is-warn {
  border-color: rgba(217, 86, 50, .24);
  color: var(--accent-strong);
  background: #fff4ec;
}

#apiKey[readonly],
.secret-row textarea[readonly] {
  border-color: rgba(11, 143, 122, .28);
  background: #f1fbf7;
}

.secret-row textarea.is-secret {
  -webkit-text-security: disc;
}

.fast-mode {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 10px 0 12px;
  padding: 10px;
  border: 1px solid rgba(11, 143, 122, .28);
  border-radius: var(--radius);
  color: var(--muted);
  background: #f1fbf7;
  font-size: .82rem;
  font-weight: 650;
}

.fast-mode strong,
.fast-mode span span {
  display: block;
}

.fast-mode strong {
  color: #075f52;
  font-size: .9rem;
}

.fast-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  color: #075f52;
  background: #dff8ef;
}

.ghost-button,
.icon-button,
.tab,
.primary-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.ghost-button:hover,
.icon-button:hover,
.tab:hover {
  border-color: rgba(217, 86, 50, .45);
  background: var(--surface-strong);
}

.ghost-button {
  padding: 0 14px;
  font-weight: 800;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: .78rem;
}

.danger-button {
  color: #992b22;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
}

.icon-button:disabled {
  opacity: .45;
}

.source-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 0 0 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f5ecde;
}

.tab {
  min-height: 36px;
  font-weight: 800;
  background: transparent;
}

.tab.is-active {
  color: #fff;
  border-color: var(--ink);
  background: var(--ink);
  box-shadow: 0 8px 22px rgba(31, 35, 32, .16);
}

.source-pane {
  margin-bottom: 10px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 94px;
  border: 1.5px dashed #d7cbb9;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(245, 182, 74, .18), transparent),
    var(--surface);
  text-align: center;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.drop-zone.is-over,
.drop-zone:hover {
  border-color: var(--accent);
  background:
    linear-gradient(135deg, rgba(245, 182, 74, .28), rgba(11, 143, 122, .1)),
    var(--surface);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-art {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 4px;
  border-radius: var(--radius);
  color: var(--accent-strong);
  background: #fff4e3;
}

.drop-title {
  display: block;
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 850;
}

.drop-meta,
.hint {
  display: block;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 600;
}

.hint {
  margin: 10px 0 0;
}

.social-cookie-box {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.social-cookie-head {
  display: grid;
  gap: 3px;
}

.social-cookie-head strong {
  color: var(--ink);
  font-size: .9rem;
}

.social-cookie-head span {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 650;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
  font-size: .88rem;
  font-weight: 800;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  margin-top: 14px;
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 900;
  box-shadow: 0 14px 26px rgba(217, 86, 50, .24);
}

.primary-button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.primary-button:disabled {
  opacity: .7;
  transform: none;
}

.output-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.54fr) minmax(300px, .8fr);
  gap: 22px;
  margin-top: 22px;
}

.transcript-panel,
.queue-panel {
  min-height: 360px;
}

.status-badge {
  color: var(--ink);
  border-color: rgba(64, 82, 166, .22);
  background: #eef0ff;
  font-weight: 850;
}

.status-badge.is-working {
  color: var(--accent-strong);
  background: #fff0e6;
}

.status-badge.is-success {
  color: #075f52;
  background: #e7fff9;
}

.status-badge.is-error {
  color: #992b22;
  background: #fff0ee;
}

.progress-track {
  height: 7px;
  margin: 16px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #eee5d8;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width .35s ease;
}

.transcript-text {
  flex: 1;
  min-height: 230px;
  max-height: 480px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf4;
  color: #252923;
  padding: 18px;
  font: 500 1rem/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.details-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 247, 235, .72);
  font-size: .9rem;
}

.details-panel[hidden] {
  display: none;
}

.details-panel code {
  color: var(--ink);
}

.queue-list {
  display: grid;
  gap: 10px;
}

.notes-panel {
  min-height: 188px;
}

.notes-panel .metric-row {
  padding-top: 0;
}

.queue-item,
.empty-state {
  margin: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.queue-item {
  display: grid;
  gap: 7px;
  text-align: left;
}

.queue-item strong {
  font-size: .95rem;
}

.queue-item span {
  color: var(--muted);
  font-size: .84rem;
}

.queue-item p {
  margin: 0;
  color: var(--ink);
  font-size: .86rem;
  line-height: 1.42;
}

.queue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.empty-state {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100% - 32px));
  padding: 13px 15px;
  border: 1px solid rgba(31, 35, 32, .12);
  border-radius: var(--radius);
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
}

.login-page {
  display: grid;
  min-height: 100vh;
}

.login-shell {
  display: grid;
  place-items: center;
  width: min(100% - 32px, 480px);
  margin: 0 auto;
  padding: 40px 0;
}

.login-card {
  width: 100%;
  padding: clamp(24px, 6vw, 34px);
  border: 1px solid rgba(232, 223, 208, .9);
  border-radius: var(--radius);
  background: rgba(255, 253, 250, .92);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 28px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.login-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(153, 43, 34, .2);
  border-radius: var(--radius);
  color: #992b22;
  background: #fff0ee;
  font-size: .9rem;
  font-weight: 750;
}

@media (max-width: 980px) {
  .workspace-grid,
  .output-grid {
    grid-template-columns: 1fr;
  }

  .intro-panel {
    min-height: auto;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 14px;
  }

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    gap: 7px;
  }

  .workspace-grid {
    gap: 14px;
  }

  .intro-panel,
  .control-panel,
  .transcript-panel,
  .queue-panel,
  .notes-panel {
    padding: 16px;
  }

  h1 {
    font-size: 2.65rem;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .key-row,
  .secret-row {
    grid-template-columns: 1fr;
  }

  .ghost-button {
    min-height: 42px;
  }

  .drop-zone {
    min-height: 156px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }
}
