/* =========================================================
   StudyNet 学习舱 — foundation
   ========================================================= */

@font-face {
  font-family: 'Manrope';
  src: url('../fonts/manrope-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f2efe8;
  --bg-warm: #f8f4ec;
  --surface: #fffdf9;
  --surface-2: #f8f5ee;
  --surface-3: #efebe2;
  --ink: #171e2c;
  --ink-2: #303848;
  --muted: #737a87;
  --muted-2: #9ba1ab;
  --line: #e7e1d6;
  --line-strong: #d9d2c5;
  --primary: #3157f5;
  --primary-deep: #2544ce;
  --primary-soft: #e9edff;
  --primary-wash: #f2f4ff;
  --lime: #d9f36a;
  --lime-deep: #b9d63f;
  --coral: #ef735d;
  --coral-soft: #ffebe6;
  --mint: #179b7f;
  --mint-soft: #e1f7f0;
  --amber: #eeb140;
  --amber-soft: #fff4d8;
  --navy: #101828;
  --navy-2: #15223a;
  --navy-3: #1c2d4c;
  --white: #ffffff;
  --danger: #d94d42;
  --danger-soft: #fdecea;
  --shadow-xs: 0 1px 2px rgba(23, 30, 44, 0.04);
  --shadow-sm: 0 8px 24px -18px rgba(23, 30, 44, 0.25), 0 2px 6px rgba(23, 30, 44, 0.03);
  --shadow-md: 0 24px 60px -34px rgba(19, 27, 42, 0.34), 0 4px 14px rgba(19, 27, 42, 0.035);
  --shadow-lg: 0 42px 110px -38px rgba(10, 17, 30, 0.48);
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-2xl: 34px;
  --sidebar-w: 248px;
  --sidebar-gap: 14px;
  --rail-w: 76px;
  --topbar-h: 70px;
  --page-max: 1480px;
  --font: 'Manrope', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif;
  --font-cn: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', var(--font);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

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

html {
  min-width: 320px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 600px at 6% -8%, rgba(255, 250, 238, 0.96), transparent 60%),
    radial-gradient(900px 500px at 92% 2%, rgba(49, 87, 245, 0.045), transparent 62%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.has-dialog {
  overflow: hidden;
}

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

h1,
h2,
h3,
h4 {
  font-family: var(--font-cn);
  color: var(--ink);
  letter-spacing: -0.025em;
  line-height: 1.25;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

img,
svg {
  display: block;
  max-width: 100%;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

::selection {
  background: rgba(49, 87, 245, 0.2);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d8d2c7;
  border: 3px solid transparent;
  border-radius: 20px;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #c3bbad;
  border: 3px solid transparent;
  background-clip: padding-box;
}

.hidden,
[hidden] {
  display: none !important;
}

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

.sn-icon {
  flex: none;
}

/* ----------------------------- Brand ----------------------------- */

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

.brand__mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  color: var(--navy);
  background:
    radial-gradient(circle at 78% 20%, #f7ffd0 0 10%, transparent 11%),
    linear-gradient(145deg, #e6ff87, #c8e84a);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.48), 0 8px 18px -10px rgba(217, 243, 106, 0.7);
}

.brand__mark::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 9px;
  border: 1px solid rgba(16, 24, 40, 0.08);
  pointer-events: none;
}

.brand__text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}

.brand__text strong {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: inherit;
}

.brand__text small {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #8d96a5;
  transform: translateY(-1px);
}

.brand--compact .brand__mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.brand--compact .brand__text strong {
  font-size: 15px;
}

/* ----------------------------- App shell ----------------------------- */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  z-index: 40;
  top: var(--sidebar-gap);
  bottom: var(--sidebar-gap);
  left: var(--sidebar-gap);
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 14px;
  border-radius: var(--r-2xl);
  background:
    radial-gradient(420px 240px at 10% -10%, rgba(63, 91, 164, 0.3), transparent 58%),
    linear-gradient(182deg, #131e31 0%, #0d1625 100%);
  color: #d8deea;
  box-shadow: 0 30px 60px -32px rgba(14, 20, 33, 0.62), inset 0 0 0 1px rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.sidebar::after {
  content: '';
  position: absolute;
  right: -80px;
  bottom: 110px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 34px rgba(255, 255, 255, 0.018), 0 0 0 70px rgba(255, 255, 255, 0.012);
  pointer-events: none;
}

.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 7px 24px;
}

.sidebar .brand {
  color: #f8fafc;
}

.sidebar .brand__text small {
  color: #78849a;
}

.sidebar__version {
  padding: 4px 6px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #6f7c93;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.sidebar__nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 2px;
  scrollbar-width: none;
}

.sidebar__nav::-webkit-scrollbar {
  display: none;
}

.nav-group {
  padding: 0 0 16px;
}

.nav-group__label {
  padding: 0 13px 8px;
  color: #657187;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 0 11px;
  margin-bottom: 3px;
  border-radius: 13px;
  color: #aab5c6;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.055);
}

.nav-item.is-active {
  color: #152034;
  background: #f6f2e9;
  box-shadow: 0 10px 22px -16px rgba(0, 0, 0, 0.55);
}

.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 16px;
  border-radius: 0 4px 4px 0;
  background: var(--coral);
  transform: translateY(-50%);
}

.nav-item__icon {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  color: #8592a7;
  transition: color 0.18s ease;
}

.nav-item:hover .nav-item__icon {
  color: #dfe6f2;
}

.nav-item.is-active .nav-item__icon {
  color: var(--primary);
}

.nav-item__label {
  flex: 1;
  white-space: nowrap;
}

.nav-item__count {
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 7px;
  background: var(--coral);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 800;
}

.nav-item__badge {
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--lime);
  color: #182033;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.07em;
}

.sidebar__bottom {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding-top: 12px;
}

.sidebar-focus {
  display: block;
  padding: 14px;
  margin-bottom: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.075);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.sidebar-focus:hover {
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(255, 255, 255, 0.12);
}

.sidebar-focus__top {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #96a2b5;
  font-size: 10.5px;
  font-weight: 600;
}

.sidebar-focus__top strong {
  margin-left: auto;
  color: #f7fafc;
  font-size: 11px;
  font-weight: 700;
}

.sidebar-focus__icon {
  color: var(--lime);
}

.sidebar-focus__bar {
  height: 4px;
  margin: 11px 0 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.sidebar-focus__bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lime-deep), var(--lime));
  transition: width 0.6s var(--ease);
}

