:root {
  --sidebar-width: 232px;
  --content-max: 1260px;
  --surface-raised: rgba(250, 250, 252, .9);
  --warm: #b98b62;
  --warm-pale: #f7eee5;
  --focus-ring: rgba(112, 101, 207, .3);
}

html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

html {
  scroll-behavior: smooth;
}

body {
  line-height: 1.45;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: #fff;
  background: var(--accent-dark);
  transform: translateY(-150%);
  transition: transform .18s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  padding: 26px 16px 20px;
}

.brand-block {
  width: 100%;
  padding: 0 10px;
  text-align: left;
}

.brand-name {
  font-size: 14px;
  letter-spacing: -.01em;
}

.brand-subtitle {
  max-width: 145px;
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-nav {
  gap: 4px;
  margin-top: 42px;
}

.nav-group-label {
  display: block;
  padding: 0 13px 7px;
  color: #a8a9b6;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.nav-group-label.secondary {
  margin-top: 19px;
}

.nav-item {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 12px;
}

.nav-item.active::before {
  left: -16px;
  top: 11px;
}

.nav-item[aria-current="page"] {
  color: var(--accent-dark);
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-pale), rgba(236, 234, 241, .58));
}

.sidebar-footer {
  display: grid;
  gap: 10px;
}

.streak-card {
  margin: 0;
  padding: 12px;
}

.sidebar-account-link {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 9px;
  text-align: left;
}

.sidebar-account-link:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.account-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c5c5cf;
  box-shadow: 0 0 0 3px rgba(197, 197, 207, .2);
}

.main-content {
  width: auto;
  max-width: none;
  margin-left: var(--sidebar-width);
  padding: 24px clamp(24px, 4vw, 58px) 72px;
}

.main-content > .view,
.topbar {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
}

.login-shell,
.study-layout,
.study-active .study-layout,
.retell-layout {
  width: 100%;
  max-width: none;
}

body.study-active {
  overflow-y: scroll;
}

.topbar {
  min-height: 42px;
  margin-bottom: 28px;
}

.topbar-context {
  display: flex;
  align-items: center;
  gap: 7px;
}

.topbar-context #topbar-section,
.topbar-divider {
  color: #a0a1ad;
  font-size: 9px;
}

.topbar-title {
  margin-top: 4px;
  font-size: 12px;
}

.home-hero {
  min-height: 278px;
  padding: 38px clamp(32px, 5vw, 62px);
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: 24px;
  background:
    radial-gradient(circle at 87% 8%, rgba(255, 255, 255, .95), transparent 24%),
    linear-gradient(118deg, #eceaf7 0%, #f2f0f8 52%, #f8f6f5 100%);
  box-shadow: 0 20px 52px rgba(61, 58, 86, .07);
}

.hero-copy {
  max-width: 660px;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(126, 120, 158, .13);
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, .62);
  font-size: 9px;
  font-weight: 700;
}

.hero-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(120, 149, 134, .12);
}

.hero-copy h1 {
  margin: 17px 0 11px;
  font-size: clamp(29px, 3.2vw, 43px);
}

.hero-copy p {
  max-width: 630px;
  line-height: 1.7;
}

.hero-actions {
  gap: 11px;
  margin-top: 22px;
}

.hero-primary {
  min-height: 43px;
  padding-inline: 20px;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 43px;
  padding: 11px 16px;
  border: 1px solid rgba(111, 103, 154, .17);
  border-radius: 11px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, .6);
  font-size: 11px;
  font-weight: 650;
  transition: .18s ease;
}

.secondary-button:hover {
  border-color: rgba(111, 103, 154, .3);
  background: rgba(255, 255, 255, .9);
  transform: translateY(-1px);
}

.hero-microcopy {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 18px;
  margin-top: 15px;
  color: #9695a5;
  font-size: 9px;
}

.hero-microcopy span {
  position: relative;
}

.hero-microcopy span + span::before {
  content: "·";
  position: absolute;
  left: -11px;
}

.hero-progress-wrap {
  margin-right: 2%;
}

.progress-ring {
  width: 132px;
  height: 132px;
  box-shadow: 0 12px 30px rgba(92, 84, 145, .1);
}

