:root {
  color-scheme: light;
  --bg: #fbfaf5;
  --ink: #223033;
  --muted: #617174;
  --panel: #ffffff;
  --line: #dde6e2;
  --teal: #2f7d78;
  --teal-soft: #d9efea;
  --coral: #b84a3f;
  --coral-soft: #ffe1d8;
  --gold: #ad7b17;
  --gold-soft: #ffefbd;
  --blue: #316d9f;
  --blue-soft: #dce9ff;
  --green: #347955;
  --green-soft: #dff1df;
  --shadow: 0 14px 32px rgba(32, 48, 51, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(217, 239, 234, 0.65), transparent 320px),
    var(--bg);
}

button {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
audio:focus-visible {
  outline: 3px solid #316d9f;
  outline-offset: 3px;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 10px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sync-indicator {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  border-radius: 8px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.sync-indicator i {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #2f7d78;
}

.sync-indicator.status-syncing i,
.sync-indicator.status-pending i {
  background: #d08a16;
}

.sync-indicator.status-offline i,
.sync-indicator.status-auth i,
.sync-indicator.status-error i {
  background: #d95b4f;
}

.brand {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.brand h1 {
  margin: 0;
  font-size: 2.25rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.icon-button,
.speak-button,
.clear-button,
.primary-button,
.secondary-button,
.danger-button {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}

.icon-button:disabled {
  opacity: 0;
  pointer-events: none;
}

.icon-button svg,
.speak-button svg,
.clear-button svg,
.primary-button svg,
.secondary-button svg,
.danger-button svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  color: #ffffff;
  background: var(--teal);
  box-shadow: none;
}

.danger-button {
  color: #ffffff;
  background: var(--coral);
  box-shadow: none;
}

.secondary-button:disabled,
.danger-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.content {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0 22px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.portal-content {
  display: grid;
  align-items: start;
}

.portal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  width: min(820px, 100%);
  margin: 18px auto 0;
}

.portal-button {
  display: grid;
  min-height: 290px;
  grid-template-rows: 1fr auto;
  justify-items: center;
  gap: 18px;
  padding: 24px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--line);
  cursor: pointer;
}

.portal-button img {
  width: min(180px, 100%);
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
}

.portal-button span {
  display: grid;
  gap: 6px;
  text-align: center;
}

.portal-button strong {
  font-size: 1.75rem;
}

.portal-button small {
  color: var(--muted);
  font-size: 0.95rem;
}

.portal-button.communicate {
  border-top: 6px solid var(--teal);
}

.portal-button.learn {
  border-top: 6px solid var(--gold);
}

.learning-content {
  padding-bottom: 40px;
}

.learning-heading {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.learning-heading div {
  display: grid;
  gap: 4px;
}

.learning-heading h2 {
  margin: 0;
  font-size: 1.85rem;
}

.learning-heading span {
  color: var(--muted);
}

.learning-heading > strong {
  display: grid;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.learning-module-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.learning-module-card {
  position: relative;
  display: grid;
  min-height: 230px;
  grid-template-rows: 1fr auto;
  gap: 12px;
  padding: 14px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--line);
  cursor: pointer;
}

.learning-module-card:nth-child(1) { border-top: 5px solid var(--gold); }
.learning-module-card:nth-child(2) { border-top: 5px solid var(--blue); }
.learning-module-card:nth-child(3) { border-top: 5px solid var(--coral); }
.learning-module-card:nth-child(4) { border-top: 5px solid var(--teal); }
.learning-module-card:nth-child(5) { border-top: 5px solid var(--green); }

.learning-module-card img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
}

.learning-module-card span,
.learning-item-label {
  display: grid;
  gap: 4px;
  text-align: center;
}

.learning-module-card strong {
  font-size: 1.05rem;
}

.learning-module-card small,
.learning-item-label small {
  color: var(--muted);
}

.learning-module-card em {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  min-width: 36px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  font-style: normal;
  font-weight: 900;
}

.number-blocks {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
  padding-bottom: 4px;
}

.english-categories,
.learning-mode-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
  padding-bottom: 4px;
}

.learning-mode-tabs {
  margin-bottom: 10px;
}

.learning-progress-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.learning-progress-summary span {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 0.9rem;
}

.learning-progress-summary strong {
  color: var(--teal);
}

.learning-activity {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: clamp(18px, 4vw, 32px);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.activity-prompt {
  min-height: 74px;
  display: grid;
  place-items: center;
}

.activity-listen-button {
  display: inline-flex;
  min-height: 58px;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
  font-weight: 900;
  cursor: pointer;
}

.activity-listen-button svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.activity-target {
  display: grid;
  gap: 6px;
  text-align: center;
}

.activity-target small {
  color: var(--muted);
}

.activity-target strong {
  font-size: 2.2rem;
}

.activity-choice-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.activity-choice {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}

.activity-choice img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
}

.activity-choice.chosen {
  opacity: 0.46;
  box-shadow: inset 0 0 0 3px var(--green);
}

.activity-feedback {
  min-height: 28px;
  color: var(--muted);
  font-weight: 900;
}

.activity-feedback.success {
  color: var(--green);
}

.activity-next {
  min-width: 180px;
}

.learning-item-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.learning-item-card {
  display: grid;
  min-height: 205px;
  grid-template-rows: 1fr auto;
  gap: 10px;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}

.learning-item-visual {
  position: relative;
  display: grid;
  min-width: 0;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
}

.learning-item-visual img {
  width: 100%;
  height: 100%;
  min-height: 130px;
  object-fit: cover;
  opacity: 1;
}

.learning-item-visual.pending img {
  opacity: 0.48;
}

.learning-item-visual b {
  position: absolute;
  display: grid;
  max-width: calc(100% - 16px);
  min-width: 68px;
  min-height: 68px;
  place-items: center;
  padding: 8px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  font-size: 2.4rem;
  line-height: 1;
}

.learning-item-label strong {
  font-size: 1.05rem;
}

.learning-loading,
.learning-error {
  grid-column: 1 / -1;
  padding: 22px;
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  font-weight: 800;
}

.learning-error {
  color: #87372d;
  background: var(--coral-soft);
}

.category-button {
  display: grid;
  min-height: 220px;
  grid-template-rows: 1fr auto;
  gap: 16px;
  align-items: center;
  justify-items: center;
  border: 0;
  border-radius: 8px;
  padding: 22px 16px 18px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(34, 48, 51, 0.07);
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
}

.category-art-wrap {
  display: grid;
  place-items: center;
  width: min(136px, 54vw);
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 22px;
  background: var(--visual-bg, var(--teal-soft));
}

.category-art,
.calm-ai-art,
.report-ai-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.category-button:active,
.tile-button:active,
.routine-step:active {
  transform: scale(0.985);
}

.category-label {
  display: grid;
  gap: 6px;
  text-align: center;
}

.category-label strong {
  font-size: 1.6rem;
  letter-spacing: 0;
}

.category-label span {
  color: var(--muted);
  font-size: 1rem;
}

.visual {
  display: grid;
  place-items: center;
  width: min(118px, 40vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--visual-bg, var(--teal-soft));
}

.visual svg {
  width: 70%;
  height: 70%;
}

.photo-visual {
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.75);
}

.photo-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-tile-visual {
  width: min(132px, 38vw);
  overflow: hidden;
  border-radius: 20px;
  background: transparent;
}

.ai-tile-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.visual .stroke {
  stroke: var(--visual-ink, var(--teal));
  stroke-width: 7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visual .fill {
  fill: var(--visual-ink, var(--teal));
}

.visual .soft-fill {
  fill: rgba(255, 255, 255, 0.68);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.category-tabs {
  display: flex;
  flex: 1 1 360px;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-button {
  flex: 0 0 auto;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}

.tab-button.active {
  color: #ffffff;
  background: var(--teal);
  box-shadow: none;
}

.phrase-bar {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  min-height: 74px;
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.phrase-text {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 54px;
  align-items: center;
  overflow: auto;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #f4f7f4;
  font-size: 1.2rem;
  font-weight: 700;
}

.phrase-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  color: #ffffff;
  background: var(--teal);
  font-weight: 900;
  line-height: 1.1;
}

.phrase-placeholder {
  color: var(--muted);
  font-weight: 600;
}

.sentence-builder {
  margin-bottom: 10px;
}

.starter-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.starter-button {
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  font-weight: 900;
}

.starter-button.active {
  color: #ffffff;
  background: var(--blue);
  box-shadow: none;
}

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

.tile-button,
.routine-step {
  display: grid;
  min-height: 172px;
  grid-template-rows: 1fr auto;
  gap: 10px;
  align-items: center;
  justify-items: center;
  border: 0;
  border-radius: 8px;
  padding: 16px 12px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px rgba(34, 48, 51, 0.08);
  cursor: pointer;
}

.tile-button.active {
  box-shadow:
    0 0 0 3px var(--teal),
    var(--shadow);
}

.tile-label,
.routine-label {
  width: 100%;
  min-height: 34px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
}

.routine-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.routine-status {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.routine-status strong,
.routine-status span {
  display: block;
}

.routine-status strong {
  font-size: 1.2rem;
}

.routine-status span {
  color: var(--muted);
  font-weight: 800;
}

.routine-progress {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #f3ead0;
}

.routine-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
}

.routine-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.routine-step {
  position: relative;
  min-height: 190px;
}

.routine-step.current {
  box-shadow:
    0 0 0 3px var(--gold),
    var(--shadow);
}

.routine-step.done {
  background: #f6fbf5;
}

.routine-step.done .visual {
  opacity: 0.72;
}

.step-number {
  position: absolute;
  top: 10px;
  left: 10px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--teal);
  font-weight: 900;
}

.step-check {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 10px;
  color: #ffffff;
  background: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
}

.step-check:empty {
  display: none;
}

.calm-content {
  padding-bottom: 92px;
}

.calm-content > .phrase-bar {
  margin-bottom: 16px;
}

.calm-hero {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  border-radius: 8px;
  padding: clamp(18px, 4vw, 36px);
  background: linear-gradient(135deg, #e8f5e9, #ffffff 62%);
  box-shadow: inset 0 0 0 1px var(--line);
}

.calm-visual-stack {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
}

.calm-ai-art {
  width: min(310px, 62vw);
  aspect-ratio: 1;
  border-radius: 28px;
  box-shadow: 0 18px 40px rgba(52, 121, 85, 0.18);
}

.breathing-orb {
  position: absolute;
  display: grid;
  place-items: center;
  inset: auto auto 10px 12px;
  width: 112px;
  height: 112px;
}

.breathing-orb span {
  width: 78px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.95), transparent 30%),
    var(--green-soft);
  box-shadow:
    0 0 0 18px rgba(52, 121, 85, 0.12),
    0 20px 42px rgba(52, 121, 85, 0.22);
  animation: breathe 5.5s ease-in-out infinite;
}

.calm-copy {
  display: grid;
  gap: 14px;
}

.calm-copy h2 {
  margin: 0;
  font-size: 3.6rem;
  line-height: 1;
}

.calm-copy p {
  margin: 0;
  color: var(--green);
  font-size: 1.5rem;
  font-weight: 900;
}

.calm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.calm-tile {
  background: #ffffff;
}

.calm-tile small {
  color: var(--muted);
  font-size: 0.78rem;
}

.calm-tile.selected {
  box-shadow: inset 0 0 0 3px var(--green);
  background: var(--green-soft);
}

.calm-sounds {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.calm-sounds > div:first-child {
  display: grid;
  gap: 4px;
}

.calm-sounds span {
  color: var(--muted);
  font-size: 0.9rem;
}

.calm-sound-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(0.82);
  }

  50% {
    transform: scale(1.08);
  }
}

.bottom-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 8px 0 16px;
}