.sidebar-focus p {
  color: #6f7c91;
  font-size: 9.5px;
}

.sidebar-focus p strong {
  color: #b4c0d1;
  font-weight: 600;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 8px;
  border-radius: 14px;
  transition: background 0.2s ease;
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-user__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.sidebar-user__meta strong {
  color: #f1f5f9;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user__meta small {
  color: #78859a;
  font-size: 9.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user__chevron {
  color: #5e6b80;
}

.avatar {
  display: grid;
  place-items: center;
  width: var(--avatar-size, 36px);
  height: var(--avatar-size, 36px);
  flex: none;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.3), transparent 35%),
    linear-gradient(145deg, #f09d82, #e26061 60%, #c94b7b);
  color: #fff7ef;
  font-family: var(--font-cn);
  font-size: calc(var(--avatar-size, 36px) * 0.38);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.avatar span {
  transform: translateY(-1px);
}

/* Topbar */

.app-main {
  min-height: 100vh;
  min-height: 100dvh;
  margin-left: calc(var(--sidebar-w) + var(--sidebar-gap) * 2);
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 34px;
  background: rgba(242, 239, 232, 0.78);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.topbar__left,
.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar__crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-2);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.topbar__crumb i {
  color: #c4bfb5;
  font-style: normal;
}

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

.topbar__date {
  padding-left: 14px;
  margin-left: 2px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.topbar__mobile-brand {
  display: none;
}

.topbar__right {
  justify-content: flex-end;
}

.save-pill,
.streak-pill,
.model-pill,
.config-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.save-pill {
  color: var(--muted);
  background: rgba(255, 253, 249, 0.62);
  border: 1px solid rgba(231, 225, 214, 0.8);
}

.save-pill i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 3px rgba(23, 155, 127, 0.1);
}

.streak-pill {
  color: #b4573f;
  background: #ffede5;
}

.model-pill {
  max-width: 160px;
  color: #43506a;
  background: rgba(255, 253, 249, 0.74);
  border: 1px solid var(--line);
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-pill .sn-icon {
  color: var(--primary);
}

.config-pill {
  color: var(--coral);
  background: var(--coral-soft);
  border: 1px solid rgba(239, 115, 93, 0.18);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 249, 0.7);
  color: var(--muted);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.icon-btn:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
}

.icon-btn:active {
  transform: scale(0.96);
}

.topbar__avatar {
  display: block;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 253, 249, 0.78);
}

.topbar__focus {
  background: rgba(255, 253, 249, 0.62);
}

.mobile-nav {
  display: none;
}

/* Page base */

.page-content {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 6px 34px 38px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 0 26px;
}

.page-head__main {
  min-width: 0;
}

.page-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-eyebrow i {
  display: inline-block;
  width: 18px;
  height: 1px;
  background: var(--primary);
}

.page-head h1 {
  font-size: clamp(28px, 2.7vw, 38px);
  font-weight: 700;
  letter-spacing: -0.045em;
}

.page-head h1 em {
  font-style: normal;
  color: var(--primary);
}

.page-head__sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  max-width: 620px;
}

.page-head__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  padding-bottom: 2px;
}

.eyebrow {
  display: inline-block;
  color: var(--primary);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.ink-mark {
  color: var(--primary);
}

/* ----------------------------- Buttons ----------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 41px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-family: var(--font-cn);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease,
    transform 0.16s ease;
}

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

.btn--primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 10px 22px -14px rgba(49, 87, 245, 0.9);
}

.btn--primary:hover {
  background: var(--primary-deep);
  box-shadow: 0 13px 28px -14px rgba(49, 87, 245, 0.9);
}

.btn--dark {
  background: var(--navy);
  color: #ffffff;
  box-shadow: 0 12px 24px -16px rgba(16, 24, 40, 0.8);
}

.btn--dark:hover {
  background: #1e2b43;
}

.btn--lime {
  background: var(--lime);
  color: #162034;
}

.btn--lime:hover {
  background: #e5ff83;
}

.btn--soft {
  background: var(--primary-soft);
  color: var(--primary-deep);
}

.btn--soft:hover {
  background: #dde4ff;
}

.btn--ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink-2);
}

.btn--ghost:hover {
  background: var(--surface);
  border-color: #c8c0b2;
}

.btn--danger {
  background: var(--danger);
  color: white;
}

.btn--danger:hover {
  background: #c44035;
}

.btn--danger-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}

.btn--danger-ghost:hover {
  background: var(--danger-soft);
}

.btn--sm {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 11px;
}

.btn--lg {
  min-height: 50px;
  padding: 0 23px;
  border-radius: 14px;
  font-size: 13.5px;
}

.btn--icon {
  width: 40px;
  padding: 0;
}

.btn--block {
  width: 100%;
}

.btn.is-loading {
  pointer-events: none;
  opacity: 0.78;
}

.btn .sn-icon {
  flex: none;
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.link-arrow:hover {
  gap: 7px;
}

/* ----------------------------- Pills / tags ----------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 27px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.chip--primary {
  background: var(--primary-soft);
  color: var(--primary-deep);
}

.chip--coral {
  background: var(--coral-soft);
  color: #b44f3d;
}

.chip--mint {
  background: var(--mint-soft);
  color: #0b735d;
}

.chip--lime {
  background: #f2ffc0;
  color: #617019;
}

.subject-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border-radius: 7px;
  background: var(--subject-soft);
  color: var(--subject-ink);
  font-family: var(--font-cn);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.subject-tag i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--subject);
}

.dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ----------------------------- Cards ----------------------------- */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.card--flat {
  box-shadow: none;
}

.card--soft {
  background: var(--surface-2);
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 0;
}

.card__title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.card__sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10.5px;
}

