/*
 * NorskDojo mockup fidelity layer.
 * Restores the alpine Frøya composition from the approved UI images while
 * leaving the working Norwegian application structure and APIs untouched.
 */

:root {
  --blue: #0b94a4;
  --blue-text: #087986;
  --green: #28ad91;
  --green-text: #16836f;
  --orange: #ff965b;
  --orange-text: #bd6430;
  --red: #e86767;
  --red-text: #c64d57;
  --indigo: #5967c8;
  --bg: #eef6fb;
  --card: rgba(255, 255, 255, .96);
  --card2: #eff7fa;
  --card3: #e6eff4;
  --ink: #10284d;
  --ink2: #617493;
  --ink3: #91a2b9;
  --sep: #dfe9f1;
  --material: rgba(245, 251, 255, .9);
  --tabbar-material: rgba(255, 255, 255, .96);
  --btn-ink: #fff;
  --shadow: 0 18px 42px -28px rgba(25, 66, 102, .46), 0 2px 9px rgba(25, 66, 102, .05);
  --shadow-sm: 0 10px 24px -18px rgba(25, 66, 102, .56);
  --r-card: 24px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --blue: #63c8d8;
  --blue-text: #8edce7;
  --green: #43c69f;
  --green-text: #80dfc0;
  --orange: #ff9a5c;
  --orange-text: #ffc08d;
  --red: #ef7373;
  --red-text: #ff9c9c;
  --indigo: #a9b5ff;
  --bg: #071522;
  --card: rgba(14, 34, 52, .97);
  --card2: #102a3e;
  --card3: #19384f;
  --ink: #f5f9fd;
  --ink2: #c9d8e7;
  --ink3: #91a8be;
  --sep: #29475f;
  --material: rgba(7, 21, 34, .92);
  --tabbar-material: rgba(10, 27, 42, .97);
  --btn-ink: #06131f;
  --shadow: 0 20px 46px -28px rgba(0, 0, 0, .92), 0 2px 10px rgba(0, 0, 0, .2);
  --shadow-sm: 0 11px 26px -18px rgba(0, 0, 0, .95);
  color-scheme: dark;
}

body {
  font-family: "Nunito", "Hanken Grotesk", ui-rounded, system-ui, sans-serif;
  color: var(--ink);
  background: #eaf4fa;
  font-size: 16px;
}
/* Backdrop on a position:fixed pseudo-element, not background-attachment:fixed
   on body — mobile browsers ignore `fixed` attachment and size `cover` against
   the whole scrollable document (phones showed a giant zoomed blur; laptops
   were fine). A fixed element is viewport-sized everywhere. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(224, 243, 252, .04), rgba(219, 238, 246, .18)),
    url("img/fjord-summer-day-v2.webp") center top / cover no-repeat,
    #eaf4fa;
}

#app {
  --hero-image: url("img/header-today.webp");
  --hero-position: center 76px;
  --hero-size: 100% auto;
  --hero-height: 304px;
  position: relative;
  isolation: isolate;
  width: min(100%, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow-x: clip;
  /* Slightly translucent stack so the fjord/aurora backdrop on body::before
     glows through — with every layer opaque it could never be seen at all,
     especially on phones where #app is full-width. */
  background:
    linear-gradient(180deg, rgba(230, 244, 252, .08) 0 300px, rgba(248, 251, 253, .28) 500px),
    var(--hero-image) var(--hero-position) / var(--hero-size) no-repeat,
    rgba(248, 251, 253, .56);
  box-shadow: 0 0 70px rgba(28, 65, 100, .14);
}

#app::before {
  content: none;
}

#app::after {
  content: none;
}

#app[data-hero="today"] { --hero-image: url("img/header-today.webp"); }
#app[data-hero="words"] { --hero-image: url("img/header-words.webp"); }
#app[data-hero="speak"] { --hero-image: url("img/header-speak.webp"); }
#app[data-hero="write"] { --hero-image: url("img/header-write.webp"); }
#app[data-hero="chat"] { --hero-image: url("img/header-chat.webp"); }
#app[data-hero="tables"] { --hero-image: url("img/header-tables.webp"); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  min-height: 78px;
  padding: calc(15px + env(safe-area-inset-top)) 28px 10px;
  gap: 10px;
  overflow: visible;
  /* First line IS the picture (same treatment as DeutschDojo): the topbar
     paints the backdrop art directly with a legibility wash, so it blends
     with the page instead of sitting as a separate strip. */
  background:
    linear-gradient(180deg, rgba(242, 249, 254, .6), rgba(242, 249, 254, .74)),
    url("img/fjord-summer-day-v2.webp") center top / cover no-repeat;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.topbar .brand {
  gap: 10px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.035em;
}

.brand-fox {
  width: 40px;
  height: 40px;
  padding: 2px;
  border: 2px solid rgba(255, 255, 255, .82);
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow-sm);
}

.brand-mark {
  position: relative;
  width: 44px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
}

.brand-translate-icon {
  width: 42px;
  height: 42px;
  display: block;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  background: #071d37;
  box-shadow: 0 5px 15px -7px rgba(21, 220, 201, .72);
}

.level-badge {
  padding: 4px 10px;
  color: var(--ink);
  border: 1px solid rgba(128, 160, 187, .28);
  background: rgba(255, 255, 255, .42);
  box-shadow: none;
}

