/* ==========================================================================
   MIRPET — medical-premium interface
   ASCII is reserved exclusively for the pet. Everything else is clean,
   calm, spacious and clinical.
   ========================================================================== */

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

:root {
  --bg: #f3f7f9;
  --bg-deep: #edf4f6;
  --surface: #ffffff;
  --surface-soft: #f8fbfc;
  --ink: #152b33;
  --ink-soft: #3f5963;
  --muted: #71858d;
  --muted-soft: #94a5ab;
  --line: #e3ecef;
  --line-strong: #d3e2e6;
  --teal-900: #083c4c;
  --teal-800: #0b4a5e;
  --teal-700: #0e5a70;
  --teal-600: #14728a;
  --teal-500: #1c8c9c;
  --turquoise: #21b6ad;
  --turquoise-soft: #e5f7f5;
  --sage: #7fa595;
  --sage-soft: #edf5f0;
  --blue-soft: #eaf3f8;
  --danger: #a94e4e;
  --danger-soft: #fbf0f0;
  --success: #2e8067;
  --success-soft: #ecf7f2;
  --amber: #a97a22;
  --amber-soft: #fbf4e5;
  --shadow-xs: 0 1px 2px rgba(12, 48, 60, 0.04);
  --shadow-sm: 0 4px 16px -6px rgba(12, 48, 60, 0.08), 0 1px 3px rgba(12, 48, 60, 0.03);
  --shadow-md: 0 18px 45px -28px rgba(10, 52, 65, 0.3), 0 2px 8px rgba(10, 52, 65, 0.03);
  --shadow-lg: 0 40px 90px -45px rgba(8, 45, 58, 0.42), 0 4px 16px rgba(8, 45, 58, 0.04);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 30px;
  --font-sans: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  --gutter: clamp(16px, 4vw, 40px);
  --max-width: 1180px;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(33, 182, 173, 0.075), transparent 65%),
    radial-gradient(900px 600px at 94% 8%, rgba(20, 114, 138, 0.055), transparent 60%),
    radial-gradient(800px 500px at 55% 108%, rgba(127, 165, 149, 0.07), transparent 70%);
}

::selection {
  background: rgba(20, 114, 138, 0.18);
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

svg {
  flex: none;
}

[hidden] {
  display: none !important;
}

.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: fixed;
  top: 10px;
  left: 50%;
  z-index: 300;
  transform: translate(-50%, -150%);
  background: var(--teal-700);
  color: white;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translate(-50%, 0);
}

:focus-visible {
  outline: 2.5px solid rgba(20, 114, 138, 0.5);
  outline-offset: 2px;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(216, 231, 235, 0.65);
  background: rgba(246, 250, 251, 0.84);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.topbar__inner {
  display: flex;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 13px var(--gutter);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  min-width: 0;
  border-radius: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: white;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(14, 90, 112, 0.06);
  flex: none;
}

.brand-mark svg {
  display: block;
  border-radius: 10px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.brand-name {
  font-size: 1.02rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  line-height: 1.1;
  color: var(--teal-900);
}

.brand-sub {
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.055em;
  color: var(--muted);
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.next-pill,
.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-xs);
  font-size: 0.78rem;
  white-space: nowrap;
  color: var(--ink-soft);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.next-pill .icon {
  color: var(--teal-600);
}

.next-pill__text {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.next-pill__time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--teal-800);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.next-pill.is-off .icon,
.next-pill.is-off .next-pill__time {
  color: var(--muted-soft);
}

.streak-pill {
  color: #8e671c;
  background: linear-gradient(180deg, #fdf8ed, #fbf3e2);
  border-color: #f0e4c9;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  gap: 5px;
}

.streak-pill .icon {
  color: #c08a24;
}

.streak-pill__label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #aa843e;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink-soft);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease,
    box-shadow 0.18s ease, color 0.18s ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: #c7dde2;
  background: #fff;
  color: var(--teal-700);
  box-shadow: var(--shadow-sm);
}

.icon-button:active {
  transform: translateY(0);
}

.icon-button--small {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  border-radius: 9px;
}

.icon-button--small:hover {
  background: rgba(255, 255, 255, 0.7);
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.layout {
  display: grid;
  width: 100%;
  max-width: var(--max-width);
  flex: 1;
  margin: 0 auto;
  padding: clamp(20px, 3.2vw, 38px) var(--gutter) 0;
  grid-template-columns: minmax(300px, 358px) minmax(0, 1fr);
  gap: clamp(18px, 2.6vw, 30px);
  align-items: start;
}

.pet-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.study-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  outline: none;
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Pet card
   -------------------------------------------------------------------------- */

.pet-card {
  position: relative;
  overflow: hidden;
  padding: 21px;
  border: 1px solid rgba(14, 90, 112, 0.09);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, #ffffff 0%, #f9fcfc 56%, #f1f8f8 100%);
  box-shadow: var(--shadow-md);
}

.pet-card::before {
  content: "";
  position: absolute;
  inset: -160px -60px auto auto;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(33, 182, 173, 0.11), transparent 66%);
  pointer-events: none;
}

.pet-card__head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.pet-card__status {
  min-width: 0;
}

.mood-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--sage-soft);
  color: #336e5d;
  font-size: 0.69rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  transition: background 0.3s ease, color 0.3s ease;
}

.mood-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ba184;
  box-shadow: 0 0 0 3px rgba(75, 161, 132, 0.1);
}

.mood-chip[data-mood="sad"] {
  background: #f2f6f8;
  color: #617b84;
}

.mood-chip[data-mood="sad"] .mood-chip__dot {
  background: #8399a0;
  box-shadow: 0 0 0 3px rgba(131, 153, 160, 0.1);
}