.card__body {
  padding: 18px 24px 24px;
}

.card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
}

.section-label {
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ----------------------------- Forms ----------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 700;
}

.field__label small {
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 500;
}

.field__help {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.field__hint-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 9.5px;
  font-weight: 600;
}

.required {
  color: var(--coral);
}

.input {
  width: 100%;
  height: 43px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.input::placeholder {
  color: #b0aca2;
}

.input:hover {
  border-color: #c8c0b3;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(49, 87, 245, 0.1);
}

.input--lg {
  height: 49px;
  padding: 0 14px;
  font-size: 13px;
}

.textarea {
  height: auto;
  min-height: 90px;
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.65;
}

select.input {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23737a87' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 15px;
}

.input-affix {
  position: relative;
}

.input-affix .input {
  padding-right: 42px;
}

.input-affix__btn {
  position: absolute;
  top: 50%;
  right: 5px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
}

.input-affix__btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* Hide the browser's native password reveal so it does not overlap ours. */
input[type='password']::-ms-reveal,
input[type='password']::-ms-clear {
  display: none;
}

input[type='password']::-webkit-credentials-auto-fill-button,
input[type='password']::-webkit-contacts-auto-fill-button {
  position: absolute;
  right: 0;
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}

.form-grid {
  display: grid;
  gap: 14px;
}

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

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

.study-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.study-form .input {
  background: #fffefa;
}

.choice-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.choice-chip {
  position: relative;
  cursor: pointer;
}

.choice-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  transition: all 0.16s ease;
}

.choice-chip:hover span {
  border-color: #bdb5a8;
  color: var(--ink-2);
}

.choice-chip input:checked + span {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
  box-shadow: 0 8px 16px -12px rgba(23, 30, 44, 0.6);
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-3);
}

.segmented--full {
  width: 100%;
}

.segmented label {
  position: relative;
  flex: 1;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  transition: all 0.16s ease;
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(23, 30, 44, 0.08);
}

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

.subject-choice {
  position: relative;
  cursor: pointer;
}

.subject-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.subject-choice span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  transition: all 0.16s ease;
}

.subject-choice span i {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--subject-soft);
  color: var(--subject);
  font-style: normal;
  font-size: 9px;
  font-weight: 800;
}

.subject-choice:hover span {
  border-color: var(--subject);
}

.subject-choice input:checked + span {
  border-color: var(--subject);
  background: var(--subject-soft);
  color: var(--subject-ink);
  box-shadow: inset 0 0 0 1px var(--subject);
}