.streak-pill {
  height: 44px;
  padding: 0 17px;
  color: var(--ink);
  font-size: 18px;
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--shadow-sm);
}

.streak-pill .flame-img {
  width: 20px;
  height: 24px;
}

.profile-wrap {
  position: relative;
  z-index: 410;
}

.profile-btn {
  min-width: 68px;
  height: 46px;
  padding: 4px 10px 4px 4px;
  gap: 7px;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, .82);
  background: rgba(255, 255, 255, .93);
  box-shadow: var(--shadow-sm);
}

.profile-btn img {
  width: 36px;
  height: 36px;
}

.profile-btn #profileInitial {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, #123957, #087f98);
  color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6);
  font-size: 14px;
  font-weight: 900;
}

.profile-menu {
  position: fixed;
  top: calc(70px + env(safe-area-inset-top));
  right: max(14px, calc((100vw - 760px) / 2 + 20px));
  z-index: 500;
  width: min(310px, calc(100vw - 28px));
  padding: 10px;
  color: var(--ink);
  border: 1px solid var(--sep);
  border-radius: 22px;
  background: rgba(255, 255, 255, .99);
  box-shadow: 0 26px 64px -24px rgba(11, 33, 68, .5);
}

.profile-summary {
  padding: 7px 7px 13px;
}

.profile-summary strong {
  color: var(--ink);
  font-size: 17px;
}

.profile-summary small,
.profile-label {
  color: var(--ink2);
}

.theme-choices {
  background: var(--card2);
}

.theme-choices button {
  min-height: 36px;
  color: var(--ink2);
}

