:root {
  --ink: #17332e;
  --muted: #667a75;
  --green: #176b5b;
  --green-dark: #0f5145;
  --mint: #dff3ec;
  --cream: #f7f4ec;
  --paper: #fffdfa;
  --line: #dfe8e4;
  --danger: #a54337;
  --shadow: 0 18px 45px rgba(18, 65, 55, 0.09);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--cream); }
body { margin: 0; min-height: 100vh; background: var(--cream); }
button, input, textarea { font: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }

.site-header {
  height: 74px;
  padding: 14px max(20px, env(safe-area-inset-left));
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(23, 107, 91, 0.12);
  background: rgba(247, 244, 236, 0.92);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header > div { display: grid; gap: 2px; }
.site-header strong { font-family: Georgia, "Songti SC", serif; font-size: 17px; }
.eyebrow, .section-label, .trial-kicker {
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.text-button { border: 0; color: var(--muted); background: transparent; padding: 10px; }

.login-page { min-height: 100vh; display: grid; grid-template-rows: minmax(270px, 42vh) 1fr; }
.brand-panel {
  padding: max(44px, env(safe-area-inset-top)) 28px 42px;
  background:
    radial-gradient(circle at 85% 18%, rgba(255,255,255,.24) 0 3px, transparent 4px),
    linear-gradient(145deg, #0f5449, #1e7b69);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
}
.brand-panel::after {
  content: ""; position: absolute; width: 240px; height: 240px; border: 1px solid rgba(255,255,255,.16);
  border-radius: 50%; right: -90px; top: -80px; box-shadow: 0 0 0 35px rgba(255,255,255,.035), 0 0 0 70px rgba(255,255,255,.025);
}
.brand-panel .eyebrow { color: #bce4d9; }
.brand-panel h1 { margin: 10px 0 8px; font: 700 clamp(34px, 9vw, 52px)/1.1 Georgia, "Songti SC", serif; }
.brand-panel p { margin: 0; color: #d6eee8; font-size: 16px; }
.brand-mark { width: 54px; height: 54px; margin-bottom: 28px; border: 1px solid rgba(255,255,255,.4); border-radius: 50%; display: flex; align-items: center; justify-content: center; gap: 3px; }
.brand-mark span { display: block; width: 5px; border-radius: 5px; background: #d7f1e9; }
.brand-mark span:nth-child(1) { height: 15px; }.brand-mark span:nth-child(2) { height: 29px; }.brand-mark span:nth-child(3) { height: 21px; }

.login-card { padding: 32px 24px max(32px, env(safe-area-inset-bottom)); max-width: 520px; width: 100%; margin: 0 auto; }
.login-card h2 { font: 700 28px/1.2 Georgia, "Songti SC", serif; margin: 7px 0; }
.muted { color: var(--muted); line-height: 1.65; }
form { margin-top: 28px; display: grid; gap: 10px; }
form label { font-weight: 700; font-size: 14px; margin-top: 5px; }
input:not([type="range"]), textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); color: var(--ink);
  padding: 15px 16px; min-height: 52px; outline: none; transition: border .2s, box-shadow .2s;
}
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,91,.12); }
.primary-button, .jspsych-btn {
  width: 100%; border: 0; border-radius: 14px; min-height: 54px; padding: 14px 20px; margin-top: 12px;
  background: var(--green); color: white; font-weight: 800; cursor: pointer; box-shadow: 0 8px 20px rgba(23,107,91,.18);
}
.primary-button:hover, .jspsych-btn:hover { background: var(--green-dark); }
.primary-button:disabled, .jspsych-btn:disabled { background: #aebdb9; box-shadow: none; cursor: not-allowed; }
.privacy-note { color: var(--muted); text-align: center; font-size: 12px; margin-top: 22px; line-height: 1.6; }
.form-error { color: var(--danger); background: #fbe9e6; border-radius: 11px; padding: 11px 13px; font-size: 14px; }

.dashboard-page { width: min(760px, 100%); margin: 0 auto; padding: 28px 20px max(40px, env(safe-area-inset-bottom)); }
.welcome-row { display: flex; gap: 20px; justify-content: space-between; align-items: flex-end; margin: 6px 0 24px; }
.welcome-row h1 { margin: 8px 0 0; max-width: 520px; font: 700 clamp(29px, 8vw, 44px)/1.18 Georgia, "Songti SC", serif; }
.day-badge { min-width: 75px; height: 75px; border-radius: 50%; background: var(--mint); display: grid; place-content: center; text-align: center; color: var(--green); flex: 0 0 auto; }
.day-badge strong { font-size: 22px; line-height: 1; }.day-badge span { font-size: 11px; margin-top: 4px; }
.progress-card, .task-card, .help-card { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.progress-card { padding: 19px 20px; margin-bottom: 16px; }
.progress-copy { display: flex; justify-content: space-between; font-size: 14px; }.progress-copy strong { color: var(--green); }
.progress-track { height: 8px; background: #e4ebe8; overflow: hidden; border-radius: 99px; margin: 13px 0 9px; }
.progress-track div { height: 100%; background: linear-gradient(90deg, var(--green), #59a893); border-radius: inherit; }
.progress-card p { margin: 0; font-size: 12px; color: var(--muted); }
.task-card { padding: 26px 24px; background: linear-gradient(145deg, #fffdfa, #f2f8f5); }
.task-index { color: var(--muted); margin: 12px 0 5px; font-size: 14px; }
.task-card h2 { font: 700 30px/1.2 Georgia, "Songti SC", serif; margin: 5px 0 10px; }
.task-card p { color: var(--muted); line-height: 1.65; margin: 0 0 12px; }
.help-card { display: flex; gap: 14px; padding: 18px 19px; margin-top: 16px; box-shadow: none; background: transparent; }
.help-icon { width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid var(--green); border-radius: 50%; color: var(--green); flex: 0 0 auto; }
.help-card p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.rest-icon, .finish-seal { width: 64px; height: 64px; margin: 18px 0; border-radius: 50%; display: grid; place-items: center; background: var(--mint); color: var(--green); font-size: 30px; }

#jspsych-target { min-height: calc(100vh - 74px); }
.jspsych-display-element { background: var(--cream); color: var(--ink); }
.jspsych-content-wrapper { padding: 24px 18px max(36px, env(safe-area-inset-bottom)); }
.jspsych-content { max-width: 760px; width: 100%; }
#jspsych-progressbar-container { color: var(--muted); font-size: 12px; background: var(--paper); border-bottom: 1px solid var(--line); padding: 12px 20px; }
#jspsych-progressbar-outer { border: 0; background: #e0e8e5; height: 7px; margin-top: 8px; }
#jspsych-progressbar-inner { background: var(--green); }
.trial-card { text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: clamp(22px, 5vw, 34px); box-shadow: var(--shadow); }
.trial-card h1 { font: 700 clamp(27px, 7vw, 38px)/1.25 Georgia, "Songti SC", serif; margin: 10px 0 12px; }
.safety-note { background: #edf7f3; border-left: 4px solid var(--green); border-radius: 10px; padding: 15px 16px; margin: 22px 0; }
.safety-note p { margin: 5px 0 0; line-height: 1.6; color: var(--muted); }
.training-video { width: 100%; max-height: 62vh; border-radius: 15px; background: #0a1311; margin-top: 15px; display: block; }
.watch-status { margin: 13px 0 0; border-radius: 10px; padding: 11px 13px; background: #edf1ef; color: var(--muted); font-size: 13px; }
.watch-status.complete { background: var(--mint); color: var(--green-dark); }.watch-status.error { background: #fbe9e6; color: var(--danger); }
#jspsych-html-button-response-btngroup { display: grid; gap: 10px; margin-top: 14px; }
#jspsych-html-button-response-btngroup .jspsych-btn { max-width: 480px; margin-inline: auto; }
.answer-button { width: 100%; display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 12px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 14px; padding: 12px 16px; text-align: left; min-height: 62px; cursor: pointer; }
.answer-button span { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--mint); color: var(--green); font-weight: 800; }
.answer-button:hover, .answer-button:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,91,.1); }
.feedback-form { text-align: left; display: grid; gap: 16px; margin-top: 18px; }
.scale-block { background: var(--paper); border: 1px solid var(--line); border-radius: 15px; padding: 17px 16px 14px; }
.scale-block label { font-weight: 700; display: flex; justify-content: space-between; gap: 12px; }
.scale-block output { color: var(--green); font-size: 18px; }
input[type="range"] { width: 100%; accent-color: var(--green); margin: 20px 0 8px; }
.scale-labels { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.scale-labels span { flex: 1; }.scale-labels span:nth-child(2) { text-align: center; }.scale-labels span:last-child { text-align: right; }
.comment-label { font-weight: 700; margin-top: 7px; }
.result-card { text-align: center; }.result-icon { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 20px; background: var(--mint); color: var(--green); font-size: 38px; }
.error-result .result-icon { background: #fbe9e6; color: var(--danger); }
.loading-page { min-height: 60vh; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 25px; color: var(--muted); text-align: center; }
.loader { width: 34px; height: 34px; border: 3px solid #cfddd8; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 760px) {
  .login-page { grid-template-columns: 1.05fr .95fr; grid-template-rows: 100vh; }
  .brand-panel { padding: 70px clamp(50px, 8vw, 110px); }
  .login-card { align-self: center; padding: 50px; }
  .task-card .primary-button { width: auto; min-width: 220px; }
}

@media (max-width: 420px) {
  .welcome-row { align-items: flex-start; }.day-badge { width: 64px; min-width: 64px; height: 64px; }
  .trial-card { padding: 21px 18px; border-radius: 17px; }
  .jspsych-content-wrapper { padding-inline: 12px; }
}

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