.today-strip {
  display: grid;
  grid-template-columns: 1.18fr repeat(3, 1fr);
  gap: 1px;
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--line);
  box-shadow: var(--shadow-small);
}

.today-strip-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 16px 18px;
  background: var(--surface-raised);
}

.today-strip-item.priority {
  background: linear-gradient(120deg, #f2f0fa, #f8f7fb);
}

.today-strip-item > div {
  min-width: 0;
}

.today-strip-item small,
.today-strip-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-strip-item small {
  color: var(--ink-soft);
  font-size: 9px;
}

.today-strip-item strong {
  margin-top: 4px;
  font-size: 13px;
}

.today-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  flex: 0 0 30px;
  border-radius: 10px;
  color: var(--accent-dark);
  background: var(--accent-pale);
}

.learning-paths {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, .8fr);
  gap: 16px;
  margin-top: 34px;
}

.path-card {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface-raised);
  box-shadow: 0 10px 30px rgba(61, 58, 86, .045);
}

.path-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.path-card h2 {
  margin: 7px 0 5px;
  font-size: 18px;
  letter-spacing: -.025em;
}

.path-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.65;
}

.path-card .mode-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 20px;
}

.path-card .mode-card {
  align-items: flex-start;
  min-height: 93px;
  padding: 14px;
}

.path-card .mode-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 10px;
  font-size: 15px;
}

.path-card .mode-copy {
  gap: 4px;
}

.path-card .mode-copy strong {
  font-size: 11px;
}

.path-card .mode-copy small {
  line-height: 1.45;
}

.path-start-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--accent-dark);
  background: var(--accent-pale);
  font-size: 10px;
  font-weight: 700;
}

.path-start-button:hover {
  background: #e4e1ef;
}

.speaking-path {
  position: relative;
  overflow: hidden;
  border-color: #eadfd4;
  background:
    radial-gradient(circle at 100% 0, rgba(255,255,255,.9), transparent 35%),
    linear-gradient(145deg, #faf6f2, #f4ece5);
}

.speaking-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  margin-bottom: 20px;
  border-radius: 13px;
  color: #9a691f;
  background: #fff0bd;
  font-size: 19px;
}

.speaking-path h2 {
  max-width: 260px;
  margin-top: 8px;
  font-size: 20px;
}

.speaking-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 24px;
}

.speaking-summary div {
  min-width: 0;
  padding: 10px 6px;
  border: 1px solid rgba(160, 125, 92, .12);
  border-radius: 10px;
  background: rgba(255, 255, 255, .46);
  text-align: center;
}

.speaking-summary strong,
.speaking-summary span {
  display: block;
}

.speaking-summary strong {
  font-size: 16px;
}

.speaking-summary span {
  margin-top: 3px;
  color: #9a8675;
  font-size: 8px;
  white-space: nowrap;
}

.path-start-button.warm {
  color: #815e3f;
  background: rgba(228, 207, 188, .55);
}

.path-start-button.warm:hover {
  background: rgba(220, 194, 170, .68);
}

.section-heading.compact {
  margin-top: 34px;
}

.overview-panel {
  min-height: 164px;
  border-radius: 16px;
  background: var(--surface-raised);
}

.page-heading {
  margin-bottom: 24px;
}

.page-heading h1 {
  max-width: 760px;
  margin: 8px 0 7px;
  font-size: clamp(26px, 3vw, 36px);
}

.page-heading p {
  max-width: 680px;
  line-height: 1.65;
}

.study-topline {
  margin-bottom: 18px;
}

.study-progress-row {
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-raised);
}

.word-card {
  border-radius: 22px;
  box-shadow: 0 20px 56px rgba(61, 58, 86, .085);
}

.study-rail .rail-card {
  border-radius: 15px;
  background: var(--surface-raised);
}

.retell-page-heading {
  align-items: flex-end;
}

.retell-deck-bar {
  border-radius: 14px;
  background: var(--surface-raised);
}

.retell-deck-bar > div:first-child {
  align-items: center;
}