.theme-choices button.on {
  color: #fff;
  background: linear-gradient(135deg, #078fa8, #28aa8d);
}

.profile-menu-item {
  min-height: 46px;
  color: var(--ink);
}

.profile-menu-item:hover,
.profile-menu-item:focus-visible {
  background: var(--card2);
}

main {
  position: relative;
  z-index: 2;
  max-width: none;
  padding: 0 28px 42px;
}

.view {
  position: relative;
}

h1 {
  color: var(--ink);
  font-size: clamp(36px, 6vw, 45px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -.045em;
}

h2,
h3,
h4,
b,
strong {
  color: var(--ink);
}

.page-intro {
  min-height: 286px;
  max-width: 62%;
  padding-top: 42px;
}

.page-intro h1 {
  margin: 0 0 12px;
}

.page-intro p {
  color: var(--ink2);
  font-size: 19px;
  line-height: 1.55;
}

.greet {
  min-height: 286px;
  padding: 48px 0 22px;
  align-items: flex-start;
}

.greet h2 {
  max-width: 65%;
  color: var(--ink);
  font-size: clamp(32px, 5.4vw, 42px);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -.035em;
}

.greet .placed {
  max-width: 61%;
  margin-top: 16px;
  color: var(--ink2);
  font-size: 18px;
  line-height: 1.55;
}

.greet-mascot,
.greet-hero .level-chip {
  display: none;
}

.card,
.stat-card,
.quick3,
.scenario-card,
.gram-sec,
.vocab-feature-card {
  color: var(--ink);
  border: 1px solid rgba(205, 222, 235, .68);
  background: var(--card);
  box-shadow: var(--shadow);
}

.card {
  padding: 22px;
  margin-bottom: 14px;
}

.sec {
  margin-top: 16px;
}

.btn {
  min-height: 54px;
  padding-inline: 24px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(105deg, #078fa8, #28a98d);
  box-shadow: 0 13px 25px -15px rgba(5, 137, 156, .9);
  font-size: 16px;
}

.btn.secondary,
.btn.ghost {
  color: var(--blue-text);
  border: 1.5px solid color-mix(in srgb, var(--blue) 50%, var(--sep));
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.btn.quiet {
  color: var(--blue-text);
  background: transparent;
  box-shadow: none;
}

/* Home */
#view-today.active {
  display: flex;
  flex-direction: column;
}

#view-today .greet { order: 0; }
#view-today .stat-scroll { order: 1; }
#view-today .session-length { order: 2; }
#view-today .mission-cta { order: 3; }
#view-today .return-note { order: 4; }
#view-today .card:not(.froya-card):not(.factcard) { order: 5; }
#view-today .factcard { order: 6; }
#view-today .quick3 { order: 7; }
#view-today .today-details { order: 8; }
#view-today .froya-card { display: none; }

.stat-scroll {
  grid-template-columns: 1.2fr .9fr;
  gap: 16px;
  margin-top: 0;
}

.stat-card {
  min-height: 206px;
  padding: 22px;
  border-radius: 24px;
}

.stat-card.streak::before {
  content: "Streak";
  display: block;
  margin-bottom: 13px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
}

.stat-card.streak header img {
  width: 34px;
  height: 44px;
}

.stat-card.streak .big {
  color: var(--ink);
  font-size: 46px;
}

.stat-card.streak .lbl,
.stat-card.streak .cheer,
.ringcard .sub-s,
.ringcard .xpline {
  color: var(--ink2);
}

.week-dots {
  gap: 8px;
  margin-top: 18px;
}

.week-dots i {
  width: 18px;
  height: 18px;
  background: var(--card3);
  border: 1px solid color-mix(in srgb, var(--ink3) 65%, transparent);
}

.week-dots i.on {
  border-color: transparent;
  background: linear-gradient(135deg, #078fa8, #28aa8d);
}

.stat-card.ringcard {
  justify-content: center;
  padding: 48px 18px 18px;
}

.stat-card.ringcard::before {
  content: "Today";
  position: absolute;
  top: 21px;
  left: 22px;
  color: var(--ink);
  font-weight: 800;
}

.stat-card.ringcard .ring {
  width: 108px;
  height: 108px;
}

.ring::before {
  background: conic-gradient(#0790a6 calc(var(--p) * 1%), var(--card3) 0);
}

.ringcard .meta {
  display: none;
}

.session-length {
  order: 2;
  gap: 4px;
  margin: 16px 0 12px;
  padding: 4px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.session-length button {
  min-height: 66px;
  border-radius: 999px;
  color: var(--ink);
}

.session-length button.on {
  color: var(--ink);
  background: linear-gradient(90deg, color-mix(in srgb, var(--blue) 10%, var(--card)), color-mix(in srgb, var(--green) 9%, var(--card)));
  box-shadow: inset 0 0 0 2px #078f9d;
}

.session-length button span,
.return-note {
  color: var(--ink2);
}

.mission-cta {
  min-height: 62px;
  margin-top: 0;
  font-size: 18px;
}

.plan-head h3 {
  font-size: 24px;
}

.steps {
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--sep);
  border-radius: 20px;
}

.steps .step {
  min-height: 78px;
  padding: 10px 14px;
  border-radius: 0;
}

.steps .step + .step {
  border-top: 1px solid var(--sep);
}

.steps .step .dot,
.steps .step.active .dot,
.steps .step.done .dot {
  width: 40px;
  height: 40px;
  color: #fff;
  border: 0;
  background: linear-gradient(135deg, #078fa8, #27a989);
}

.steps .step .rail::before {
  width: 0;
  border-left: 2px dotted #1499a4;
  background: transparent;
}

.steps .step.locked b,
.steps .step.locked .sub-s {
  opacity: 1;
}

.factcard {
  width: 100%;
  min-height: 132px;
  text-align: left;
  border: 0;
  outline: 0;
  box-shadow: var(--shadow-sm);
}

.factcard .fact-eyebrow {
  color: var(--blue-text);
}

.quick3 {
  padding: 0;
  overflow: hidden;
  margin: 16px 0 24px;
  border-radius: 24px;
}

.quick3 button {
  min-height: 110px;
  color: var(--ink);
}

.quick3 .icn-tile {
  color: var(--blue-text);
  background: color-mix(in srgb, var(--blue) 10%, var(--card));
}

/* Words */
#vocabHome > .tiles {
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

#vocabHome > .tiles .tile {
  min-height: 150px;
  padding: 22px;
  border: 1px solid rgba(205, 222, 235, .68);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
}

#vocabHome > .tiles .big {
  color: #0793a0 !important;
  font-size: 48px;
}

.vocab-feature-card {
  margin: 18px 0 14px;
  padding: 24px;
  border-radius: 24px;
}

.vocab-word-head {
  display: flex;
  align-items: center;
  gap: 18px;
}

.vocab-word-head img {
  width: 124px;
  height: 124px;
  object-fit: cover;
  border-radius: 50%;
  background: var(--card2);
}

.feature-kicker {
  color: var(--blue-text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.vocab-word-head h2 {
  margin: 5px 0 6px;
  font-size: 33px;
}

.vocab-word-head p {
  color: var(--ink2);
}

.noun-gender {
  display: inline-grid;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  place-items: center;
  border-radius: 50%;
  color: #0879ba;
  background: #e5f4ff;
  font-size: 14px;
  font-weight: 800;
}

.word-audio {
  display: grid;
  width: 50px;
  height: 50px;
  flex: none;
  place-items: center;
  color: var(--blue-text);
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--blue) 10%, var(--card));
  cursor: pointer;
}

.word-audio .icn {
  width: 24px;
  height: 24px;
}

.noun-forms {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--sep);
  text-align: center;
}

.noun-forms dt {
  min-height: 38px;
  color: var(--ink2);
  font-size: 12px;
}

.noun-forms dd {
  margin: 8px 0 0;
  color: var(--blue-text);
  font-size: 17px;
  font-weight: 800;
}

.word-example {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px 14px;
  padding-top: 18px;
  font-size: 14px;
}

.word-example > span,
.word-example small {
  color: var(--ink2);
}

.word-example small {
  display: block;
  margin-top: 3px;
}

.pager-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.pager-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--card3);
}

.pager-dots i:first-child {
  background: var(--blue);
}

.packs {
  gap: 10px;
}

.pack {
  min-height: 110px;
  border-color: var(--sep);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.pack.current {
  border: 2px solid var(--blue);
  background: color-mix(in srgb, var(--blue) 7%, var(--card));
}

/* Speak, write, chat, tables */
.seg {
  padding: 5px;
  border: 1px solid var(--sep);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.seg button {
  min-height: 58px;
  border-radius: 18px;
  color: var(--ink2);
}

.seg button.on {
  color: var(--blue-text);
  background: color-mix(in srgb, var(--blue) 8%, var(--card));
  box-shadow: inset 0 0 0 1.5px var(--blue);
}

#shadowMode > .card,
#view-write > .card {
  padding: 28px;
}

.shadow-sentence {
  text-align: left;
  color: var(--ink);
  font-size: clamp(25px, 4.2vw, 33px);
  line-height: 1.45;
}

.shadow-sentence.veiled {
  filter: none;
  opacity: 1;
}

#peekBtn {
  display: none;
}

.shadow-translation {
  text-align: left;
  color: var(--ink2);
  font-size: 17px;
}

.round-btn {
  width: 66px;
  height: 66px;
}

.round-btn.rec,
.icon-btn.primary {
  background: linear-gradient(135deg, #078fa8, #28aa8d);
}

.prompt-box {
  color: var(--ink);
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.35;
}

.field {
  min-height: 54px;
  color: var(--ink);
  border-color: color-mix(in srgb, var(--ink3) 64%, var(--sep));
  background: color-mix(in srgb, var(--card) 90%, transparent);
}

textarea.field {
  min-height: 160px;
}

.field:focus,
.chat-input textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 17%, transparent);
}