.mood-chip[data-mood="sick"],
.mood-chip[data-mood="tired"] {
  background: var(--amber-soft);
  color: #906b26;
}

.mood-chip[data-mood="sick"] .mood-chip__dot,
.mood-chip[data-mood="tired"] .mood-chip__dot {
  background: #c79a45;
  box-shadow: 0 0 0 3px rgba(199, 154, 69, 0.12);
}

.mood-chip[data-mood="critical"] {
  background: var(--danger-soft);
  color: #964747;
}

.mood-chip[data-mood="critical"] .mood-chip__dot {
  background: #bd6262;
  box-shadow: 0 0 0 3px rgba(189, 98, 98, 0.12);
}

.mood-chip[data-mood="celebrating"],
.mood-chip[data-mood="recovering"] {
  background: var(--turquoise-soft);
  color: #1d6d66;
}

.level-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 9px;
  background: linear-gradient(160deg, var(--teal-700), var(--teal-800));
  color: white;
  font-size: 0.71rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  box-shadow: 0 6px 16px -8px rgba(11, 74, 94, 0.6);
  white-space: nowrap;
}

.pet-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 214px;
  margin: 16px 0 7px;
  padding: 25px 10px 20px;
  overflow: hidden;
  border: 1px solid #deedef;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(242, 249, 250, 0.94)),
    radial-gradient(70% 90% at 50% 0%, rgba(33, 182, 173, 0.07), transparent);
  isolation: isolate;
}

.pet-stage__glow {
  position: absolute;
  top: 24%;
  left: 50%;
  width: 235px;
  height: 195px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(33, 182, 173, 0.19), rgba(33, 182, 173, 0) 67%);
  filter: blur(7px);
  z-index: 0;
  transition: opacity 0.4s ease;
}

.pet-stage__grain {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.45;
  background-image: radial-gradient(rgba(14, 90, 112, 0.16) 0.7px, transparent 0.7px);
  background-size: 15px 15px;
  -webkit-mask-image: radial-gradient(ellipse 80% 75% at 50% 58%, black, transparent 78%);
  mask-image: radial-gradient(ellipse 80% 75% at 50% 58%, black, transparent 78%);
  pointer-events: none;
}

.pet-stage__platform {
  position: absolute;
  bottom: 17px;
  left: 50%;
  width: 44%;
  height: 22px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(14, 90, 112, 0.12), rgba(14, 90, 112, 0) 70%);
  pointer-events: none;
}

.pet-sprite {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0;
  color: var(--teal-700);
  font-family: var(--font-mono);
  font-size: clamp(16px, 2.5vw, 21px);
  font-weight: 500;
  line-height: 1.28;
  letter-spacing: 0.035em;
  text-align: center;
  white-space: pre;
  user-select: none;
  -webkit-user-select: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
  animation: petBreathe 5.4s ease-in-out infinite;
  transition: color 0.35s ease;
  will-change: transform;
}

.pet-stage[data-mood="happy"] .pet-sprite {
  color: #0c7567;
}

.pet-stage[data-mood="sad"] .pet-sprite {
  color: #597b88;
}

.pet-stage[data-mood="tired"] .pet-sprite {
  color: #7c7f68;
}

.pet-stage[data-mood="sick"] .pet-sprite {
  color: #977023;
}

.pet-stage[data-mood="critical"] .pet-sprite {
  color: #a45353;
  animation: petCritical 2.2s ease-in-out infinite;
}

.pet-stage[data-mood="celebrating"] .pet-sprite {
  color: #0a7f73;
}

.pet-fx {
  position: absolute;
  top: 13px;
  left: 50%;
  z-index: 3;
  min-height: 14px;
  transform: translateX(-50%);
  color: var(--teal-500);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

.pet-fx--pulse {
  animation: petFx 1.6s ease-out both;
}

.pet-stage--correct .pet-sprite,
.pet-stage--streak .pet-sprite {
  animation: petJump 0.62s cubic-bezier(0.34, 1.56, 0.64, 1) 3;
}

.pet-stage--wrong .pet-sprite {
  animation: petShake 0.38s ease-in-out 4;
}

.pet-stage--levelup .pet-sprite {
  animation: petJump 0.72s cubic-bezier(0.34, 1.56, 0.64, 1) 4;
}

.pet-stage--levelup .pet-stage__glow {
  animation: glowPulse 1.05s ease-in-out 3;
}

.pet-stage--recovery .pet-sprite {
  animation: petRecover 1.2s ease-in-out 2;
}

.pet-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 2px;
}

.pet-identity h2 {
  font-size: 1.36rem;
  font-weight: 720;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}

.pet-tier {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 7px;
  background: var(--sage-soft);
  color: #4e7868;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pet-message {
  min-height: 2.6em;
  margin: 7px 4px 0;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.45;
  text-align: center;
}

.meters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 17px;
  padding-top: 17px;
  border-top: 1px solid rgba(218, 232, 236, 0.8);
}

.meter__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.68rem;
}

.meter__label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-soft);
  font-weight: 650;
  letter-spacing: 0.015em;
}

.meter__label .icon {
  color: var(--muted);
}

.meter__value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.67rem;
  font-weight: 550;
  white-space: nowrap;
}

.meter__track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8f0f2;
  box-shadow: inset 0 1px 2px rgba(14, 65, 80, 0.05);
}

.meter__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 0.7s cubic-bezier(0.22, 0.8, 0.3, 1), background 0.3s ease;
}

