:root {
  --surface: #ffffff;
  --app-bg: #f6f5f3;
  --hairline: rgba(0, 0, 0, 0.08);
  --card-shadow: 0 1px 2px rgba(24, 20, 16, 0.035), 0 12px 28px -20px rgba(24, 20, 16, 0.14);
  --text: #1c1b19;
  --text-strong: #2f2e2e;
  --text-muted: rgba(0, 0, 0, 0.55);
  --radius-card: 12px;
  --radius-control: 10px;
  --radius-pill: 20px;
  --brand: #9f6846;
  --brand-soft: rgba(164, 153, 133, 0.18);
  --brand-ink: #2f2e2e;
  --error-fg: #a5443a;
  --error-bg: #f7e3e0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--app-bg);
  color: var(--text);
}

.shell {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar .brand {
  font-weight: 600;
  color: var(--brand-ink);
  font-size: 13px;
  text-align: right;
}

.topbar .brand small {
  display: block;
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
}

/* Progress + clock — kept in the top-left corner and always visible
 * (sticky header) so the candidate can track time without scrolling up. */
.progress-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 15px;
  min-width: 56px;
  text-align: center;
}

.timer.low {
  background: var(--error-bg);
  color: var(--error-fg);
}

/* The per-chapter countdown — a second, smaller clock next to the overall
 * one. Candidates couldn't previously see how much time was left in the
 * CURRENT chapter (only the whole-interview total), so a chapter ending
 * came as a surprise mid-answer. This makes it visible; ".low" (shared with
 * the overall timer) kicks in well before a chapter's own time runs out,
 * not just in the interview's last two minutes. */
.timer-station {
  font-size: 12px;
  padding: 4px 10px;
  min-width: 44px;
  font-weight: 600;
  opacity: 0.9;
}

.timer-station::before {
  content: "Chapter ";
  font-weight: 400;
  font-size: 10px;
  opacity: 0.8;
}

/* Shown in place of the numeric countdown while the app prepares the next
 * station (its opening line is being generated) — the clock is paused for
 * this stretch, so we swap in an hourglass rather than let it keep ticking. */
.timer.preparing {
  background: var(--brand-soft);
  color: var(--brand-ink);
  animation: hourglass-pulse 1.1s ease-in-out infinite;
}

@keyframes hourglass-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 16px;
}

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

.card h1 {
  font-size: 20px;
  margin: 0 0 12px;
}

.card p {
  line-height: 1.55;
  color: var(--text-strong);
  font-size: 14.5px;
}

.lang-block {
  border-top: 1px solid var(--hairline);
  padding-top: 14px;
  margin-top: 14px;
}

.lang-block:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.lang-block h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.lang-choices {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.lang-choices button {
  flex: 1;
}

.pill-button {
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-control);
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.pill-button.selected {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0;
  font-size: 14px;
}

.consent-row input {
  margin-top: 3px;
}

.primary-button {
  width: 100%;
  border: none;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-control);
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.primary-button:disabled {
  background: #cfc7bd;
  cursor: not-allowed;
}

.text-link-button {
  background: none;
  border: none;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 13px;
  padding: 8px 0 0;
  display: block;
  width: 100%;
  text-align: center;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px;
  scroll-behavior: smooth;
}

.bubble {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 14.5px;
  white-space: pre-wrap;
}

.bubble.hugo {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-bottom-left-radius: 4px;
}

.bubble.candidate {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}

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

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

.composer textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14.5px;
  min-height: 44px;
  max-height: 140px;
}

.composer-buttons {
  display: flex;
  gap: 8px;
}

.composer-buttons button {
  flex: 1;
  border: none;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-control);
  padding: 0 18px;
  height: 40px;
  font-weight: 600;
  cursor: pointer;
}

.composer-buttons button:disabled {
  background: #cfc7bd;
  cursor: not-allowed;
}

.record-button {
  background: var(--surface);
  border: 1px solid var(--brand);
  color: var(--brand-ink);
}

/* Emphasized when the candidate chose voice recording at the mic-check
 * step — text/typing still always works too, this is just which button
 * looks primary by default. */
.record-button.preferred {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.composer-buttons button.secondary {
  background: var(--surface);
  border: 1px solid var(--brand);
  color: var(--brand-ink);
}

.record-button.recording {
  background: var(--error-bg);
  border-color: var(--error-fg);
  color: var(--error-fg);
  animation: record-pulse 1.4s ease-in-out infinite;
}

@keyframes record-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
  }
}

.station-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

.mic-preview {
  min-height: 56px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.center-message {
  text-align: center;
  margin: auto;
  max-width: 420px;
}

.hidden {
  display: none !important;
}

.error-banner {
  background: var(--error-bg);
  color: var(--error-fg);
  border-radius: var(--radius-control);
  padding: 10px 14px;
  font-size: 13.5px;
}

/* Brand accents — same values as the Arcto Data Room's [data-brand] scheme,
 * set on <html data-brand="..."> per the candidate's session (admin picks
 * this when generating the link). */
[data-brand="arcto"] {
  --brand: #9f6846;
  --brand-soft: rgba(164, 153, 133, 0.18);
  --brand-ink: #2f2e2e;
}

[data-brand="tuulikarhu"] {
  --brand: #1b67d4;
  --brand-soft: rgba(27, 103, 212, 0.12);
  --brand-ink: #193240;
}

[data-brand="aurinkokarhu"] {
  --brand: #57634c;
  --brand-soft: rgba(241, 202, 132, 0.3);
  --brand-ink: #41473c;
}