.scenario-card {
  min-height: 112px;
  border-radius: 22px;
}

.bubble.bot,
.msg.them {
  color: var(--ink);
  border: 1px solid var(--sep);
  background: var(--card);
}

.bubble.user,
.msg.me {
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--blue) 16%, var(--sep));
  background: color-mix(in srgb, var(--blue) 9%, var(--card));
}

.gram-sec {
  overflow: hidden;
  border-radius: 22px;
}

.gram-sec summary {
  min-height: 76px;
  padding: 19px 22px;
}

.gram-sec summary::before {
  display: inline-grid;
  width: 38px;
  height: 38px;
  margin-right: 12px;
  place-items: center;
  color: #fff;
  border-radius: 50%;
  background: linear-gradient(135deg, #078fa8, #28aa8d);
}

.g-scroll {
  border-color: var(--sep);
}

/* Insights */
.ins-grid {
  gap: 14px;
}

.ins-grid .card,
.ins-grid .stat-card {
  min-height: 190px;
  padding: 22px;
  border-radius: 22px;
}

.ins-grid .stat-card.streak::before {
  content: "Streak";
}

.heat i {
  border-radius: 4px;
}

.tag-row .meter i,
.bars i {
  background: linear-gradient(180deg, var(--blue), var(--green));
}

/* Navigation and Frøya helper */
.tabbar {
  left: 50%;
  bottom: 0;
  z-index: 80;
  width: min(100%, 760px);
  min-height: calc(78px + env(safe-area-inset-bottom));
  padding: 8px 20px env(safe-area-inset-bottom);
  transform: translateX(-50%);
  border: 1px solid var(--sep);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  background: var(--tabbar-material);
  box-shadow: 0 -12px 38px -28px rgba(25, 66, 102, .6);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.tab {
  min-width: 0;
  color: var(--ink2);
  font-size: 11px;
}

.tab svg {
  width: 27px;
  height: 27px;
}

.tab.active {
  color: var(--blue-text);
}

.tab.active::before {
  background: linear-gradient(90deg, #078fa8, #28aa8d);
}

/* Insights tab restored: hiding it left the 7-column tabbar with a dead empty
   slot after Tables, and no way to reach Insights at all. */

.fab {
  right: max(18px, calc((100vw - 760px) / 2 + 20px));
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 75;
  width: 60px;
  min-width: 60px;
  height: 60px;
  padding: 5px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .38);
  border-radius: 50%;
  background: linear-gradient(135deg, #078fa8, #28aa8d);
  box-shadow: 0 18px 36px -18px rgba(3, 97, 112, .9);
  display: grid;
  place-items: center;
}

.fab .fab-logo {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  background: #d8edf7;
}

.fab .fab-question {
  position: absolute;
  top: -4px;
  right: -4px;
  z-index: 3;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #0a2b45;
  color: #fff;
  box-shadow: 0 6px 14px rgba(3, 35, 55, .28);
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

.chat-input-tab {
  width: min(calc(100% - 24px), 736px);
  bottom: calc(78px + env(safe-area-inset-bottom));
  border-radius: 24px;
  background: var(--card);
}

/* Dark theme */
html[data-theme="dark"] body { background: #020914; }
html[data-theme="dark"] body::before {
  background:
    radial-gradient(ellipse 64% 38% at 8% -4%, rgba(43, 255, 185, .18), transparent 66%),
    radial-gradient(ellipse 58% 42% at 92% 5%, rgba(47, 155, 255, .2), transparent 68%),
    linear-gradient(180deg, rgba(1, 7, 18, .06), rgba(1, 7, 18, .38)),
    url("img/aurora-fjord-night-v3.webp") center top / cover no-repeat,
    #020914;
}

/* No synthetic aurora radials any more: they tinted the hero art green/violet
   and their edges read as visible bands. The REAL aurora photo on body::before
   provides that glow; .3 on the hero rows keeps Frøya visible. */
html[data-theme="dark"] #app {
  background:
    linear-gradient(180deg, rgba(2, 10, 22, .3) 0 260px, rgba(4, 17, 31, .56) 430px, rgba(6, 20, 33, .38) 590px),
    var(--hero-image) var(--hero-position) / var(--hero-size) no-repeat,
    rgba(6, 20, 33, .52);
  box-shadow: 0 0 90px rgba(0, 0, 0, .62), inset 0 0 90px rgba(34, 205, 172, .035);
}

html[data-theme="dark"] #app::before {
  display: none;
  animation: none;
}

/* Dark hero overlay removed: its teal/violet glows tinted the header art, the
   brightness(.66) filter faded Frøya, and its bottom edge drew a visible line
   across the page. The linear veil inside #app's own background is enough. */

html[data-theme="dark"] .topbar {
  border-bottom: 1px solid rgba(112, 233, 213, .13);
  background:
    linear-gradient(180deg, rgba(4, 15, 28, .52), rgba(4, 15, 28, .68)),
    url("img/aurora-fjord-night-v3.webp") center top / cover no-repeat;
  box-shadow: 0 10px 30px -24px rgba(60, 239, 200, .55);
}

html[data-theme="dark"] .profile-btn,
html[data-theme="dark"] .profile-menu,
html[data-theme="dark"] .streak-pill {
  color: var(--ink);
  border-color: rgba(123, 223, 216, .2);
  background: rgba(8, 28, 45, .88);
  box-shadow: 0 14px 30px -22px rgba(62, 228, 192, .7);
}

html[data-theme="dark"] .greet h2,
html[data-theme="dark"] .page-intro h1 {
  color: #fff;
  text-shadow: 0 2px 16px rgba(0, 0, 0, .78);
}

html[data-theme="dark"] .greet .placed,
html[data-theme="dark"] .page-intro p {
  width: fit-content;
  padding: 9px 12px;
  color: #f3f8fd;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 14px;
  background: rgba(5, 20, 34, .72);
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .quick3,
html[data-theme="dark"] .scenario-card,
html[data-theme="dark"] .gram-sec,
html[data-theme="dark"] .vocab-feature-card,
html[data-theme="dark"] #vocabHome > .tiles .tile {
  border-color: rgba(111, 222, 214, .18);
  background:
    linear-gradient(145deg, rgba(19, 49, 68, .94), rgba(8, 28, 45, .96));
  box-shadow: 0 22px 45px -34px rgba(71, 236, 203, .48);
}

html[data-theme="dark"] .tabbar {
  border-color: rgba(100, 222, 210, .18);
  background:
    linear-gradient(100deg, rgba(16, 62, 72, .9), rgba(8, 25, 42, .96) 43%, rgba(24, 40, 78, .92));
  box-shadow: 0 -18px 48px -30px rgba(54, 227, 196, .58);
}

html[data-theme="dark"] .tab.active,
html[data-theme="dark"] .tab.active svg {
  color: #72ead1;
}

html[data-theme="dark"] .primary,
html[data-theme="dark"] .quick-start {
  background: linear-gradient(110deg, #16a6b6, #32c99a);
  box-shadow: 0 15px 34px -20px rgba(62, 239, 197, .75);
}

html[data-theme="dark"] .noun-gender {
  color: #a9e8f1;
  background: #153a4b;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --blue: #63c8d8;
    --blue-text: #8edce7;
    --green: #43c69f;
    --green-text: #80dfc0;
    --orange: #ff9a5c;
    --orange-text: #ffc08d;
    --red: #ef7373;
    --red-text: #ff9c9c;
    --indigo: #a9b5ff;
    --bg: #071522;
    --card: rgba(14, 34, 52, .97);
    --card2: #102a3e;
    --card3: #19384f;
    --ink: #f5f9fd;
    --ink2: #c9d8e7;
    --ink3: #91a8be;
    --sep: #29475f;
    --material: rgba(7, 21, 34, .92);
    --tabbar-material: rgba(10, 27, 42, .97);
    --btn-ink: #06131f;
    color-scheme: dark;
  }

  html:not([data-theme]) body { background: #020914; }
  html:not([data-theme]) body::before {
    background:
      radial-gradient(ellipse 64% 38% at 8% -4%, rgba(43, 255, 185, .16), transparent 66%),
      radial-gradient(ellipse 58% 42% at 92% 5%, rgba(47, 155, 255, .18), transparent 68%),
      linear-gradient(180deg, rgba(1, 7, 18, .06), rgba(1, 7, 18, .38)),
      url("img/aurora-fjord-night-v3.webp") center top / cover no-repeat,
      #020914;
  }
  html:not([data-theme]) #app {
    background:
      linear-gradient(180deg, rgba(7, 21, 34, .3) 0 260px, rgba(7, 21, 34, .38) 500px),
      var(--hero-image) var(--hero-position) / var(--hero-size) no-repeat,
      rgba(7, 21, 34, .52);
  }
  html:not([data-theme]) #app::before {
    display: none;
    animation: none;
  }
  /* dark hero overlay removed — see the explicit-dark block above */
  html:not([data-theme]) .topbar {
    /* Match the explicit-dark topbar. The old fade-to-transparent let the
       bright hero art dissolve straight through the bar on system-dark
       phones — the "weird overlap on the header". */
    border-bottom: 1px solid rgba(112, 233, 213, .13);
    background:
      linear-gradient(180deg, rgba(4, 15, 28, .52), rgba(4, 15, 28, .68)),
      url("img/aurora-fjord-night-v3.webp") center top / cover no-repeat;
  }
  html:not([data-theme]) .profile-btn,
  html:not([data-theme]) .profile-menu,
  html:not([data-theme]) .streak-pill {
    color: var(--ink);
    border-color: var(--sep);
    background: rgba(14, 34, 52, .99);
  }
  html:not([data-theme]) .greet h2,
  html:not([data-theme]) .page-intro h1 {
    color: #fff;
    text-shadow: 0 2px 16px rgba(0, 0, 0, .78);
  }
  html:not([data-theme]) .greet .placed,
  html:not([data-theme]) .page-intro p {
    width: fit-content;
    padding: 9px 12px;
    color: #f3f8fd;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 14px;
    background: rgba(5, 20, 34, .72);
    text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
  html:not([data-theme]) .card,
  html:not([data-theme]) .stat-card,
  html:not([data-theme]) .quick3,
  html:not([data-theme]) .scenario-card,
  html:not([data-theme]) .gram-sec,
  html:not([data-theme]) .vocab-feature-card,
  html:not([data-theme]) #vocabHome > .tiles .tile {
    border-color: var(--sep);
    background: var(--card);
  }
}

@media (max-width: 560px) {
  #app {
    --hero-position: 58% 68px;
    --hero-size: 100% auto;
    --hero-height: 224px;
  }

  .topbar {
    min-height: 68px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 8px;
  }

  .topbar .brand {
    gap: 7px;
    font-size: 19px;
  }

  .brand-fox {
    width: 34px;
    height: 34px;
  }

  .brand-mark {
    width: 38px;
    height: 36px;
    flex-basis: 38px;
  }

  .brand-translate-icon {
    width: 36px;
    height: 36px;
  }

  .streak-pill {
    height: 40px;
    padding: 0 12px;
    font-size: 16px;
  }

  main {
    padding: 0 16px 30px;
  }

  .page-intro,
  .greet {
    min-height: 210px;
    padding-top: 32px;
  }

  .page-intro {
    max-width: 64%;
  }

  .page-intro p,
  .greet .placed {
    font-size: 15.5px;
    line-height: 1.45;
  }

  .greet h2 {
    font-size: 30px;
  }

  .stat-scroll {
    gap: 10px;
  }

  .stat-card {
    min-height: 184px;
    padding: 16px;
  }

  .stat-card.ringcard::before {
    top: 16px;
    left: 16px;
  }

  .stat-card.ringcard .ring {
    width: 88px;
    height: 88px;
  }

  .week-dots {
    gap: 4px;
  }

  .week-dots i {
    width: 15px;
    height: 15px;
  }

  .card {
    padding: 18px;
  }

  .quick3 b {
    font-size: 12px;
  }

  .quick3 small {
    display: none;
  }

  .vocab-feature-card {
    padding: 16px;
  }

  .vocab-word-head {
    gap: 12px;
  }

  .vocab-word-head img {
    width: 86px;
    height: 86px;
  }

  .vocab-word-head h2 {
    font-size: 27px;
  }

  .noun-forms {
    gap: 4px;
  }

  .noun-forms dt {
    font-size: 10px;
  }

  .noun-forms dd {
    font-size: 14px;
  }

  .word-example {
    grid-template-columns: 74px 1fr;
  }

  .profile-btn {
    min-width: 48px;
    width: 48px;
    padding: 4px;
  }

  .profile-btn > span,
  .profile-btn > svg {
    display: none;
  }
}

@media (max-width: 390px) {
  .level-badge {
    display: none;
  }

  .topbar {
    gap: 6px;
  }

  .topbar .brand {
    font-size: 17px;
  }

  .page-intro {
    max-width: 59%;
  }

  .stat-card {
    padding: 14px;
  }

  .fab {
    right: 12px;
    min-width: 54px;
    width: 54px;
    height: 54px;
    padding: 4px;
  }

  .fab .fab-logo {
    width: 46px;
    height: 46px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .greet-mascot {
    animation: none;
  }

  #app::before {
    animation: none;
  }
}

/* ---- Refined generated artwork: preserve each atlas cell's natural proportions ---- */
.scenario-card .sc-ic {
  height: auto;
  aspect-ratio: 16 / 10;
  border-radius: 15px;
}

.factcard {
  padding: 20px;
}

.factcard .fact-body {
  gap: 18px;
}

.factcard .fact-art {
  width: 112px;
  height: 84px;
  border-radius: 18px;
  border: 0;
  background-color: var(--card2);
  background-position: center;
  background-size: cover;
  transform: translateY(-3px) rotate(-1deg);
  transform-origin: center;
  transition: transform .2s var(--spring), box-shadow .2s ease;
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, .48),
    inset 0 -9px 14px rgba(5, 31, 50, .3),
    0 7px 0 color-mix(in srgb, var(--blue) 24%, #0c3852),
    0 15px 24px -12px rgba(4, 38, 61, .68);
}

.factcard:active .fact-art {
  transform: translateY(2px) rotate(-.35deg) scale(.985);
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, .38),
    inset 0 -5px 10px rgba(5, 31, 50, .28),
    0 2px 0 color-mix(in srgb, var(--blue) 24%, #0c3852),
    0 8px 14px -10px rgba(4, 38, 61, .6);
}

.factcard .fact-text {
  min-width: 0;
  font-size: 16px;
  overflow-wrap: anywhere;
}

/* ---- Word Spotlight is now a real deck carousel ---- */
.word-orbit {
  display: grid;
  width: 88px;
  height: 88px;
  flex: none;
  place-items: center;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 28px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .36), transparent 31%),
    linear-gradient(145deg, #176ca1, #21a591);
  box-shadow: 0 18px 34px -24px rgba(4, 74, 112, .8);
}

