/*
 * TheraQuiz design correction RC2
 * Presentation-only successor layer. Existing runtime, identifiers, and data flows stay product-owned.
 */

:root {
  --ink: #17203a;
  --ink-strong: #111a33;
  --muted: #667187;
  --line: #dde3ee;
  --line-strong: #cbd4e3;
  --soft: #f3f5fa;
  --canvas: #f6f8fc;
  --blue: #4e72ff;
  --blue-hover: #3f61f0;
  --blue-active: #3153de;
  --blue-soft: #eef2ff;
  --coral: #fe6468;
  --coral-soft: #fff0f1;
  --yellow: #ffd558;
  --yellow-soft: #fff8dc;
  --green: #33c480;
  --green-soft: #eaf8f2;
  --focus: rgba(78, 114, 255, 0.35);
  --shadow-hover: 0 12px 28px rgba(23, 32, 58, 0.07);
}

html { min-width: 320px; }

body {
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 150px, rgba(255, 213, 88, 0.13), transparent 260px),
    var(--canvas);
}

body,
button,
input,
select { font-family: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }

button,
input,
.my-theralab-link,
.reference-item a { min-height: 44px; }

button:focus-visible,
input:focus-visible,
a:focus-visible,
[role="option"]:focus-visible,
dialog:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.owner-review-banner {
  min-height: 32px;
  padding: 6px 16px;
  display: grid;
  place-items: center;
  border-bottom: 1px solid #ead27b;
  color: #6b5100;
  background: var(--yellow-soft);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.01em;
  text-align: center;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 64px;
  height: 64px;
  padding-inline: max(20px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: none;
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 17px;
  height: 17px;
  display: grid;
  grid-template-columns: repeat(2, 7px);
  grid-template-rows: repeat(2, 7px);
  gap: 3px;
  flex: 0 0 17px;
  border-radius: 0;
  background: transparent;
}

.brand-mark i { width: 7px; height: 7px; display: block; border-radius: 50%; }
.brand-mark i:nth-child(1) { background: var(--blue); }
.brand-mark i:nth-child(2) { background: var(--coral); }
.brand-mark i:nth-child(3) { background: var(--yellow); }
.brand-mark i:nth-child(4) { background: var(--green); }

.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { color: var(--ink-strong); font-size: 17px; font-weight: 820; letter-spacing: -0.025em; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; }

.topbar-actions { gap: 10px; }

.account-chip {
  min-height: 44px;
  padding-left: 13px;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}

.account-chip .link-button {
  min-height: 44px;
  padding-inline: 12px;
  border-left: 1px solid var(--line);
  border-radius: 0 11px 11px 0;
}

.my-theralab-link {
  gap: 7px;
  padding-inline: 14px;
  border-color: var(--line-strong);
  color: #2946bc;
  box-shadow: none;
}

.my-theralab-link:hover { border-color: var(--blue); background: var(--blue-soft); }

.shell {
  width: min(100%, 1180px);
  max-width: 1180px;
  padding: 28px 24px 72px;
}

.eyebrow,
.kicker {
  color: #3856c8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.115em;
}

h1 { color: var(--ink-strong); }
h2 { color: var(--ink-strong); font-size: 20px; }

.card,
.auth-card,
.quiz-card,
.lesson-reader,
.module-header,
.study-today,
.study-search-box {
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: none;
}

.card { padding: 24px; border-radius: 18px; }

.primary,
.secondary {
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 11px;
  font-weight: 760;
}

.primary { color: #fff; background: var(--blue); box-shadow: 0 7px 15px rgba(78, 114, 255, 0.18); }
.primary:hover { background: var(--blue-hover); filter: none; }
.primary:active { background: var(--blue-active); transform: translateY(1px); }
.secondary { border-color: var(--line-strong); color: #2946bc; background: #fff; }
.secondary:hover { border-color: var(--blue); background: var(--blue-soft); }
.link-button { min-height: 44px; border-radius: 9px; color: #3856c8; }
.link-button:hover { background: var(--blue-soft); }

/* Sign-in is a product entry, not a floating document form. */
.auth-card {
  width: min(100%, 920px);
  max-width: 920px;
  min-height: 520px;
  margin: 26px auto 10px;
  padding: 44px;
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(360px, 1.12fr);
  grid-template-rows: min-content min-content min-content 1fr;
  column-gap: 64px;
  align-content: center;
  overflow: hidden;
  border-radius: 24px;
  background:
    linear-gradient(90deg, rgba(255, 248, 220, 0.72) 0 43%, #fff 43% 100%);
}

.auth-card::before {
  content: "";
  width: 58px;
  height: 5px;
  grid-column: 1;
  margin-bottom: 24px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue) 0 25%, var(--coral) 25% 50%, var(--yellow) 50% 75%, var(--green) 75%);
}

.auth-card > .eyebrow,
.auth-card > h1,
.auth-card > .lede { grid-column: 1; }

.auth-card > h1 {
  align-self: end;
  margin: 8px 0 16px;
  font-size: clamp(40px, 5.6vw, 62px);
  line-height: 0.98;
}

.auth-card > .lede { align-self: start; margin: 0; font-size: 16px; }

.auth-card > .auth-tabs,
.auth-card > #auth-form,
.auth-card > #login-message,
.auth-card > .fineprint {
  grid-column: 2;
}

.auth-card > .auth-tabs { grid-row: 1; align-self: end; margin: 0 0 14px; }
.auth-card > #auth-form { grid-row: 2 / span 3; }
.auth-card > #login-message { grid-row: 4; }
.auth-card > .fineprint { grid-row: 5; }
.auth-card label { margin: 0 0 13px; }
.auth-card input { min-height: 48px; border-color: var(--line-strong); }
.auth-card .wide { min-height: 48px; }
.auth-divider { margin-top: 14px; }
.fineprint { line-height: 1.55; }

/* The first viewport holds orientation and a real next action. */
.welcome-row {
  position: relative;
  min-height: 148px;
  align-items: center;
  margin: 0 0 18px;
  padding: 26px 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(103deg, #fff 0 72%, var(--yellow-soft) 72% 100%);
}

.welcome-row::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--yellow);
}

.welcome-copy { min-width: 0; }

.welcome-row h1 {
  max-width: 700px;
  margin: 5px 0 8px;
  font-size: clamp(34px, 4.1vw, 46px);
  line-height: 1.01;
}

.welcome-row .lede { max-width: 700px; margin: 0; color: var(--muted); font-size: 15px; }

.welcome-actions {
  width: 276px;
  min-width: 276px;
  display: grid;
  gap: 10px;
  justify-items: stretch;
}

.welcome-actions #resume { width: 100%; }

.workspace-tabs,
.auth-tabs {
  width: 100%;
  padding: 4px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #edf0f6;
}

.tab { min-height: 44px; padding: 9px 13px; }
.tab.active,
.tab[aria-selected="true"] {
  color: #2946bc;
  background: #fff;
  box-shadow: 0 1px 4px rgba(23, 32, 58, 0.08), inset 0 0 0 1px #d6defc;
}

#message { margin: 0; }
#message:empty { display: none; }

/* Practice home: deliberate bento for full access, equal choices for Free access. */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(320px, 0.78fr);
  grid-template-areas:
    "build daily"
    "build progress";
  gap: 18px;
  align-items: stretch;
}

.build-card {
  grid-area: build;
  min-width: 0;
  min-height: 530px;
  display: flex;
  flex-direction: column;
}

.daily-card {
  grid-area: daily;
  min-width: 0;
  min-height: 246px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  gap: 16px;
}

.progress-card {
  grid-area: progress;
  min-width: 0;
  min-height: 266px;
}

#app[data-access="free"] .dashboard-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "daily build"
    "progress progress";
}