.nav-button {
  display: grid;
  flex: 0 1 90px;
  min-width: 74px;
  min-height: 54px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}

.nav-button.active {
  color: #ffffff;
  background: var(--teal);
}

.nav-button svg {
  width: 26px;
  height: 26px;
  stroke: currentColor;
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-content {
  padding-bottom: 92px;
}

.settings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.settings-heading h2 {
  margin: 0;
  font-size: 1.8rem;
}

.settings-tabs {
  margin-bottom: 14px;
}

.migration-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border-left: 5px solid var(--gold);
  border-radius: 6px;
  background: var(--gold-soft);
}

.migration-banner div:first-child {
  display: grid;
  gap: 4px;
}

.migration-banner span {
  color: #66521f;
  font-size: 0.9rem;
}

.migration-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.settings-notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: #245c58;
  background: var(--teal-soft);
  font-weight: 800;
}

.settings-disclaimer {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(320px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.settings-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 230px);
  overflow: auto;
  padding-right: 4px;
}

.settings-item {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 92px;
  border: 0;
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  text-align: left;
  cursor: pointer;
}

.settings-item.active {
  box-shadow:
    0 0 0 3px var(--teal),
    var(--shadow);
}

.settings-item .visual {
  width: 64px;
}

.settings-item strong,
.settings-item small {
  display: block;
}