.word-orbit .icn {
  width: 38px;
  height: 38px;
}

.spotlight-pager {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.spotlight-pager > button {
  width: 38px;
  height: 38px;
  color: var(--ink);
  border: 1px solid var(--sep);
  border-radius: 50%;
  background: var(--card2);
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.spotlight-pager .pager-dots {
  margin: 0;
}

.pager-dots button {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--card3);
  cursor: pointer;
}

.pager-dots button.on {
  width: 25px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

/* ---- Tables: clearer hierarchy and easier scanning ---- */
#view-grammar .page-intro {
  margin-bottom: 14px;
}

#gramNav {
  position: sticky;
  top: calc(72px + env(safe-area-inset-top));
  z-index: 20;
  display: flex;
  flex-wrap: nowrap;
  gap: 9px;
  margin: 0 -8px 18px;
  padding: 10px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
}

#gramNav::-webkit-scrollbar {
  display: none;
}

#gramNav .chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: 42px;
  padding: 7px 14px 7px 8px;
  border: 1px solid var(--sep);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

#gramNav .chip > span {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  color: var(--blue-text);
  background: color-mix(in srgb, var(--blue) 12%, var(--card));
  font-size: 11px;
  font-weight: 900;
}

#gramNav .chip.on {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(120deg, #087f9a, #209a82);
}