#app[data-access="free"] .daily-card,
#app[data-access="free"] .build-card {
  min-height: 294px;
}

#app[data-access="free"] .progress-card { min-height: 0; }

.daily-card,
.build-card,
.progress-card,
.library-grid .card {
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.daily-card:hover,
.build-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-hover); }

.card-heading { min-width: 0; }
.card-heading h2 { margin-top: 6px; font-size: clamp(21px, 2vw, 25px); }
.card-heading p { margin: 0; color: var(--muted); }

.card-icon {
  width: 50px;
  height: 50px;
  border: 1px solid #f1d474;
  border-radius: 15px;
  color: #705400;
  background: var(--yellow-soft);
  font-size: 21px;
}

.daily-card .primary { grid-column: 1 / -1; width: 100%; align-self: end; }
.build-card > .primary { width: 100%; margin-top: auto; }

.filter-tray {
  margin: 20px 0 18px;
  padding: 18px;
  border-color: var(--line);
  border-radius: 15px;
  background: var(--soft);
}

.filter-tray-header { margin-bottom: 14px; }
.filter-tray-header > .field-label { margin: 0; color: var(--ink-strong); font-size: 13px; }
.filter-summary { color: var(--muted); }
.builder { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-label,
.count-field > span { color: #4d5970; font-size: 12px; }

.picker-trigger {
  min-height: 46px;
  padding-inline: 13px;
  overflow: hidden;
  border-color: var(--line-strong);
  border-radius: 10px;
}

.picker-trigger > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.picker-popover {
  border-color: var(--line-strong);
  box-shadow: 0 18px 44px rgba(23, 32, 58, 0.16);
}

.picker-option { min-height: 44px; }

.decision-rail {
  width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border-color: var(--line);
  background: #e9edf5;
}

.count-option {
  min-width: 0;
  min-height: 44px;
  padding-inline: 8px;
  border-radius: 9px;
  white-space: nowrap;
}

.count-option.active,
.count-option[aria-checked="true"] {
  border-color: #c6d1ff;
  color: #2946bc;
  background: #fff;
  box-shadow: 0 1px 4px rgba(23, 32, 58, 0.08);
}

.progress-card .card-header { align-items: start; }
.progress-card .card-header h2 { margin-bottom: 0; }
.score-strip { margin: 18px 0 10px; }
.score-strip strong { color: var(--ink-strong); font-size: 38px; }
.weak-row { min-height: 44px; }

.library-grid { gap: 18px; margin-top: 18px; }
.library-grid .card { min-height: 190px; }
.library-grid h2 { margin-bottom: 16px; }
.list p:first-child { border-top: 0; }

/* Question flow: clear sequence, scannable answers, honest feedback. */
.quiz-card {
  width: min(100%, 900px);
  max-width: 900px;
  margin-top: 0;
  padding: 30px;
  border-radius: 22px;
}

.quiz-topline { min-height: 44px; }
.journey-rail { margin: 14px 0; }
.journey-rail li { min-height: 42px; display: flex; align-items: center; }
.progress-track { height: 7px; margin: 12px 0 28px; }
.question-stem { color: var(--ink-strong); font-size: clamp(20px, 2.5vw, 24px); }

.choices { counter-reset: answer; gap: 11px; }

.choice {
  counter-increment: answer;
  min-height: 62px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  padding: 13px 15px;
  border-color: var(--line-strong);
  border-radius: 14px;
}

.choice::before {
  content: counter(answer, upper-alpha);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #59647a;
  background: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.choice:hover:not(:disabled) { border-color: #aebdff; background: #fbfcff; }
.choice.selected { border-color: var(--blue); background: var(--blue-soft); }
.choice.selected::before { border-color: var(--blue); color: #2946bc; background: #fff; }
.choice.correct { border-color: #76cda6; background: var(--green-soft); }
.choice.correct::before { border-color: #76cda6; color: #0d6b48; background: #fff; }
.choice.wrong { border-color: #f09a9e; background: var(--coral-soft); }
.choice.wrong::before { border-color: #f09a9e; color: #a42c32; background: #fff; }
.choice-state { white-space: nowrap; }

.feedback-card { padding: 20px; border: 1px solid var(--line); border-radius: 14px; }
.feedback-card.correct { border-left: 4px solid var(--green); }
.feedback-card.wrong { border-left: 4px solid var(--coral); }
.feedback-actions { align-items: center; }

/* Study Guide keeps the same grammar while becoming a real learning surface. */
.study-hero {
  min-height: 154px;
  margin-bottom: 18px;
  padding: 26px 28px;
  overflow: hidden;
  border-radius: 22px;
  background: linear-gradient(104deg, #fff 0 76%, var(--yellow-soft) 76% 100%);
}

.study-hero h1 { margin: 5px 0 8px; font-size: clamp(32px, 4vw, 44px); }
.study-hero p { max-width: 720px; }
.study-summary {
  width: 104px;
  min-width: 104px;
  height: 104px;
  display: grid;
  place-content: center;
  justify-items: center;
  border: 8px solid #ffe790;
  border-radius: 50%;
  color: var(--ink-strong);
  background: #fff;
}

.study-summary strong { color: var(--ink-strong); font-size: 30px; }
.study-summary span { text-align: center; }

.study-today { padding: 22px; border-radius: 18px; }
.study-today-grid { align-items: stretch; }
.today-action { min-height: 144px; align-content: start; border-color: var(--line); background: var(--soft); }
.today-action strong { margin-top: 4px; }
.today-action.today-primary { border-color: #c8d3ff; background: var(--blue-soft); }
.today-action:not(:disabled):hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); }

.learning-summary-grid { gap: 12px; }
.learning-summary-card { min-height: 112px; border-color: var(--line); }
.learning-summary-card strong { color: var(--ink-strong); }

.study-search-box { align-items: center; padding: 20px 22px; }
.study-search-controls input { min-height: 46px; border-color: var(--line-strong); }
.module-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
.module-card { min-height: 230px; border-color: var(--line); box-shadow: none; }
.module-card:hover { transform: translateY(-1px); border-color: var(--line-strong); box-shadow: var(--shadow-hover); }
.module-progress-fill { background: var(--blue); }

.module-header { border-radius: 20px; }
.lesson-row { min-height: 72px; border-color: var(--line); }
.lesson-row:hover { border-color: #aebdff; background: #fbfcff; }
.lesson-reader { border-radius: 20px; }
.recall-panel { border-color: var(--line); background: var(--soft); }
.recall-card { border-color: var(--line); }
.study-search-result,
.recommendation-card { border-color: var(--line); }

.decision-dialog { border-color: var(--line-strong); border-radius: 20px; }
.decision-dialog::backdrop { background: rgba(17, 26, 51, 0.48); }
.dialog-actions button { min-width: 142px; }

footer {
  width: min(calc(100% - 48px), 1180px);
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 0 38px;
  border-color: var(--line);
}

@media (max-width: 980px) {
  .dashboard-grid,
  #app[data-access="free"] .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "daily" "build" "progress";
  }

  .daily-card,
  .build-card,
  .progress-card,
  #app[data-access="free"] .daily-card,
  #app[data-access="free"] .build-card {
    min-height: 0;
  }

  .build-card { order: 1; }
  .daily-card { order: 0; }
  .progress-card { order: 2; }
  .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  .topbar { min-height: 64px; height: auto; padding: 9px 16px; }
  .account-chip #identity { display: none; }
  .account-chip { padding-left: 0; border: 0; background: transparent; }
  .account-chip .link-button { border: 0; border-radius: 9px; }
  .shell { padding: 18px 16px 56px; }

  .auth-card {
    min-height: 0;
    padding: 30px 26px;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 0;
    background: #fff;
  }

  .auth-card::before,
  .auth-card > .eyebrow,
  .auth-card > h1,
  .auth-card > .lede,
  .auth-card > .auth-tabs,
  .auth-card > #auth-form,
  .auth-card > #login-message,
  .auth-card > .fineprint {
    grid-column: 1;
    grid-row: auto;
  }

  .auth-card::before { margin-bottom: 18px; }
  .auth-card > h1 { margin-bottom: 13px; font-size: clamp(38px, 12vw, 52px); }
  .auth-card > .lede { margin-bottom: 24px; }
  .auth-card > .auth-tabs { margin-bottom: 14px; }

  .welcome-row {
    min-height: 0;
    padding: 22px;
    align-items: stretch;
    flex-direction: column;
    background: #fff;
  }

  .welcome-actions { width: 100%; min-width: 0; }
  .welcome-row h1 { font-size: clamp(31px, 8.5vw, 40px); }
  .builder { grid-template-columns: 1fr; }
  .field-group.full-span,
  .count-field.full-span { grid-column: 1; }
  .library-grid,
  .learning-summary-grid,
  .module-grid,
  .recommendation-grid,
  .due-recall-grid { grid-template-columns: 1fr; }
  .library-grid .card { min-height: 0; }

  .study-hero,
  .module-header,
  .lesson-header { align-items: stretch; flex-direction: column; }
  .study-summary { width: 92px; min-width: 92px; height: 92px; place-self: start; }
  .study-search-box { align-items: stretch; flex-direction: column; }
  .study-search-controls { width: 100%; }
  .picker-popover { position: relative; inset: 7px auto auto; }
}

@media (max-width: 560px) {
  .owner-review-banner { padding-inline: 12px; }
  .brand-copy small { display: none; }
  .my-theralab-link { padding-inline: 11px; }
  .card,
  .quiz-card,
  .lesson-reader,
  .module-header { padding: 20px; border-radius: 16px; }
  .daily-card { grid-template-columns: 46px minmax(0, 1fr); gap: 13px; }
  .card-icon { width: 44px; height: 44px; border-radius: 13px; }
  .filter-tray { padding: 14px; }
  .filter-tray-header { align-items: start; flex-direction: column; }
  .filter-summary { text-align: left; }
  .decision-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice { grid-template-columns: 32px minmax(0, 1fr); }
  .choice-state { grid-column: 2; justify-self: start; white-space: normal; }
  .study-search-controls { flex-direction: column; }
  .study-search-controls .secondary { width: 100%; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; min-width: 0; }
  footer { width: calc(100% - 28px); }
}

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