.meter__fill--hp {
  background: linear-gradient(90deg, #1c9a83, #56b99d);
  box-shadow: 0 0 8px rgba(40, 154, 129, 0.25);
}

.meter__fill--energy {
  background: linear-gradient(90deg, #d0a043, #e4c476);
  box-shadow: 0 0 8px rgba(208, 160, 67, 0.2);
}

.meter__fill--hp.meter__fill--warn {
  background: linear-gradient(90deg, #d0a043, #e4c476);
  box-shadow: 0 0 8px rgba(208, 160, 67, 0.2);
}

.meter__fill--hp.meter__fill--critical {
  background: linear-gradient(90deg, #a94e4e, #c96a6a);
  box-shadow: 0 0 8px rgba(169, 78, 78, 0.2);
}

.meter__fill--energy.meter__fill--critical {
  background: linear-gradient(90deg, #a94e4e, #c96a6a);
  box-shadow: 0 0 8px rgba(169, 78, 78, 0.2);
}

.meter--exp {
  margin-top: 1px;
  padding-top: 12px;
  border-top: 1px dashed rgba(218, 232, 236, 0.8);
}

.pet-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-top: 14px;
}

.pet-badges:empty {
  display: none;
}

.badge-mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 23px;
  padding: 0 8px;
  border: 1px solid #e0ebed;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 600;
}

.badge-mini::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--turquoise);
}

.badge-mini--locked {
  opacity: 0.58;
}

.badge-mini--locked::before {
  background: var(--muted-soft);
}

.aside-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid rgba(220, 234, 237, 0.8);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.46);
}

.aside-note__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--sage);
  box-shadow: inset 0 0 0 1px rgba(127, 165, 149, 0.12);
}

.aside-note strong {
  display: block;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--ink-soft);
  margin-bottom: 1px;
}

.aside-note p {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.4;
}

/* --------------------------------------------------------------------------
   Template notice
   -------------------------------------------------------------------------- */

.template-notice {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border: 1px solid #d9e9ee;
  border-radius: 16px;
  background: linear-gradient(180deg, #f6fbfd, #f2f9fa);
  box-shadow: var(--shadow-xs);
}

.template-notice__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: white;
  color: var(--teal-600);
  box-shadow: inset 0 0 0 1px #e3eff2;
}

.template-notice__body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.template-notice__body strong {
  font-size: 0.76rem;
  font-weight: 650;
  color: var(--teal-900);
}

.template-notice__body span {
  font-size: 0.71rem;
  color: var(--muted);
  line-height: 1.4;
}

.text-button {
  flex: none;
  padding: 5px 2px;
  border: 0;
  background: none;
  color: var(--teal-700);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 7px;
}