#gramNav .chip.on > span {
  color: #fff;
  background: rgba(255, 255, 255, .18);
}

.gram-sec {
  margin-bottom: 16px;
  border: 1px solid var(--sep);
  border-radius: 24px;
  box-shadow: 0 18px 42px -34px rgba(20, 46, 72, .65);
}

.gram-sec summary {
  min-height: 82px;
  padding: 16px 20px;
}

.gram-sec summary::before {
  display: none;
}

.gram-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: none;
  place-items: center;
  color: #fff;
  border-radius: 14px;
  background: linear-gradient(145deg, #0a8fac, #23a08a);
}

.gram-tone-1 .gram-icon { background: linear-gradient(145deg, #516fd0, #7567cb); }
.gram-tone-2 .gram-icon { background: linear-gradient(145deg, #d27739, #e49b42); }
.gram-tone-3 .gram-icon { background: linear-gradient(145deg, #347aa8, #20a3a0); }

.gram-summary-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.gram-summary-copy b {
  font-size: 17px;
}

.gram-summary-copy small {
  color: var(--ink2);
  font-size: 12px;
  font-weight: 600;
}

.gram-sec .g-note,
.gram-sec .g-cap,
.gram-sec .g-tips {
  margin-left: 20px;
  margin-right: 20px;
}

.gram-sec .g-note {
  margin-top: -4px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--blue);
  border-radius: 0 12px 12px 0;
  background: color-mix(in srgb, var(--blue) 7%, var(--card));
}

.gram-sec .g-cap {
  margin-top: 16px;
  color: var(--ink);
  font-size: 13px;
}

.gram-sec .g-scroll {
  margin: 0 20px 18px;
  border: 1px solid var(--sep);
  border-radius: 15px;
}

table.gram {
  min-width: 480px;
}

table.gram th,
table.gram td {
  padding: 11px 13px;
}

table.gram thead th {
  color: var(--blue-text);
  background: color-mix(in srgb, var(--blue) 8%, var(--card));
}

table.gram tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--blue) 3.5%, var(--card));
}

table.gram tbody tr:hover {
  background: color-mix(in srgb, var(--green) 7%, var(--card));
}

.gram-sec .g-tips {
  margin-bottom: 20px;
  padding: 14px 18px 14px 36px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--green) 7%, var(--card));
}