.settings-item small {
  margin-top: 4px;
  color: var(--muted);
}

.settings-form {
  display: grid;
  gap: 14px;
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.form-preview {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 8px;
  text-align: center;
  font-size: 1.25rem;
}

.settings-form label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

.settings-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
}

.settings-form input[type="file"] {
  min-height: auto;
  padding: 10px;
}

.remove-photo-button {
  justify-self: start;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.audio-panel {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.audio-title {
  color: var(--muted);
  font-weight: 900;
}

.audio-panel audio {
  width: 100%;
}

.report-intro {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.report-ai-art {
  width: 96px;
  aspect-ratio: 1;
  border-radius: 18px;
}

.report-intro strong,
.report-intro span {
  display: block;
}

.report-intro strong {
  font-size: 1.5rem;
}

.report-intro span {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 800;
}

.report-content {
  padding-bottom: 92px;
}

.report-loading,
.report-error {
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 900;
}

.report-error {
  margin: 0 0 16px;
  color: #8a2e2e;
  background: #fff2f0;
}

.report-section-title {
  margin: 22px 0 10px;
  font-size: 1.15rem;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.learning-report-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.report-summary article,
.report-panel {
  border-radius: 8px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.report-summary article {
  display: grid;
  gap: 4px;
  min-height: 104px;
  align-content: center;
  padding: 14px;
}

.report-summary strong {
  font-size: 2.6rem;
  line-height: 1;
}

.report-summary span {
  color: var(--muted);
  font-weight: 900;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.report-panel {
  padding: 16px;
}

.report-panel.wide {
  grid-column: 1 / -1;
}

.report-panel h3 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.report-list,
.timeline {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.report-list.numbered {
  counter-reset: report-rank;
}

.report-list li,
.timeline li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f4f7f4;
}

.report-list.numbered li {
  counter-increment: report-rank;
}

.report-list.numbered li::before {
  content: counter(report-rank);
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  height: 30px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--teal);
  font-weight: 900;
}

.report-list span,
.timeline span {
  font-weight: 900;
}

.report-list small,
.timeline time {
  color: var(--muted);
  font-weight: 800;
}

.timeline li {
  justify-content: flex-start;
}

.timeline time {
  flex: 0 0 170px;
  white-space: nowrap;
}

.empty-report {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.learning-report-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.learning-report-list li {
  display: flex;
  min-height: 92px;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  border-left: 4px solid var(--teal);
  border-radius: 6px;
  padding: 12px;
  background: #f4f7f4;
}

.learning-report-list span,
.learning-report-list small {
  display: block;
}

.learning-report-list small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 800;
}

.learning-report-count > strong {
  font-size: 1.35rem;
}

.report-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.auth-pending #app,
.auth-required #app {
  visibility: hidden;
}

html.auth-required,
html.account-open {
  overflow: hidden;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(217, 239, 234, 0.82), transparent 360px),
    var(--bg);
}

.auth-screen {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 24px 16px;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.auth-brand img,
.auth-loading img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
}

.auth-brand.compact {
  margin-bottom: 20px;
}

.auth-brand h1,
.auth-status-panel h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.auth-brand p,
.auth-status-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

.auth-avatar {
  display: grid;
  width: 60px;
  height: 60px;
  flex: 0 0 60px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--teal);
  font-size: 1.5rem;
  font-weight: 900;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 22px;
  padding: 4px;
  border-radius: 8px;
  background: #eef3f1;
}

.auth-tab {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.auth-tab.active {
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(32, 48, 51, 0.1);
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-form label {
  margin-top: 7px;
  font-size: 0.88rem;
  font-weight: 800;
}

.auth-form input,
.auth-form select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #bdcbc7;
  border-radius: 7px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
}

.auth-form input:focus,
.auth-form select:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(47, 125, 120, 0.16);
}

.profile-range-row {
  display: grid;
  grid-template-columns: 1fr 52px;
  align-items: center;
  gap: 12px;
}

.profile-range-row input[type="range"] {
  min-height: 40px;
  padding: 0;
  accent-color: var(--teal);
}

.profile-range-row output {
  display: grid;
  min-height: 40px;
  place-items: center;
  border-radius: 7px;
  background: #edf2f0;
  font-weight: 900;
}

.voice-gender-fieldset {
  min-width: 0;
  margin: 8px 0 2px;
  padding: 0;
  border: 0;
}

.voice-gender-fieldset legend {
  margin-bottom: 8px;
  font-size: 0.88rem;
  font-weight: 800;
}

.voice-gender-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #edf2f0;
}

.voice-gender-control label {
  position: relative;
  cursor: pointer;
}

.voice-gender-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.voice-gender-control span {
  display: grid;
  min-height: 44px;
  place-items: center;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  font-size: 0.88rem;
  font-weight: 850;
}

.voice-gender-control input:checked + span {
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(32, 48, 51, 0.1);
}

.voice-gender-control input:focus-visible + span {
  outline: 3px solid rgba(47, 125, 120, 0.22);
}

.voice-engine-name {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.profile-voice-test {
  width: 100%;
  margin-top: 2px;
}

.auth-message {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-left: 4px solid var(--coral);
  color: #87372d;
  background: var(--coral-soft);
  font-size: 0.9rem;
}

.auth-submit,
.auth-secondary,
.auth-link-button {
  min-height: 48px;
  margin-top: 12px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.auth-submit {
  color: #ffffff;
  background: var(--teal);
}

.auth-secondary {
  color: var(--ink);
  background: #edf2f0;
}

.auth-link-button {
  margin-top: 2px;
  color: var(--muted);
  background: transparent;
}

.auth-submit:disabled,
.auth-secondary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.auth-loading {
  display: grid;
  justify-items: center;
  gap: 14px;
  font-size: 1.25rem;
}

.auth-status-panel {
  text-align: center;
}

.auth-header-slot {
  display: flex;
}

.account-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 6px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 800;
  cursor: pointer;
}

.account-initial {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--teal);
}

.account-name {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 16px;
}

.account-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 35, 37, 0.48);
}

