:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --surface-blue: #eef4ff;
  --text: #172033;
  --text-secondary: #5f6b7e;
  --line: #dce3ed;
  --blue: #246bfd;
  --blue-dark: #1452c9;
  --green: #16845b;
  --green-soft: #e8f6f0;
  --orange: #c56a0a;
  --orange-soft: #fff4df;
  --red: #c0363f;
  --red-soft: #fff0f1;
  --shadow: 0 10px 30px rgba(35, 56, 91, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  border-top: 4px solid var(--blue);
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a, label, input, textarea, summary {
  -webkit-tap-highlight-color: transparent;
}

main {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

main.narrow { width: min(680px, calc(100% - 32px)); }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.75rem; line-height: 1.15; font-weight: 760; }
h2 { margin-bottom: 6px; font-size: 1.35rem; line-height: 1.25; font-weight: 740; }
h3 { margin-bottom: 4px; font-size: 1.08rem; line-height: 1.3; font-weight: 720; }
p { margin-bottom: 12px; }
a { color: var(--blue-dark); }

.eyebrow {
  margin-bottom: 4px;
  color: var(--blue-dark);
  font-size: 0.7rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  line-height: 1.25;
  text-transform: uppercase;
}

.muted, .statusline, .field-note { color: var(--text-secondary); }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 52px;
  margin-bottom: 24px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon { width: 48px; height: 48px; flex: none; border-radius: 11px; }
.brand h1 { white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.statusline { margin: 0; font-size: 0.84rem; white-space: nowrap; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.start-card { overflow: hidden; }
.start-intro { padding: 22px 24px 14px; }
.start-intro h2 { margin: 0; }

.source-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 24px 20px;
  padding: 4px;
  border-radius: 10px;
  background: #e8edf5;
}

.source-choice {
  display: grid;
  min-height: 40px;
  place-items: center;
  border-radius: 7px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 680;
}

.source-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.source-choice.active { background: var(--surface); color: var(--blue-dark); box-shadow: 0 1px 4px rgba(35, 56, 91, 0.16); }
.source-choice:has(input:focus-visible) { outline: 3px solid rgba(36, 107, 253, 0.25); }

.source-form { border-top: 1px solid var(--line); background: var(--surface-soft); }
.form-heading { padding: 16px 24px 8px; }
.form-heading h3 { margin: 0; color: var(--blue-dark); }
.source-form form { display: grid; gap: 0; padding-bottom: 22px; }

.form-group { padding: 12px 24px; }
.form-group + .form-group { border-top: 1px solid var(--line); }

label { display: grid; gap: 7px; font-size: 0.9rem; font-weight: 680; line-height: 1.35; }
.label-title { display: block; }
.label-hint { margin-left: 4px; color: var(--text-secondary); font-size: 0.78rem; font-weight: 520; }
.field-note { margin: 5px 0 0; font-size: 0.78rem; line-height: 1.4; }

input, textarea {
  width: 100%;
  border: 1px solid #cbd5e2;
  border-radius: 9px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
}

input { min-height: 44px; padding: 10px 12px; }
textarea { padding: 11px 12px; resize: vertical; }
.transcript-input { min-height: 176px; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36, 107, 253, 0.15); }
input[type="file"] { padding: 6px; color: var(--text-secondary); background: var(--surface); }
input[type="file"]::file-selector-button {
  min-height: 32px;
  margin-right: 10px;
  border: 0;
  border-radius: 7px;
  padding: 6px 10px;
  background: var(--surface-blue);
  color: var(--blue-dark);
  font: inherit;
  font-weight: 680;
}

.option-grid { margin: 12px 24px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.check { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 58px; padding: 10px 12px; cursor: pointer; }
.check + .check { border-top: 1px solid var(--line); }
.check span { display: grid; order: 1; gap: 1px; }
.check small { color: var(--text-secondary); font-size: 0.76rem; font-weight: 500; }
.check input {
  order: 2;
  width: 51px;
  min-width: 51px;
  height: 31px;
  min-height: 31px;
  margin: 0;
  padding: 2px;
  border: 0;
  border-radius: 16px;
  appearance: none;
  background: #c7ced8;
  cursor: pointer;
  transition: background 0.18s ease;
}
.check input::after { display: block; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); content: ""; transition: transform 0.18s ease; }
.check input:checked { background: var(--blue); }
.check input:checked::after { transform: translateX(20px); }
.source-form > form > .check { margin: 12px 24px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }

button, .download {
  min-height: 46px;
  border: 0;
  border-radius: 9px;
  padding: 11px 16px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
}
button:hover, .download:hover { background: var(--blue-dark); }
button:focus-visible, .download:focus-visible { outline: 3px solid rgba(36, 107, 253, 0.25); outline-offset: 2px; }
button:disabled { cursor: wait; opacity: 0.6; }
.source-form form > button { margin: 18px 24px 0; }
button.secondary, .secondary-link { background: #657187; }
button.danger { background: var(--red); }

.upload-status { min-height: 20px; margin: 10px 24px 0; color: var(--blue-dark); font-size: 0.84rem; font-weight: 650; }
.alert { margin: 12px 24px 0; border-left: 4px solid var(--red); border-radius: 8px; padding: 11px 12px; background: var(--red-soft); color: #8c222a; font-size: 0.88rem; line-height: 1.45; }
.alert.warning { border-color: var(--orange); background: var(--orange-soft); color: #7c4507; }
.hidden, [hidden] { display: none !important; }

.settings-panel { position: relative; }
.settings-panel > summary {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--blue-dark);
  cursor: pointer;
  font-size: 1.25rem;
  list-style: none;
}
.settings-panel > summary::-webkit-details-marker { display: none; }
.settings-panel[open] > summary { background: var(--surface-blue); }
.settings-content { position: absolute; z-index: 20; top: 52px; right: 0; width: min(410px, calc(100vw - 32px)); max-height: min(660px, calc(100vh - 86px)); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--surface); box-shadow: 0 18px 50px rgba(23, 32, 51, 0.2); }
.settings-content h2 { margin-bottom: 16px; }
.settings-content p { font-size: 0.88rem; line-height: 1.45; }
.settings-content form { display: grid; gap: 10px; margin-top: 16px; }
.connection-details { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.connection-details summary { color: var(--blue-dark); cursor: pointer; font-weight: 680; }
.token { display: block; border-radius: 8px; padding: 9px; background: var(--surface-soft); overflow-wrap: anywhere; user-select: all; }
.dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; }
.dot.ok { background: var(--green); }
.dot.warn { background: var(--orange); }

.sessions-card { margin-top: 20px; overflow: hidden; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0; padding: 18px 20px 14px; }
.section-title h2 { margin: 0; }
.session-count { display: grid; min-width: 30px; height: 30px; place-items: center; border-radius: 15px; padding: 0 9px; background: var(--green-soft); color: var(--green); font-size: 0.82rem; font-weight: 760; }
.jobs { margin: 0; padding: 0; list-style: none; }
.jobs li { border-top: 1px solid var(--line); }
.jobs a { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 64px; padding: 10px 18px; color: var(--text); text-decoration: none; }
.jobs strong, .jobs small { display: block; overflow: hidden; text-overflow: ellipsis; }
.jobs strong { font-size: 0.92rem; white-space: nowrap; }
.jobs small { margin-top: 2px; color: var(--text-secondary); font-size: 0.78rem; line-height: 1.35; }
.job-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 8px; background: var(--surface-blue); color: var(--blue-dark); font-weight: 760; }
.job-progress { color: var(--green); font-size: 0.78rem; font-weight: 760; }
.empty-state { margin: 0; border-top: 1px solid var(--line); padding: 22px 20px; color: var(--text-secondary); font-size: 0.9rem; }

.back-link { margin: 0 0 14px; }
.back-link a { font-weight: 680; text-decoration: none; }
.job-card { padding: 24px; }
.job-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.job-heading h1 { max-width: 520px; font-size: 1.45rem; line-height: 1.3; overflow-wrap: anywhere; }
.progress-number { display: flex; align-items: baseline; flex: none; border-radius: 10px; padding: 8px 10px; background: var(--surface-blue); color: var(--blue-dark); font-size: 1.6rem; font-weight: 780; line-height: 1; }
.progress-number small { font-size: 0.8rem; }
.progress-card { margin: 20px 0 16px; border: 1px solid #cbdafc; border-radius: 10px; padding: 18px; background: var(--surface-blue); }
.progress-label { margin-bottom: 3px; color: var(--blue-dark); font-size: 0.7rem; font-weight: 760; letter-spacing: 0.07em; text-transform: uppercase; }
.stage-text { margin-bottom: 14px; font-size: 1rem; font-weight: 690; line-height: 1.4; }
.progress-track { height: 12px; overflow: hidden; border-radius: 6px; background: #d5e1fb; }
.progress-bar { height: 100%; min-width: 2%; border-radius: inherit; background: var(--blue); transition: width 0.5s ease; }
.progress-note { margin: 9px 0 0; font-size: 0.78rem; }
#outputs { display: grid; gap: 8px; margin: 16px 0; }
.manual-step { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 20px; }
.manual-step li + li { margin-top: 6px; }
.manual-step form { display: grid; gap: 12px; }
.job-card > details { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
.job-card > details summary { color: var(--red); cursor: pointer; font-size: 0.88rem; font-weight: 680; }
.job-card > details form { display: grid; gap: 12px; margin-top: 14px; }

.login-card { max-width: 430px; margin: 10vh auto 0; padding: 24px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand img { width: 52px; height: 52px; border-radius: 12px; }
.login-card form { display: grid; gap: 14px; margin-top: 18px; }

@media (max-width: 640px) {
  body { border-top-width: 3px; }
  main, main.narrow { width: 100%; padding: 0 0 32px; }
  .app-header { position: sticky; z-index: 10; top: 0; min-height: 66px; margin: 0; padding: 10px 16px; border-bottom: 1px solid rgba(220, 227, 237, 0.9); background: rgba(243, 246, 251, 0.94); backdrop-filter: blur(16px); }
  .brand-icon { width: 38px; height: 38px; border-radius: 9px; }
  .brand h1 { font-size: 1.28rem; }
  .brand .eyebrow, .statusline { display: none; }
  .settings-panel > summary { width: 42px; height: 42px; }
  .settings-content { position: fixed; top: 70px; right: 12px; left: 12px; width: auto; max-height: calc(100dvh - 84px); }
  .start-card { margin: 16px; }
  .start-intro { padding: 18px 18px 12px; }
  .source-switch { margin: 0 18px 14px; }
  .form-heading { padding: 14px 18px 6px; }
  .form-group { padding: 12px 18px; }
  .option-grid { margin-right: 18px; margin-left: 18px; }
  .source-form > form > .check { margin-right: 18px; margin-left: 18px; }
  .source-form form > button { margin-right: 18px; margin-left: 18px; }
  .upload-status, .alert { margin-right: 18px; margin-left: 18px; }
  .sessions-card { margin: 18px 16px 0; }
  .jobs a { grid-template-columns: auto minmax(0, 1fr); }
  .job-progress { grid-column: 2; }
  .back-link { margin: 0; padding: 15px 16px 10px; }
  .job-card { margin: 0 16px; padding: 20px 18px; }
  .job-heading { gap: 12px; }
  .job-heading h1 { font-size: 1.2rem; }
  .progress-number { font-size: 1.35rem; }
  .progress-card { padding: 16px; }
  .login-card { margin: 16px; padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