.range {
  width: 100%;
  height: 20px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.difficulty-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.difficulty-row .range {
  flex: 1;
}

.difficulty-row span {
  min-width: 30px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.check-row input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

.field--note p {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ----------------------------- Dialog ----------------------------- */

.sn-dialog {
  width: min(680px, calc(100vw - 32px));
  max-width: none;
  max-height: 92vh;
  max-height: 92dvh;
  padding: 0;
  border: 0;
  border-radius: var(--r-xl);
  background: transparent;
  color: var(--ink);
  overflow: visible;
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  transition: opacity 0.22s ease, transform 0.32s var(--ease-out);
}

.sn-dialog[open] {
  display: block;
}

.sn-dialog.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.sn-dialog::backdrop {
  background: rgba(10, 16, 28, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: backdrop-in 0.25s ease;
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
}

.sn-dialog--sm {
  width: min(440px, calc(100vw - 32px));
}

.sn-dialog--md {
  width: min(610px, calc(100vw - 32px));
}

.sn-dialog--lg {
  width: min(790px, calc(100vw - 32px));
}

.sn-dialog--xl {
  width: min(980px, calc(100vw - 32px));
}

.sn-dialog--drawer {
  width: min(570px, 100vw);
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  border-radius: 0;
  transform: translateX(30px);
}

.sn-dialog--drawer.is-open {
  transform: translateX(0);
}

.sn-dialog__panel {
  display: flex;
  flex-direction: column;
  max-height: 92vh;
  max-height: 92dvh;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.sn-dialog--drawer .sn-dialog__panel {
  height: 100%;
  max-height: 100%;
  border-radius: 26px 0 0 26px;
  border-right: 0;
}

.sn-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px 16px;
  border-bottom: 1px solid transparent;
}

.sn-dialog__heading {
  min-width: 0;
}

.sn-dialog__eyebrow {
  margin-bottom: 5px;
  color: var(--primary);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.sn-dialog__head h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.035em;
}

.sn-dialog__sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.sn-dialog__close {
  width: 34px;
  height: 34px;
  border-color: var(--line);
  background: var(--surface-2);
}

.sn-dialog__body {
  flex: 1;
  min-height: 0;
  padding: 6px 26px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sn-dialog__foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 15px 26px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.dialog-foot-spacer {
  flex: 1;
}

.dialog-foot-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted-2);
  font-size: 9.5px;
}

.confirm-message {
  padding: 4px 0 2px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.65;
}

.confirm-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

/* ----------------------------- Toasts ----------------------------- */

.toast-stack {
  position: fixed;
  z-index: 1200;
  right: 24px;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(370px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 13px;
  background: rgba(19, 29, 46, 0.96);
  color: #f4f6f9;
  box-shadow: 0 18px 40px -20px rgba(11, 17, 29, 0.75);
  font-size: 11.5px;
  line-height: 1.5;
  pointer-events: auto;
  animation: toast-in 0.32s var(--ease-out);
  backdrop-filter: blur(16px);
}

.toast.is-leaving {
  animation: toast-out 0.2s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.toast__icon {
  display: flex;
  padding-top: 1px;
  color: #aebbd0;
}

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

.toast--error .toast__icon {
  color: #ff9a87;
}

.toast__text {
  flex: 1;
}

.toast__action {
  border: 0;
  background: transparent;
  color: var(--lime);
  font-size: 10.5px;
  font-weight: 700;
}

/* ----------------------------- Empty state ----------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 190px;
  padding: 26px 20px;
  text-align: center;
}

.empty-state__art {
  display: grid;
  place-items: center;
  width: 55px;
  height: 55px;
  margin-bottom: 13px;
  border-radius: 17px;
  background: var(--primary-soft);
  color: var(--primary);
  transform: rotate(-3deg);
}

.empty-state h3 {
  font-size: 14px;
  font-weight: 700;
}

.empty-state p {
  max-width: 300px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.6;
}

.empty-state .btn {
  margin-top: 14px;
}

/* ----------------------------- Markdown ----------------------------- */

.markdown {
  color: var(--ink-2);
  font-family: var(--font-cn);
  font-size: 13px;
  line-height: 1.82;
  word-break: break-word;
}

.markdown > *:first-child {
  margin-top: 0;
}

.markdown > *:last-child {
  margin-bottom: 0;
}

.markdown p {
  margin: 0 0 10px;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  margin: 19px 0 8px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.4;
}

.markdown h2 {
  font-size: 17px;
}

.markdown h3 {
  font-size: 15px;
}

.markdown h4 {
  font-size: 13.5px;
}

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

.markdown ul,
.markdown ol {
  margin: 6px 0 11px;
  padding-left: 20px;
}

.markdown li {
  margin: 3px 0;
  padding-left: 2px;
}

.markdown li::marker {
  color: var(--primary);
}

.markdown blockquote {
  margin: 12px 0;
  padding: 9px 13px;
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  background: var(--primary-wash);
  color: #46516a;
}

.markdown hr {
  height: 1px;
  margin: 17px 0;
  border: 0;
  background: var(--line);
}

.markdown a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: rgba(49, 87, 245, 0.3);
  text-underline-offset: 3px;
}

.markdown code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #efebe2;
  color: #a14732;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.88em;
}

.markdown pre {
  margin: 0;
  padding: 15px 16px;
  overflow-x: auto;
  background: #111b2c;
  color: #dbe4f4;
  font-size: 11.5px;
  line-height: 1.7;
}

.markdown pre code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}

.code-block {
  margin: 12px 0;
  border-radius: 12px;
  overflow: hidden;
  background: #111b2c;
}

.code-block__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.045);
  color: #7d8ca4;
  font-family: var(--font);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #8d9bb0;
  font-size: 9px;
}

.code-copy:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.code-copy.is-copied {
  color: var(--lime);
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 11.5px;
}

.markdown th,
.markdown td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.markdown th {
  background: var(--surface-2);
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 700;
}

.md-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
}

.math-inline,
.math-block {
  color: var(--ink);
}

.math-inline .katex {
  font-size: 1.04em;
}

.math-block {
  display: block;
  width: 100%;
  margin: 14px 0;
  padding: 11px 14px;
  overflow-x: auto;
  border-radius: 10px;
  background: var(--surface-2);
  text-align: center;
}

.katex-display {
  margin: 0 !important;
}

/* ----------------------------- Utilities ----------------------------- */

.stack {
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  align-items: center;
}

.gap-6 {
  gap: 6px;
}

.gap-8 {
  gap: 8px;
}

