:root {
  color-scheme: light;
  --ink: #1d2925;
  --muted: #637069;
  --paper: #f4f1ea;
  --surface: #fffefa;
  --line: #d8d9d2;
  --green: #176b51;
  --green-dark: #0f4d3b;
  --coral: #d65c45;
  --coral-soft: #f7e1da;
  --yellow: #e4b84d;
  --danger: #a4382d;
  --shadow: 0 20px 55px rgba(35, 48, 42, 0.09);
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

body.language-locked { overflow: hidden; }

.language-gate {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(29, 41, 37, 0.78);
  backdrop-filter: blur(5px);
}
.language-gate[hidden] { display: none; }
.language-panel {
  width: min(500px, 100%);
  padding: clamp(28px, 6vw, 48px);
  background: var(--surface);
  border-top: 5px solid var(--green);
  box-shadow: var(--shadow);
}
.language-panel h1 { font-size: clamp(30px, 6vw, 42px); }
.language-panel > p:not(.eyebrow) { color: var(--muted); line-height: 1.7; }
.language-mark { margin-bottom: 24px; }
.language-select { display: grid; gap: 9px; margin-top: 22px; }
.language-select span { color: var(--ink); font-size: 13px; font-weight: 800; }
.language-select select { width: 100%; height: 50px; padding: 0 12px; border: 1px solid #aeb5b0; background: white; color: var(--ink); }
.google-translate-engine { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.language-panel .button { width: 100%; margin-top: 18px; }

button, input, select { font: inherit; }

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: block;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
}
.brand-mark.language-mark { width: 48px; height: 48px; }
.brand div { display: grid; gap: 2px; }
.brand strong { font-size: 15px; }
.brand span:last-child { color: var(--muted); font-size: 12px; }
.privacy-chip { font-size: 13px; color: var(--green-dark); font-weight: 700; }
.privacy-chip span { color: #31a677; margin-right: 6px; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.language-button { min-height: 40px; padding: 0 14px; border: 1px solid var(--green); background: #eef7f2; color: var(--green-dark); font-size: 13px; font-weight: 800; white-space: nowrap; }
.language-button:hover { background: #dcefe6; }

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 42px auto;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.progress-panel { position: sticky; top: 24px; padding: 18px 8px; }
.eyebrow {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.progress-list { list-style: none; padding: 0; margin: 22px 0 30px; }
.progress-list li { position: relative; display: flex; gap: 12px; min-height: 70px; color: #87908b; }
.progress-list li::after { content: ""; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 1px; background: var(--line); }
.progress-list li:last-child::after { display: none; }
.progress-list li > span {
  z-index: 1;
  display: grid;
  place-items: center;
  flex: 0 0 31px;
  height: 31px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 12px;
  font-weight: 800;
}
.progress-list li div { display: grid; align-content: start; gap: 3px; padding-top: 4px; }
.progress-list strong { font-size: 14px; }
.progress-list small { font-size: 12px; }
.progress-list li.is-active { color: var(--ink); }
.progress-list li.is-active > span { color: white; border-color: var(--green); background: var(--green); }
.progress-list li.is-complete > span { color: white; border-color: var(--green); background: var(--green); }
.progress-list li.is-complete > span { font-size: 0; }
.progress-list li.is-complete > span::before { content: "✓"; font-size: 13px; }
.privacy-note { border-left: 3px solid var(--yellow); padding: 3px 0 3px 14px; }
.privacy-note strong { font-size: 13px; }
.privacy-note p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.workspace {
  min-height: 620px;
  padding: clamp(28px, 5vw, 58px);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.step { display: none; }
.step.is-visible { display: block; animation: reveal 220ms ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
h1 { max-width: 680px; margin: 0; font-family: Georgia, "Noto Serif TC", serif; font-size: clamp(32px, 5vw, 50px); line-height: 1.1; letter-spacing: 0; font-weight: 700; }
.lead { max-width: 680px; margin: 18px 0 30px; color: var(--muted); font-size: 16px; line-height: 1.8; }

.privacy-assurance {
  margin: 26px 0;
  padding: 22px 24px;
  color: #123f32;
  background: #e3f2ea;
  border-top: 5px solid var(--green);
  border-left: 5px solid var(--coral);
}
.privacy-assurance strong {
  display: block;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: clamp(25px, 4vw, 34px);
  line-height: 1.25;
}
.privacy-assurance p { margin: 12px 0 8px; font-size: 16px; font-weight: 700; line-height: 1.7; }
.privacy-assurance small { display: block; color: #3f6559; font-size: 12px; line-height: 1.6; }
.privacy-assurance-task { margin-top: 0; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 34px 0; background: var(--line); border: 1px solid var(--line); }
.info-grid article { padding: 22px; background: var(--surface); }
.info-grid h2 { margin: 14px 0 8px; font-size: 15px; }
.info-grid p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.info-icon { display: inline-grid; place-items: center; width: 30px; height: 25px; color: var(--coral); border-bottom: 2px solid var(--coral); font-size: 11px; font-weight: 900; }
.consent-row { display: flex; gap: 14px; padding: 18px; background: #f6f7f2; border: 1px solid var(--line); cursor: pointer; }
.consent-row input { width: 20px; height: 20px; accent-color: var(--green); }
.consent-row span { display: grid; gap: 5px; }
.consent-row strong { font-size: 14px; }
.consent-row small { color: var(--muted); line-height: 1.5; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin: 34px 0 18px; }
.form-grid label { display: grid; gap: 9px; }
.form-grid label > span, .fixed-language-field > span, .section-label { color: var(--ink); font-size: 13px; font-weight: 800; }
.form-grid input, .form-grid select {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  color: var(--ink);
  border: 1px solid #bdc2bd;
  border-radius: 0;
  background: white;
  outline: none;
}
.form-grid input:focus, .form-grid select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 81, 0.12); }
.full-width { grid-column: 1 / -1; max-width: calc(50% - 11px); }
.field-help { display: block; color: var(--muted); font-size: 12px; line-height: 1.55; }
.language-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.language-fields legend { margin-bottom: 8px; padding: 0; font-size: 13px; font-weight: 800; }
.fixed-language-field { display: grid; gap: 9px; align-content: start; }
.fixed-language-field strong { display: flex; align-items: center; min-height: 48px; padding: 0 13px; border-left: 4px solid var(--green); background: #eef7f2; color: var(--green-dark); font-size: 15px; }
.repeatable-fields { display: grid; gap: 10px; margin-top: 10px; }
.repeatable-row { display: grid; grid-template-columns: 1fr 40px; gap: 8px; }
.repeatable-row:only-child { grid-template-columns: 1fr; }
.other-language-note { margin-top: 8px; overflow-wrap: anywhere; }
.remove-language { width: 40px; min-height: 48px; border: 1px solid var(--line); background: transparent; color: var(--danger); font-size: 20px; }
.text-button { margin-top: 10px; padding: 6px 0; border: 0; background: transparent; color: var(--green); font-size: 13px; font-weight: 800; }

.actions { display: flex; justify-content: space-between; gap: 14px; margin-top: 34px; }
.actions-end { justify-content: flex-end; }
.button { min-height: 46px; padding: 0 18px; border: 1px solid transparent; border-radius: 2px; font-weight: 800; font-size: 13px; }
.button-primary { background: var(--green); color: white; }
.button-primary:hover:not(:disabled) { background: var(--green-dark); }
.button-quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.button-quiet:hover:not(:disabled) { background: #f4f5f0; }
.button-small { min-height: 36px; padding: 0 12px; }

.task-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.task-heading h1 { font-size: clamp(29px, 4vw, 42px); }
.status-pill { flex: 0 0 auto; padding: 7px 10px; background: #eeeae0; color: var(--muted); font-size: 11px; font-weight: 800; }
.status-pill.ready { background: #dcefe6; color: var(--green-dark); }
.task-rule { margin: 26px 0; padding: 20px 22px; border-left: 4px solid var(--coral); background: var(--coral-soft); }
.task-rule strong { font-family: Georgia, "Noto Serif TC", serif; font-size: 21px; }
.task-rule p { margin: 0; color: #70564f; line-height: 1.6; }
.stimulus-strip { display: grid; grid-template-columns: 145px 42px 1fr 50px; align-items: center; gap: 14px; min-height: 82px; padding: 14px 18px; border: 1px solid var(--line); }
.stimulus-strip > div:first-child { display: grid; gap: 5px; }
.stimulus-strip p { margin: 0; color: var(--muted); font-size: 12px; }
.round-button { display: grid; place-items: center; width: 42px; height: 42px; padding-left: 4px; border: 0; border-radius: 50%; background: var(--green); color: white; }
.round-button.is-playing { padding-left: 0; }
.waveform { height: 30px; opacity: 0.65; background: repeating-linear-gradient(90deg, var(--green) 0 2px, transparent 2px 6px); clip-path: polygon(0 42%,4% 20%,8% 55%,12% 30%,16% 70%,20% 18%,24% 82%,28% 35%,32% 55%,36% 10%,40% 76%,44% 27%,48% 62%,52% 15%,56% 87%,60% 34%,64% 68%,68% 19%,72% 78%,76% 31%,80% 58%,84% 12%,88% 72%,92% 37%,96% 60%,100% 42%,100% 58%,0 58%); }
#stimulus-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.recorder { margin-top: 18px; padding: 22px; border: 1px solid var(--line); }
.section-row { display: flex; justify-content: space-between; gap: 16px; }
.section-row small { color: var(--muted); font-size: 12px; }
.recorder-main { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.record-button { display: grid; place-items: center; flex: 0 0 54px; width: 54px; height: 54px; border: 1px solid #e7c2b9; border-radius: 50%; background: #fff7f4; }
.record-button span { width: 18px; height: 18px; border-radius: 50%; background: var(--coral); }
.record-button.is-recording span { border-radius: 2px; }
.record-copy { display: grid; gap: 4px; min-width: 0; }
.record-copy strong { font-size: 14px; }
.record-copy span { color: var(--muted); font-size: 12px; }
#record-time { margin-left: auto; font-family: ui-monospace, monospace; font-size: 20px; }
.processing-row, .preview-row { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.processing-row { display: flex; align-items: center; gap: 12px; }
.processing-row[hidden], .preview-row[hidden] { display: none; }
.processing-row div { display: grid; gap: 3px; }
.processing-row small { color: var(--muted); }
.spinner { width: 26px; height: 26px; border: 3px solid #cfe0da; border-top-color: var(--green); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.preview-row { display: flex; align-items: center; gap: 12px; }
.preview-row audio { min-width: 0; width: 100%; height: 38px; }
.alert { margin-bottom: 22px; padding: 13px 15px; color: var(--danger); background: #fae4df; border-left: 4px solid var(--danger); font-size: 13px; line-height: 1.5; }
.completion { text-align: center; padding: 45px 0; }
.completion .lead { margin-left: auto; margin-right: auto; }
.success-mark { display: grid; place-items: center; width: 62px; height: 62px; margin: 0 auto 24px; color: white; background: var(--green); border-radius: 50%; font-size: 28px; }
.completion-proof { display: inline-grid; gap: 8px; min-width: min(440px, 100%); padding: 22px; border: 1px solid var(--line); background: #f6f7f2; }
.completion-proof span { color: var(--muted); font-size: 12px; }
.completion-proof strong { color: var(--green-dark); font-family: Georgia, "Noto Serif TC", serif; font-size: 24px; }
.completion-proof p { max-width: 360px; margin: 4px auto 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.proof-button { display: block; margin: 18px auto 0; }
.finish-note { color: var(--muted); font-size: 13px; }

.device-grid { display: grid; gap: 14px; margin: 30px 0 18px; }
.device-card { display: grid; grid-template-columns: 42px 1fr 54px; align-items: center; gap: 18px; padding: 20px; border: 1px solid var(--line); background: white; }
.device-card h2 { margin: 0 0 6px; font-size: 16px; }
.plain-language-note { display: block; margin: -1px 0 6px; color: var(--green-dark); font-size: 12px; font-weight: 800; line-height: 1.5; }
.device-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.device-heard-confirm { grid-column: 2 / -1; display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 13px; font-weight: 700; }
.device-heard-confirm input { width: 18px; height: 18px; accent-color: var(--green); }
.device-number { display: grid; place-items: center; width: 34px; height: 34px; color: var(--coral); border-bottom: 2px solid var(--coral); font-size: 11px; font-weight: 900; }
.record-button.compact { width: 50px; height: 50px; }
.device-result { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; padding: 18px 20px; background: #f6f7f2; border-left: 4px solid var(--yellow); }
.device-result > div { display: grid; gap: 4px; }
.device-result small { color: var(--muted); }
.device-result time { font-family: ui-monospace, monospace; }
.device-result audio { grid-column: 1 / -1; width: 100%; height: 38px; }

footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto 28px; display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }

@media (max-width: 820px) {
  .topbar { padding: 0 18px; }
  .shell { width: min(100% - 24px, 680px); margin: 18px auto 30px; display: block; }
  .progress-panel { position: static; padding: 8px 0 16px; }
  .progress-panel > .eyebrow, .privacy-note, .progress-list li div { display: none; }
  .progress-list { display: flex; margin: 0; }
  .progress-list li { flex: 1; min-height: auto; align-items: center; }
  .progress-list li::after { left: 32px; right: 0; top: 15px; bottom: auto; width: auto; height: 1px; }
  .progress-list li > span { flex-basis: 31px; }
  .workspace { min-height: 0; padding: 30px 22px; }
  .info-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .full-width { grid-column: auto; max-width: none; }
  .stimulus-strip { grid-template-columns: 1fr 42px; }
  .stimulus-wave, #stimulus-time { display: none; }
  footer { width: calc(100% - 30px); gap: 15px; flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .brand span:last-child, .privacy-chip { display: none; }
  .topbar-actions { gap: 8px; }
  h1 { font-size: 34px; }
  .workspace { padding: 26px 18px; }
  .privacy-assurance { padding: 18px; }
  .task-heading { display: block; }
  .status-pill { display: inline-block; margin-top: 12px; }
  .preview-row { align-items: stretch; flex-direction: column; }
  .device-card { grid-template-columns: 34px 1fr; }
  .device-card > button { grid-column: 2; }
  .actions { align-items: stretch; flex-direction: column-reverse; }
  .actions-end { flex-direction: column; }
  .button { width: 100%; }
}