.text-button:hover {
  color: var(--teal-500);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Question card
   -------------------------------------------------------------------------- */

.question-card {
  position: relative;
  padding: clamp(21px, 3.5vw, 38px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.question-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 340px;
  color: var(--muted);
  font-size: 0.82rem;
}

.spinner {
  display: block;
  width: 26px;
  height: 26px;
  border: 2px solid #e3eef0;
  border-top-color: var(--teal-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.question-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.question-crumb {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 550;
  line-height: 1.45;
  overflow-wrap: anywhere;
  padding-top: 3px;
}

.question-crumb strong {
  color: var(--ink-soft);
  font-weight: 650;
}

.favorite-btn {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  flex: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--muted-soft);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.favorite-btn:hover {
  transform: translateY(-1px);
  color: #b58a2e;
  border-color: #ecdfbe;
  background: #fdfaf2;
}

.favorite-btn[aria-pressed="true"] {
  color: #b8862b;
  border-color: #ecdbb2;
  background: #fdf8eb;
}

.favorite-btn[aria-pressed="true"] svg {
  fill: currentColor;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 23px;
  padding: 0 8px;
  border-radius: 6px;
  background: #f2f6f7;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 650;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

.tag--new {
  background: var(--turquoise-soft);
  color: #23736b;
}

.tag--review {
  background: var(--amber-soft);
  color: #976e24;
}

.tag--exam {
  background: var(--blue-soft);
  color: #3b6f83;
}

.tag--difficulty-easy {
  background: var(--success-soft);
  color: #3c7d68;
}

.tag--difficulty-medium {
  background: var(--amber-soft);
  color: #92701f;
}

.tag--difficulty-hard {
  background: var(--danger-soft);
  color: #985353;
}

.tag--source {
  background: #f4f7f8;
  color: var(--muted);
}

.statement {
  max-width: 72ch;
  margin: 18px 0 22px;
  color: var(--ink);
  font-size: clamp(1.28rem, 2.1vw, 1.56rem);
  font-weight: 630;
  letter-spacing: -0.018em;
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: anywhere;
  outline: none;
}

.clinical {
  margin-bottom: 23px;
  padding: 14px 16px 15px;
  border: 1px solid #e5eef1;
  border-radius: 16px;
  background: linear-gradient(180deg, #f9fcfc, #f6fafb);
}

.clinical__head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--teal-700);
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.clinical__head .icon {
  color: var(--teal-500);
}

.clinical__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-bottom: 4px;
}

.clinical__item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.78rem;
}

.clinical__item span {
  color: var(--muted);
  font-size: 0.7rem;
}

.clinical__item strong {
  color: var(--ink-soft);
  font-weight: 650;
}

.clinical__findings {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
}

.clinical__findings:empty {
  display: none;
}

.clinical__findings li {
  position: relative;
  padding-left: 13px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

.clinical__findings li::before {
  content: "";
  position: absolute;
  top: 0.55em;
  left: 1px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--turquoise);
  opacity: 0.75;
}

.clinical__notes {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-style: italic;
  line-height: 1.5;
}

.options-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.option {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 58px;
  padding: 11px 15px;
  border: 1.5px solid #e3edf0;
  border-radius: 15px;
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease,
    transform 0.18s ease, opacity 0.2s ease;
}

.option:hover {
  transform: translateY(-1px);
  border-color: #bfd9df;
  background: #fcfefe;
  box-shadow: 0 6px 18px -12px rgba(13, 83, 105, 0.22);
}

.option:active {
  transform: translateY(0);
}

.option__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.option__letter {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border-radius: 10px;
  background: #f1f6f7;
  color: #52707a;
  font-size: 0.79rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.option__text {
  font-size: 0.91rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.option__badge {
  display: none;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 0.59rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.option:has(.option__input:checked) {
  border-color: var(--teal-600);
  background: linear-gradient(0deg, rgba(20, 114, 138, 0.045), rgba(20, 114, 138, 0.045)), #fff;
  box-shadow: 0 0 0 3px rgba(20, 114, 138, 0.085);
}

.option:has(.option__input:checked) .option__letter {
  background: var(--teal-700);
  color: #fff;
  box-shadow: 0 5px 12px -6px rgba(11, 74, 94, 0.55);
}

.option:has(.option__input:checked) .option__text {
  color: var(--ink);
  font-weight: 550;
}

.option:has(.option__input:focus-visible) {
  outline: 2.5px solid rgba(20, 114, 138, 0.36);
  outline-offset: 2px;
}

.options.is-locked .option {
  cursor: default;
  pointer-events: none;
}

.option.is-correct {
  border-color: #9fd2bd;
  background: #f3fbf7;
  box-shadow: none;
  opacity: 1;
}

.option.is-correct .option__letter {
  background: #3f9477;
  color: #fff;
}

.option.is-correct .option__badge {
  display: inline-flex;
  background: #dff2e9;
  color: #2e7a60;
}

.option.is-wrong {
  border-color: #e3b2b2;
  background: #fdf6f6;
  box-shadow: none;
  opacity: 1;
}

.option.is-wrong .option__letter {
  background: #b46464;
  color: #fff;
}

.option.is-wrong .option__badge {
  display: inline-flex;
  background: #f7e2e2;
  color: #984d4d;
}

.option.is-dim {
  opacity: 0.58;
}

.answer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
}

.hint {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.83rem;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease,
    background 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  transform: none;
  cursor: not-allowed;
}

.btn--primary {
  border-color: transparent;
  background: linear-gradient(135deg, #14748b 0%, #0c5268 100%);
  color: #fff;
  box-shadow: 0 12px 26px -14px rgba(11, 74, 94, 0.65);
}

.btn--primary:hover:not(:disabled) {
  box-shadow: 0 16px 30px -14px rgba(11, 74, 94, 0.7);
  filter: brightness(1.035);
}

.btn--primary:disabled {
  background: #b9cfd4;
  color: rgba(255, 255, 255, 0.92);
  opacity: 1;
  box-shadow: none;
}

.btn--soft {
  border-color: #dbeaed;
  background: #eff7f8;
  color: var(--teal-700);
}

.btn--soft:hover {
  background: #e8f3f5;
  border-color: #c9e1e6;
}

.btn--ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--ink-soft);
}

.btn--ghost:hover {
  background: #fbfdfd;
  border-color: #d1e3e7;
}

.btn--danger-ghost {
  border-color: #f0d9d9;
  background: #fdf8f8;
  color: #9e4f4f;
}

.btn--danger-ghost:hover {
  background: #fbefef;
  border-color: #e8c7c7;
}

.btn--small {
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 0.74rem;
}

.btn__icon {
  width: 17px;
  height: 17px;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Result
   -------------------------------------------------------------------------- */

.result {
  margin-top: 27px;
  padding-top: 27px;
  border-top: 1px dashed #dde8eb;
  animation: resultIn 0.4s cubic-bezier(0.22, 0.8, 0.3, 1) both;
}

.result__banner {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  border: 1px solid #d4ecdf;
  border-radius: 17px;
  background: linear-gradient(180deg, #f6fcf8, #f0faf5);
}

.result--wrong .result__banner {
  border-color: #f0dada;
  background: linear-gradient(180deg, #fdf9f9, #fbf2f2);
}

.result__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: #fff;
  color: var(--success);
  box-shadow: 0 5px 16px -9px rgba(30, 103, 78, 0.4);
}

.result--wrong .result__icon {
  color: var(--danger);
}

.result__headline {
  min-width: 0;
}

.result__title {
  font-size: 0.96rem;
  font-weight: 700;
  color: #265f4f;
  letter-spacing: -0.01em;
}

.result--wrong .result__title {
  color: #864747;
}

.result__subtitle {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.result__rewards {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  margin-left: auto;
}

.reward-chip {
  display: inline-flex;
  align-items: center;
  height: 25px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: #356e5d;
  font-size: 0.67rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.result--wrong .reward-chip {
  color: #8e5454;
}

.reward-chip--xp {
  color: #2b7286;
}

.result__answer {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #e0ecef;
  border-radius: 13px;
  background: #f8fbfc;
  font-size: 0.82rem;
  line-height: 1.5;
}

.result__answer strong {
  color: var(--ink);
  font-weight: 700;
}

.result__answer .answer-letter {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: none;
  border-radius: 7px;
  background: var(--teal-700);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 750;
}

.result__section-title {
  margin: 20px 0 9px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.general-explanation {
  padding: 13px 15px;
  border: 1px solid #e4eef1;
  border-radius: 13px;
  background: #fbfdfd;
  color: var(--ink-soft);
  font-size: 0.81rem;
  line-height: 1.6;
  white-space: pre-line;
}

.explain-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.explain {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-left: 3px solid #cbdadf;
  border-radius: 11px;
  background: #fcfdfd;
}

.explain--correct {
  border-left-color: #58a98b;
  background: #f8fcfa;
}

.explain--selected-wrong {
  border-left-color: #cf8585;
  background: #fdf9f9;
}

.explain__head {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.explain__letter {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 6px;
  background: #eef4f5;
  color: #5c7881;
  font-size: 0.65rem;
  font-weight: 750;
}

.explain--correct .explain__letter {
  background: #e3f3eb;
  color: #2f7d63;
}

.explain__option {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 550;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.explain__status {
  flex: none;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 750;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.explain--correct .explain__status {
  color: #337b62;
}

.explain--selected-wrong .explain__status {
  color: #a05a5a;
}

.explain__text {
  margin-top: 5px;
  padding-left: 29px;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.55;
  white-space: pre-line;
}

.explain__text--missing {
  color: #9aa9ae;
  font-style: italic;
}

.result__source {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 15px;
  color: var(--muted-soft);
  font-size: 0.66rem;
  line-height: 1.5;
}

.result__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #eef3f4;
}

.result__hint {
  color: var(--muted-soft);
  font-size: 0.69rem;
}

/* --------------------------------------------------------------------------
   Question empty state
   -------------------------------------------------------------------------- */

.question-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 32px 20px;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin-bottom: 16px;
  border: 1px solid #e1edef;
  border-radius: 19px;
  background: linear-gradient(180deg, #fbfefe, #f2f9fa);
  color: var(--teal-500);
}

.question-empty h2 {
  margin-bottom: 7px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.question-empty p {
  max-width: 42ch;
  margin-bottom: 19px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

/* --------------------------------------------------------------------------
   Stats strip
   -------------------------------------------------------------------------- */

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-xs);
  transition: background 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
  background: #fff;
  transform: translateY(-1px);
}

.stat-card--ring {
  gap: 11px;
}

.stat-card__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 10px;
  background: #f4f8f9;
  color: var(--teal-600);
}

.stat-card__text {
  min-width: 0;
}

.stat-label {
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.015em;
  white-space: nowrap;
}

.stat-value {
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 720;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.stat-value--small {
  font-size: 0.77rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.stat-muted {
  color: var(--muted-soft);
  font-size: 0.74rem;
  font-weight: 550;
}

.ring {
  --value: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--teal-500) calc(var(--value) * 1%), #e7f0f2 0);
  transition: background 0.6s ease;
}

.ring::before {
  content: "";
  position: absolute;
  inset: 4.5px;
  border-radius: 50%;
  background: #fff;
}

.ring span {
  position: relative;
  z-index: 1;
  color: var(--teal-700);
  font-size: 0.58rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.ring--large {
  width: 68px;
  height: 68px;
}

.ring--large::before {
  inset: 6px;
}

.ring--large span {
  font-size: 0.72rem;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 26px var(--gutter) 22px;
  color: var(--muted-soft);
  font-size: 0.67rem;
}

.footer__dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #c5d3d7;
}

.footer__version {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Reminder banner
   -------------------------------------------------------------------------- */

.reminder-banner {
  position: fixed;
  top: 76px;
  left: 50%;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(600px, calc(100vw - 28px));
  padding: 12px 14px;
  transform: translateX(-50%);
  border: 1px solid #cfe7ea;
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 55px -24px rgba(8, 45, 58, 0.45);
  backdrop-filter: blur(10px);
  animation: bannerIn 0.35s cubic-bezier(0.22, 0.8, 0.3, 1) both;
}

.reminder-banner__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 11px;
  background: var(--turquoise-soft);
  color: var(--teal-700);
}

.reminder-banner__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.reminder-banner__body strong {
  color: var(--teal-900);
  font-size: 0.76rem;
  font-weight: 700;
}

.reminder-banner__body span {
  color: var(--muted);
  font-size: 0.71rem;
  line-height: 1.4;
}

/* --------------------------------------------------------------------------
   Dialogs
   -------------------------------------------------------------------------- */

.modal {
  width: min(720px, calc(100vw - 28px));
  max-width: none;
  max-height: calc(100vh - 36px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

.modal::backdrop {
  background: rgba(7, 34, 43, 0.42);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.modal[open] .modal__panel {
  animation: modalIn 0.3s cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

.modal__panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 36px);
  overflow: hidden;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 45px 110px -30px rgba(4, 28, 36, 0.55);
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 21px clamp(20px, 4vw, 32px) 15px;
  border-bottom: 1px solid #edf3f4;
  background: linear-gradient(180deg, #fff, #fdfefe);
}

.modal__head .eyebrow {
  margin-bottom: 2px;
}

.modal__head h2 {
  font-size: 1.3rem;
  font-weight: 720;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.modal__body {
  padding: 0 clamp(20px, 4vw, 32px) 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cddfe3 transparent;
}

.modal__body::-webkit-scrollbar {
  width: 8px;
}

.modal__body::-webkit-scrollbar-thumb {
  border: 2px solid #fff;
  border-radius: 99px;
  background: #d3e2e6;
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px clamp(20px, 4vw, 32px);
  border-top: 1px solid #edf3f4;
  background: #fbfdfd;
}

.settings-section {
  padding: 21px 0;
  border-top: 1px solid #edf3f4;
}

.settings-section:first-child {
  border-top: 0;
}

.section-heading {
  margin-bottom: 13px;
}

.section-heading h3 {
  margin-bottom: 2px;
  font-size: 0.93rem;
  font-weight: 700;
  letter-spacing: -0.012em;
}

.section-heading p {
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.45;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin-bottom: 5px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 13px;
}

.field > span,
.field__label {
  color: var(--ink-soft);
  font-size: 0.73rem;
  font-weight: 650;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="time"] {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfdfd;
  color: var(--ink);
  font-size: 0.84rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.field input:hover {
  border-color: #d0e2e6;
}

.field input:focus {
  outline: none;
  border-color: var(--teal-500);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(20, 114, 138, 0.1);
}

.field__custom {
  margin-top: 8px;
  max-width: 220px;
}

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0 3px;
  cursor: pointer;
  user-select: none;
}

.switch-row__text {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 1px;
  min-width: 0;
}

.switch-row__text strong {
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 650;
}

.switch-row__text small {
  color: var(--muted);
  font-size: 0.71rem;
  font-weight: 400;
  line-height: 1.4;
}

.switch-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  width: 41px;
  height: 24px;
  flex: none;
  border-radius: 999px;
  background: #dce8ea;
  box-shadow: inset 0 1px 2px rgba(13, 66, 80, 0.08);
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(13, 66, 80, 0.22);
  transition: transform 0.2s cubic-bezier(0.3, 0.8, 0.4, 1);
}

.switch-row input:checked + .switch {
  background: var(--teal-600);
}

.switch-row input:checked + .switch::after {
  transform: translateX(17px);
}

.switch-row input:focus-visible + .switch {
  outline: 2.5px solid rgba(20, 114, 138, 0.4);
  outline-offset: 2px;
}

.permission-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 9px;
}

.permission-pill {
  display: inline-flex;
  align-items: center;
  height: 27px;
  padding: 0 9px;
  border-radius: 8px;
  background: #f2f6f7;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 650;
}

.permission-pill--granted {
  background: var(--success-soft);
  color: #377862;
}

.permission-pill--denied {
  background: var(--danger-soft);
  color: #975050;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  height: 31px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.chip:hover {
  border-color: #c6dee3;
  color: var(--teal-700);
}

.chip--active {
  border-color: var(--teal-600);
  background: var(--teal-700);
  color: #fff;
  box-shadow: 0 4px 10px -6px rgba(11, 74, 94, 0.55);
}

.day-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.day {
  position: relative;
}

.day input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.day span {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  cursor: pointer;
  transition: all 0.16s ease;
}

.day span:hover {
  border-color: #c6dee3;
  color: var(--teal-700);
}

.day input:checked + span {
  border-color: var(--teal-700);
  background: var(--teal-700);
  color: #fff;
  box-shadow: 0 5px 12px -8px rgba(11, 74, 94, 0.65);
}

.day input:focus-visible + span {
  outline: 2.5px solid rgba(20, 114, 138, 0.4);
  outline-offset: 2px;
}

.field-note {
  margin-top: 10px;
  color: var(--muted-soft);
  font-size: 0.68rem;
  line-height: 1.55;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.bank-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.bank-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfdfd;
}

.bank-row__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: #eef6f7;
  color: var(--teal-600);
}

.bank-row__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.bank-row__text strong {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-row__text small {
  color: var(--muted);
  font-size: 0.65rem;
}

.bank-row__remove {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-soft);
  cursor: pointer;
}

.bank-row__remove:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.bank-feedback {
  margin-top: 11px;
  padding: 11px 13px;
  border: 1px solid #f0dada;
  border-radius: 11px;
  background: #fdf8f8;
  color: #8d4f4f;
  font-size: 0.72rem;
  line-height: 1.5;
}

.bank-feedback--ok {
  border-color: #d6ecdf;
  background: #f7fcf9;
  color: #34725e;
}

.bank-feedback strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

.bank-feedback ul {
  margin: 4px 0 0;
  padding-left: 16px;
}

.bank-feedback li {
  margin-top: 2px;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Progress dialog
   -------------------------------------------------------------------------- */

.progress-overview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin: 21px 0 15px;
}

.overview-stat {
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(180deg, #fbfdfd, #f8fbfc);
  text-align: center;
}

.overview-stat span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 600;
  white-space: nowrap;
}

.overview-stat strong {
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 730;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.progress-goal {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 22px;
  padding: 14px 16px;
  border: 1px solid #dcecef;
  border-radius: 16px;
  background: linear-gradient(120deg, #f4fbfb, #f9fdfd 65%, #f4faf6);
}

.progress-goal h3 {
  margin-bottom: 2px;
  font-size: 0.84rem;
  font-weight: 700;
}

.progress-goal p {
  color: var(--muted);
  font-size: 0.73rem;
}

.achievement-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 23px;
}

.achievement {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fcfdfd;
  opacity: 0.66;
}

.achievement--unlocked {
  border-color: #d4e9e0;
  background: linear-gradient(160deg, #f8fdfa, #ffffff);
  opacity: 1;
}

.achievement__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: #f1f6f7;
  color: #6f858c;
}

.achievement--unlocked .achievement__icon {
  background: #e4f4ec;
  color: #378067;
}

.achievement__body {
  min-width: 0;
  flex: 1;
}

.achievement__title {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.achievement__check {
  display: none;
  color: #3f8b70;
}

.achievement--unlocked .achievement__check {
  display: inline-flex;
}

.achievement__desc {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.4;
}

.achievement__progress {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f3;
}

.achievement__progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #57a98c, #21b6ad);
  transition: width 0.5s ease;
}

.achievement__count {
  margin-top: 3px;
  color: var(--muted-soft);
  font-size: 0.58rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hierarchy {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bank-group {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fcfdfd;
}

.bank-group__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.bank-group__head strong {
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 700;
}

.bank-group__head span {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.62rem;
  white-space: nowrap;
}

.tree,
.tree ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree ul {
  margin-left: 8px;
  padding-left: 13px;
  border-left: 1px solid #e5eef1;
}

.tree > ul {
  margin-left: 0;
  padding-left: 0;
  border-left: 0;
}

.tree li {
  position: relative;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 25px;
  padding: 2px 0;
  font-size: 0.73rem;
}

.tree-row__name {
  color: var(--ink-soft);
  font-weight: 550;
}

.tree-row__accuracy {
  color: var(--muted-soft);
  font-size: 0.6rem;
  font-variant-numeric: tabular-nums;
}

.tree-row__count {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 99px;
  background: #f0f6f7;
  color: var(--muted);
  font-size: 0.59rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tree-empty {
  color: var(--muted-soft);
  font-size: 0.7rem;
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Toasts and effects
   -------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 220;
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: min(350px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal-500);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 15px 40px -18px rgba(8, 45, 58, 0.38);
  opacity: 0;
  transform: translateY(8px);
  animation: toastIn 0.28s ease forwards;
  pointer-events: auto;
}

.toast--out {
  animation: toastOut 0.25s ease forwards;
}

.toast--success {
  border-left-color: #57a98c;
}

.toast--warning {
  border-left-color: #d0a043;
}

.toast--error {
  border-left-color: #c07070;
}

.toast__icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  margin-top: 1px;
  border-radius: 7px;
  background: #f2f7f8;
  color: var(--teal-600);
}

.toast--success .toast__icon {
  background: var(--success-soft);
  color: var(--success);
}

.toast--warning .toast__icon {
  background: var(--amber-soft);
  color: var(--amber);
}

.toast--error .toast__icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.toast__body {
  min-width: 0;
  flex: 1;
}

.toast__title {
  display: block;
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.35;
}

.toast__message {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 210;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  position: absolute;
  top: -16px;
  width: 7px;
  height: 11px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes petBreathe {
  0%,
  100% {
    transform: translateY(0) scaleY(1);
  }
  50% {
    transform: translateY(-1.5px) scaleY(1.012);
  }
}

@keyframes petCritical {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.62;
  }
}

@keyframes petJump {
  0%,
  100% {
    transform: translateY(0);
  }
  38% {
    transform: translateY(-9px);
  }
  62% {
    transform: translateY(-3px);
  }
}

@keyframes petShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

@keyframes petRecover {
  0% {
    opacity: 0.65;
    transform: translateY(3px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes glowPulse {
  0%,
  100% {
    opacity: 0.55;
    transform: translateX(-50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.35);
  }
}

@keyframes petFx {
  0% {
    opacity: 0;
    transform: translate(-50%, 5px);
  }
  22% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -9px);
  }
}

@keyframes resultIn {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bannerIn {
  from {
    opacity: 0;
    transform: translate(-50%, -12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes toastIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(5px);
  }
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  100% {
    opacity: 0.15;
    transform: translate3d(var(--drift, 20px), 105vh, 0) rotate(var(--spin, 540deg));
  }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1020px) {
  .layout {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: 16px;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pet-sprite {
    font-size: 18px;
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 18px;
    gap: 14px;
  }

  .pet-column {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .aside-note {
    display: none;
  }

  .pet-card {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    grid-template-areas:
      "head head"
      "stage identity"
      "stage message"
      "stage meters"
      "badges badges";
    column-gap: 18px;
    align-items: center;
    padding: 18px;
  }

  .pet-card__head {
    grid-area: head;
    margin-bottom: 12px;
  }

  .pet-stage {
    grid-area: stage;
    min-height: 190px;
    margin: 0;
    align-self: stretch;
  }

  .pet-identity {
    grid-area: identity;
    justify-content: flex-start;
    margin: 0;
    align-self: end;
  }

  .pet-message {
    grid-area: message;
    min-height: 2.4em;
    margin: 5px 0 0;
    text-align: left;
  }

  .meters {
    grid-area: meters;
    margin-top: 9px;
    padding-top: 10px;
    border-top: 0;
    align-self: start;
  }

  .meter--exp {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .pet-badges {
    grid-area: badges;
    justify-content: flex-start;
    margin-top: 2px;
  }

  .question-card {
    padding: 24px;
  }

  .statement {
    font-size: clamp(1.2rem, 3.4vw, 1.45rem);
  }
}

@media (max-width: 680px) {
  .topbar__inner {
    padding: 10px 15px;
    gap: 10px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }

  .brand-mark svg {
    width: 24px;
    height: 24px;
  }

  .brand-name {
    font-size: 0.94rem;
  }

  .brand-sub {
    display: none;
  }

  .next-pill {
    height: 36px;
    padding: 0 10px;
    gap: 5px;
  }

  .next-pill__text {
    display: none;
  }

  .streak-pill {
    height: 36px;
    padding: 0 10px;
  }

  .streak-pill__label {
    display: none;
  }

  .icon-button {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }

  .top-actions {
    gap: 5px;
  }

  .layout {
    padding: 14px 14px 0;
  }

  .pet-card {
    display: block;
    padding: 15px;
    border-radius: 23px;
  }

  .pet-card__head {
    margin-bottom: 10px;
  }

  .pet-stage {
    min-height: 175px;
    margin: 0 0 8px;
    padding: 19px 8px 14px;
    border-radius: 18px;
  }

  .pet-sprite {
    font-size: 16px;
    line-height: 1.32;
  }

  .pet-stage__platform {
    bottom: 12px;
  }

  .pet-identity {
    justify-content: center;
    margin: 3px 0 0;
  }

  .pet-identity h2 {
    font-size: 1.18rem;
  }

  .pet-message {
    min-height: 0;
    margin: 4px 0 0;
    text-align: center;
    font-size: 0.72rem;
  }

  .meters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(218, 232, 236, 0.8);
  }

  .meter--exp {
    margin: 0;
    padding: 0;
    border: 0;
  }

  .meter__head {
    display: block;
    margin-bottom: 5px;
  }

  .meter__label {
    display: flex;
    font-size: 0.61rem;
  }

  .meter__label .icon {
    width: 12px;
    height: 12px;
  }

  .meter__value {
    display: block;
    margin-top: 1px;
    font-size: 0.59rem;
  }

  .meter__track {
    height: 6px;
  }

  .pet-badges {
    margin-top: 9px;
    justify-content: center;
  }

  .template-notice {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 11px;
  }

  .template-notice__body {
    flex-basis: calc(100% - 44px);
  }

  .template-notice .text-button {
    margin-left: 41px;
  }

  .template-notice .icon-button--small {
    order: 2;
    margin-left: auto;
  }

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

  .question-crumb {
    font-size: 0.68rem;
  }

  .statement {
    margin: 14px 0 17px;
    font-size: 1.2rem;
    line-height: 1.46;
  }

  .clinical {
    margin-bottom: 17px;
    padding: 12px 13px;
  }

  .option {
    min-height: 54px;
    grid-template-columns: 31px minmax(0, 1fr);
    gap: 11px;
    padding: 10px 12px;
  }

  .option__letter {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  .option__text {
    font-size: 0.86rem;
  }

  .option__badge {
    grid-column: 2;
    justify-self: start;
    margin-top: -3px;
  }

  .answer-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-top: 18px;
  }

  .hint {
    text-align: center;
    order: 2;
    font-size: 0.66rem;
  }

  .answer-bar .btn {
    order: 1;
    width: 100%;
    min-height: 47px;
  }

  .result {
    margin-top: 22px;
    padding-top: 22px;
  }

  .result__banner {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
  }

  .result__icon {
    width: 34px;
    height: 34px;
  }

  .result__rewards {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
    padding-left: 44px;
  }

  .result__answer {
    font-size: 0.78rem;
  }

  .explain__option {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .explain__text {
    padding-left: 0;
    font-size: 0.74rem;
  }

  .result__footer {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .result__footer .btn {
    width: 100%;
    min-height: 46px;
  }

  .result__hint {
    text-align: center;
    order: 2;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .stat-card {
    padding: 11px;
    border-radius: 14px;
  }

  .stat-card__icon {
    width: 29px;
    height: 29px;
    border-radius: 9px;
  }

  .stat-value {
    font-size: 0.94rem;
  }

  .stat-value--small {
    font-size: 0.71rem;
  }

  .stat-label {
    font-size: 0.6rem;
  }

  .ring {
    width: 38px;
    height: 38px;
  }

  .ring::before {
    inset: 4px;
  }

  .ring span {
    font-size: 0.53rem;
  }

  .footer {
    justify-content: center;
    padding: 20px 14px 18px;
    font-size: 0.62rem;
    gap: 6px;
  }

  .footer__version {
    display: none;
  }

  dialog.modal {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: 100%;
    max-height: 93vh;
    margin: 0;
    border-radius: 24px 24px 0 0;
  }

  .modal[open] .modal__panel {
    animation: sheetIn 0.32s cubic-bezier(0.2, 0.85, 0.25, 1) both;
  }

  .modal__panel {
    max-height: 93vh;
    border-radius: 24px 24px 0 0;
  }

  .modal__head {
    padding: 18px 18px 13px;
  }

  .modal__body {
    padding: 0 18px 22px;
  }

  .modal__footer {
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .progress-overview {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .achievement-grid {
    grid-template-columns: 1fr;
  }

  .toasts {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

  .reminder-banner {
    top: 66px;
    flex-wrap: wrap;
    gap: 9px;
  }

  .reminder-banner__body {
    flex-basis: calc(100% - 50px);
  }

  .reminder-banner .btn {
    margin-left: 45px;
  }

  .reminder-banner .icon-button--small {
    order: 2;
    margin-left: auto;
  }

  .bank-row__text small {
    white-space: normal;
  }

  .btn {
    font-size: 0.79rem;
  }

  .modal__footer .btn {
    flex: 1;
  }
}

@media (max-width: 420px) {
  .brand-name {
    font-size: 0.88rem;
    letter-spacing: 0.12em;
  }

  .next-pill {
    padding: 0 8px;
  }

  .next-pill .icon {
    display: inline-flex;
  }

  .streak-pill {
    padding: 0 8px;
  }

  .top-actions {
    gap: 4px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .pet-sprite {
    font-size: 15px;
  }

  .pet-stage {
    min-height: 158px;
  }

  .question-card {
    padding: 15px;
  }

  .statement {
    font-size: 1.12rem;
  }

  .option__text {
    font-size: 0.82rem;
  }

  .stats-strip {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card {
    padding: 9px 10px;
    gap: 8px;
  }

  .ring {
    width: 34px;
    height: 34px;
  }

  .ring span {
    font-size: 0.49rem;
  }

  .stat-value {
    font-size: 0.88rem;
  }

  .stat-value--small {
    font-size: 0.66rem;
  }

  .overview-stat {
    padding: 10px 7px;
  }

  .overview-stat strong {
    font-size: 0.97rem;
  }

  .day span {
    width: 34px;
    height: 34px;
  }
}

@keyframes sheetIn {
  from {
    opacity: 0.6;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .pet-sprite,
  .pet-fx {
    animation: none !important;
  }
}