.gap-10 {
  gap: 10px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.spacer {
  flex: 1;
}

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

.small {
  font-size: 10.5px;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.text-coral {
  color: var(--coral);
}

.text-mint {
  color: var(--mint);
}

.text-primary {
  color: var(--primary);
}

.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, #eeeae1 25%, #f7f4ed 37%, #eeeae1 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* =========================================================
   Onboarding
   ========================================================= */

body.is-onboarding {
  overflow: hidden;
}

.onboarding {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 600px at 12% 8%, rgba(42, 72, 145, 0.3), transparent 60%),
    radial-gradient(700px 500px at 92% 86%, rgba(239, 115, 93, 0.13), transparent 60%),
    #0b1320;
  opacity: 0;
  visibility: hidden;
  overflow-y: auto;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.onboarding.is-open {
  opacity: 1;
  visibility: visible;
}

.onboarding.is-leaving {
  opacity: 0;
}

.onboarding__glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}

.onboarding__glow--one {
  top: -260px;
  left: -160px;
  width: 640px;
  height: 640px;
  border: 1px solid rgba(217, 243, 106, 0.12);
  box-shadow: 0 0 0 80px rgba(217, 243, 106, 0.025), 0 0 0 160px rgba(217, 243, 106, 0.018);
}

.onboarding__glow--two {
  right: -220px;
  bottom: -260px;
  width: 560px;
  height: 560px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 60px rgba(255, 255, 255, 0.018), 0 0 0 120px rgba(255, 255, 255, 0.01);
}

.onboarding__panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  grid-template-rows: minmax(0, 1fr);
  width: min(1230px, 100%);
  min-height: min(830px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  border-radius: 33px;
  background: var(--bg-warm);
  box-shadow: 0 50px 120px -55px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  transform: translateY(8px) scale(0.992);
  transition: transform 0.45s var(--ease-out);
}

.onboarding.is-open .onboarding__panel {
  transform: translateY(0) scale(1);
}

.onboarding__story {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 38px 40px 30px;
  background:
    radial-gradient(600px 400px at 80% 18%, rgba(49, 87, 245, 0.28), transparent 60%),
    radial-gradient(500px 380px at 6% 92%, rgba(239, 115, 93, 0.15), transparent 58%),
    linear-gradient(155deg, #16243b 0%, #0c1422 76%);
  color: #eef3fa;
  overflow: hidden;
}

.onboarding__story::before {
  content: '';
  position: absolute;
  top: 29%;
  right: -130px;
  width: 380px;
  height: 380px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 50%;
  box-shadow: 0 0 0 48px rgba(255, 255, 255, 0.018), 0 0 0 96px rgba(255, 255, 255, 0.012);
  pointer-events: none;
}

.onboarding__story-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: relative;
  z-index: 2;
}

.onboarding__story .brand {
  color: #f8fafc;
}

.onboarding__story .brand__text small {
  color: #8492a8;
}

.onboarding__beta {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #7f8da3;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.onboarding__story-copy {
  position: relative;
  z-index: 2;
  margin-top: 66px;
  max-width: 460px;
}

.onboarding__story-copy .eyebrow {
  color: var(--lime);
}

.onboarding__story-copy h1 {
  margin-top: 12px;
  color: #f8fafc;
  font-size: clamp(34px, 3.4vw, 49px);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.055em;
}

.onboarding__story-copy h1 em {
  color: var(--lime);
  font-style: normal;
}

.onboarding__story-copy p {
  max-width: 390px;
  margin-top: 18px;
  color: #94a2b7;
  font-size: 12.5px;
  line-height: 1.8;
}

.onboarding__mock {
  position: relative;
  flex: 1;
  min-height: 240px;
  margin-top: 24px;
}

.mock-card {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.065);
  box-shadow: 0 20px 40px -24px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.mock-card__label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #9dabc0;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.mock-card--task {
  top: 5px;
  left: 0;
  width: 245px;
  padding: 13px;
  transform: rotate(-2deg);
}

.mock-task {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  color: #cad4e3;
  font-size: 8.5px;
}

.mock-task:last-child {
  border-bottom: 0;
}

.mock-task i {
  display: grid;
  place-items: center;
  width: 11px;
  height: 11px;
  border: 1px solid #64738a;
  border-radius: 3px;
  font-style: normal;
}

.mock-task span {
  flex: 1;
}

.mock-task b {
  color: #8493a9;
  font-size: 7.5px;
  font-weight: 600;
}

.mock-task.is-done span {
  color: #64738a;
  text-decoration: line-through;
}

.mock-task.is-done i {
  border-color: var(--lime);
  background: var(--lime);
  color: #172033;
}

.mock-card--focus {
  top: 88px;
  right: 1%;
  width: 174px;
  padding: 14px;
  text-align: center;
  transform: rotate(3deg);
}

.mock-card--focus .mock-card__label {
  justify-content: center;
}

.mock-card--focus strong {
  display: block;
  margin: 8px 0 6px;
  color: #f6f9fc;
  font-family: var(--font);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.06em;
}

.mock-focus-bar {
  height: 3px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.mock-focus-bar span {
  display: block;
  width: 62%;
  height: 100%;
  background: var(--lime);
}

.mock-card--focus small {
  display: block;
  margin-top: 7px;
  color: #78879d;
  font-size: 7.5px;
}

.mock-card--wrong {
  bottom: 14px;
  left: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 180px;
  padding: 11px 13px;
  transform: rotate(1deg);
}

.mock-card--wrong .mock-card__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: rgba(239, 115, 93, 0.16);
  color: #ffa08d;
}

.mock-card--wrong b,
.mock-card--wrong small {
  display: block;
}

.mock-card--wrong b {
  color: #e7edf5;
  font-size: 9px;
}

.mock-card--wrong small {
  margin-top: 1px;
  color: #79889e;
  font-size: 7.5px;
}

.mock-orbit {
  position: absolute;
  border: 1px dashed rgba(217, 243, 106, 0.17);
  border-radius: 50%;
  pointer-events: none;
}

.mock-orbit--one {
  right: 8%;
  bottom: 22px;
  width: 62px;
  height: 62px;
}

.mock-orbit--two {
  right: 13%;
  bottom: 44px;
  width: 12px;
  height: 12px;
  border-style: solid;
  background: var(--coral);
  box-shadow: 0 0 22px rgba(239, 115, 93, 0.55);
}

.onboarding__story-foot {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  color: #6f7e94;
  font-size: 8.5px;
}

.onboarding__story-foot span:first-child {
  display: flex;
  align-items: center;
  gap: 5px;
}