.account-dialog {
  position: relative;
  width: min(520px, 100%);
  max-height: min(720px, calc(100vh - 32px));
  overflow-y: auto;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 64px rgba(22, 35, 37, 0.3);
}

.account-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.account-heading h2,
.session-section h3 {
  margin: 0;
  letter-spacing: 0;
}

.account-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.account-close {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: #edf2f0;
  font-size: 1.6rem;
  cursor: pointer;
}

.account-actions-list {
  display: grid;
  padding: 10px 24px;
}

.account-actions-list button {
  min-height: 48px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  text-align: left;
  font-weight: 800;
  cursor: pointer;
}

.account-actions-list button.danger {
  color: #a13f34;
}

.session-section {
  padding: 18px 24px 24px;
}

.session-section h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.session-row {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
}

.session-row div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.session-row span,
.session-loading {
  color: var(--muted);
  font-size: 0.82rem;
}

.session-row div span {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-row button,
.current-session {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  color: var(--ink);
  background: #edf2f0;
  font-weight: 800;
}

.current-session {
  display: inline-flex;
  align-items: center;
}

.account-password-form {
  padding: 18px 24px 26px;
}

.account-form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 900px) {
  .sync-indicator {
    width: 34px;
    padding: 0;
    justify-content: center;
  }

  .sync-indicator > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .account-name {
    display: none;
  }

  .account-button {
    width: 44px;
    padding: 0;
    justify-content: center;
  }

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

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

  .learning-item-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .calm-sounds {
    align-items: stretch;
    flex-direction: column;
  }

  .calm-sound-options {
    justify-content: flex-start;
  }

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

  .routine-status,
  .calm-hero,
  .report-summary,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .learning-report-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .routine-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .brand h1 {
    font-size: 1.35rem;
  }

  .learning-heading h2,
  .settings-heading h2 {
    font-size: 1.5rem;
  }

  .activity-target strong {
    font-size: 1.75rem;
  }

  .learning-item-visual b {
    font-size: 2rem;
  }

  .category-label strong,
  .report-intro strong {
    font-size: 1.35rem;
  }

  .calm-copy h2 {
    font-size: 2.5rem;
  }

  .calm-copy p {
    font-size: 1.25rem;
  }

  .report-summary strong {
    font-size: 2.25rem;
  }

  .portal-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 4px;
  }

  .portal-button {
    min-height: 210px;
    grid-template-columns: 118px 1fr;
    grid-template-rows: 1fr;
    padding: 16px;
  }

  .portal-button img {
    width: 118px;
  }

  .portal-button strong {
    font-size: 1.4rem;
  }

  .learning-module-grid,
  .learning-item-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .learning-module-card {
    min-height: 210px;
    padding: 10px;
  }

  .learning-item-card {
    min-height: 180px;
    padding: 9px;
  }

  .learning-item-visual img {
    min-height: 112px;
  }

  .learning-heading {
    align-items: flex-start;
  }

  .learning-activity {
    padding: 14px;
  }

  .activity-choice {
    padding: 8px;
  }

  .migration-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .migration-actions > button {
    flex: 1;
  }

  .auth-screen {
    align-items: start;
    padding: 12px 10px;
  }

  .auth-panel {
    padding: 22px 18px;
  }

  .auth-brand img {
    width: 62px;
    height: 62px;
  }

  .account-overlay {
    align-items: end;
    padding: 0;
  }

  .account-dialog {
    width: 100%;
    max-height: 92vh;
    border-radius: 8px 8px 0 0;
  }

  .account-heading,
  .session-section {
    padding-right: 18px;
    padding-left: 18px;
  }

  .account-actions-list {
    padding-right: 18px;
    padding-left: 18px;
  }

  .account-password-form {
    padding-right: 18px;
    padding-left: 18px;
  }

  .account-form-actions {
    grid-template-columns: 1fr;
  }

  .topbar {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    grid-template-columns: 44px 1fr auto;
    padding-top: 10px;
  }

  .header-actions {
    gap: 6px;
  }

  .brand p {
    display: none;
  }

  .content,
  .bottom-nav {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
  }

  .home-grid,
  .tile-grid,
  .routine-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .category-button {
    min-height: 176px;
    padding: 18px 10px 14px;
  }

  .category-art-wrap {
    width: min(106px, 34vw);
    border-radius: 18px;
  }

  .tile-button,
  .routine-step {
    min-height: 150px;
    padding: 14px 8px;
  }

  .phrase-bar {
    grid-template-columns: 1fr 48px 48px 48px;
  }

  .routine-status {
    gap: 10px;
  }

  .routine-actions .primary-button,
  .routine-actions .secondary-button,
  .calm-actions .primary-button,
  .calm-actions .secondary-button {
    flex: 1 1 140px;
  }

  .breathing-orb {
    width: 92px;
    height: 92px;
  }

  .breathing-orb span {
    width: 62px;
  }

  .calm-visual-stack {
    min-height: 230px;
  }

  .bottom-nav {
    gap: 6px;
  }

  .nav-button {
    flex: 1 1 0;
    min-width: 0;
  }

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

  .visual {
    width: min(92px, 34vw);
  }

  .ai-tile-visual {
    width: min(116px, 38vw);
    border-radius: 18px;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .heading-actions {
    width: 100%;
    justify-content: stretch;
  }

  .heading-actions .secondary-button {
    flex: 1 1 120px;
  }

  .timeline li,
  .report-list li {
    align-items: flex-start;
    flex-direction: column;
  }

  .timeline time {
    flex: 0 0 auto;
  }

  .learning-report-list {
    grid-template-columns: 1fr;
  }

  .settings-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    padding-right: 0;
  }

  .settings-item {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .settings-item .visual {
    width: 74px;
  }
}

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

@media print {
  body {
    background: #ffffff;
  }

  .topbar,
  .bottom-nav,
  .heading-actions,
  .report-actions {
    display: none !important;
  }

  .content,
  .report-content {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .report-summary,
  .report-grid {
    grid-template-columns: 1fr 1fr;
  }

  .report-panel.wide {
    grid-column: 1 / -1;
  }
}