@media (max-width: 560px) {
  .scenario-card .sc-ic {
    aspect-ratio: 4 / 3;
  }

  .factcard .fact-body {
    align-items: flex-start;
    gap: 12px;
  }

  .factcard .fact-art {
    width: 88px;
    height: 66px;
    border-radius: 14px;
  }

  .word-orbit {
    width: 62px;
    height: 62px;
    border-radius: 20px;
  }

  .word-orbit .icn {
    width: 29px;
    height: 29px;
  }

  .noun-forms {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 15px;
  }

  #gramNav {
    top: calc(66px + env(safe-area-inset-top));
  }

  .gram-sec summary {
    min-height: 74px;
    padding: 13px 14px;
  }

  .gram-icon {
    width: 39px;
    height: 39px;
  }

  .gram-sec .g-note,
  .gram-sec .g-cap,
  .gram-sec .g-tips {
    margin-left: 14px;
    margin-right: 14px;
  }

  .gram-sec .g-scroll {
    margin-left: 14px;
    margin-right: 14px;
  }
}

/* In a conversation the tab's hero art expands to cover the whole column, so
   the chat area shows the scene instead of a flat dark slab (the aurora photo
   behind the translucent column is mostly dark below its sky band, which is
   why "transparent" still looked like a void on phones). Bubbles and the
   composer are opaque cards, so legibility is carried by them. */
body.in-convo #app {
  --hero-size: cover;
  --hero-position: center;
}

/* Correction tile: its old 90%-transparent orange wash was fine on a flat
   page but unreadable over the full-scene chat backdrop. Same orange tint,
   now over a frosted card ground. */