.retell-deck-bar > div:first-child > span:last-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.retell-deck-bar small {
  color: var(--ink-soft);
  font-size: 7px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.retell-layout {
  display: block;
  min-height: 620px;
  border-radius: 18px;
}

.retell-card-shell {
  min-height: 620px;
  padding: 25px 36px 30px;
  box-shadow: 0 18px 50px rgba(61, 58, 86, .075);
}

.retell-card-topline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
}

.retell-card-topline > :last-child {
  justify-self: end;
}

.retell-round-inline {
  justify-self: center;
  letter-spacing: 0;
}

.retell-card,
.retell-phase {
  min-height: 520px;
}

.retell-vocab-footer {
  display: grid;
  grid-template-columns: minmax(150px, .55fr) minmax(0, 2fr);
  gap: 18px;
  align-items: start;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.retell-is-blind .retell-vocab-footer {
  display: none;
}

.retell-vocab-footer .retell-context {
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.retell-vocab-footer .retell-vocab-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  max-height: none;
}

.library-heading-actions {
  align-self: flex-start;
}

.library-kind-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: -4px 0 14px;
}

.library-kind-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 17px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink-soft);
  background: var(--surface-raised);
  text-align: left;
}

.library-kind-tab span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 720;
}

.library-kind-tab small {
  font-size: 9px;
}

.library-kind-tab.active {
  border-color: #d8d4ed;
  color: var(--accent-dark);
  background: var(--accent-pale);
  box-shadow: inset 3px 0 0 var(--accent);
}

.retell-word-row {
  grid-template-columns: 50px minmax(120px, 1.05fr) minmax(120px, .8fr) minmax(190px, 1.7fr) 70px minmax(80px, .65fr);
}

.retell-word-scene {
  justify-self: end;
  color: var(--ink-soft);
  font-size: 9px;
}

.library-toolbar {
  position: sticky;
  z-index: 8;
  top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 248, 250, .9);
  box-shadow: 0 10px 26px rgba(61, 58, 86, .055);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.search-box {
  border: 1px solid var(--line);
  background: var(--surface);
}

.word-list {
  overflow: hidden;
  border-radius: 15px;
  box-shadow: 0 10px 28px rgba(61, 58, 86, .04);
}

.stats-hero-grid {
  grid-template-columns: repeat(4, 1fr);
}

.stats-highlight {
  min-width: 0;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 17px;
  box-shadow: 0 12px 30px rgba(61, 58, 86, .045);
}