.onboarding__form-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 30px 44px 30px;
  background:
    radial-gradient(500px 300px at 100% 0%, rgba(255, 255, 255, 0.7), transparent 55%),
    var(--bg-warm);
  overflow: hidden;
}

.onboarding__form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.onboarding__mobile-brand {
  display: none;
}

.onboarding__form-head .brand__text strong {
  color: var(--ink);
}

.onboarding__step-count {
  color: var(--muted-2);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.onboarding__step-count b {
  color: var(--primary);
  font-weight: 800;
}

.setup-progress {
  display: flex;
  gap: 5px;
  margin-top: 20px;
}

.setup-progress span {
  flex: 1;
  height: 3px;
  border-radius: 9px;
  background: #e4ded3;
  transition: background 0.3s ease;
}

.setup-progress span.is-active {
  background: var(--primary);
}

.setup-progress span.is-done {
  background: #aebdfb;
}

.setup-form {
  flex: 1;
  min-height: 0;
  padding-top: 29px;
  padding-right: 4px;
  padding-bottom: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.setup-step {
  animation: step-in 0.36s var(--ease-out);
}

@keyframes step-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
}

.setup-title {
  margin-bottom: 24px;
}

.setup-title h2 {
  margin-top: 8px;
  font-size: clamp(26px, 2.3vw, 33px);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.045em;
}

.setup-title p {
  max-width: 430px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.setup-step > .field,
.setup-step > .form-grid,
.setup-step > .provider-grid,
.setup-step > .setup-test-row,
.setup-step > .setup-advanced,
.setup-step > .setup-privacy {
  margin-bottom: 14px;
}

.setup-step > .field:last-child {
  margin-bottom: 0;
}

.setup-form .field__label {
  font-size: 10.5px;
}

.setup-form .input {
  background: rgba(255, 253, 249, 0.82);
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.provider-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 57px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 249, 0.74);
  text-align: left;
  transition: all 0.18s ease;
}

.provider-card:hover {
  border-color: #c7bfb2;
  background: var(--surface);
}

.provider-card.is-active {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.provider-card__logo {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex: none;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 800;
}

.provider-card.is-active .provider-card__logo {
  background: var(--primary);
  color: #fff;
}

.provider-card > span:nth-child(2) {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.provider-card strong {
  color: var(--ink);
  font-size: 9.5px;
  font-weight: 700;
  white-space: nowrap;
}

.provider-card small {
  color: var(--muted-2);
  font-size: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.provider-card > i {
  display: none;
  color: var(--primary);
}

.provider-card.is-active > i {
  display: block;
}

.setup-test-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 3px 0;
}

.setup-test-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.setup-test-status.is-ok {
  color: var(--mint);
}

.setup-test-status.is-error {
  color: var(--danger);
}

.setup-test-status.is-pending {
  color: var(--primary);
}

.setup-advanced {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 253, 249, 0.5);
}

.setup-advanced summary {
  padding: 10px 13px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.setup-advanced summary::-webkit-details-marker {
  display: none;
}

.setup-advanced summary span {
  color: var(--muted-2);
  font-size: 8px;
}

.setup-advanced[open] summary {
  border-bottom: 1px solid var(--line);
}

.setup-advanced .form-grid {
  padding: 12px 13px 13px;
  margin: 0 !important;
}

.setup-privacy {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 10px 11px;
  border-radius: 9px;
  background: #efece4;
  color: var(--muted);
  font-size: 8.5px;
  line-height: 1.55;
}

.setup-privacy .sn-icon {
  margin-top: 1px;
  color: var(--mint);
}

.setup-footer {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 22px;
  margin-top: auto;
}

.setup-footer__note {
  color: var(--muted-2);
  font-size: 8.5px;
}

.setup-footer .btn {
  min-height: 45px;
  border-radius: 12px;
  padding: 0 19px;
}

.setup-done {
  padding-top: 4px;
}

.setup-done__mark {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin-bottom: 20px;
  border-radius: 22px;
  background: var(--lime);
  color: #192234;
  box-shadow: 0 18px 32px -24px rgba(157, 184, 42, 0.85);
  transform: rotate(-4deg);
}

.setup-done h2 {
  margin-top: 8px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.045em;
}

.setup-done > p {
  max-width: 430px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.75;
}

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

.setup-summary > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 249, 0.7);
}

.setup-summary span {
  color: var(--muted-2);
  font-size: 8px;
  font-weight: 600;
}

.setup-summary strong {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.setup-summary small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.setup-ready-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.setup-ready-list span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #edf7e9;
  color: #3f6f35;
  font-size: 8.5px;
  font-weight: 600;
}

/* ----------------------------- Shell responsive ----------------------------- */

@media (max-width: 1200px) {
  :root {
    --sidebar-w: 232px;
  }

  .topbar {
    padding: 0 26px;
  }

  .page-content {
    padding-left: 26px;
    padding-right: 26px;
  }

  .save-pill {
    display: none;
  }

  .onboarding__story {
    padding: 34px 32px 26px;
  }

  .onboarding__form-wrap {
    padding: 28px 34px;
  }

  .onboarding__story-copy {
    margin-top: 50px;
  }
}

@media (max-width: 1023px) {
  :root {
    --sidebar-w: var(--rail-w);
    --sidebar-gap: 12px;
    --topbar-h: 64px;
  }

  .sidebar {
    padding: 19px 9px 10px;
    border-radius: 24px;
    align-items: center;
  }

  .sidebar__top {
    width: 100%;
    justify-content: center;
    padding: 2px 0 24px;
  }

  .sidebar .brand__text,
  .sidebar__version,
  .nav-group__label,
  .nav-item__label,
  .nav-item__badge,
  .nav-item__count,
  .sidebar-focus,
  .sidebar-user__meta,
  .sidebar-user__chevron {
    display: none;
  }

  .sidebar__nav {
    width: 100%;
    padding: 0;
  }

  .nav-group {
    padding-bottom: 10px;
  }

  .nav-item {
    justify-content: center;
    width: 50px;
    height: 46px;
    min-height: 46px;
    margin: 0 auto 5px;
    padding: 0;
    border-radius: 14px;
  }

  .nav-item.is-active::before {
    left: -9px;
  }

  .nav-item__icon {
    width: 23px;
    height: 23px;
  }

  .sidebar__bottom {
    width: 100%;
  }

  .sidebar-user {
    justify-content: center;
    padding: 9px 0;
  }

  .sidebar .avatar {
    --avatar-size: 34px !important;
  }

  .app-main {
    margin-left: calc(var(--rail-w) + var(--sidebar-gap) * 2);
  }

  .topbar {
    padding: 0 22px;
  }

  .topbar__date {
    display: none;
  }

  .topbar__crumb span,
  .topbar__crumb i {
    display: none;
  }

  .model-pill {
    display: none;
  }

  .page-content {
    padding: 2px 22px 28px;
  }

  .onboarding__panel {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    min-height: min(790px, calc(100dvh - 32px));
    max-height: calc(100dvh - 32px);
  }

  .onboarding {
    padding: 16px;
  }

  .onboarding__story {
    padding: 28px 26px 24px;
  }

  .onboarding__story-copy {
    margin-top: 38px;
  }

  .onboarding__story-copy h1 {
    font-size: 34px;
  }

  .mock-card--task {
    width: 210px;
  }

  .mock-card--focus {
    width: 148px;
  }

  .mock-card--wrong {
    left: 12px;
  }

  .onboarding__form-wrap {
    padding: 26px 27px;
  }

  .provider-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .provider-card {
    min-height: 50px;
  }

  .provider-card small {
    font-size: 8px;
  }

  .setup-title h2 {
    font-size: 27px;
  }

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

@media (max-width: 980px) {
  .onboarding {
    align-items: flex-start;
  }

  .onboarding__panel {
    display: block;
    width: min(650px, 100%);
    min-height: 0;
    max-height: none;
    margin: auto;
    border-radius: 28px;
  }

  .onboarding__story {
    display: none;
  }

  .onboarding__mobile-brand {
    display: block;
  }

  .onboarding__form-wrap {
    height: min(790px, calc(100dvh - 32px));
    min-height: 0;
    padding: 30px 38px;
    overflow: hidden;
  }

  .setup-form {
    padding-top: 34px;
  }

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

  .provider-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-height: 96px;
    padding: 11px;
  }

  .provider-card > i {
    position: absolute;
    top: 10px;
    right: 9px;
  }

  .provider-card small {
    white-space: normal;
    line-height: 1.45;
  }
}

@media (max-width: 767px) {
  :root {
    --topbar-h: 58px;
    --mobile-nav-h: 70px;
  }

  body {
    background:
      radial-gradient(700px 340px at 10% -4%, rgba(255, 250, 238, 0.95), transparent 60%),
      radial-gradient(600px 300px at 96% 4%, rgba(49, 87, 245, 0.045), transparent 60%),
      var(--bg);
  }

  .sidebar {
    display: none;
  }

  .app-main {
    margin-left: 0;
    padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom) + 18px);
  }

  .topbar {
    padding: 0 16px;
    gap: 10px;
    background: rgba(242, 239, 232, 0.88);
  }

  .topbar__crumb,
  .topbar__date,
  .streak-pill,
  .topbar__focus {
    display: none;
  }

  .topbar__mobile-brand {
    display: block;
  }

  .topbar__right {
    gap: 8px;
  }

  .config-pill {
    height: 30px;
    padding: 0 9px;
    font-size: 9px;
  }

  .topbar__avatar .avatar {
    --avatar-size: 32px !important;
  }

  .page-content {
    padding: 0 14px 24px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
    padding: 7px 0 17px;
    gap: 13px;
  }

  .page-head__main {
    width: 100%;
  }

  .page-head h1 {
    font-size: 27px;
    letter-spacing: -0.05em;
  }

  .page-head__sub {
    margin-top: 6px;
    font-size: 11.5px;
    line-height: 1.6;
  }

  .page-head__actions {
    width: 100%;
    gap: 7px;
    align-self: stretch;
    padding-bottom: 0;
  }

  .page-head__actions .btn {
    min-height: 38px;
    padding: 0 13px;
    font-size: 11px;
  }

  .page-head__actions .btn--primary {
    flex: 1;
  }

  .page-eyebrow {
    margin-bottom: 6px;
    font-size: 9px;
  }

  .card {
    border-radius: 19px;
  }

  .card__head {
    padding: 18px 18px 0;
  }

  .card__body {
    padding: 15px 18px 19px;
  }

  .card__footer {
    padding: 12px 18px;
  }

  .mobile-nav {
    position: fixed;
    z-index: 50;
    left: 12px;
    right: 12px;
    bottom: max(10px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    height: calc(var(--mobile-nav-h) + 4px);
    padding: 7px 4px 5px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 23px;
    background: rgba(255, 253, 249, 0.93);
    box-shadow: 0 18px 50px -20px rgba(21, 28, 42, 0.36), 0 2px 8px rgba(21, 28, 42, 0.04);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
  }

  .mobile-nav__item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    height: 100%;
    padding-bottom: 2px;
    color: #9298a3;
    font-size: 8.5px;
    font-weight: 600;
  }

  .mobile-nav__icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 27px;
    border-radius: 9px;
  }

  .mobile-nav__item.is-active {
    color: var(--ink);
  }

  .mobile-nav__item.is-active .mobile-nav__icon {
    color: var(--primary);
    background: var(--primary-soft);
  }

  .mobile-nav__item--ai {
    margin-top: -22px;
  }

  .mobile-nav__item--ai .mobile-nav__icon {
    width: 46px;
    height: 46px;
    border-radius: 15px;
    background: linear-gradient(150deg, #4266ff, #203ecf);
    color: #ffffff;
    box-shadow: 0 12px 22px -10px rgba(49, 87, 245, 0.75), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  }

  .mobile-nav__item--ai.is-active .mobile-nav__icon,
  .mobile-nav__item--ai .mobile-nav__icon {
    background: linear-gradient(150deg, #4266ff, #203ecf);
    color: #fff;
  }

  .mobile-nav__label {
    line-height: 1;
  }

  .mobile-nav__item--ai .mobile-nav__label {
    color: var(--ink-2);
    font-weight: 700;
  }

  .mobile-nav__badge {
    position: absolute;
    top: 0;
    right: 50%;
    display: grid;
    place-items: center;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 5px;
    background: var(--coral);
    color: #fff;
    font-size: 7.5px;
    font-weight: 800;
    transform: translateX(19px);
    border: 1.5px solid var(--surface);
  }

  .toast-stack {
    top: auto;
    right: 12px;
    bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom) + 22px);
    left: 12px;
    width: auto;
  }

  .toast {
    border-radius: 12px;
  }

  .sn-dialog {
    width: calc(100vw - 20px);
    max-height: 90dvh;
  }

  .sn-dialog__panel {
    max-height: 90dvh;
    border-radius: 22px;
  }

  .sn-dialog__head {
    padding: 19px 18px 13px;
  }

  .sn-dialog__head h2 {
    font-size: 19px;
  }

  .sn-dialog__body {
    padding: 4px 18px 19px;
  }

  .sn-dialog__foot {
    padding: 13px 18px 16px;
    flex-wrap: wrap;
  }

  .sn-dialog--drawer {
    width: 100vw;
    height: 100dvh;
    margin: 0;
  }

  .sn-dialog--drawer .sn-dialog__panel {
    border-radius: 0;
    border: 0;
  }

  .sn-dialog--drawer .sn-dialog__head {
    padding-top: calc(19px + env(safe-area-inset-top));
  }

  .sn-dialog--drawer .sn-dialog__foot {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

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

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

  .subject-choice span {
    gap: 3px;
    height: 32px;
    font-size: 9.5px;
  }

  .subject-choice span i {
    display: none;
  }

  .onboarding {
    display: block;
    padding: 0;
    overflow-y: auto;
    background: var(--bg-warm);
  }

  .onboarding__glow {
    display: none;
  }

  .onboarding__panel {
    width: 100%;
    min-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    background: var(--bg-warm);
    transform: none !important;
  }

  .onboarding__form-wrap {
    height: auto;
    min-height: 100dvh;
    padding: 21px 19px calc(104px + env(safe-area-inset-bottom));
    overflow: visible;
  }

  .setup-form {
    padding-top: 26px;
  }

  .setup-title {
    margin-bottom: 20px;
  }

  .setup-title h2 {
    font-size: 25px;
  }

  .setup-title p {
    font-size: 10.5px;
  }

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

  .provider-card {
    flex-direction: row;
    align-items: center;
    min-height: 53px;
    padding: 9px 11px;
  }

  .provider-card small {
    white-space: nowrap;
  }

  .provider-card > i {
    position: static;
    margin-left: auto;
  }

  /* Keep the primary action always reachable, including above the mobile keyboard. */
  .setup-footer {
    position: fixed;
    z-index: 2;
    right: 19px;
    bottom: var(--setup-keyboard-inset, 0px);
    left: 19px;
    padding: 18px 0 calc(14px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(248, 244, 236, 0), var(--bg-warm) 28%);
    transition: bottom 0.16s ease;
  }

  .setup-footer__note {
    display: none;
  }

  .setup-footer .btn--primary {
    margin-left: auto;
  }

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

  .setup-summary > div {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
    padding: 10px 12px;
  }

  .setup-summary strong {
    margin-top: 0;
  }

  .setup-summary small {
    margin-top: 0;
    margin-left: auto;
  }

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

  /* Keep form controls at 16px to prevent iOS Safari from zooming on focus. */
  .input,
  .composer__textarea,
  .search-box input,
  .toolbar-select,
  .composer__select {
    font-size: 16px;
  }

  .study-form .form-grid--three {
    grid-template-columns: 1fr 1fr;
  }

  .study-form .form-grid--three .field:last-child {
    grid-column: 1 / -1;
  }

  .dialog-foot-note {
    display: none;
  }

  .dialog-foot-spacer {
    display: none;
  }

  .sn-dialog__foot .btn {
    flex: 1;
    min-width: 0;
    padding: 0 12px;
  }

  .sn-dialog__foot .btn--danger-ghost {
    flex: 0 0 auto;
  }
}

@media (max-width: 400px) {
  .page-head h1 {
    font-size: 24px;
  }

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

  .subject-choice span {
    font-size: 9px;
  }

  .mobile-nav__label {
    font-size: 8px;
  }
}

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