.bubble-note {
  background:
    linear-gradient(color-mix(in srgb, var(--orange) 12%, transparent),
                    color-mix(in srgb, var(--orange) 12%, transparent)),
    color-mix(in srgb, var(--card) 94%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

/* ---- WhatsApp-style conversation view ------------------------------------
   Wallpaper = the scene art under a flat calm veil; bubbles fully opaque and
   crisp; slim composer; the convo bar pinned like a chat header. */
body.in-convo #app {
  background:
    linear-gradient(rgba(248, 251, 253, .32), rgba(248, 251, 253, .32)),
    var(--hero-image) center / cover no-repeat,
    rgba(248, 251, 253, .56);
}
html[data-theme="dark"] body.in-convo #app {
  background:
    linear-gradient(rgba(3, 12, 22, .45), rgba(3, 12, 22, .45)),
    var(--hero-image) center / cover no-repeat,
    rgba(6, 20, 33, .52);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) body.in-convo #app {
    background:
      linear-gradient(rgba(3, 12, 22, .45), rgba(3, 12, 22, .45)),
      var(--hero-image) center / cover no-repeat,
      rgba(6, 20, 33, .52);
  }
}
/* bubbles: fully opaque over the wallpaper, WhatsApp-grade contrast */
body.in-convo .bubble.bot {
  background: linear-gradient(var(--card), var(--card)), var(--bg);
  box-shadow: var(--shadow-sm);
}
body.in-convo .bubble.user {
  background:
    linear-gradient(color-mix(in srgb, var(--blue) 14%, var(--card)),
                    color-mix(in srgb, var(--blue) 14%, var(--card))),
    var(--bg);
  box-shadow: var(--shadow-sm);
}
/* slim single-line composer that grows only as you type */
.chat-input textarea.field { min-height: 46px; }
/* convo bar = pinned chat header chip, not a floating band */
#chatConvo .convo-bar {
  position: sticky;
  top: calc(84px + env(safe-area-inset-top));
  z-index: 20;
  padding: 8px 14px;
  border-radius: 18px;
  border: 1px solid var(--sep);
  background: var(--material);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
}

/* In-conversation, WhatsApp rules: no floating mascot over the send button,
   no bottom tab bar (the convo bar's back button exits), composer sits at the
   true bottom — typing with the keyboard open stops feeling cramped. */
body.in-convo .fab { display: none !important; }
body.in-convo .tabbar { display: none; }
body.in-convo .chat-input-tab { bottom: calc(10px + env(safe-area-inset-bottom)); }
body.in-convo main { padding-bottom: 110px; }
/* correction explanation: full ink, not the muted grey that sank into the tile */
.bubble-note .err-why { color: var(--ink); opacity: .85; }

/* ---- Fritrening + flashcard micro-animations ---- */
.practice-btn { margin-top: 8px; }
.practice-btn small { display: block; font-weight: 600; opacity: .75; font-size: 12px; }
.done-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.flashcard .flash-inner { transition: transform .3s cubic-bezier(.2, .7, .3, 1.05); }
.flashcard.anim-in { animation: fcIn .3s cubic-bezier(.2, .7, .3, 1.05); }
@keyframes fcIn { from { opacity: 0; transform: translateX(46px) scale(.97); } to { opacity: 1; transform: none; } }
.flashcard.anim-out-ok { animation: fcOut .22s ease-in forwards; }
@keyframes fcOut { to { opacity: 0; transform: translateX(-70px) rotate(-2deg); } }
.flashcard.anim-again { animation: fcShake .3s ease-in-out; }
@keyframes fcShake { 0%, 100% { transform: none; } 25% { transform: translateX(-8px); } 55% { transform: translateX(7px); } 80% { transform: translateX(-3px); } }
.grade-btn { transition: transform .12s ease; }
.grade-btn:active { transform: scale(.92); }
@media (prefers-reduced-motion: reduce) {
  .flashcard .flash-inner { transition: none; }
  .flashcard.anim-in, .flashcard.anim-out-ok, .flashcard.anim-again { animation: none; }
}

/* ---- Layout switcher: Compact / Library homes ---- */
html.layout-compact #view-today > *:not(#homeCompact) { display: none !important; }
html.layout-library #view-today > *:not(#homeLibrary) { display: none !important; }
html.layout-compact #homeCompact, html.layout-library #homeLibrary { display: block; }
#homeCompact, #homeLibrary { padding-top: 14px; }
.cockpit-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.cockpit-stats span { display: flex; flex-direction: column; align-items: center; padding: 12px;
  background: var(--card); border: 1px solid var(--sep); border-radius: 16px; }
.cockpit-stats b { font-size: 24px; }
.cockpit-stats small { color: var(--ink2); }
.cockpit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.cockpit-tile { display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 20px 10px; background: var(--card); border: 1px solid var(--sep);
  border-radius: 18px; cursor: pointer; box-shadow: var(--shadow-sm); }
.cockpit-tile b { font-size: 16px; }
.cockpit-tile small { color: var(--ink2); min-height: 1em; }
.cockpit-tile:active { transform: scale(.97); }
.lib-rows h2 { margin: 14px 0 8px; }
.lib-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px;
  margin-bottom: 8px; background: var(--card); border: 1px solid var(--sep);
  border-radius: 14px; cursor: pointer; text-align: left; color: var(--ink); }
.lib-row .grow { flex: 1; }
.lib-row .pill { flex: none; font-weight: 800; }
.lib-actions { display: flex; gap: 8px; margin-top: 12px; }
.lib-actions .btn { flex: 1; }
