/* =====================================================================
   ใจพร้อม – MindTrack Teen
   assets/css/style.css
   โทน: Blue / Cyan / White / Soft Green · Mobile-first · Animation เล็กน้อย
   ===================================================================== */

:root {
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;
  --cyan-500: #06b6d4;
  --cyan-400: #22d3ee;
  --cyan-100: #cffafe;
  --green-600: #16a34a;
  --green-500: #22c55e;
  --green-200: #bbf7d0;
  --green-50:  #f0fdf4;
  --amber-100: #fef3c7;
  --amber-700: #b45309;
  --red-600:  #dc2626;
  --red-100:  #fee2e2;
  --rose-500: #f43f5e;

  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --white: #ffffff;

  --bg: #f5fbff;
  --grad-main: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  --grad-soft: linear-gradient(160deg, #eff6ff 0%, #ecfeff 55%, #f0fdf4 100%);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 8px 24px rgba(37, 99, 235, .08);
  --shadow-lg: 0 16px 40px rgba(37, 99, 235, .14);

  --font: "Noto Sans Thai", "Sarabun", "Leelawadee UI", "Tahoma", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tap: 52px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-900);
  background: var(--grad-soft) fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; }
a { color: var(--blue-600); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
hr.divider { border: 0; border-top: 1px dashed var(--ink-200); margin: 1.5rem 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 8px; background: var(--white); padding: 8px 12px; border-radius: 8px; z-index: 100;
}
.skip-link:focus { left: 8px; }

:focus-visible { outline: 3px solid var(--cyan-400); outline-offset: 2px; }

.muted { color: var(--ink-500); font-size: .92rem; }
.center { text-align: center; }
.link { font-weight: 600; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------------
   Layout
   --------------------------------------------------------------------- */
.page { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 16px 120px; }
.layout-focus .page { max-width: 760px; padding-top: 12px; }
.layout-auth .page { display: flex; align-items: center; justify-content: center; }
.screen-wrap { max-width: 720px; margin: 0 auto; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--ink-200);
}
.topbar__inner { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink-900); }
.brand__logo { font-size: 1.7rem; }
.brand__text { font-weight: 700; font-size: 1.15rem; line-height: 1.1; }
.brand__text small { display: block; font-weight: 500; font-size: .72rem; color: var(--ink-500); letter-spacing: .02em; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }
.topbar__user { font-weight: 600; color: var(--ink-700); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-form { display: inline; margin: 0; }

.site-footer { text-align: center; padding: 20px 16px 96px; font-size: .85rem; color: var(--ink-500); }
.site-footer p { margin: 0 0 4px; }
.layout-focus .site-footer { padding-bottom: 110px; }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  border-radius: 999px; border: 2px solid transparent;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease, opacity .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn--lg { min-height: var(--tap); padding: 12px 28px; font-size: 1.05rem; }
.btn--sm { min-height: 38px; padding: 6px 16px; font-size: .92rem; }
.btn--block { width: 100%; }
.btn--primary { background: var(--grad-main); color: var(--white); box-shadow: 0 6px 16px rgba(37, 99, 235, .28); }
.btn--primary:hover { box-shadow: 0 10px 22px rgba(37, 99, 235, .34); }
.btn--secondary { background: var(--white); color: var(--blue-700); border-color: var(--blue-100); }
.btn--secondary:hover { border-color: var(--blue-500); }
.btn--success { background: linear-gradient(135deg, #16a34a, #22c55e); color: var(--white); box-shadow: 0 6px 16px rgba(34, 197, 94, .3); }
.btn--ghost { background: transparent; color: var(--ink-700); border-color: var(--ink-200); }
.btn--ghost:hover { background: var(--white); }
.btn--sos { background: linear-gradient(135deg, #f43f5e, #fb7185); color: var(--white); box-shadow: 0 6px 16px rgba(244, 63, 94, .3); }

/* ---------------------------------------------------------------------
   Alerts / badges
   --------------------------------------------------------------------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin: 0 auto 14px; max-width: 720px; font-weight: 500; animation: fadeUp .35s ease both; }
.alert--success { background: var(--green-50); color: #166534; border: 1px solid var(--green-200); }
.alert--error { background: var(--red-100); color: #991b1b; border: 1px solid #fecaca; }
.alert--info { background: var(--blue-50); color: var(--blue-700); border: 1px solid var(--blue-100); }
.alert--warning { background: var(--amber-100); color: var(--amber-700); border: 1px solid #fde68a; }
.alert--calm { background: var(--cyan-100); color: #155e75; border: 1px solid #a5f3fc; }

.form-error { background: var(--red-100); color: #991b1b; border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 14px; font-weight: 500; }

.badge { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: .82rem; font-weight: 600; background: var(--blue-50); color: var(--blue-700); }
.badge--success { background: var(--green-50); color: var(--green-600); }
.badge--muted { background: var(--ink-100); color: var(--ink-500); }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 6px 14px; border-radius: 999px; background: var(--white); border: 1px solid var(--blue-100); font-weight: 600; color: var(--blue-700); }

/* ---------------------------------------------------------------------
   Card
   --------------------------------------------------------------------- */
.card {
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 24px 20px; margin-bottom: 16px; animation: fadeUp .4s ease both;
}
.card__title { font-size: 1.5rem; font-weight: 700; }
.card__subtitle { color: var(--ink-500); margin-bottom: 18px; }
.section-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
.page-title { font-size: 1.6rem; }

.field-label { display: block; font-weight: 600; margin: 18px 0 8px; color: var(--ink-700); }
.input {
  width: 100%; font: inherit; color: var(--ink-900);
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 2px solid var(--ink-200); background: var(--white);
  transition: border-color .2s, box-shadow .2s;
}
.input:focus { outline: none; border-color: var(--cyan-500); box-shadow: 0 0 0 4px rgba(6, 182, 212, .15); }
.input--lg { min-height: var(--tap); }

.form-actions { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.form-actions--split { flex-direction: row; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.form-actions--split > * { flex: 1 1 auto; }
.mt-form.is-busy { opacity: .85; }

/* ---------------------------------------------------------------------
   ProgressHeader / ProgressBar
   --------------------------------------------------------------------- */
.progress-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(245, 251, 255, .92);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 10px 2px 12px; margin-bottom: 8px;
}
.progress-header__top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.progress-header__back {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border-radius: 50%; background: var(--white); box-shadow: var(--shadow-sm);
  text-decoration: none; color: var(--ink-700); font-size: 1.2rem;
}
.progress-header__title { flex: 1; min-width: 0; line-height: 1.25; }
.progress-header__title strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-header__week { font-size: .82rem; color: var(--blue-600); font-weight: 600; }
.progress-header__count { font-weight: 700; color: var(--ink-500); font-size: .95rem; }

.steps { display: flex; gap: 6px; margin-bottom: 8px; }
.steps__dot { flex: 1; height: 6px; border-radius: 99px; background: var(--ink-200); transition: background .3s; }
.steps__dot--done { background: var(--cyan-500); }
.steps__dot--current { background: var(--blue-600); }

.progress { height: 10px; background: var(--ink-100); border-radius: 99px; overflow: hidden; }
.progress__fill { height: 100%; background: var(--grad-main); border-radius: 99px; transition: width .6s ease; }
.progress--thin { height: 6px; margin: 6px 0; }
.progress--green .progress__fill { background: linear-gradient(90deg, #22c55e, #86efac); }
.progress-header .progress { display: none; }

/* ---------------------------------------------------------------------
   Hero (Welcome)
   --------------------------------------------------------------------- */
.card--hero { text-align: center; padding: 36px 22px; background: linear-gradient(180deg, #ffffff 0%, #f0f9ff 100%); }
.hero__emoji { font-size: 4.5rem; line-height: 1; margin-bottom: 12px; animation: float 4s ease-in-out infinite; }
.hero__message { font-size: 1.2rem; font-weight: 500; color: var(--ink-700); max-width: 520px; margin: 0 auto 18px; }
.hero__action { margin-top: 24px; }
.check-list { list-style: none; padding: 0; margin: 0 auto; max-width: 460px; text-align: left; }
.check-list li { position: relative; padding: 6px 0 6px 34px; }
.check-list li::before {
  content: "✓"; position: absolute; left: 0; top: 7px; width: 24px; height: 24px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--green-50); color: var(--green-600); font-size: .8rem; font-weight: 700;
}

/* ---------------------------------------------------------------------
   MoodSelector
   --------------------------------------------------------------------- */
.mood-selector { border: 0; padding: 0; margin: 0; }
.mood-selector__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mood-option { position: relative; cursor: pointer; }
.mood-option input { position: absolute; opacity: 0; pointer-events: none; }
.mood-option__emoji {
  display: grid; place-items: center; aspect-ratio: 1; font-size: 2.3rem;
  background: var(--blue-50); border: 2px solid transparent; border-radius: 20px;
  transition: transform .2s ease, border-color .2s, background .2s, box-shadow .2s;
}
.mood-option__label { display: block; text-align: center; font-size: .9rem; font-weight: 600; margin-top: 4px; color: var(--ink-700); }
.mood-option:hover .mood-option__emoji { transform: translateY(-2px); }
.mood-option input:checked + .mood-option__emoji {
  background: var(--white); border-color: var(--blue-600); box-shadow: 0 6px 18px rgba(37, 99, 235, .22); transform: scale(1.06);
}
.mood-option input:focus-visible + .mood-option__emoji { outline: 3px solid var(--cyan-400); }

/* ---------------------------------------------------------------------
   IntensitySlider
   --------------------------------------------------------------------- */
.intensity__row { display: flex; align-items: center; gap: 14px; }
.intensity__range {
  --fill: 50%;
  flex: 1; -webkit-appearance: none; appearance: none; height: 12px; border-radius: 99px;
  background: linear-gradient(90deg, var(--cyan-500) 0%, var(--blue-600) var(--fill), var(--ink-200) var(--fill));
}
.intensity__range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--white); border: 4px solid var(--blue-600); box-shadow: var(--shadow); cursor: grab;
}
.intensity__range::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%; background: var(--white); border: 4px solid var(--blue-600); cursor: grab;
}
.intensity__value {
  min-width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px;
  font-size: 1.4rem; font-weight: 700; background: var(--blue-50); color: var(--blue-700); transition: background .2s, color .2s;
}
.intensity.is-high .intensity__value { background: #ffe4e6; color: #be123c; }
.intensity__labels { display: flex; justify-content: space-between; font-size: .85rem; color: var(--ink-500); margin-top: 6px; }

/* ---------------------------------------------------------------------
   ChoiceChips
   --------------------------------------------------------------------- */
.chips { border: 0; padding: 0; margin: 0; }
.chips__grid { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip__body {
  display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 8px 18px;
  border-radius: 999px; border: 2px solid var(--ink-200); background: var(--white);
  font-weight: 600; color: var(--ink-700); transition: all .18s ease;
}
.chip--emoji .chip__body { padding-left: 12px; }
.chip__emoji { font-size: 1.35rem; }
.chip:hover .chip__body { border-color: var(--cyan-400); }
.chip input:checked + .chip__body { background: var(--blue-50); border-color: var(--blue-600); color: var(--blue-700); box-shadow: 0 4px 12px rgba(37, 99, 235, .15); }
.chip input:checked + .chip__body::after { content: "✓"; font-weight: 700; color: var(--blue-600); }
.chip input:focus-visible + .chip__body { outline: 3px solid var(--cyan-400); }
.chips__other { margin-top: 12px; }
.chips__hint { font-size: .85rem; color: var(--ink-500); margin: 8px 0 0; }
.chips__hint.is-warn { color: var(--rose-500); font-weight: 600; animation: shake .35s ease; }

/* ---------------------------------------------------------------------
   ReflectionTextBox
   --------------------------------------------------------------------- */
.reflection__input { resize: vertical; min-height: 96px; }
.reflection__counter { text-align: right; font-size: .8rem; color: var(--ink-500); margin-top: 4px; }

/* ---------------------------------------------------------------------
   QuizCard (Assessment)
   --------------------------------------------------------------------- */
.quiz-card__meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .9rem; color: var(--ink-500); margin-bottom: 4px; flex-wrap: wrap; }
.quiz-card__instruction { color: var(--ink-500); font-size: .95rem; margin-top: 14px; }
.quiz-card__question { font-size: 1.3rem; font-weight: 700; margin: 6px 0 18px; }
.quiz-card__options, .option-list { display: flex; flex-direction: column; gap: 10px; }
.option-row { position: relative; display: flex; align-items: center; gap: 14px; min-height: var(--tap); padding: 12px 16px; border-radius: var(--radius); border: 2px solid var(--ink-200); background: var(--white); cursor: pointer; transition: all .18s ease; }
.option-row input { position: absolute; opacity: 0; pointer-events: none; }
.option-row__dot { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 2px solid var(--ink-300); transition: all .18s; }
.option-row__label { font-weight: 600; }
.option-row:hover { border-color: var(--cyan-400); }
.option-row:has(input:checked) { border-color: var(--blue-600); background: var(--blue-50); }
.option-row input:checked ~ .option-row__dot { border-color: var(--blue-600); background: radial-gradient(circle, var(--blue-600) 45%, transparent 50%); }
.option-row input:focus-visible ~ .option-row__dot { outline: 3px solid var(--cyan-400); outline-offset: 2px; }
.option-row--big { min-height: 60px; font-size: 1.1rem; }
.autosave-status { min-height: 1.4em; font-size: .88rem; color: var(--ink-500); margin: 10px 0 0; }
.autosave-status.is-ok { color: var(--green-600); }
.autosave-status.is-error { color: var(--red-600); }
.disclaimer { font-size: .82rem; color: var(--ink-500); margin-top: 18px; text-align: center; }

/* ---------------------------------------------------------------------
   ScenarioCard / DragDropGame / Emotion Radar
   --------------------------------------------------------------------- */
.scenario-card {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px; margin-bottom: 16px;
  border-radius: var(--radius); background: linear-gradient(135deg, #e0f2fe, #ecfeff);
  border: 1px solid var(--cyan-100);
}
.scenario-card__emoji { font-size: 2.6rem; }
.scenario-card__label { font-size: .8rem; font-weight: 700; color: var(--blue-600); text-transform: uppercase; letter-spacing: .04em; }
.scenario-card__text { font-size: 1.2rem; font-weight: 700; margin: 0; }
.instruction { color: var(--ink-700); }

.dnd__zone {
  position: relative; min-height: 180px; border-radius: var(--radius-lg); padding: 18px;
  border: 2px dashed var(--cyan-400); background: radial-gradient(circle at center, #ecfeff 0%, #ffffff 70%);
  overflow: hidden; transition: border-color .2s, background .2s;
}
.dnd__zone.is-over { border-color: var(--blue-600); background: radial-gradient(circle at center, #dbeafe 0%, #ffffff 70%); }
.dnd__zone-label { position: relative; text-align: center; font-weight: 700; color: var(--cyan-500); margin: 0 0 10px; }
.dnd__zone.has-items .dnd__zone-label { color: var(--blue-600); }
.dnd__dropped { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 60px; }
.dnd__pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; min-height: 60px; padding: 8px; border-radius: var(--radius); }
.dnd__pool.is-over { background: var(--ink-100); }

.radar { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.radar span { position: absolute; border-radius: 50%; border: 1px solid rgba(6, 182, 212, .25); animation: pulse 3.2s ease-out infinite; }
.radar span:nth-child(1) { width: 90px; height: 90px; }
.radar span:nth-child(2) { width: 170px; height: 170px; animation-delay: .6s; }
.radar span:nth-child(3) { width: 250px; height: 250px; animation-delay: 1.2s; }

.emotion-card {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 88px; padding: 10px 12px;
  border-radius: var(--radius); border: 2px solid var(--ink-200); background: var(--white);
  font: inherit; font-weight: 600; color: var(--ink-700); cursor: grab; box-shadow: var(--shadow-sm);
  transition: transform .18s ease, border-color .18s, box-shadow .18s;
  touch-action: manipulation;
}
.emotion-card:hover { transform: translateY(-2px); border-color: var(--cyan-400); }
.emotion-card__emoji { font-size: 1.8rem; line-height: 1.2; }
.emotion-card.is-in { border-color: var(--blue-600); background: var(--blue-50); color: var(--blue-700); animation: pop .25s ease; }
.emotion-card.is-dragging { opacity: .5; }

.question-title { font-size: 1.25rem; margin: 6px 0 16px; }
.js .game-step { display: none; }
.js .game-step.is-active { display: block; animation: fadeUp .35s ease both; }
.game-step--2 { margin-top: 18px; }

.game-feedback { text-align: center; padding: 10px 4px 4px; animation: fadeUp .4s ease both; }
.game-feedback__score {
  width: 120px; height: 120px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-content: center; background: var(--grad-main); color: var(--white); box-shadow: var(--shadow-lg);
}
.game-feedback__score span { font-size: 2.4rem; font-weight: 700; line-height: 1; }
.game-feedback__score small { font-size: .8rem; opacity: .9; }
.game-feedback.is-correct .game-feedback__score { background: linear-gradient(135deg, #16a34a, #22d3ee); }
.game-feedback__text { font-size: 1.1rem; font-weight: 500; }
.key-message { background: var(--green-50); border: 1px solid var(--green-200); color: #166534; border-radius: var(--radius); padding: 12px 16px; font-weight: 600; margin: 14px 0 20px; }

/* ---------------------------------------------------------------------
   WeekSummary
   --------------------------------------------------------------------- */
.summary-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.summary-tile { background: var(--blue-50); border-radius: var(--radius); padding: 16px; }
.summary-tile h3 { font-size: 1rem; }
.summary-tile .check-list { max-width: none; }
.challenge-card {
  display: flex; gap: 14px; align-items: flex-start; margin-top: 14px; padding: 16px;
  border-radius: var(--radius); background: linear-gradient(135deg, #f0fdf4, #ecfeff); border: 1px solid var(--green-200);
}
.challenge-card__icon { font-size: 2.2rem; }
.challenge-card__label { font-size: .78rem; font-weight: 700; color: var(--green-600); text-transform: uppercase; letter-spacing: .05em; }
.challenge-card__text { font-weight: 700; font-size: 1.05rem; margin: 2px 0 4px; }
.reco { margin-top: 14px; }
.reco h3 { font-size: 1rem; }
.reco__item { background: var(--white); border: 1px solid var(--blue-100); border-left: 4px solid var(--cyan-500); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; }
.reco__item p { margin: 4px 0 0; color: var(--ink-700); }

/* ---------------------------------------------------------------------
   Dashboard
   --------------------------------------------------------------------- */
.dash-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 20px; border-radius: var(--radius-lg); color: var(--white);
  background: var(--grad-main); box-shadow: var(--shadow-lg); margin-bottom: 16px; animation: fadeUp .4s ease both;
}
.dash-hero h1 { font-size: 1.6rem; margin: 0; }
.dash-hero__hello { margin: 0; opacity: .9; }
.dash-hero__week { margin: 6px 0 0; opacity: .95; }

.ring {
  --p: 0;
  width: 112px; height: 112px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(#a7f3d0 calc(var(--p) * 1%), rgba(255, 255, 255, .25) 0);
}
.ring__inner { width: 88px; height: 88px; border-radius: 50%; background: rgba(255, 255, 255, .95); color: var(--blue-700); display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring__inner strong { font-size: 1.5rem; }
.ring__inner small { font-size: .68rem; color: var(--ink-500); }

.resume-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 18px; border-radius: var(--radius); background: var(--white);
  border: 2px solid var(--cyan-400); box-shadow: var(--shadow); margin-bottom: 16px;
}
.resume-banner > div { flex: 1 1 240px; }
.resume-banner__label { font-size: .78rem; font-weight: 700; color: var(--cyan-500); text-transform: uppercase; letter-spacing: .05em; }
.resume-banner__title { font-weight: 700; margin: 2px 0 8px; }

.dash-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.panel { background: var(--white); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.dash-side .panel { margin-bottom: 16px; }

.week-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.week { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius); background: var(--ink-100); transition: transform .15s; }
.week__icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--white); font-size: 1.2rem; font-weight: 700; }
.week__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.week__no { font-size: .78rem; font-weight: 700; color: var(--ink-500); }
.week__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week__meta { font-size: .8rem; color: var(--ink-500); }
.week__action { flex: none; }
.week--done { background: var(--green-50); }
.week--done .week__icon { background: var(--green-500); color: var(--white); }
.week--progress { background: var(--blue-50); border: 2px solid var(--blue-100); }
.week--progress .week__icon { background: var(--blue-600); color: var(--white); }
.week--ready { background: #ecfeff; border: 2px solid var(--cyan-100); }
.week--locked { opacity: .7; }
.week--locked .week__icon { background: var(--ink-200); }

.challenge-mini { padding: 10px 0; border-top: 1px solid var(--ink-100); }
.challenge-mini:first-of-type { border-top: 0; }
.challenge-mini p { margin: 0; }

/* ---------------------------------------------------------------------
   Auth
   --------------------------------------------------------------------- */
.auth { width: 100%; max-width: 420px; }
.auth__card { background: var(--white); border-radius: var(--radius-lg); padding: 30px 24px; box-shadow: var(--shadow-lg); animation: fadeUp .4s ease both; }
.auth__brand { text-align: center; margin-bottom: 18px; }
.auth__logo { font-size: 3.4rem; display: inline-block; animation: float 4s ease-in-out infinite; }
.auth__brand h1 { font-size: 2rem; margin: 4px 0 0; background: var(--grad-main); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth__brand p { color: var(--ink-500); font-size: .95rem; }
.auth__form .btn { margin-top: 22px; }
.auth__help { text-align: center; color: var(--ink-500); font-size: .88rem; margin: 16px 0 0; }
.password-field { position: relative; }
.password-field .input { padding-right: 52px; }
.password-field__toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: 0; background: transparent; cursor: pointer; font-size: 1.1rem; }

/* ---------------------------------------------------------------------
   Safety
   --------------------------------------------------------------------- */
.sos-fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 10px 18px 10px 14px;
  border-radius: 999px; background: linear-gradient(135deg, #f43f5e, #fb7185); color: var(--white);
  font-weight: 700; text-decoration: none; box-shadow: 0 10px 26px rgba(244, 63, 94, .38);
  transition: transform .15s ease, box-shadow .2s;
}
.sos-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(244, 63, 94, .45); }
.sos-fab__icon { font-size: 1.3rem; }

.card--safety { border-top: 6px solid #fb7185; animation: none; }
.safety-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.safety-head__icon { font-size: 2.8rem; }
.safety-options { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: 10px; }
.safety-option { position: relative; display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 12px 16px; border-radius: var(--radius); border: 2px solid var(--ink-200); background: var(--white); cursor: pointer; transition: all .18s; }
.safety-option input { position: absolute; opacity: 0; pointer-events: none; }
.safety-option__emoji { font-size: 1.7rem; }
.safety-option__label { font-weight: 600; font-size: 1.05rem; }
.safety-option:has(input:checked) { border-color: var(--rose-500); background: #fff1f2; }
.safety-option input:focus-visible ~ .safety-option__label { text-decoration: underline; }

.emergency { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--ink-200); }
.emergency__note { font-weight: 600; color: #9f1239; }
.contact-list { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 8px; }
.contact { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "phone name" "phone note"; column-gap: 14px; align-items: center; padding: 12px 16px; border-radius: var(--radius); background: var(--blue-50); text-decoration: none; color: var(--ink-900); border: 2px solid transparent; transition: border-color .18s; }
.contact:hover { border-color: var(--blue-500); }
.contact__phone { grid-area: phone; font-size: 1.5rem; font-weight: 700; color: var(--blue-700); min-width: 64px; text-align: center; }
.contact__name { grid-area: name; font-weight: 600; }
.contact__note { grid-area: note; font-size: .85rem; color: var(--ink-500); }
.contact--static { background: var(--ink-100); }
.support-message { font-size: 1.1rem; background: var(--cyan-100); color: #155e75; padding: 14px 16px; border-radius: var(--radius); }

.calm-box { display: flex; align-items: center; gap: 18px; margin-top: 18px; padding: 16px; border-radius: var(--radius); background: var(--green-50); flex-wrap: wrap; }
.breathing { width: 90px; height: 90px; display: grid; place-items: center; flex: none; margin: 0 auto; }
.breathing span { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle, #86efac, #22d3ee); animation: breathe 8s ease-in-out infinite; }
.calm-steps { margin: 0; padding-left: 20px; }

/* ---------------------------------------------------------------------
   Admin
   --------------------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 16px 0; }
.stat { background: var(--white); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.stat__value { font-size: 1.8rem; font-weight: 700; color: var(--blue-700); }
.stat__label { color: var(--ink-500); font-size: .9rem; }
.stat--warn .stat__value { color: var(--rose-500); }
.week-bars { display: flex; flex-direction: column; gap: 8px; }
.week-bar { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; gap: 10px; font-weight: 600; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--ink-100); text-align: left; vertical-align: top; }
.table th { color: var(--ink-500); font-weight: 600; white-space: nowrap; }
.table tr.is-overdue td { background: #fff1f2; }
.level { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.level--critical { background: #ffe4e6; color: #be123c; }
.level--high { background: var(--amber-100); color: var(--amber-700); }
.level--medium { background: var(--blue-50); color: var(--blue-700); }
.level--low { background: var(--green-50); color: var(--green-600); }

/* ---------------------------------------------------------------------
   Animations (เล็กน้อย)
   --------------------------------------------------------------------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pop { 0% { transform: scale(.9); } 100% { transform: scale(1); } }
@keyframes pulse { 0% { opacity: .9; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.15); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 40% { transform: scale(2); } 55% { transform: scale(2); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

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

/* ---------------------------------------------------------------------
   Responsive: Tablet / Desktop
   --------------------------------------------------------------------- */
@media (min-width: 600px) {
  .card { padding: 32px; }
  .mood-selector__grid { grid-template-columns: repeat(7, 1fr); }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-tile--wide { grid-column: 1 / -1; }
  .safety-options { grid-template-columns: 1fr 1fr; }
  .contact-list { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .form-actions { flex-direction: row; justify-content: flex-end; }
  .form-actions .btn--block { width: auto; flex: 1; }
  .progress-header .progress { display: none; }
}

@media (min-width: 900px) {
  body { font-size: 17.5px; }
  .dash-grid { grid-template-columns: 1.6fr 1fr; align-items: start; }
  .dash-hero { padding: 28px 32px; }
  .dash-hero h1 { font-size: 2rem; }
  .ring { width: 132px; height: 132px; }
  .ring__inner { width: 104px; height: 104px; }
}

@media (max-width: 420px) {
  body { font-size: 16px; }
  .mood-option__emoji { font-size: 2rem; border-radius: 16px; }
  .sos-fab { padding: 8px 14px 8px 10px; font-size: .9rem; min-height: 48px; right: 12px; }
  .dash-hero { flex-direction: column; align-items: flex-start; }
  .ring { align-self: center; }
  .topbar__user { display: none; }
}

/* =====================================================================
   Week 2–8 Components
   ===================================================================== */

.instruction { color: var(--ink-700); }
.card--learn .key-message, .card--worksheet .key-message { margin-top: 18px; }

/* LearningCards */
.learn-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.learn-card {
  background: linear-gradient(160deg, #ffffff 0%, var(--blue-50) 100%); border: 1px solid var(--blue-100);
  border-radius: var(--radius); padding: 16px; animation: fadeUp .4s ease both; animation-delay: calc(var(--i, 0) * 70ms);
}
.learn-card__emoji { font-size: 2rem; display: block; margin-bottom: 4px; }
.learn-card h3 { font-size: 1.05rem; }
.learn-card p { margin: 0; color: var(--ink-700); }

.chain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.chain__node {
  position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; margin-bottom: 22px;
  background: var(--white); border: 2px solid var(--cyan-100); border-radius: var(--radius); animation: fadeUp .4s ease both; animation-delay: calc(var(--i, 0) * 80ms);
}
.chain__node:not(:last-child)::after {
  content: "↓"; position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); color: var(--cyan-500); font-weight: 700;
}
.chain__emoji { font-size: 1.7rem; line-height: 1.2; }
.chain__node strong { display: block; }
.chain__node p { margin: 0; color: var(--ink-700); }
.chain--compact .chain__node { padding: 8px 12px; margin-bottom: 18px; }
.chain--compact .chain__node:not(:last-child)::after { bottom: -19px; }

.reveal { display: grid; grid-template-columns: 1fr; gap: 14px; }
.reveal__title { font-size: 1rem; color: var(--blue-600); margin: 6px 0 8px; }
.reveal-card {
  display: block; width: 100%; text-align: left; font: inherit; cursor: pointer; margin-bottom: 8px;
  padding: 12px 14px; border-radius: var(--radius-sm); border: 2px dashed var(--cyan-400); background: #ecfeff; color: var(--ink-900);
  transition: background .2s, border-color .2s, transform .15s;
}
.reveal-card:hover { transform: translateY(-1px); }
.reveal-card__front small { color: var(--cyan-500); font-weight: 600; margin-left: 6px; }
.reveal-card.is-open { border-style: solid; border-color: var(--blue-100); background: var(--white); animation: pop .25s ease; }
.js .reveal-card__back { display: none; }
.js .reveal-card.is-open .reveal-card__back { display: block; }
.js .reveal-card.is-open .reveal-card__front { display: none; }
.js .reveal-card:not(.is-open) .reveal-card__back { display: none; }

/* QuizStepper */
.quiz__meta { display: flex; justify-content: space-between; font-size: .9rem; color: var(--ink-500); }
.quiz-item { border: 0; padding: 0; margin: 18px 0 0; min-width: 0; }
.js .quiz-item:not(.is-active):not(.is-done) { display: none; }
.js .quiz-item.is-active { animation: fadeUp .3s ease both; }
.quiz-item__text { font-size: 1.2rem; font-weight: 700; margin-bottom: 14px; padding: 0; }
.quiz-item__options { display: flex; flex-direction: column; gap: 10px; }
.quiz-item__options--myth_fact, .quiz-item__options--sort { display: grid; grid-template-columns: 1fr 1fr; }
.quiz-option { position: relative; cursor: pointer; }
.quiz-option input { position: absolute; opacity: 0; pointer-events: none; }
.quiz-option__label {
  display: flex; align-items: center; justify-content: flex-start; min-height: var(--tap); height: 100%; padding: 12px 16px;
  border-radius: var(--radius); border: 2px solid var(--ink-200); background: var(--white); font-weight: 600; transition: all .18s ease;
}
.quiz-item__options--myth_fact .quiz-option__label, .quiz-item__options--sort .quiz-option__label { justify-content: center; text-align: center; min-height: 72px; }
.quiz-option:hover .quiz-option__label { border-color: var(--cyan-400); }
.quiz-option input:checked + .quiz-option__label { border-color: var(--blue-600); background: var(--blue-50); }
.quiz-option input:focus-visible + .quiz-option__label { outline: 3px solid var(--cyan-400); }
.quiz-item.is-answered .quiz-option { pointer-events: none; }
.quiz-item.is-answered .quiz-option:not(.is-correct):not(.is-wrong):not(.is-answer) .quiz-option__label { opacity: .55; }
.quiz-option.is-correct input + .quiz-option__label, .quiz-option.is-answer input + .quiz-option__label { border-color: var(--green-500); background: var(--green-50); color: #166534; }
.quiz-option.is-wrong input + .quiz-option__label { border-color: #fda4af; background: #fff1f2; color: #9f1239; }
.quiz-item__feedback { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); font-weight: 500; animation: fadeUp .25s ease both; }
.quiz-item__feedback.is-good { background: var(--green-50); color: #166534; border: 1px solid var(--green-200); }
.quiz-item__feedback.is-soft { background: var(--amber-100); color: #92400e; border: 1px solid #fde68a; }
.quiz-item__next { margin-top: 12px; }
.js .quiz-submit:not(.is-ready) { display: none; }

.chat-bubble { display: flex; gap: 10px; align-items: flex-end; margin: 10px 0; }
.chat-bubble > div { max-width: 85%; padding: 10px 14px; border-radius: 18px; }
.chat-bubble p { margin: 0; }
.chat-bubble small { display: block; font-weight: 700; color: var(--blue-600); font-size: .78rem; }
.chat-bubble--them > div { background: var(--white); border: 1px solid var(--blue-100); border-bottom-left-radius: 4px; box-shadow: var(--shadow-sm); }
.chat-bubble__avatar { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--cyan-100); font-size: 1.3rem; }
.chat-bubble--me { justify-content: flex-end; }
.chat-bubble--me > div { background: var(--grad-main); color: var(--white); border-bottom-right-radius: 4px; }
.chat-bubble--draft > div { background: #fff1f2; color: #9f1239; border: 1px dashed #fda4af; }
.chat-bubble--draft small { color: #be123c; }
.chat-bubble__stamp { font-size: .75rem; color: #be123c; font-weight: 700; white-space: nowrap; }
.quiz--chat .quiz-item { background: var(--blue-50); border-radius: var(--radius); padding: 12px; }
.js .quiz--chat .quiz-item.is-answered .quiz-item__options { display: none; }

.activity-feedback { text-align: center; padding: 10px 4px 4px; animation: fadeUp .4s ease both; }
.activity-feedback.is-correct .game-feedback__score { background: linear-gradient(135deg, #16a34a, #22d3ee); }

/* RatingItems */
.rating-list { display: flex; flex-direction: column; gap: 6px; }
.rating-item { border: 0; padding: 0; margin: 0 0 8px; }
.scale-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale-button { position: relative; cursor: pointer; }
.scale-button input { position: absolute; opacity: 0; pointer-events: none; }
.scale-button span {
  display: grid; place-items: center; min-height: 48px; border-radius: 14px; border: 2px solid var(--ink-200);
  background: var(--white); font-weight: 700; font-size: 1.1rem; transition: all .15s ease;
}
.scale-button input:checked + span { background: var(--grad-main); color: var(--white); border-color: transparent; transform: scale(1.05); }
.scale-button input:focus-visible + span { outline: 3px solid var(--cyan-400); }
.scale-buttons--sm span { min-height: 38px; font-size: .95rem; border-radius: 10px; }

/* SupportPersonPicker */
.people { display: flex; flex-direction: column; gap: 12px; }
.person-row { border: 2px solid var(--blue-100); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0; background: var(--white); min-width: 0; }
.js .person-row--extra { display: none; }
.person-row__title { font-weight: 700; color: var(--blue-700); padding: 0 6px; }
.person-row__rel { margin: 10px 0; }
.chip--sm .chip__body { min-height: 38px; padding: 4px 12px; font-size: .9rem; }
.trust { display: flex; flex-direction: column; gap: 6px; }
.trust__label { font-size: .85rem; color: var(--ink-500); font-weight: 600; }

/* Skill practice */
.js .skill-step { display: none; }
.js .skill-step.is-active { display: block; animation: fadeUp .35s ease both; }
.skill-step + .skill-step { margin-top: 18px; }
.skill-instructions { padding-left: 20px; color: var(--ink-700); }
.skill-timer { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--blue-50); color: var(--blue-700); font-weight: 700; font-variant-numeric: tabular-nums; }
.bubble-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.bubble { width: 240px; height: 240px; display: grid; place-items: center; }
.bubble__circle {
  width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; padding: 10px;
  background: radial-gradient(circle at 30% 30%, #cffafe, #22d3ee 60%, #2563eb);
  color: var(--white); font-weight: 700; text-shadow: 0 1px 2px rgba(15, 23, 42, .3);
  box-shadow: 0 10px 30px rgba(6, 182, 212, .35); transition-property: transform; transition-timing-function: ease-in-out; transform: scale(1);
}
.bubble__circle.is-inhale, .bubble__circle.is-hold { transform: scale(1.8); }
.bubble__circle.is-exhale { transform: scale(1); }
.bubble__circle.is-done { background: radial-gradient(circle at 30% 30%, #dcfce7, #4ade80 60%, #16a34a); }
.bubble__circle span { font-size: .85rem; line-height: 1.2; }
.bubble__circle.is-inhale span, .bubble__circle.is-hold span { transform: scale(.55); }
.bubble__count { margin: 0; font-weight: 600; color: var(--ink-700); }
.btn.is-pulse { animation: pop .6s ease 3; }

.grounding__list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 10px; }
.grounding__step { padding: 12px; border-radius: var(--radius); background: var(--white); border: 2px solid var(--ink-200); transition: border-color .2s, background .2s; }
.grounding__step.is-done { border-color: var(--green-500); background: var(--green-50); }
.grounding__head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; cursor: pointer; font-weight: 600; }
.grounding__head input { width: 22px; height: 22px; accent-color: var(--green-600); }
.grounding__count { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--grad-main); color: var(--white); font-weight: 700; }
.grounding__emoji { font-size: 1.4rem; }

.pause-steps { list-style: none; padding: 0; margin: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); border: 2px solid var(--ink-200); background: var(--white); cursor: pointer; font-weight: 600; }
.check-row input { position: absolute; opacity: 0; pointer-events: none; }
.check-row__box { width: 24px; height: 24px; flex: none; border-radius: 8px; border: 2px solid var(--ink-300); display: grid; place-items: center; }
.check-row:has(input:checked) { border-color: var(--green-500); background: var(--green-50); }
.check-row input:checked ~ .check-row__box { background: var(--green-500); border-color: var(--green-500); }
.check-row input:checked ~ .check-row__box::after { content: "✓"; color: var(--white); font-size: .85rem; }
.check-row input:focus-visible ~ .check-row__box { outline: 3px solid var(--cyan-400); }
.check-row__emoji { font-size: 1.3rem; }

/* Worksheet */
.ws-field { margin-bottom: 4px; }
.ws-view { margin: 12px 0; padding: 12px; border-radius: var(--radius); background: var(--blue-50); }
.ws-display { background: var(--blue-50); border-left: 4px solid var(--cyan-500); border-radius: var(--radius-sm); padding: 10px 14px; margin: 10px 0; }
.ws-display--accent { border-left-color: var(--green-500); background: var(--green-50); }
.ws-display__label { display: block; font-size: .82rem; font-weight: 700; color: var(--blue-700); }
.ws-display p { margin: 2px 0 0; }
.ws-display__list { margin: 4px 0 0; padding-left: 20px; }
.text-field .input { min-height: 48px; }
.list-input { border: 0; padding: 0; margin: 0 0 6px; min-width: 0; }
.list-input__row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.js .list-input__row--extra { display: none; }
.list-input__no { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--cyan-100); color: #155e75; font-weight: 700; font-size: .9rem; }
.prompts { margin: 12px 0; padding: 12px 14px; border-radius: var(--radius); background: var(--amber-100); color: #78350f; }
.prompts__title { font-weight: 700; }
.prompts ul { margin: 6px 0 0; padding-left: 20px; }

/* Thought Lab / Action Plan / Mind Plan / Toolkit */
.lab { display: flex; flex-direction: column; gap: 10px; }
.lab__row { background: var(--white); border: 1px solid var(--blue-100); border-radius: var(--radius); padding: 12px 14px; }
.lab__row p { margin: 4px 0 0; }
.lab__row small { color: var(--ink-500); }
.lab__row--old { background: #fff7ed; border-color: #fed7aa; }
.lab__row--new { background: var(--green-50); border-color: var(--green-200); }
.lab__tag { font-size: .82rem; font-weight: 700; color: var(--blue-700); }
.lab__cols { display: grid; grid-template-columns: 1fr; gap: 10px; }
.lab__delta { margin: 8px 0 0; font-weight: 700; color: var(--ink-700); }
.lab__delta.is-down { color: var(--green-600); }
.level-bar { display: grid; grid-template-columns: 56px 1fr 44px; gap: 10px; align-items: center; margin-top: 6px; font-size: .9rem; }
.level-bar--before .progress__fill { background: linear-gradient(90deg, #fb7185, #f43f5e); }
.level-bar--after .progress__fill { background: linear-gradient(90deg, #22d3ee, #22c55e); }

.plan-steps { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.plan-steps li { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--white); border: 1px solid var(--blue-100); }
.plan-step__no { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--grad-main); color: var(--white); font-weight: 700; font-size: .85rem; }
.plan__meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.plan__meta span { padding: 4px 12px; border-radius: 999px; background: var(--blue-50); font-weight: 600; font-size: .9rem; }

.mind-plan { display: grid; grid-template-columns: 1fr; gap: 10px; }
.mind-plan__block { padding: 12px 14px; border-radius: var(--radius); background: var(--blue-50); }
.mind-plan__block h4 { margin: 0 0 6px; font-size: .95rem; }
.mind-plan__block p { margin: 0; }
.mind-plan__block--warn { background: #fff7ed; }
.mind-plan__block--calm { background: var(--green-50); }
.mind-plan__block--sos { background: #fff1f2; }
.mind-plan-details summary { cursor: pointer; list-style: none; margin: 0; }
.mind-plan-details[open] summary { margin-bottom: 12px; }
.pill--tool { background: var(--cyan-100); border-color: transparent; color: #155e75; }
.toolkit p { margin-top: 8px; }
.summary-view { margin: 14px 0; padding: 14px; border-radius: var(--radius); border: 2px solid var(--cyan-100); background: #f8feff; }
.summary-view h3 { font-size: 1rem; }

.skill-stats { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.skill-stats li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--white); border: 1px solid var(--blue-100); }
.skill-stats small { flex-basis: 100%; color: var(--ink-500); }
.skill-stats small.is-good { color: var(--green-600); font-weight: 600; }

.journey { display: flex; flex-direction: column; gap: 12px; }
.stat-grid--journey { margin: 0; }
.stat-grid--journey .stat { background: var(--blue-50); box-shadow: none; }

.challenge-mini__form { margin: 6px 0 0; }

@media (min-width: 600px) {
  .learn-grid { grid-template-columns: 1fr 1fr; }
  .reveal { grid-template-columns: 1fr 1fr; }
  .lab__cols { grid-template-columns: 1fr 1fr; }
  .mind-plan { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .quiz-item__options--sort { grid-template-columns: 1fr; }
  .bubble { width: 200px; height: 200px; }
  .stat-grid--journey { grid-template-columns: 1fr 1fr; }
}

/* =====================================================================
   Phase 4: Safety System (student notices + staff console)
   ===================================================================== */

.safety-notice {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 16px; border-radius: var(--radius);
  background: var(--white); border: 2px solid var(--cyan-100); text-decoration: none; color: var(--ink-900); box-shadow: var(--shadow);
}
.safety-notice strong { display: block; }
.safety-notice small { color: var(--ink-500); }
.safety-notice__icon { font-size: 1.8rem; }
.safety-notice--new { border-color: #fb7185; background: #fff1f2; animation: fadeUp .4s ease both; }

.message-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.staff-message { padding: 12px 14px; border-radius: var(--radius); background: var(--blue-50); border: 1px solid var(--blue-100); }
.staff-message--new { background: #fff7ed; border-color: #fed7aa; }
.staff-message__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.staff-message__head small { color: var(--ink-500); }
.staff-message p { margin: 0; }
.request-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.request-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius); background: var(--white); border: 1px solid var(--ink-200); }
.request-item > div { flex: 1; min-width: 0; }
.request-item strong { display: block; }
.request-item small { color: var(--ink-500); }
.request-item__emoji { font-size: 1.5rem; }
.request-item--closed { opacity: .8; }

/* Staff console */
.layout-admin .page { max-width: 1240px; }
.topbar__sub { max-width: 1240px; margin: 0 auto; padding: 0 16px 8px; overflow-x: auto; }
.admin-nav { display: flex; gap: 6px; white-space: nowrap; }
.admin-nav__link { padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--ink-700); font-weight: 600; font-size: .92rem; }
.admin-nav__link:hover { background: var(--blue-50); }
.admin-nav__link.is-active { background: var(--grad-main); color: var(--white); }
.nav-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--rose-500); color: var(--white); font-size: .75rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.stat--link { text-decoration: none; color: inherit; transition: transform .15s, box-shadow .2s; }
.stat--link:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tabs { display: flex; gap: 6px; margin: 8px 0 12px; overflow-x: auto; border-bottom: 2px solid var(--ink-200); }
.tabs__tab { padding: 10px 16px; text-decoration: none; color: var(--ink-500); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs__tab.is-active { color: var(--blue-700); border-bottom-color: var(--blue-600); }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; font-size: .85rem; font-weight: 600; color: var(--ink-700); gap: 4px; }
.filters .input { padding: 8px 10px; min-width: 140px; }
.check-inline { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 6px; font-weight: 600; font-size: .92rem; }
.check-inline input { width: 18px; height: 18px; accent-color: var(--blue-600); }
.check-row-inline { display: flex; flex-wrap: wrap; gap: 18px; margin: 12px 0; }
.text-danger { color: var(--red-600); font-weight: 600; }
.nowrap { white-space: nowrap; }
.table tr.is-inactive td { opacity: .55; }
code.cond { display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 6px; background: var(--ink-100); color: var(--ink-700); font-size: .8rem; white-space: normal; }

.case-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 12px; }
.case-head__chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.case-head__due { display: flex; flex-direction: column; padding: 10px 16px; border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow-sm); min-width: 220px; }
.case-head__due strong { font-size: 1.2rem; }
.case-head__due small { color: var(--ink-500); }
.case-head__due.is-overdue { background: #fff1f2; }
.case-head__due.is-overdue strong { color: var(--red-600); }
.case-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.kv { width: 100%; border-collapse: collapse; font-size: .92rem; }
.kv th { text-align: left; vertical-align: top; width: 38%; padding: 7px 8px 7px 0; color: var(--ink-500); font-weight: 600; }
.kv td { padding: 7px 0; border-bottom: 1px solid var(--ink-100); }
.kv tr.is-revealed td, .kv tr.is-revealed th { background: #fff7ed; }
.protocol-steps { margin: 0 0 10px; padding-left: 22px; }
.protocol-steps li { margin-bottom: 4px; }
.case-notes { white-space: pre-wrap; font-family: inherit; font-size: .9rem; background: var(--ink-100); padding: 10px 12px; border-radius: var(--radius-sm); margin: 0 0 12px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--blue-100); }
.timeline li { position: relative; padding: 0 0 12px 12px; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--cyan-500); border: 2px solid var(--white); }
.timeline small { display: block; color: var(--ink-500); }
.timeline p { margin: 2px 0 0; font-size: .92rem; }
.stack-form { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-bottom: 1px dashed var(--ink-200); }
.stack-form:last-of-type { border-bottom: 0; }
.stack-form .field-label { margin: 0; }
.stack-form .input { padding: 9px 12px; }
.stack-form--danger { background: var(--green-50); border-radius: var(--radius-sm); padding: 12px; border: 0; margin-top: 8px; }
.subhead { font-size: .95rem; margin: 14px 0 6px; color: var(--ink-700); }
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.mini-list small { display: block; color: var(--ink-500); }

.admin-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; color: var(--ink-700); }
.admin-form .input { padding: 9px 12px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
.clause-list, .contact-editor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.clause-row, .contact-editor__row { display: grid; grid-template-columns: 30px 1fr; gap: 6px; align-items: center; }
.clause-row > :not(.clause-row__no), .contact-editor__row > :not(.clause-row__no) { grid-column: 2; }
.clause-row__no { grid-row: span 4; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--cyan-100); color: #155e75; font-weight: 700; font-size: .85rem; align-self: start; }
.contact-editor__row .clause-row__no { grid-row: span 3; }
.sandbox-result { margin-top: 12px; }
.protocol-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.protocol-card.is-inactive { opacity: .6; }

@media (min-width: 900px) {
  .case-grid { grid-template-columns: 1.5fr 1fr; align-items: start; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .clause-row { grid-template-columns: 30px 1.6fr 1fr 1.2fr 1.2fr; }
  .clause-row > :not(.clause-row__no) { grid-column: auto; }
  .clause-row__no { grid-row: auto; align-self: center; }
  .contact-editor__row { grid-template-columns: 30px 1.4fr 1fr 1.6fr; }
  .contact-editor__row > :not(.clause-row__no) { grid-column: auto; }
  .contact-editor__row .clause-row__no { grid-row: auto; align-self: center; }
  .protocol-grid { grid-template-columns: repeat(2, 1fr); }
}
.safety-page .chips { margin-top: 18px; }
.safety-page .chips .field-label { margin-top: 0; }

/* =====================================================================
   Phase 5: Registration · Student admin · PHQ-A screening
   ===================================================================== */
.badge--warn { background: var(--amber-100); color: var(--amber-700); }

/* Registration */
.auth--wide { max-width: 520px; }
.auth__divider { display: flex; align-items: center; gap: 10px; margin: 22px 0 12px; color: var(--ink-500); font-size: .88rem; }
.auth__divider::before, .auth__divider::after { content: ""; flex: 1; height: 1px; background: var(--ink-200); }
.auth__card > .btn--secondary { margin-top: 0; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.field-error { margin: 6px 0 0; color: #991b1b; font-size: .88rem; font-weight: 500; }
.input[aria-invalid="true"] { border-color: #f87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, .18); }
.register-form__row { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.register-form select.input { appearance: auto; }
.assent-box { margin-top: 20px; padding: 14px 16px; border-radius: var(--radius); background: var(--blue-50); border: 1px solid var(--blue-100); font-size: .92rem; }
.assent-box p { margin: 0 0 6px; }
.assent-box ul { margin: 0 0 12px; padding-left: 20px; color: var(--ink-700); }
.assent-box li { margin-bottom: 4px; }
.password-hint { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .84rem; color: var(--ink-500); }
.password-hint li::before { content: "○ "; }
.password-hint li.is-ok { color: var(--green-600); }
.password-hint li.is-ok::before { content: "✓ "; }

/* Dashboard PHQ-A card */
.phqa-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; padding: 16px 18px; border-radius: var(--radius-lg); background: var(--white); box-shadow: var(--shadow); border-left: 6px solid var(--cyan-500); animation: fadeUp .35s ease both; }
.phqa-card--new, .phqa-card--due { background: linear-gradient(120deg, #ffffff 0%, #ecfeff 100%); }
.phqa-card--progress { border-left-color: var(--blue-600); }
.phqa-card--done { border-left-color: var(--green-500); }
.phqa-card__icon { font-size: 2.2rem; line-height: 1; }
.phqa-card__body { flex: 1 1 240px; min-width: 0; }
.phqa-card__label { display: inline-block; font-size: .78rem; font-weight: 700; color: #155e75; background: var(--cyan-100); padding: 2px 10px; border-radius: 999px; }
.phqa-card__title { font-size: 1.08rem; margin: 6px 0 2px; }
.phqa-card__body .muted { margin: 0 0 4px; }
.phqa-card__actions { flex: 0 0 auto; }

/* PHQ-A page */
.card--phqa .hero__emoji { text-align: center; }
.phqa-intro { text-align: center; }
.phqa-facts { list-style: none; padding: 0; margin: 0 auto 8px; max-width: 520px; text-align: left; display: flex; flex-direction: column; gap: 6px; font-size: .95rem; color: var(--ink-700); }
.resume-inline { margin: 16px 0 0; padding: 12px 14px; border-radius: var(--radius); background: var(--blue-50); }
.resume-inline p { margin: 0 0 6px; }
.phqa-history__title { margin-top: 26px; }
.phqa-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.phqa-history li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--ink-100); }
.phqa-history__date { font-weight: 600; min-width: 96px; }
.phqa-history .link { margin-left: auto; }
.phqa-result { text-align: center; }
.phqa-result__title { font-size: 1.35rem; margin: 4px 0 8px; }
.phqa-result__level { margin: 0 0 12px; }
.phqa-level { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: .84rem; font-weight: 700; background: var(--ink-100); color: var(--ink-700); }
.phqa-level--minimal { background: var(--green-50); color: var(--green-600); }
.phqa-level--mild { background: var(--cyan-100); color: #155e75; }
.phqa-level--moderate { background: var(--amber-100); color: var(--amber-700); }
.phqa-level--mod_severe { background: #ffedd5; color: #c2410c; }
.phqa-level--severe { background: var(--red-100); color: #991b1b; }
.score-meter { max-width: 360px; margin: 0 auto 10px; }
.score-meter__bar { height: 12px; border-radius: 999px; background: var(--ink-100); overflow: hidden; }
.score-meter__bar span { display: block; height: 100%; border-radius: inherit; background: var(--grad-main); }
.score-meter__text { margin: 6px 0 0; font-size: .92rem; color: var(--ink-500); }
.card--phqa .contact-list { margin-bottom: 8px; }

/* Admin students */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.settings-details > summary { cursor: pointer; list-style: none; }
.settings-details > summary::-webkit-details-marker { display: none; }
.settings-details > summary::after { content: " ▾"; color: var(--ink-500); }
.settings-details[open] > summary::after { content: " ▴"; }
.table tr.is-inactive-soft td { background: #fafafa; color: var(--ink-500); }
.week-bars--wide .week-bar { grid-template-columns: 110px 1fr 40px; }
.inline-form + .inline-form, .btn + .inline-form { margin-left: 4px; }

@media (min-width: 640px) {
  .register-form__row { grid-template-columns: repeat(2, 1fr); }
}
.table .badge, .table .phqa-level { white-space: nowrap; }

/* Admin: แก้ไขข้อความแบบประเมิน */
.assessment-editor .panel > label, .cutoff-editor__item > label { margin-bottom: 12px; }
.assessment-editor textarea.input { resize: vertical; font-family: inherit; line-height: 1.55; }
.scale-editor { display: grid; grid-template-columns: 1fr; gap: 8px; }
.scale-editor--inline { margin-top: 8px; padding: 10px; border-radius: var(--radius-sm); background: var(--ink-100); }
.scale-editor__row { display: grid !important; grid-template-columns: 36px 1fr; align-items: center; gap: 8px !important; }
.scale-editor__value { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--blue-50); color: var(--blue-700); font-weight: 700; }
.question-editor { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.question-editor__item { padding-bottom: 14px; border-bottom: 1px dashed var(--ink-200); }
.question-editor__item:last-child { border-bottom: 0; }
.question-editor__item.is-inactive { opacity: .6; }
.question-editor__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.cutoff-editor { display: flex; flex-direction: column; gap: 12px; }
.cutoff-editor__item { border: 1px solid var(--ink-200); border-radius: var(--radius); padding: 12px 14px; margin: 0; }
.cutoff-editor__item legend { display: flex; gap: 8px; align-items: center; padding: 0 6px; }
.cutoff-editor__fb { display: grid; grid-template-columns: 90px 1fr; gap: 10px; }
.assessment-editor__warn { max-width: none; margin-bottom: 16px; }
.save-bar { position: sticky; bottom: 12px; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: var(--radius-lg); background: rgba(255, 255, 255, .96); box-shadow: var(--shadow-lg); }
.change-details summary { cursor: pointer; font-weight: 600; }
.change-row { font-size: .85rem; margin: 6px 0; word-break: break-word; }
.change-row del { color: #991b1b; }
.change-row ins { color: var(--green-600); text-decoration: none; }
@media (min-width: 900px) {
  .scale-editor { grid-template-columns: repeat(2, 1fr); }
}
.scale-editor--inline > .muted { grid-column: 1 / -1; font-size: .85rem; }
.phqa-credit { margin-top: 6px; font-size: .76rem; }
.assessment-main { min-width: 0; }
.question-editor__no { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 50%; background: var(--cyan-100); color: #155e75; font-weight: 700; font-size: .85rem; }
.question-editor__tools { margin-left: auto; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.question-editor__tools .btn[disabled] { opacity: .35; cursor: default; }
.question-editor__item:target { background: #fefce8; border-radius: var(--radius-sm); box-shadow: 0 0 0 6px #fefce8; }
.cutoff-editor__range { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.cutoff-editor__range label:last-child { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .cutoff-editor__range { grid-template-columns: 110px 110px 1fr; }
  .cutoff-editor__range label:last-child { grid-column: auto; }
}
.text-group { border: 1px solid var(--ink-200); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; }
.text-group > summary { cursor: pointer; font-weight: 700; color: var(--ink-700); }
.text-group[open] > summary { margin-bottom: 10px; }
.text-group > label { margin-bottom: 10px; }
.token-hint { font-weight: 500; color: var(--blue-700); background: var(--blue-50); padding: 0 6px; border-radius: 6px; }
.admin-form label > .token-hint { align-self: flex-start; }
