:root {
  --ink: #172321;
  --muted: #66726e;
  --paper: #f3f1eb;
  --panel: #fbfaf6;
  --white: #fff;
  --line: #d9ddd5;
  --teal: #1d655a;
  --teal-dark: #11483f;
  --mint: #b8e0ce;
  --lime: #d9e26e;
  --orange: #e57d4a;
  --danger: #a43f37;
  --shadow: 0 24px 70px rgba(26, 45, 39, .08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--teal); }
.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.eyebrow {
  margin: 0 0 12px;
  color: var(--teal);
  font: 500 12px/1.3 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .13em;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1 { font: 500 clamp(48px, 7vw, 92px)/.94 Georgia, "Times New Roman", serif; letter-spacing: -.04em; }
h2 { font: 500 30px/1.05 Georgia, "Times New Roman", serif; letter-spacing: -.02em; }
.lead { max-width: 680px; color: var(--muted); font-size: 19px; line-height: 1.7; }
.muted { color: var(--muted); line-height: 1.7; }
.microcopy { margin: 16px 0 0; color: var(--muted); font-size: 12px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.button {
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: 100px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, opacity .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--teal); }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { color: var(--teal); border: 1px solid var(--teal); background: transparent; }
.button.danger { color: #fff; background: var(--danger); }
.button.danger:hover { background: #812b26; }
.button.compact { min-height: 38px; padding: 0 16px; font-size: 13px; }
.button:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.toast { position: fixed; z-index: 50; top: 18px; left: 50%; translate: -50% 0; max-width: min(640px, calc(100% - 36px)); padding: 13px 18px; border-radius: 100px; color: #fff; background: var(--teal); box-shadow: var(--shadow); font-size: 14px; }
.toast.error { background: var(--danger); }
.notice { margin: 18px 0; padding: 14px 16px; border-radius: 12px; }
.notice.error { color: #812b26; background: #f8ded9; }

/* Welcome */
.welcome-shell { padding: 70px 0 100px; }
.hero { position: relative; min-height: 370px; padding: 70px 0; }
.hero h1 { max-width: 820px; margin-bottom: 20px; }
.brand-mark { position: absolute; top: 34px; right: 5%; width: 210px; height: 210px; border: 1px solid rgba(29,101,90,.18); border-radius: 50%; animation: rotate 25s linear infinite; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; inset: 23px; border: 1px solid rgba(29,101,90,.28); border-radius: 42% 58% 47% 53%; }
.brand-mark::after { inset: 55px; border-color: var(--orange); border-radius: 50%; }
.brand-mark span { position: absolute; top: 50%; left: 50%; width: 7px; height: 42px; border-radius: 99px; background: var(--teal); transform-origin: 50% 0; }
.brand-mark span:nth-child(1) { rotate: 0deg; }
.brand-mark span:nth-child(2) { rotate: 90deg; background: var(--orange); }
.brand-mark span:nth-child(3) { rotate: 180deg; background: var(--lime); }
.brand-mark span:nth-child(4) { rotate: 270deg; background: var(--mint); }
@keyframes rotate { to { rotate: 360deg; } }
.consent-card, .profile-card { display: grid; grid-template-columns: 100px 1fr; gap: 30px; padding: 40px; margin-top: 24px; }
.section-number { color: var(--teal); font: 500 13px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.consent-card p, .plain-list { max-width: 760px; color: var(--muted); line-height: 1.8; }
.plain-list { padding: 0; list-style: none; }
.plain-list li { position: relative; padding-left: 26px; margin: 8px 0; }
.plain-list li::before { content: "↳"; position: absolute; left: 0; color: var(--orange); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
label { color: #33423e; font-size: 13px; font-weight: 700; }
input:not([type="radio"]):not([type="checkbox"]), select, textarea {
  width: 100%;
  margin-top: 8px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border .18s ease, box-shadow .18s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(29,101,90,.12); }
textarea { resize: vertical; }
.consent-check { display: flex; align-items: flex-start; gap: 12px; margin: 24px 0; max-width: 780px; color: var(--muted); font-weight: 500; line-height: 1.6; }
.consent-check input { width: 19px; height: 19px; margin-top: 3px; accent-color: var(--teal); }

/* Rating */
.rating-shell { padding: 34px 0 90px; }
.study-header { display: flex; align-items: center; justify-content: space-between; }
.study-actions { display: flex; align-items: center; gap: 18px; }
.study-actions form { margin: 0; }
.restart-button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 100px; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; font-weight: 700; }
.restart-button:hover { border-color: var(--teal); color: var(--teal); }
.wordmark { color: var(--ink); font: 700 19px/1 Inter, system-ui, sans-serif; letter-spacing: -.04em; text-decoration: none; }
.wordmark span { margin-left: 4px; color: var(--orange); font-weight: 500; }
.progress-meta { color: var(--muted); font: 500 12px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.progress-meta strong { color: var(--teal); font-size: 16px; }
.progress-track { height: 3px; margin-top: 22px; overflow: hidden; background: #d8d8d1; }
.progress-track span { display: block; height: 100%; background: var(--orange); transition: width .35s ease; }
.rating-layout { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(520px, 1.2fr); gap: 40px; padding-top: 58px; align-items: start; }
.sample-panel { position: sticky; top: 28px; padding: 10px 0; }
.sample-panel h1 { max-width: 560px; margin: 0 0 40px; font-size: clamp(52px, 6vw, 76px); }
.sample-context { display: flex; justify-content: space-between; gap: 20px; max-width: 440px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.sample-context span { color: var(--muted); font: 400 11px/1.5 ui-monospace, "SFMono-Regular", Consolas, monospace; text-transform: uppercase; letter-spacing: .08em; }
.audio-frame { max-width: 440px; margin-top: 32px; padding: 26px; border-radius: var(--radius); background: var(--teal); color: #fff; box-shadow: 0 24px 60px rgba(17,72,63,.18); }
.audio-frame audio { width: 100%; margin: 18px 0 8px; accent-color: var(--lime); }
.audio-frame p { margin: 4px 0 0; color: rgba(255,255,255,.68); font-size: 11px; }
.audio-icon { width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.45); border-radius: 50%; display: grid; place-items: center; font-size: 24px; }
.question-panel { padding: 38px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.question-progress { margin: -8px 0 28px; color: var(--muted); font-size: 12px; }
fieldset { min-width: 0; margin: 0 0 36px; padding: 0 0 32px; border: 0; border-bottom: 1px solid var(--line); }
fieldset.answered legend::after { content: "✓"; float: right; color: var(--teal); }
legend { width: 100%; margin-bottom: 17px; color: var(--ink); font-size: 15px; font-weight: 700; line-height: 1.5; }
legend span { margin-right: 12px; color: var(--orange); font: 500 11px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.choice-grid { display: grid; gap: 8px; }
.phone-grid, .four-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice-grid label { cursor: pointer; }
.choice-grid input { position: absolute; opacity: 0; pointer-events: none; }
.choice-grid label span { min-height: 48px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; display: grid; place-items: center; background: #fff; color: var(--muted); text-align: center; font-size: 12px; transition: all .15s ease; }
.phone-grid label span { min-height: 64px; font: 500 20px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; color: var(--ink); }
.phone-grid label:nth-child(n+3) span { font: 600 11px/1.2 Inter, system-ui, sans-serif; color: var(--muted); }
.choice-grid input:focus-visible + span { outline: 3px solid rgba(29,101,90,.22); outline-offset: 2px; }
.choice-grid input:checked + span { border-color: var(--teal); color: var(--teal); background: #eaf3ef; box-shadow: inset 0 0 0 1px var(--teal); }
.scale-grid { grid-template-columns: repeat(5, 1fr); }
.scale-labels { display: flex; justify-content: space-between; margin: -5px 0 8px; color: var(--muted); font-size: 10px; }
.comment-field span { color: var(--muted); font-weight: 400; }
.submit-row { margin-top: 24px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.submit-row p { max-width: 230px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.submit-row p.ready { color: var(--teal); }

/* Complete */
.complete-shell { min-height: 100vh; display: grid; place-items: center; padding: 40px 0; }
.completion-card { max-width: 650px; text-align: center; }
.completion-card h1 { margin-bottom: 20px; }
.completion-card > p:not(.eyebrow) { color: var(--muted); font-size: 17px; line-height: 1.7; }
.completion-orbit { width: 130px; height: 130px; margin: 0 auto 32px; border: 1px solid var(--mint); border-radius: 50%; display: grid; place-items: center; position: relative; }
.completion-orbit::before { content: ""; position: absolute; inset: 16px; border: 1px dashed var(--orange); border-radius: 50%; }
.completion-orbit span { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--teal); font-size: 24px; }
.completion-code { width: 260px; margin: 32px auto 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.completion-code span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.completion-code strong { display: block; margin-top: 6px; font: 500 20px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: .12em; }
.completion-restart { margin-top: 22px; }

/* Admin */
.admin-page { background: #edf0eb; }
.admin-login-shell { min-height: 100vh; display: grid; place-items: center; }
.admin-login { width: min(440px, 100%); padding: 42px; }
.admin-login h1 { font-size: 50px; }
.admin-login form { display: grid; gap: 16px; margin: 30px 0; }
.text-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.admin-header { min-height: 74px; padding: 0 max(24px, calc((100vw - 1240px) / 2)); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; background: #f8f8f4; }
.admin-header > div { display: flex; align-items: baseline; gap: 18px; }
.admin-header p { margin: 0; color: var(--muted); font-size: 11px; }
.admin-header nav { display: flex; align-items: center; gap: 18px; }
.admin-header nav > a:not(.button), .link-button { color: var(--muted); border: 0; background: none; font-size: 12px; text-decoration: none; cursor: pointer; }
.admin-content { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 55px 0 90px; }
.admin-title { display: flex; align-items: end; justify-content: space-between; }
.admin-title h1 { margin-bottom: 0; font-size: 68px; }
.study-url { margin: 0; color: var(--muted); text-align: right; font-size: 11px; line-height: 1.7; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 34px 0 20px; }
.metric-grid article { min-height: 140px; padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: #f8f8f4; display: grid; grid-template-columns: 1fr auto; align-items: start; }
.metric-grid span, .metric-grid small { color: var(--muted); font-size: 11px; }
.metric-grid strong { font: 500 45px/1 Georgia, "Times New Roman", serif; color: var(--teal); }
.metric-grid small { grid-column: 1 / -1; align-self: end; }
.analysis-card { margin-bottom: 20px; }
.analysis-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 24px 0; }
.analysis-summary article { padding: 18px; border-radius: 14px; display: grid; gap: 5px; background: #edf3ef; }
.analysis-summary span, .analysis-summary small { color: var(--muted); font-size: 11px; }
.analysis-summary strong { color: var(--teal); font: 500 30px/1.1 Georgia, "Times New Roman", serif; }
.analysis-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; }
.analysis-grid h3 { margin: 4px 0 5px; font-size: 15px; }
.analysis-help, .analysis-note { color: var(--muted); font-size: 11px; line-height: 1.6; }
.bar-chart { display: grid; gap: 13px; margin-top: 20px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, .8fr) minmax(120px, 1.4fr) 52px; align-items: center; gap: 10px; }
.bar-label strong, .bar-label span { display: block; }
.bar-label strong { font-size: 12px; }
.bar-label span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.bar-track { height: 11px; overflow: hidden; border-radius: 100px; background: #dfe4de; }
.bar-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #4f9a86); }
.bar-row b { color: var(--teal); text-align: right; font-size: 11px; }
.analysis-table-wrap { overflow-x: auto; margin-top: 16px; }
.analysis-table th, .analysis-table td { padding: 9px 10px; font-size: 10px; }
.effect-list { margin-top: 15px; padding: 12px 14px; border-radius: 12px; background: #fff5eb; }
.effect-list p { margin: 7px 0; font-size: 11px; line-height: 1.5; }
.effect-list strong, .effect-list span { display: block; }
.effect-list span { color: var(--muted); }
.analysis-note { margin: 22px 0 0; padding-top: 15px; border-top: 1px solid var(--line); }
.empty-analysis { margin-top: 22px; padding: 28px; border-radius: 14px; color: var(--muted); background: #edf0eb; text-align: center; font-size: 12px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, .7fr); gap: 20px; }
.admin-card { padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: #f8f8f4; }
.manifest-import-card { margin-bottom: 20px; }
.manifest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 22px 0; }
.manifest-grid .wide { grid-column: 1 / -1; }
.compact-upload input[type="file"] { padding: 10px; background: #fff; }
.compact-upload input[type="file"]::file-selector-button { margin-right: 10px; padding: 8px 12px; border: 0; border-radius: 100px; color: #fff; background: var(--teal); cursor: pointer; }
.file-feedback { display: block; margin-top: 7px; color: var(--muted); font-weight: 500; }
.import-rules { margin: 0 0 22px; padding: 16px; border-radius: 13px; display: grid; gap: 7px; color: var(--muted); background: #edf3ef; font-size: 11px; line-height: 1.55; }
.import-rules strong { color: var(--teal); }
.card-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.card-heading h2 { margin-bottom: 0; }
.step-pill, .condition-tag { padding: 6px 9px; border-radius: 100px; color: var(--teal); background: #e4efe9; font: 500 10px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; text-transform: uppercase; }
.upload-card .field-grid { margin: 20px 0; }
.drop-zone { min-height: 150px; margin-top: 20px; border: 1px dashed #9db3aa; border-radius: 14px; display: grid; place-items: center; align-content: center; background: #f0f5f1; cursor: pointer; text-align: center; }
.drop-zone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop-zone small { display: block; margin-top: 4px; color: var(--muted); font-weight: 400; }
.upload-symbol { width: 40px; height: 40px; margin-bottom: 8px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--teal); font-size: 22px; }
.drop-zone.has-files { border-style: solid; border-color: var(--teal); background: #e7f1ec; }
.protocol-card { color: #fff; background: var(--teal); }
.protocol-card .eyebrow { color: var(--lime); }
.protocol-card h2 { color: #fff; }
.protocol-card ol { margin: 24px 0; padding: 0; list-style: none; }
.protocol-card li { display: flex; gap: 12px; padding: 13px 0; border-top: 1px solid rgba(255,255,255,.16); font-size: 12px; line-height: 1.5; }
.protocol-card li span { color: var(--lime); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.protocol-note { padding: 15px; border-radius: 12px; color: rgba(255,255,255,.82); background: rgba(0,0,0,.12); font-size: 11px; line-height: 1.6; }
.sample-table-card { margin-top: 20px; padding: 0; overflow: hidden; }
.sample-table-card .card-heading { padding: 28px; }
.inventory-actions { display: flex; align-items: center; gap: 10px; }
.clear-samples-form { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 18px; color: var(--muted); background: #edf0eb; text-align: left; font: 500 10px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; text-transform: uppercase; letter-spacing: .06em; }
td { padding: 15px 18px; border-top: 1px solid var(--line); color: #44514d; font-size: 12px; }
td strong, td small { display: block; }
td small { max-width: 260px; margin-top: 3px; overflow: hidden; color: #86908d; text-overflow: ellipsis; white-space: nowrap; }
.status-button { padding: 6px 10px; border: 0; border-radius: 100px; cursor: pointer; font-size: 10px; font-weight: 700; }
.status-button.active { color: #176047; background: #dcefe5; }
.status-button.inactive { color: #815428; background: #f4e5d3; }
.empty-state { padding: 50px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; }

@media (max-width: 920px) {
  .brand-mark { opacity: .22; right: 0; }
  .rating-layout { grid-template-columns: 1fr; }
  .sample-panel { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .sample-panel .eyebrow, .sample-panel h1 { grid-column: 1 / -1; }
  .sample-panel h1 { margin-bottom: 10px; }
  .audio-frame { grid-column: 1 / -1; max-width: none; }
  .admin-grid { grid-template-columns: 1fr; }
  .analysis-grid { grid-template-columns: 1fr; }
  .admin-title { align-items: start; flex-direction: column; gap: 20px; }
  .study-url { text-align: left; }
}

@media (max-width: 650px) {
  .shell, .admin-content { width: min(100% - 24px, 1180px); }
  .welcome-shell { padding-top: 32px; }
  .hero { min-height: auto; padding: 55px 0 35px; }
  .hero h1, .admin-title h1 { font-size: 49px; }
  .brand-mark { width: 150px; height: 150px; }
  .consent-card, .profile-card { grid-template-columns: 1fr; padding: 25px; }
  .field-grid { grid-template-columns: 1fr; }
  .manifest-grid { grid-template-columns: 1fr; }
  .manifest-grid .wide { grid-column: auto; }
  .rating-shell { padding-top: 22px; }
  .rating-layout { padding-top: 35px; }
  .sample-panel { display: block; }
  .sample-context { max-width: none; }
  .question-panel { padding: 24px 18px; }
  .phone-grid, .four-grid { grid-template-columns: repeat(2, 1fr); }
  .submit-row { align-items: stretch; flex-direction: column; }
  .submit-row p { max-width: none; }
  .admin-header { padding: 16px; align-items: flex-start; gap: 16px; }
  .admin-header > div p, .admin-header nav > a:not(.button) { display: none; }
  .admin-header nav { gap: 8px; }
  .sample-table-card .card-heading { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr; }
  .analysis-summary { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 105px 1fr 48px; }
  .metric-grid article { min-height: 110px; }
}

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