:root {
  --ink: #17181c;
  --ink-soft: #5b6070;
  --ink-faint: #9aa0af;
  --card: #ffffff;
  --field: #f4f5f8;
  --field-border: #e4e6ec;
  --blue: #4b64e6;
  --blue-dark: #3a50c4;
  --coral: #ff6b57;
  --amber: #f5a623;
  --green: #1fa971;
  --radius-card: 28px;
  --radius-field: 14px;
  --shadow-card: 0 24px 60px rgba(10, 12, 30, 0.35);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
}

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

body {
  font-family: var(--font-sans);
  color: var(--ink);
  min-height: 100vh;
  background: #101223;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ---------- background artwork ---------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(160deg, #101223 0%, #1a1c3a 45%, #2a1e3f 100%);
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  animation: drift 24s ease-in-out infinite alternate;
}
.blob-1 { width: 48vw; height: 48vw; background: #4b64e6; top: -18vw; right: -12vw; }
.blob-2 { width: 38vw; height: 38vw; background: #ff6b57; bottom: -16vw; left: -10vw; animation-delay: -8s; }
.blob-3 { width: 26vw; height: 26vw; background: #f5a623; top: 42%; left: 58%; opacity: 0.3; animation-delay: -16s; }

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(4vw, -3vw) scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(10, 12, 30, 0.25);
  padding: 10px 18px;
  margin: 20px auto 0;
  width: min(1100px, calc(100% - 32px));
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
}
.brand-name { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }

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

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--field);
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.badge.loading { background: #fdf3dd; color: #a06b00; }
.badge.recording { background: #e2f6ec; color: var(--green); }
.badge.recording::before { content: "● "; animation: pulse 1.4s infinite; }
.badge.error { background: #fdeae7; color: var(--coral); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 22px;
  width: min(1100px, calc(100% - 32px));
  margin: 26px auto;
  align-items: start;
  flex: 1;
}

.card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

/* ---------- control card ---------- */

.control-card { padding: 30px 28px 26px; }

h1 {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.08;
  margin-bottom: 10px;
}
h1 em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sub {
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.55;
  margin-bottom: 22px;
}

.fields { display: flex; flex-direction: column; gap: 14px; }

.control-group { display: flex; flex-direction: column; gap: 6px; }
.control-group label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

select {
  appearance: none;
  background: var(--field) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235b6070' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--ink);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-field);
  padding: 12px 36px 12px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.15s;
}
select:hover:not(:disabled) { border-color: var(--ink-faint); }
select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
select:disabled { opacity: 0.5; cursor: not-allowed; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-field);
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s;
}
.toggle-row small { color: var(--ink-faint); }
.toggle-row input { accent-color: var(--blue); width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }
.toggle-row:has(input:checked) { color: var(--ink); border-color: var(--blue); }
.toggle-row:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }

/* ---------- buttons ---------- */

button {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  background: var(--field);
  color: var(--ink);
  transition: background 0.15s, color 0.15s, opacity 0.15s, transform 0.1s;
}
button:hover:not(:disabled) { background: #e9ebf1; }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button.primary { background: var(--blue); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--blue-dark); }

button.danger { background: #fff; color: var(--coral); box-shadow: inset 0 0 0 1.5px var(--coral); }
button.danger:hover:not(:disabled) { background: #fdeae7; }

.cta-row { display: flex; gap: 10px; margin-top: 20px; }
.cta-row .primary { flex: 1; padding: 14px 22px; font-size: 0.95rem; }

/* ---------- progress ---------- */

.progress-section { margin-top: 18px; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.83rem; font-weight: 600; margin-bottom: 8px; }
.progress-track { height: 6px; background: var(--field); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--blue); border-radius: 999px; transition: width 0.2s; }
.hint { color: var(--ink-faint); font-size: 0.75rem; margin-top: 8px; }

/* ---------- hint box ---------- */

.hint-box {
  margin-top: 20px;
  border-top: 1px solid var(--field-border);
  padding-top: 14px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.55;
}
.hint-box summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.hint-box summary::-webkit-details-marker { display: none; }
.hint-box summary::after { content: "+"; font-size: 1.1rem; color: var(--ink-faint); }
.hint-box[open] summary::after { content: "–"; }
.hint-box ul { margin: 10px 0 0 18px; display: flex; flex-direction: column; gap: 6px; }
.hint-box em { color: var(--ink); font-style: normal; font-weight: 600; }
.hint-box strong { color: var(--ink); }

/* ---------- transcript card ---------- */

.transcript-card { display: flex; flex-direction: column; overflow: hidden; min-height: 480px; }

.transcript-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px 12px;
  gap: 8px;
  flex-wrap: wrap;
}
.session-info { font-size: 0.78rem; font-weight: 600; color: var(--ink-faint); }
.toolbar-buttons { display: flex; gap: 6px; margin-left: auto; }
.toolbar-buttons button { padding: 8px 16px; font-size: 0.8rem; }

.transcript {
  padding: 6px 24px 12px;
  flex: 1;
  min-height: 260px;
  max-height: 56vh;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.7;
}
.transcript .placeholder { color: var(--ink-faint); font-family: var(--font-serif); font-style: italic; font-size: 1.05rem; }
.transcript .line { margin-bottom: 12px; display: flex; gap: 12px; }
.transcript .ts {
  color: var(--blue);
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  padding-top: 4px;
  flex-shrink: 0;
  user-select: none;
}

.live-line {
  padding: 0 24px 12px;
  color: #a06b00;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
  min-height: 1.3em;
}
.live-line:not(:empty)::after { content: "▋"; animation: pulse 1s infinite; }

.meter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 18px;
}
.meter-label { font-size: 0.68rem; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.08em; }
.meter-canvas { flex: 1; height: 40px; display: block; min-width: 0; }

/* ---------- footer ---------- */

footer {
  text-align: center;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.75rem;
  padding: 0 16px 22px;
}

/* ---------- modal ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 14, 30, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.modal {
  background: var(--card);
  border-radius: 24px;
  max-width: 580px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 26px;
  box-shadow: var(--shadow-card);
}

.modal h2 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 14px; }

.guide-warning {
  background: #fdeae7;
  color: #c2371f;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  line-height: 1.5;
}

.guide-steps {
  margin: 0 0 4px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.89rem;
  line-height: 1.55;
  color: var(--ink-soft);
}
.guide-steps em { color: var(--ink); font-style: normal; font-weight: 600; }
.guide-steps u { text-decoration-color: var(--amber); text-decoration-thickness: 2px; }
.guide-steps li.critical {
  background: #eef1fd;
  border: 1.5px solid var(--blue);
  border-radius: 12px;
  padding: 10px 12px;
  margin-left: -22px;
  list-style-position: inside;
  color: var(--ink);
}
.mock-check { color: var(--blue); font-weight: 700; }

.step-figure {
  margin: 10px auto 2px;
  max-width: 400px;
  background: var(--field);
  border-radius: 14px;
  padding: 12px;
}
.guide-steps li.critical .step-figure { background: #fff; }
.step-figure svg { display: block; width: 100%; height: auto; }
.step-figure svg text { font-family: var(--font-sans); }

.guide-note { color: var(--ink-faint); font-size: 0.8rem; line-height: 1.55; margin-top: 12px; }
.guide-note:empty { display: none; }
.guide-note em { color: var(--ink); font-style: normal; font-weight: 600; }

.guide-skip { margin-top: 14px; font-size: 0.8rem; background: transparent; border: none; padding: 4px 0; }

.modal-buttons { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.87rem;
  font-weight: 500;
  max-width: 90vw;
  box-shadow: 0 12px 32px rgba(10, 12, 30, 0.45);
  z-index: 30;
}
.toast.error { background: var(--coral); }

.hidden { display: none !important; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .transcript-card { min-height: 0; }
  .transcript { max-height: 42vh; min-height: 180px; }
  h1 { font-size: 1.8rem; }
}