.stats-highlight.speaking {
  color: #71543e;
  background: linear-gradient(145deg, #f7eee6, #fbf7f3);
}

.stats-highlight.speaking .stats-highlight-foot,
.stats-highlight.speaking .stat-label {
  color: #9e8370;
}

.stats-grid-main,
.settings-layout {
  gap: 16px;
}

.panel,
.settings-panel,
.tip-card,
.source-card {
  border-radius: 17px;
}

.settings-panel {
  overflow: hidden;
}

.settings-section {
  padding: 27px 30px;
}

.setting-row {
  min-height: 61px;
}

.modal {
  border: 1px solid rgba(255,255,255,.68);
}

body.dark {
  --surface-raised: rgba(37, 38, 56, .9);
  --warm-pale: #47382f;
}

body.dark .home-hero {
  border-color: rgba(255,255,255,.06);
  background:
    radial-gradient(circle at 87% 8%, rgba(118,109,174,.24), transparent 26%),
    linear-gradient(118deg, #302e4c 0%, #29293f 60%, #312d39 100%);
}

body.dark .hero-kicker,
body.dark .secondary-button,
body.dark .speaking-summary div {
  border-color: rgba(255,255,255,.08);
  background: rgba(255,255,255,.055);
}

body.dark .today-strip,
body.dark .today-strip-item,
body.dark .path-card,
body.dark .overview-panel,
body.dark .study-progress-row,
body.dark .retell-deck-bar,
body.dark .library-kind-tab,
body.dark .library-toolbar {
  border-color: var(--line);
  background: var(--surface-raised);
}

body.dark .today-strip-item.priority {
  background: #2c2b43;
}

body.dark .speaking-path {
  border-color: #4a3d37;
  background: linear-gradient(145deg, #342d2e, #2d2b36);
}

@media (max-width: 1120px) {
  :root {
    --sidebar-width: 210px;
  }

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

  .speaking-path {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 18px;
  }

  .speaking-mark {
    grid-row: 1 / span 4;
  }

  .speaking-path .eyebrow,
  .speaking-path h2,
  .speaking-path p {
    grid-column: 2;
  }

  .speaking-summary,
  .speaking-path .path-start-button {
    grid-column: 1 / -1;
  }

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

@media (max-width: 820px) {
  body {
    padding-bottom: 72px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    inset: auto 0 0;
    width: 100%;
    height: 68px;
    padding: 6px max(7px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left));
    border-top: 1px solid rgba(255,255,255,.72);
    border-right: 0;
    background: rgba(246, 246, 248, .91);
    box-shadow: 0 -12px 36px rgba(42, 40, 66, .09);
  }

  .brand-block,
  .sidebar-footer,
  .nav-group-label {
    display: none;
  }

  .main-nav {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
    margin: 0;
    overflow: visible;
  }

  .nav-item {
    min-width: 0;
    min-height: 52px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 5px 2px;
    font-size: 8px;
    line-height: 1;
    text-align: center;
  }

  .nav-icon {
    width: auto;
    font-size: 15px;
  }

  .nav-pill {
    position: absolute;
    top: 3px;
    right: calc(50% - 19px);
    min-width: 15px;
    padding: 2px 3px;
    font-size: 7px;
  }

  .main-content {
    width: 100%;
    margin-left: 0;
    padding: 18px 16px 38px;
  }

  .topbar {
    margin-bottom: 20px;
  }

  .home-hero {
    padding: 29px 26px;
  }

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

  .path-card .mode-grid {
    grid-template-columns: 1fr;
  }

  .path-card .mode-card {
    align-items: center;
    min-height: 67px;
  }

  .library-toolbar {
    top: 8px;
  }

  .retell-word-row {
    grid-template-columns: 40px minmax(110px, 1fr) minmax(110px, .75fr) minmax(160px, 1.4fr) 65px;
  }

  .retell-word-scene {
    display: none;
  }
}

@media (max-width: 600px) {
  .main-content {
    padding-inline: 13px;
  }

  .topbar-title {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-hero {
    min-height: 0;
    padding: 26px 22px;
  }

  .hero-copy h1 {
    font-size: 29px;
  }

  .hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-primary,
  .secondary-button {
    width: 100%;
  }

  .hero-progress-wrap {
    align-self: flex-start;
    width: 100%;
    justify-content: center;
  }

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

  .today-strip-item {
    padding: 13px;
  }

  .today-strip-item.priority {
    grid-column: 1 / -1;
  }

  .today-strip-item:last-child {
    grid-column: 1 / -1;
  }

  .learning-paths {
    margin-top: 24px;
  }

  .path-card {
    padding: 19px;
  }

  .path-card-heading {
    gap: 10px;
  }

  .speaking-path {
    display: block;
  }

  .speaking-mark {
    margin-bottom: 17px;
  }

  .speaking-summary {
    grid-template-columns: repeat(3, 1fr);
  }

  .overview-panel {
    padding: 18px;
  }

  .page-heading h1 {
    font-size: 28px;
  }

  .retell-page-heading {
    gap: 14px;
  }

  .library-heading-actions,
  .library-heading-actions button {
    width: 100%;
  }

  .library-kind-tabs {
    grid-template-columns: 1fr;
  }

  .library-kind-tab {
    padding: 12px 14px;
  }

  .retell-card-shell {
    min-height: 580px;
    padding: 18px 16px 22px;
  }

  .retell-card,
  .retell-phase {
    min-height: 485px;
  }

  .retell-card-topline {
    grid-template-columns: 1fr auto;
  }

  .retell-round-inline {
    display: none;
  }

  .retell-vocab-footer {
    grid-template-columns: 1fr;
  }

  .retell-deck-stats {
    display: grid;
    grid-template-columns: repeat(3, auto);
    row-gap: 6px;
  }

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

  .stats-highlight {
    min-height: 118px;
  }

  .settings-section {
    padding: 22px 18px;
  }
}

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