:root {
  color-scheme: light;
  --bg: #f8f6f2;
  --panel: #ffffff;
  --panel-soft: #f4f1ed;
  --text: #202321;
  --muted: #727773;
  --line: #e7e1db;
  --accent: #a63830;
  --accent-dark: #7d2723;
  --choice: #fbfaf8;
  --choice-line: #e5dfd9;
  --guide: #fbefec;
  --guide-line: #ecd5d0;
  --shadow: 0 12px 30px rgba(74, 43, 38, 0.08);
}

/* Account and settings: a calm, full-page mobile surface with restrained cinnabar accents. */
.mobile-settings-head {
  display: grid !important;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
}

.mobile-settings-head h2 {
  text-align: center;
  font-size: 17px;
  line-height: 1.2;
}

.mobile-settings-back {
  width: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 0 1px 3px 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 30px;
  font-weight: 350;
  line-height: 1;
}

.mobile-settings-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.mobile-settings-group {
  margin-top: 22px;
}

.mobile-settings-group h3 {
  margin: 0 0 8px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.mobile-account-card em {
  justify-self: end;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f7eae7;
  color: var(--accent-dark);
  font-size: 10px;
  font-style: normal;
  font-weight: 750;
}

.mobile-profile-danger {
  width: 100%;
  min-height: 52px;
  margin-top: 22px;
  border: 1px solid #ead8d4;
  border-radius: 14px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 750;
}

.mobile-settings-footnote {
  display: block;
  width: 100%;
  margin: 24px 0 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #9a9c99;
  text-align: center;
  font-size: 10px;
  font-family: inherit;
  line-height: 1.65;
  cursor: default;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mobile-profile-uid {
  width: min(100%, 320px);
  margin: 10px auto 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line));
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.mobile-profile-uid[hidden] {
  display: none;
}

.mobile-profile-uid code {
  display: block;
  margin: 4px 0 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  user-select: text;
}

.mobile-profile-uid button,
.feedback-reference-copy {
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 750;
}

.mobile-auth-head {
  display: grid !important;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
}

.mobile-auth-head > div {
  text-align: center;
}

@media (max-width: 760px) {
  :root {
    --bg: #f8f6f2;
    --panel: #ffffff;
    --panel-soft: #f4f1ed;
    --text: #202321;
    --muted: #727773;
    --line: #e7e1db;
    --accent: #a63830;
    --accent-dark: #7d2723;
    --choice: #fbfaf8;
    --choice-line: #e5dfd9;
    --guide: #fbefec;
    --guide-line: #ecd5d0;
  }

  body,
  .app {
    background: var(--bg);
  }

  .composer #sendButton,
  .mobile-logout-actions button:last-child {
    border-color: var(--accent);
    background: var(--accent);
  }

  .mobile-profile-dialog,
  .mobile-auth-dialog {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: #f7f7f5;
    box-shadow: none;
  }

  .mobile-profile-dialog::backdrop,
  .mobile-auth-dialog::backdrop {
    background: transparent;
    backdrop-filter: none;
  }

  .mobile-profile-dialog > .mobile-settings-page,
  .mobile-auth-dialog > section {
    width: 100%;
    height: 100dvh;
    max-height: none;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0;
    overflow: hidden;
    background: #f7f7f5;
  }

  .mobile-settings-head,
  .mobile-auth-head {
    min-height: calc(54px + env(safe-area-inset-top));
    margin: 0 !important;
    padding: max(8px, env(safe-area-inset-top)) 12px 7px;
    border-bottom: 1px solid #e9e9e6;
    background: rgba(247, 247, 245, 0.94);
    backdrop-filter: blur(14px);
  }

  .mobile-settings-head h2,
  .mobile-auth-head h2 {
    margin: 0;
    color: #20211f;
    font-size: 16px;
    font-weight: 650;
    letter-spacing: 0;
  }

  .mobile-settings-back {
    width: 36px;
    height: 36px;
    position: relative;
    border: 0;
    background: transparent;
    color: transparent;
    font-size: 0;
  }

  .mobile-settings-back::before {
    width: 9px;
    height: 9px;
    position: absolute;
    top: 13px;
    left: 14px;
    transform: rotate(45deg);
    border-bottom: 1.8px solid #292b28;
    border-left: 1.8px solid #292b28;
    content: "";
  }

  .mobile-settings-scroll {
    padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
  }

  .mobile-account-card {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 12px;
    margin: 0;
    padding: 16px;
    border-color: var(--line);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(64, 43, 38, 0.05);
  }

  .mobile-account-card > span {
    width: 52px;
    height: 52px;
    border-radius: 17px;
    background: var(--accent);
    font-size: 21px;
  }

  .mobile-account-card > div {
    gap: 3px;
  }

  .mobile-account-card > div strong {
    font-size: 15px;
  }

  .mobile-profile-actions {
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
  }

  .mobile-profile-actions > button {
    min-height: 58px;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 11px;
    padding: 9px 14px;
    border: 0;
    border-radius: 0;
    background: #fff;
  }

  .mobile-profile-actions > button + button {
    border-top: 1px solid var(--line);
  }

  .mobile-profile-actions > button > i {
    width: 32px;
    height: 32px;
    position: relative;
    border-radius: 10px;
    background: #f8ece9;
    color: var(--accent-dark);
  }

  .mobile-profile-actions > button > i::before {
    color: currentColor;
  }

  .mobile-action-notes::before {
    width: 13px;
    height: 16px;
    display: block;
    border: 1.5px solid currentColor;
    border-radius: 3px;
    content: "";
  }

  .mobile-action-notes::after {
    position: absolute;
    top: 11px;
    left: 10px;
    width: 9px;
    height: 1.5px;
    background: currentColor;
    box-shadow: 0 4px 0 currentColor, 0 8px 0 currentColor;
    content: "";
  }

  .mobile-action-switch::before {
    content: "⇄";
    font-size: 17px;
    font-weight: 750;
  }

  .mobile-profile-actions > button strong {
    font-size: 13px;
  }

  .mobile-profile-actions > button small {
    font-size: 10.5px;
  }

  .mobile-profile-actions > button b {
    color: #a3a5a2;
    font-size: 19px;
  }

  .mobile-auth-dialog > section {
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0;
  }

  .mobile-auth-dialog > section > :not(header) {
    width: calc(100% - 36px);
    max-width: 420px;
    justify-self: center;
  }

  .mobile-auth-brand {
    margin-top: 28px;
    background: var(--accent);
  }

  .mobile-auth-form input[type="tel"],
  .mobile-auth-form input[type="text"] {
    background: #fff;
  }

  .mobile-auth-primary {
    border-color: var(--accent);
    background: var(--accent);
  }

  .mobile-auth-status {
    background: #fbefec;
    color: var(--accent-dark);
  }

  .session-card.current {
    background: #f9ece9;
  }
}

/* Keep the history navigation as a ChatGPT-style left sidebar on phones. */
@media (max-width: 760px) {
  .session-overlay {
    bottom: 0 !important;
  }

  .session-drawer {
    top: 0;
    right: auto;
    bottom: 0;
    left: 0;
    width: min(88vw, 350px);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    border-width: 0 1px 0 0;
    border-radius: 0;
    box-shadow: 16px 0 40px rgba(25, 35, 31, 0.18);
    transform: translateX(calc(-100% - 12px));
  }

  .session-drawer.open {
    transform: translateX(0);
  }

  .session-drawer-head {
    padding-top: max(16px, env(safe-area-inset-top));
  }
}

/* Review is a first-class destination: sidebar entry -> full page -> one collection. */
.review-page {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: #fbfaf7;
  color: var(--text);
  opacity: 0;
  transform: translateX(18px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.review-page[hidden] {
  display: none;
}

.review-page.open {
  opacity: 1;
  transform: translateX(0);
}

.review-page-head {
  min-height: 68px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  border-bottom: 1px solid #e7e3de;
  background: rgba(255, 255, 255, 0.96);
}

.review-page-head > div {
  min-width: 0;
  text-align: center;
}

.review-page-head p,
.review-page-head h2 {
  margin: 0;
}

.review-page-head p {
  color: var(--muted);
  font-size: 10px;
}

.review-page-head h2 {
  margin-top: 1px;
  font-size: 17px;
  font-weight: 650;
}

.review-page-back {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 31px;
  font-weight: 300;
  line-height: 1;
}

.review-hub {
  min-height: 0;
  overflow-y: auto;
  padding: 24px max(18px, calc((100vw - 680px) / 2)) 36px;
}

.review-next-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 20px;
  border: 1px solid #e6d5cd;
  border-radius: 20px;
  background: linear-gradient(140deg, #fff 0%, #faf0ec 100%);
}

.review-next-card span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.review-next-card h3 {
  margin: 5px 0 0;
  font-size: 20px;
  line-height: 1.35;
}

.review-next-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.review-next-card > button {
  min-width: 82px;
  min-height: 42px;
  padding: 8px 15px;
  border-color: var(--accent);
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.review-next-card > button:disabled {
  border-color: #dad6d1;
  background: #e9e6e2;
  color: #96928d;
}

.review-library {
  margin-top: 28px;
}

.review-library > h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 650;
}

.review-library > button {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  margin-top: 9px;
  padding: 12px 14px;
  border: 1px solid #e5e2dd;
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.review-entry-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #f5ebe7;
  color: #9a493d;
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
}

.review-entry-icon.learning {
  background: #eef1ed;
  color: #506158;
}

.review-entry-icon.vocabulary {
  background: #f3eee2;
  color: #806735;
}

.review-library > button > span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.review-library > button strong {
  font-size: 15px;
  font-weight: 650;
}

.review-library > button small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
}

.review-library > button b {
  min-width: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f3f1ee;
  color: #666b67;
  font-size: 11px;
  font-weight: 650;
  text-align: center;
}

.review-library > button em {
  color: #a7aaa7;
  font-size: 22px;
  font-style: normal;
  font-weight: 300;
}

.review-collection {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.review-collection[hidden] {
  display: none;
}

.review-collection .notes-list {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.review-collection .vocabulary-tools {
  width: min(760px, 100%);
  margin: 0 auto;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.session-review-entry {
  display: grid !important;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 1px 10px;
  margin-top: 4px;
  border-radius: 11px;
}

.session-review-entry > span {
  width: 32px;
  height: 32px;
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #f4e8e3;
  color: var(--accent);
  font-size: 18px;
}

.session-review-entry strong,
.session-review-entry small {
  grid-column: 2;
}

.session-review-entry strong {
  align-self: end;
  font-size: 14px;
}

.session-review-entry small {
  align-self: start;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.session-review-entry b {
  grid-column: 3;
  grid-row: 1 / 3;
  color: var(--muted);
  font-size: 20px;
  font-weight: 400;
}

body.review-page-open {
  overflow: hidden;
}

@media (max-width: 760px) {
  .session-overlay {
    bottom: 0 !important;
  }

  .session-drawer {
    top: 0;
    right: auto;
    bottom: 0;
    left: 0;
    width: min(88vw, 350px);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    border-width: 0 1px 0 0;
    border-radius: 0;
    box-shadow: 16px 0 40px rgba(25, 35, 31, 0.18);
    transform: translateX(calc(-100% - 12px));
  }

  .session-drawer.open {
    transform: translateX(0);
  }

  .session-drawer-head {
    padding-top: max(16px, env(safe-area-inset-top));
  }

  .review-page-head {
    min-height: 64px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .review-hub {
    padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
  }

  .review-next-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 18px;
    border-radius: 18px;
  }

  .review-next-card h3 {
    font-size: 18px;
  }

  .review-next-card > button {
    width: 100%;
  }

  .review-library {
    margin-top: 24px;
  }

  .review-library > button {
    min-height: 72px;
    grid-template-columns: 40px minmax(0, 1fr) auto auto;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 15px;
  }

  .review-entry-icon {
    width: 40px;
    height: 40px;
  }

  .review-collection .notes-list {
    padding: 14px;
  }

  .review-collection .vocabulary-tools {
    border-right: 0;
    border-left: 0;
  }
}

/* Keep each coaching turn compact enough to scan alongside the question on phones. */
@media (max-width: 760px) {
  .guide-card {
    width: calc(100% - 8px);
    align-self: center;
    padding: 10px 11px;
    border-radius: 10px;
    box-shadow: 0 3px 12px rgba(66, 42, 34, 0.045);
  }

  .guide-meta {
    display: none;
  }

  .guide-title {
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.45;
  }

  .guide-options {
    gap: 6px;
  }

  .guide-option {
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.35;
  }
}

/* Desktop follows the same account-in-sidebar placement as the mobile drawer. */
@media (min-width: 761px) {
  .session-drawer {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  .session-account-footer {
    display: block;
    padding: 10px;
    border-top: 1px solid var(--line);
    background: var(--panel);
  }

  .session-account-footer button {
    width: 100%;
    min-height: 56px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 2px 9px;
    padding: 8px;
    border: 0;
    background: transparent;
    text-align: left;
  }

  .session-account-footer button > span {
    width: 38px;
    height: 38px;
    grid-row: 1 / 3;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--accent-dark);
    color: #fff;
    font-weight: 800;
  }

  .session-account-footer button strong {
    grid-column: 2;
    align-self: end;
    font-size: 13px;
  }

  .session-account-footer button small {
    grid-column: 2;
    align-self: start;
    color: var(--muted);
    font-size: 10px;
  }

  .session-account-footer button b {
    grid-column: 3;
    grid-row: 1 / 3;
    color: var(--muted);
    font-size: 20px;
    font-weight: 400;
  }
}

.question-round-archive {
  align-self: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #faf8f5;
}

.mobile-question-archives {
  display: none;
}

.question-round-archive > summary {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
}

.question-round-archive > summary::-webkit-details-marker {
  display: none;
}

.question-round-archive > summary > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.question-round-archive > summary small {
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.question-round-archive > summary strong {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
}

.question-round-archive > summary b {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.question-round-archive[open] > summary {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.question-round-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

@media (max-width: 760px) {
  .study-workspace.has-question > .question-stage > .mobile-question-archives:not(:empty) {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0 10px;
  }

  .study-workspace.has-question > .question-stage > .mobile-question-archives .question-round-archive {
    flex: 0 0 auto;
  }

  .question-round-archive {
    border-radius: 13px;
    background: #faf8f5;
  }

  .question-round-archive > summary {
    min-height: 46px;
    padding: 7px 11px;
  }

  .question-round-content {
    gap: 9px;
    padding: 11px;
  }
}

.mobile-composer-more {
  display: none;
}

.session-account-footer {
  display: block;
}

.session-account-footer button + button {
  margin-top: 4px;
  border-top: 1px solid var(--line);
}

/* Single-stream mobile conversation, following a chat-first interaction model. */
@media (max-width: 760px) {
  .app {
    grid-template-rows: 64px minmax(0, 1fr);
  }

  .topbar {
    position: relative;
    min-height: 64px;
    justify-content: center;
    padding: max(8px, env(safe-area-inset-top)) 58px 8px;
  }

  .topbar-brand,
  .brand-copy {
    width: auto;
    min-width: 0;
  }

  .brand-copy h1 {
    justify-content: center;
    white-space: nowrap;
  }

  .brand-copy h1 small {
    display: none;
  }

  .session-entry {
    position: absolute;
    top: 14px;
    left: 12px;
    width: 36px;
    min-height: 36px;
    display: block;
    padding: 0;
    border: 0;
    border-radius: 11px;
    background:
      linear-gradient(var(--accent-dark), var(--accent-dark)) 10px 11px / 16px 2px no-repeat,
      linear-gradient(var(--accent-dark), var(--accent-dark)) 10px 17px / 16px 2px no-repeat,
      linear-gradient(var(--accent-dark), var(--accent-dark)) 10px 23px / 12px 2px no-repeat,
      var(--panel-soft);
  }

  .session-entry span,
  .session-entry strong {
    display: none;
  }

  .topbar-brand-actions {
    position: absolute;
    top: 14px;
    right: 10px;
    gap: 5px;
  }

  .usage-entry {
    min-height: 36px;
    padding: 0 9px;
    font-size: 10px;
  }

  .new-session-entry {
    width: 36px;
    min-height: 36px;
  }

  .study-workspace,
  .study-workspace:not(.has-question),
  .study-workspace:not(.has-question):has(.chat:empty),
  .study-workspace.mobile-question-collapsed,
  .study-workspace.mobile-question-focus {
    height: 100%;
    display: block;
    overflow: hidden;
    background: var(--panel);
  }

  .question-stage,
  .mobile-question-peek,
  .mobile-study-splitter,
  .mobile-primary-nav {
    display: none !important;
  }

  .dialogue-panel,
  .study-workspace:not(.has-question) .dialogue-panel,
  .study-workspace.mobile-question-collapsed .dialogue-panel,
  .study-workspace.mobile-question-focus .dialogue-panel {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    overflow: hidden;
    background: var(--panel);
  }

  .dialogue-panel .chat,
  .study-workspace.mobile-question-focus .chat {
    grid-row: 1;
    display: flex;
    min-height: 0;
    gap: 14px;
    padding: 16px 14px 12px;
    background: var(--panel);
  }

  .chat:has(.mobile-chat-welcome:only-child) {
    justify-content: center;
  }

  .mobile-chat-welcome {
    width: min(100%, 560px);
    height: auto;
    min-height: 0;
    flex: 0 0 auto;
    align-self: center;
    gap: 18px;
    padding: 8px 4px;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .mobile-chat-welcome .study-start-copy > span {
    margin-bottom: 8px;
  }

  .mobile-chat-welcome .study-start-copy h2 {
    font-size: clamp(27px, 8vw, 34px);
  }

  .mobile-chat-welcome .study-start-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .mobile-chat-welcome .study-start-actions button {
    width: 100%;
    min-height: 42px;
    white-space: normal;
  }

  .bubble {
    max-width: 88%;
    border: 0;
    box-shadow: none;
  }

  .bubble.assistant {
    padding-left: 2px;
    background: transparent;
  }

  .bubble.user {
    border: 1px solid #ead6b9;
    border-radius: 18px 18px 5px 18px;
    background: #f6ead8;
  }

  .chat-question-card {
    width: min(100%, 620px);
    min-height: 0;
    align-self: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(25, 42, 34, 0.06);
  }

  .chat-question-card.is-collapsed .material,
  .chat-question-card.is-collapsed .stem,
  .chat-question-card.is-collapsed .choice-grid {
    display: none;
  }

  .mobile-question-focus-button {
    display: none !important;
  }

  .mobile-question-collapse-button {
    display: inline-flex;
  }

  .guide-quick-starts,
  .study-workspace.mobile-question-focus .guide-quick-starts {
    grid-row: 2;
    display: grid;
  }

  .guide-quick-starts[hidden] {
    display: none;
  }

  .composer,
  .composer:nth-child(n),
  .study-workspace.mobile-question-focus .composer {
    grid-row: 3;
    align-self: end;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid #ecece7;
    background: var(--panel);
  }

  .composer textarea {
    min-height: 48px;
    max-height: 112px;
    padding: 12px 14px;
    border-color: #d9ddd9;
    border-radius: 22px;
    background: #f7f7f4;
  }

  .composer > button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    align-self: end;
    border-radius: 50%;
  }

  .tool-debug-card,
  .trace-line {
    display: none !important;
  }

  .notes-overlay,
  .session-overlay {
    bottom: 0;
  }

  .session-drawer {
    top: 0;
    right: auto;
    bottom: 0;
    left: 0;
    width: min(340px, 88vw);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    border-width: 0 1px 0 0;
    border-radius: 0 18px 18px 0;
    transform: translateX(calc(-100% - 20px));
  }

  .session-drawer.open {
    transform: translateX(0);
  }

  .session-account-footer {
    display: block;
    padding: 10px;
    border-top: 1px solid var(--line);
    background: var(--panel);
  }

  .session-account-footer button {
    width: 100%;
    min-height: 56px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 2px 9px;
    padding: 8px;
    border: 0;
    background: transparent;
    text-align: left;
  }

  .session-account-footer button > span {
    width: 38px;
    height: 38px;
    grid-row: 1 / 3;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--accent-dark);
    color: #fff;
    font-weight: 800;
  }

  .session-account-footer button strong {
    grid-column: 2;
    align-self: end;
    font-size: 13px;
  }

  .session-account-footer button small {
    grid-column: 2;
    align-self: start;
    color: var(--muted);
    font-size: 10px;
  }

  .session-account-footer button b {
    grid-column: 3;
    grid-row: 1 / 3;
    color: var(--muted);
    font-size: 20px;
    font-weight: 400;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
textarea {
  font: inherit;
}

button,
select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

button {
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.app {
  width: min(1480px, 100%);
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 16px;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-brand {
  width: 100%;
  min-width: 310px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-copy {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 5px 8px;
}

.brand-copy h1 {
  grid-column: 1 / -1;
}

.session-entry {
  min-height: 28px;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 7px;
  border-color: transparent;
  background: var(--panel-soft);
  color: var(--accent-dark);
  font-size: 12px;
  text-align: left;
}

.session-entry span {
  color: var(--muted);
  font-size: 10px;
}

.session-entry strong {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-filter-chips {
  min-width: 0;
  display: flex;
  gap: 4px;
  overflow: hidden;
}

.session-filter-chip {
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid #c9ded6;
  border-radius: 999px;
  background: #f4faf7;
  color: var(--accent-dark);
  font-size: 10px;
  white-space: nowrap;
}

.session-filter-chip.source {
  border-color: #e2cda9;
  background: #fff9ef;
  color: #765329;
}

.topbar-brand-actions {
  display: flex;
  gap: 6px;
}

.notes-entry,
.usage-entry,
.new-session-entry {
  min-height: 36px;
  padding: 0 12px;
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.usage-entry {
  background: #f4faf7;
}

.usage-dialog {
  width: min(680px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(19, 48, 40, 0.2);
}

.usage-dialog::backdrop {
  background: rgba(21, 38, 34, 0.3);
  backdrop-filter: blur(3px);
}

.usage-window {
  display: grid;
  gap: 18px;
  padding: 24px;
  overflow: auto;
}

.usage-head,
.usage-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.usage-head p,
.usage-head h2,
.usage-card p,
.usage-mode,
.usage-empty,
.usage-upgrade p {
  margin: 0;
}

.usage-head p,
.usage-mode,
.usage-card small,
.usage-empty,
.usage-upgrade p {
  color: var(--muted);
}

.usage-head h2 {
  margin-top: 4px;
}

.usage-mode {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-soft);
  font-size: 13px;
}

.usage-windows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.usage-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.usage-card-head span,
.usage-card small {
  font-size: 11px;
}

.usage-card p {
  margin-top: 8px;
  font-size: 13px;
}

.usage-progress {
  height: 6px;
  margin: 10px 0 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8f0ed;
}

.usage-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.usage-upgrade {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid #cfe0da;
  border-radius: 12px;
  background: #f3f8f6;
}

.usage-upgrade p {
  margin-top: 4px;
  font-size: 12px;
}

.usage-upgrade button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent-dark);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.billing-admin {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.billing-admin > summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 750;
}

.billing-plan-form,
.billing-simulator,
.billing-simulator form {
  display: grid;
  gap: 10px;
}

.billing-plan-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}

.billing-plan-form label,
.billing-simulator label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.billing-plan-form input,
.billing-plan-form select,
.billing-simulator input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: #fff;
  color: var(--text);
}

.billing-plan-form .billing-inline-option {
  align-items: center;
  align-self: end;
  display: flex;
  min-height: 38px;
}

.billing-plan-form .billing-inline-option input {
  flex: 0 0 auto;
  min-height: auto;
  width: auto;
}

.billing-plan-form button,
.billing-simulator button {
  min-height: 38px;
  align-self: end;
  background: var(--accent-dark);
  color: #fff;
}

.billing-test-help {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.billing-test-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-self: end;
}

.billing-test-actions .secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent-dark);
}

.billing-simulator {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.billing-simulator h3,
.billing-simulator p {
  margin: 0;
}

.billing-simulator form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.billing-simulation-result {
  padding: 11px 12px;
  border-radius: 9px;
  background: #f4faf7;
  font-size: 13px;
  line-height: 1.6;
}

.billing-benchmark,
#billingRateText {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.billing-quota-preview {
  justify-self: start;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent-dark);
}

.quota-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 28px 80px rgba(19, 48, 40, 0.24);
}

.quota-dialog::backdrop {
  background: rgba(21, 38, 34, 0.4);
  backdrop-filter: blur(4px);
}

.quota-window {
  display: grid;
  gap: 16px;
  padding: 24px;
  overflow: auto;
}

.quota-head,
.quota-plan-card > div,
.quota-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quota-head p,
.quota-head h2,
.quota-message,
.quota-reset,
.quota-plan-card p,
.quota-checkout-status,
.quota-plans-empty {
  margin: 0;
}

.quota-head p {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.quota-head h2 {
  margin-top: 4px;
}

.quota-message {
  line-height: 1.65;
}

.quota-reset {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff8ec;
  color: #7a5727;
  font-size: 13px;
}

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

.quota-plan-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.quota-plan-card > div {
  align-items: baseline;
}

.quota-plan-card > div span {
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.quota-plan-card > div b {
  color: var(--accent-dark);
  font-size: 20px;
}

.quota-plan-card p,
.quota-plans-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.quota-plan-card button {
  min-height: 40px;
  background: var(--accent-dark);
  color: #fff;
}

.quota-plans-empty {
  grid-column: 1 / -1;
  padding: 16px;
  border-radius: 12px;
  background: var(--panel-soft);
  text-align: center;
}

.quota-checkout-status:not(:empty) {
  padding: 11px 12px;
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.quota-actions {
  justify-content: flex-end;
}

.quota-actions button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.quota-actions .secondary {
  color: var(--muted);
}

.new-session-entry {
  background: var(--accent-dark);
  color: #fff;
}

.runtime-controls {
  display: none;
}

.filter-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.filter-field > span {
  padding-left: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.filter-field select {
  width: 100%;
}

.toolbar button,
.composer button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.study-workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(520px, 1.35fr) minmax(360px, 0.8fr);
  gap: 12px;
}

.question-stage {
  display: block;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 2px 4px 12px 2px;
}

.question-stage.is-empty {
  overflow: hidden;
  padding: 0;
}

.study-start-card {
  height: 100%;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: clamp(28px, 5vw, 64px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 82% 18%, rgba(28, 111, 90, 0.1), transparent 28%),
    linear-gradient(145deg, #ffffff 0%, #f3f8f6 100%);
  box-shadow: var(--shadow);
}

.study-start-copy {
  max-width: 640px;
}

.study-start-copy > span {
  display: block;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.study-start-copy h2 {
  margin: 0;
  font-size: clamp(26px, 3vw, 38px);
  letter-spacing: -0.03em;
}

.study-start-copy p,
.study-start-hint {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.study-start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.study-start-actions.secondary {
  margin-top: -12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.study-start-actions button {
  min-height: 40px;
  padding: 8px 13px;
  border-color: #bad3ca;
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-dark);
  font-weight: 700;
}

.study-start-actions button:hover {
  border-color: var(--accent);
  background: #f0f7f4;
}

.study-start-hint {
  margin: 0;
  font-size: 12px;
}

.dialogue-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dialogue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.dialogue-head h2 {
  margin: 0;
  font-size: 15px;
}

.dialogue-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.tool-debug-toggle {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 4px 9px;
  border-color: color-mix(in srgb, var(--muted) 30%, var(--line));
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.tool-debug-toggle.active {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: #e5f1ed;
  color: var(--accent-dark);
}

.chat {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  scroll-padding-bottom: 12px;
}

.bubble,
.question-card,
.guide-card,
.learning-actions-card,
.diagnosis-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  animation: rise-in 180ms ease-out both;
}

.bubble {
  width: fit-content;
  max-width: min(760px, 92%);
  padding: 11px 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: var(--choice);
  border-color: var(--choice-line);
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--panel);
}

.message-feedback {
  display: flex;
  justify-content: flex-end;
  margin-top: 7px;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  padding-top: 5px;
  white-space: normal;
}

.message-feedback-button {
  min-height: 26px;
  padding: 2px 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.message-feedback-button:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--accent-dark);
}

.message-feedback-button.submitted {
  color: var(--accent-dark);
}

.bubble.thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  min-width: 104px;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.thinking-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.35;
  animation: thinking-dot 900ms ease-in-out infinite;
}

.thinking-dots i:nth-child(2) {
  animation-delay: 120ms;
}

.thinking-dots i:nth-child(3) {
  animation-delay: 240ms;
}

.status-line {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  animation: soft-pop 160ms ease-out both;
}

.question-timeline-item {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
}

.question-timeline-item::before,
.question-timeline-item::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.question-timeline-item span {
  flex: 0 0 auto;
  font-weight: 700;
}

.question-timeline-item button {
  min-height: 28px;
  flex: 0 0 auto;
  padding: 3px 8px;
  border-color: #c8d8d2;
  background: #fff;
  color: var(--accent-dark);
  font-size: 10px;
}

.question-timeline-item.current button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.question-card.history-preview {
  border-color: #c8d8d2;
  box-shadow: inset 4px 0 0 #91aa9f, var(--shadow);
}

.question-card.history-preview .choice-card:disabled {
  cursor: default;
  opacity: 0.82;
}

.trace-line {
  align-self: flex-start;
  min-height: 0;
  padding: 4px 8px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  line-height: 1.35;
  text-align: left;
  opacity: 0.8;
}

.trace-line:hover {
  color: var(--accent-dark);
  border-color: var(--line);
  background: var(--panel-soft);
}

.tool-debug-card {
  align-self: stretch;
  border: 1px dashed #cbd7d2;
  border-radius: 8px;
  background: #f8faf9;
  color: #52615b;
  font-size: 11px;
  animation: soft-pop 160ms ease-out both;
}

.tool-debug-card[hidden] {
  display: none;
}

.tool-debug-card > summary {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 9px;
  cursor: pointer;
  list-style: none;
}

.tool-debug-card > summary::-webkit-details-marker {
  display: none;
}

.tool-debug-card[open] > summary {
  border-bottom: 1px solid #dde5e1;
}

.tool-debug-icon {
  color: #87958f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tool-debug-name {
  color: #33433d;
  font-weight: 800;
}

.tool-debug-brief {
  min-width: 0;
  overflow: hidden;
  color: #6d7974;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-debug-status {
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 800;
}

.tool-debug-status.pending {
  background: #fff4d9;
  color: #8a6113;
}

.tool-debug-status.ok {
  background: #e4f2ed;
  color: #17634f;
}

.tool-debug-status.error {
  background: #fbe9e7;
  color: #a33d34;
}

.tool-debug-body {
  display: grid;
  gap: 7px;
  padding: 8px 10px 10px;
}

.tool-debug-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #7a8882;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
}

.tool-debug-meta code {
  color: var(--accent-dark);
}

.tool-debug-error {
  margin: 0;
  padding: 7px 8px;
  border-radius: 6px;
  background: #fbe9e7;
  color: #8e332b;
}

.tool-debug-raw {
  border: 1px solid #dde5e1;
  border-radius: 6px;
  background: #fff;
}

.tool-debug-raw > summary {
  padding: 6px 8px;
  cursor: pointer;
  color: #52615b;
  font-weight: 700;
}

.tool-debug-raw pre {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  border-top: 1px solid #e5ebe8;
  padding: 8px;
  color: #34423d;
  background: #fbfcfc;
  font-size: 10px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.question-card {
  width: 100%;
  background: var(--panel);
  padding: 16px;
}

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.question-head h2 {
  margin: 4px 0 0;
  font-size: 20px;
  letter-spacing: 0;
}

.question-head .answer-status {
  flex: 0 0 auto;
  color: var(--accent-dark);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.question-head-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.question-skip {
  min-height: 30px;
  padding: 4px 9px;
  border-color: var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

.question-skip:hover {
  color: var(--accent-dark);
  background: var(--panel-soft);
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.material,
.stem {
  margin-top: 14px;
  line-height: 1.72;
  font-size: 16px;
}

.material {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  overflow: auto;
}

.material p,
.stem p,
.choice-body p {
  margin: 0 0 10px;
}

.material img,
.stem img,
.choice-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 10px 0;
  border-radius: 4px;
}

.material img[flag="tex"],
.stem img[flag="tex"],
.choice-body img[flag="tex"] {
  display: inline-block;
  max-width: none;
  margin: 0 3px;
  vertical-align: -3px;
  border-radius: 0;
}

.choice-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.choice-card {
  min-height: 50px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 11px;
  text-align: left;
  background: #fff;
  animation: option-in 180ms ease-out both;
}

.choice-card:hover {
  background: #fbfdfc;
}

.choice-label {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.choice-body {
  min-width: 0;
  line-height: 1.6;
}

.guide-card {
  align-self: flex-start;
  width: min(720px, 100%);
  background: var(--guide);
  border-color: var(--guide-line);
  padding: 13px;
}

.guide-title {
  font-weight: 800;
  margin-bottom: 10px;
  line-height: 1.55;
}

.guide-meta {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.guide-options {
  display: grid;
  gap: 8px;
}

.guide-option {
  text-align: left;
  min-height: 44px;
  background: #fff;
  border-color: var(--guide-line);
  padding: 10px 12px;
  animation: option-in 180ms ease-out both;
}

.learning-actions-card {
  align-self: stretch;
  background: #f6faf8;
  border-color: #c9ded6;
  padding: 12px;
}

.learning-actions-meta {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.learning-actions-title {
  margin-top: 5px;
  line-height: 1.55;
  font-size: 13px;
}

.learning-actions-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.learning-action-option {
  min-height: 36px;
  padding: 7px 10px;
  border-color: #b8d3c9;
  background: #fff;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  animation: option-in 180ms ease-out both;
}

.learning-action-option:hover {
  background: var(--panel-soft);
}

.vocab-selector {
  width: 100%;
  padding: 11px;
  border: 1px solid #b8d3c9;
  border-radius: 12px;
  background: #fff;
  animation: option-in 180ms ease-out both;
}

.vocab-selector-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--accent-dark);
  font-size: 12px;
}

.vocab-selector-heading span {
  color: var(--muted);
  font-size: 11px;
}

.vocab-word-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 9px;
}

.vocab-word-chip {
  display: flex;
  min-width: 0;
  min-height: 50px;
  padding: 8px 10px;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  border-color: #cfddd8;
  background: #f8fbfa;
  color: var(--text);
  text-align: left;
  font-size: 12px;
}

.vocab-word-chip strong {
  font-size: 13px;
}

.vocab-word-chip span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.vocab-word-chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: #eaf5f1;
  color: var(--accent-dark);
}

.vocab-word-chip[aria-pressed="true"] span {
  color: #426c60;
}

@media (max-width: 640px) {
  .vocab-word-options {
    grid-template-columns: 1fr;
  }
}

.vocab-selector-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.vocab-selector-controls > div {
  display: flex;
  gap: 4px;
}

.vocab-selection-link {
  min-height: 30px;
  padding: 4px 7px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.vocab-confirm-button {
  min-height: 34px;
  padding: 6px 12px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.vocab-confirm-button:disabled {
  border-color: #cbd8d3;
  background: #dce6e2;
}

.guide-quick-starts {
	display: grid;
	gap: 7px;
	padding: 9px 12px;
	border-top: 1px solid var(--line);
	background: #fbfcfc;
}

.guide-quick-starts[hidden] {
	display: none;
}

.guide-quick-starts > span {
	color: var(--muted);
	font-size: 11px;
}

.guide-quick-starts > div {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.guide-quick-starts .guide-help-panel {
	padding-top: 7px;
	border-top: 1px dashed var(--guide-line);
}

.guide-quick-starts button {
	min-height: 32px;
	padding: 5px 9px;
	border-color: var(--guide-line);
	background: var(--guide);
	color: #344b78;
	font-size: 12px;
}

.diagnosis-card {
	align-self: stretch;
	padding: 14px;
	border-color: #bad8cc;
	background: #f4faf7;
}

.diagnosis-card h3,
.diagnosis-card h4,
.diagnosis-card p {
	margin: 0;
}

.diagnosis-card h3 {
	margin-top: 4px;
	font-size: 16px;
}

.diagnosis-card h4 {
	margin-top: 12px;
	font-size: 12px;
	color: var(--accent-dark);
}

.diagnosis-meta {
	color: var(--accent-dark);
	font-size: 11px;
	font-weight: 800;
}

.diagnosis-summary {
	margin-top: 7px !important;
	color: #44534e;
	font-size: 13px;
	line-height: 1.55;
}

.diagnosis-card ul {
	display: grid;
	gap: 7px;
	margin: 7px 0 0;
	padding: 0;
	list-style: none;
}

.diagnosis-finding {
	padding: 9px 10px;
	border: 1px solid var(--line);
	border-radius: 7px;
	background: #fff;
}

.diagnosis-finding > div {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	font-size: 13px;
}

.diagnosis-finding span {
	color: var(--muted);
	font-size: 11px;
}

.diagnosis-finding p {
	margin-top: 5px;
	color: #53615c;
	font-size: 12px;
	line-height: 1.45;
}

.diagnosis-finding.gap {
	border-color: #e5c9aa;
	background: #fffaf4;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes soft-pop {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

@keyframes thinking-dot {
  0%,
  80%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }
  40% {
    opacity: 0.9;
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bubble,
  .question-card,
  .guide-card,
  .learning-actions-card,
	.diagnosis-card,
  .status-line,
  .choice-card,
  .guide-option,
  .learning-action-option,
	.vocab-selector,
  .tool-debug-card,
  .thinking-dots i {
    animation: none;
  }
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 10px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 12px;
}

.composer #sendButton.is-stop {
  border-color: #a94f3a;
  background: #a94f3a;
  color: #fff;
}

.composer #sendButton.is-stopping {
  opacity: 0.72;
}

.quota-low-notice {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid #ead6b9;
  border-radius: 10px;
  background: #fff8ec;
  color: #765329;
  font-size: 11px;
  font-weight: 700;
}

.quota-low-notice[hidden] {
  display: none;
}

.quota-low-notice button {
  min-height: 28px;
  padding: 3px 8px;
  border-color: #dec49b;
  background: #fff;
  color: #765329;
  font-size: 11px;
}

.notes-overlay,
.session-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 28, 24, 0.28);
  opacity: 0;
  transition: opacity 180ms ease;
}

.notes-overlay.open,
.session-overlay.open {
  opacity: 1;
}

.notes-drawer {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 50;
  width: min(480px, calc(100vw - 24px));
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: -18px 0 48px rgba(15, 32, 27, 0.18);
  transform: translateX(calc(100% + 24px));
  transition: transform 180ms ease;
}

.notes-drawer.open {
  transform: translateX(0);
}

.note-question-dialog {
  width: min(980px, calc(100vw - 32px));
  height: min(820px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 28px 80px rgba(15, 32, 27, 0.3);
}

.note-question-dialog::backdrop {
  background: rgba(15, 28, 24, 0.46);
  backdrop-filter: blur(3px);
}

.note-question-window {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.note-question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.note-question-head p,
.note-question-head h2 {
  margin: 0;
}

.note-question-head p {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.note-question-head h2 {
  font-size: 19px;
}

.note-question-content {
  min-height: 0;
  overflow: auto;
  padding: 16px;
  background: var(--bg);
}

.note-source-question-card {
  min-height: 100%;
  margin: 0;
  background: var(--panel);
}

.note-source-question-card .question-head h3 {
  margin: 6px 0 0;
  font-size: 20px;
}

.note-preview-choice {
  cursor: default;
}

.note-edit-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 28px 80px rgba(15, 32, 27, 0.3);
}

.note-edit-dialog::backdrop {
  background: rgba(15, 28, 24, 0.46);
  backdrop-filter: blur(3px);
}

.note-edit-dialog form {
  display: grid;
  gap: 9px;
  padding: 18px;
}

.note-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}

.note-edit-head p,
.note-edit-head h2 {
  margin: 0;
}

.note-edit-head p {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.note-edit-head h2 {
  font-size: 20px;
}

.note-edit-dialog label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.note-edit-dialog input,
.note-edit-dialog textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.note-edit-dialog textarea {
  min-height: 150px;
  resize: vertical;
}

.note-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.note-edit-actions button {
  min-width: 90px;
}

.note-edit-actions .primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.note-edit-error {
  margin: 2px 0 0;
  padding: 8px 10px;
  border-radius: 7px;
  background: #fff1f1;
  color: #923b3b;
  font-size: 12px;
}

.feedback-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 28px 80px rgba(15, 32, 27, 0.3);
}

.feedback-dialog::backdrop {
  background: rgba(15, 28, 24, 0.46);
  backdrop-filter: blur(3px);
}

.feedback-dialog form {
  display: grid;
  gap: 11px;
  padding: 18px;
}

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

.feedback-head p,
.feedback-head h2 {
  margin: 0;
}

.feedback-head p {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.feedback-head h2 {
  font-size: 20px;
}

.feedback-categories {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.feedback-categories legend,
.feedback-comment-label {
  grid-column: 1 / -1;
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.feedback-categories label {
  cursor: pointer;
}

.feedback-categories input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.feedback-categories span {
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  text-align: center;
}

.feedback-categories input:checked + span {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  color: var(--accent-dark);
  font-weight: 800;
}

.feedback-categories input:focus-visible + span {
  outline: 2px solid color-mix(in srgb, var(--accent) 52%, transparent);
  outline-offset: 2px;
}

.feedback-dialog textarea {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.feedback-privacy,
.feedback-status {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.feedback-status.success { color: var(--accent-dark); }
.feedback-status.error { color: #923b3b; }

.feedback-status.success {
  display: grid;
  justify-items: start;
  gap: 7px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 5%, #fff);
}

.feedback-status code {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 10px;
  user-select: text;
}

.feedback-reference-copy {
  min-height: 30px;
  padding: 5px 10px;
  cursor: pointer;
}

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

.feedback-actions button { min-width: 90px; }
.feedback-actions .primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.session-drawer {
  position: fixed;
  top: 12px;
  left: 12px;
  bottom: 12px;
  z-index: 50;
  width: min(340px, calc(100vw - 24px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 18px 0 48px rgba(15, 32, 27, 0.18);
  transform: translateX(calc(-100% - 24px));
  transition: transform 180ms ease;
}

.session-drawer.open {
  transform: translateX(0);
}

.notes-drawer-head,
.session-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.notes-drawer-head p,
.notes-drawer-head h2,
.session-drawer-head p,
.session-drawer-head h2 {
  margin: 0;
}

.notes-drawer-head p,
.session-drawer-head p {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

.notes-drawer-head h2,
.session-drawer-head h2 {
  font-size: 21px;
}

.session-drawer-actions {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.session-drawer-actions button {
  width: 100%;
  justify-content: flex-start;
  min-height: 42px;
  padding: 8px 10px;
  border-color: transparent;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}

.session-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 6px 8px 12px;
}

.session-group-title {
  margin: 0;
  padding: 12px 10px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.session-card {
  position: relative;
  width: 100%;
  min-height: 0;
  overflow: visible;
  border: 0;
  border-radius: 9px;
  background: transparent;
}

.session-card-main {
  width: 100%;
  min-height: 0;
  display: grid;
  gap: 0;
  padding: 11px 44px 11px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.session-card.current {
  background: #edf1f4;
  box-shadow: none;
}

.session-card-tools {
  position: absolute;
  top: 7px;
  right: 6px;
  z-index: 2;
}

.session-card-tools summary {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding-bottom: 6px;
  border-radius: 8px;
  color: #909090;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 1px;
  list-style: none;
}

.session-card-tools summary::-webkit-details-marker {
  display: none;
}

.session-card-tools summary:hover,
.session-card-tools[open] summary {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

.session-card-menu {
  position: absolute;
  top: 36px;
  right: 0;
  width: 148px;
  display: grid;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

.session-card-menu button {
  width: 100%;
  min-height: 34px;
  justify-content: flex-start;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}

.session-card-menu button:hover {
  background: var(--panel-soft);
}

.session-trace-dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: min(820px, calc(100vh - 28px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(15, 32, 27, 0.24);
}

.session-trace-dialog::backdrop {
  background: rgba(15, 32, 27, 0.36);
  backdrop-filter: blur(2px);
}

.session-trace-window {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: min(820px, calc(100vh - 28px));
}

.session-trace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.session-trace-head p,
.session-trace-head h2 {
  margin: 0;
}

.session-trace-head p {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

.session-trace-head h2 {
  font-size: 21px;
}

.session-trace-content {
  min-height: 0;
  overflow: auto;
  padding: 18px 20px 22px;
}

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

.session-trace-stats div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f5f8f7;
}

.session-trace-stats span,
.session-trace-token-detail {
  color: var(--muted);
  font-size: 11px;
}

.session-trace-stats strong {
  font-size: 18px;
}

.session-trace-token-detail {
  margin: 10px 2px 16px;
}

.session-trace-list {
  display: grid;
  gap: 8px;
}

.session-trace-row {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  background: #fff;
}

.session-trace-row.issue {
  border-left-color: #c96b52;
}

.session-trace-row-head,
.session-trace-row-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.session-trace-row-head time,
.session-trace-row-meta,
.session-trace-row code {
  color: var(--muted);
  font-size: 11px;
}

.session-trace-row-head span {
  padding: 2px 7px;
  border-radius: 999px;
  background: #e7f4ee;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 800;
}

.session-trace-row.issue .session-trace-row-head span {
  background: #fff0eb;
  color: #9b4935;
}

.session-trace-row-meta button {
  min-height: 27px;
  padding: 3px 8px;
  font-size: 10px;
}

@media (max-width: 600px) {
  .session-trace-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .session-trace-row-meta {
    align-items: flex-start;
    flex-direction: column;
  }
}

.session-card-head,
.session-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.session-card-head strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-current-badge {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  overflow: hidden;
  padding: 0;
  border-radius: 50%;
  background: var(--accent);
  color: transparent;
  font-size: 0;
}

.session-card-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.session-card-meta {
  color: var(--muted);
  font-size: 10px;
}

.session-rename-dialog {
  width: min(420px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(15, 32, 27, 0.24);
}

.session-rename-dialog::backdrop {
  background: rgba(15, 32, 27, 0.36);
  backdrop-filter: blur(2px);
}

.session-rename-dialog form {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.session-rename-dialog p,
.session-rename-dialog h2 {
  margin: 0;
}

.session-rename-dialog p {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

.session-rename-dialog h2 {
  font-size: 20px;
}

.session-rename-dialog label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.session-rename-dialog input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.session-rename-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.session-rename-actions button {
  min-width: 80px;
}

.session-rename-actions .primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.notes-close {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--panel-soft);
  font-size: 25px;
  line-height: 1;
}

.notes-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.notes-tabs button {
  min-height: 38px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.notes-tabs button.active {
  border-color: var(--line);
  background: var(--panel);
  color: var(--accent-dark);
  box-shadow: 0 3px 10px rgba(19, 36, 31, 0.06);
}

.notes-tabs span {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  margin-left: 3px;
  place-items: center;
  border-radius: 999px;
  background: var(--panel-soft);
  font-size: 11px;
}

.wrong-attempt-card {
  gap: 10px;
}

.wrong-attempt-question {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.wrong-attempt-answer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wrong-attempt-answer span {
  padding: 6px 9px;
  border-radius: 9px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
}

.wrong-attempt-answer strong {
  margin-left: 3px;
  color: var(--ink);
}

.wrong-attempt-diagnosis {
  padding: 10px 11px;
  border-left: 3px solid var(--accent);
  border-radius: 0 9px 9px 0;
  background: var(--panel-soft);
}

.wrong-attempt-diagnosis strong,
.wrong-attempt-diagnosis p {
  margin: 0;
}

.wrong-attempt-diagnosis-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wrong-attempt-diagnosis-head button {
  min-height: 28px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 650;
}

.wrong-attempt-diagnosis strong {
  color: var(--accent-dark);
  font-size: 11px;
}

.wrong-attempt-diagnosis p {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.55;
}

.attempt-feedback-dialog {
  width: min(640px, calc(100vw - 32px));
  max-width: none;
  max-height: min(780px, calc(100dvh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 28px 80px rgba(15, 32, 27, 0.28);
}

.attempt-feedback-dialog::backdrop {
  background: rgba(15, 28, 24, 0.46);
  backdrop-filter: blur(3px);
}

.attempt-feedback-window {
  max-height: min(780px, calc(100dvh - 32px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.attempt-feedback-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.attempt-feedback-head p,
.attempt-feedback-head h2 {
  margin: 0;
}

.attempt-feedback-head p {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 10px;
}

.attempt-feedback-head h2 {
  font-size: 18px;
  font-weight: 650;
}

.attempt-feedback-content {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow-y: auto;
  padding: 18px;
  background: #fbfaf7;
}

.attempt-feedback-answers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attempt-feedback-answers span {
  padding: 6px 9px;
  border-radius: 9px;
  background: #f0eeea;
  color: var(--muted);
  font-size: 12px;
}

.attempt-feedback-answers strong {
  margin-left: 3px;
  color: var(--text);
}

.attempt-feedback-primary,
.attempt-feedback-section,
.attempt-feedback-missing {
  margin: 0;
  padding: 14px;
  border: 1px solid #e6e2dc;
  border-radius: 13px;
  background: #fff;
}

.attempt-feedback-primary {
  border-left: 3px solid var(--accent);
}

.attempt-feedback-primary > span,
.attempt-feedback-section h3 {
  display: block;
  margin: 0 0 7px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
}

.attempt-feedback-primary p,
.attempt-feedback-section p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.attempt-feedback-missing {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.vocabulary-tools {
  display: grid;
  gap: 9px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.vocabulary-tools[hidden] {
  display: none;
}

.notes-search {
  display: grid;
  gap: 5px;
}

.notes-search > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.notes-search input {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.notes-search input:focus {
  outline: 2px solid rgba(28, 111, 90, 0.16);
  border-color: var(--accent);
}

.notes-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.notes-mode-switch button {
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.notes-mode-switch button.active {
  border-color: var(--accent);
  background: var(--panel-soft);
  color: var(--accent-dark);
}

.notes-mode-switch span {
  display: inline-grid;
  min-width: 19px;
  height: 19px;
  margin-left: 4px;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  font-size: 10px;
}

.notes-list {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  overscroll-behavior: contain;
}

.note-card {
  margin-bottom: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.note-card h3 {
  margin: 0 0 7px;
  font-size: 16px;
}

.note-group-label {
  display: block;
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.review-progress,
.notes-result-count {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.review-card {
  min-height: 310px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
}

.review-card h3 {
  margin-bottom: 18px;
  font-size: 24px;
}

.review-answer {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.review-reveal {
  align-self: flex-start;
  min-width: 120px;
  margin-top: 12px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.review-rating {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 18px;
}

.review-rating button {
  min-height: 58px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 7px 5px;
  font-size: 12px;
  font-weight: 750;
}

.review-rating button span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
}

.review-rating button:last-child {
  border-color: var(--accent);
  background: var(--panel-soft);
  color: var(--accent-dark);
}

.notes-inline-error {
  margin-bottom: 9px;
  padding: 9px 10px;
  border: 1px solid #e3b7b7;
  border-radius: 8px;
  background: #fff4f4;
  color: #8b3434;
  font-size: 12px;
}

.note-card p {
  margin: 0;
  color: #34423d;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.note-tag {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--accent-dark);
  font-size: 11px;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 11px;
}

.note-source-link {
	margin-top: 0;
	padding: 7px 10px;
	border: 1px solid var(--line-strong);
	border-radius: 8px;
	background: #fff;
	color: var(--accent-dark);
	font-size: 12px;
	font-weight: 650;
	cursor: pointer;
}

.note-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.note-edit-button {
  min-height: 34px;
  padding: 7px 11px;
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.note-source-link:hover {
	border-color: var(--accent);
	background: var(--panel-soft);
}

.notes-empty,
.notes-loading {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

textarea {
  width: 100%;
  min-height: 54px;
  max-height: 160px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--text);
}

textarea:focus,
select:focus {
  outline: 2px solid rgba(28, 111, 90, 0.18);
  border-color: var(--accent);
}

@media (max-width: 900px) {
  .app {
    height: 100dvh;
    padding: 10px;
  }

  .study-workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(220px, 0.9fr) minmax(280px, 1.1fr);
  }

  .study-start-card {
    min-height: 220px;
    justify-content: flex-start;
    gap: 14px;
    padding: 22px;
    overflow: auto;
  }

  .study-start-copy h2 {
    font-size: 25px;
  }

  .study-start-hint {
    display: none;
  }
}

@media (max-width: 760px) {

  .usage-windows {
    grid-template-columns: 1fr;
  }

  .usage-upgrade {
    align-items: stretch;
    flex-direction: column;
  }

  .usage-upgrade button {
    width: 100%;
  }

  .billing-plan-form,
  .billing-simulator form,
  .quota-plans {
    grid-template-columns: 1fr;
  }

  .billing-test-actions {
    grid-template-columns: 1fr;
  }

  .note-question-dialog {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .note-question-content {
    padding: 10px;
  }

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

  .topbar-brand {
    width: 100%;
    justify-content: space-between;
  }

  .chat {
    min-height: 0;
  }

  .question-card {
    padding: 12px;
  }

  .question-head {
    flex-direction: column;
  }

  .question-head-actions {
    width: 100%;
    justify-content: space-between;
  }

  .tool-debug-card > summary {
    grid-template-columns: auto auto minmax(0, 1fr);
  }

  .tool-debug-status {
    grid-column: 2 / -1;
    justify-self: start;
  }

  .tool-debug-brief {
    white-space: normal;
  }

}

@media (max-width: 480px) {
  .topbar-brand {
    min-width: 0;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-brand-actions > button {
    flex: 1;
  }

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

/* Mobile learning shell: the same DOM and real API state as the desktop app. */
.brand-copy h1 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-copy h1 small,
.brand-mark,
.mobile-question-peek,
.mobile-study-splitter,
.mobile-primary-nav,
.mobile-question-layout-action {
  display: none;
}

.mobile-profile-dialog,
.mobile-practice-dialog {
  width: min(420px, calc(100vw - 24px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(23, 36, 31, 0.24);
}

.mobile-profile-dialog::backdrop,
.mobile-practice-dialog::backdrop {
  background: rgba(24, 35, 31, 0.36);
  backdrop-filter: blur(3px);
}

.mobile-profile-dialog > section,
.mobile-practice-dialog > section {
  padding: 20px;
}

.mobile-profile-dialog header,
.mobile-practice-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.mobile-profile-dialog header p,
.mobile-profile-dialog header h2,
.mobile-practice-dialog header p,
.mobile-practice-dialog header h2 {
  margin: 0;
}

.mobile-profile-dialog header p,
.mobile-practice-dialog header p {
  color: var(--muted);
  font-size: 11px;
}

.mobile-profile-actions {
  display: grid;
  gap: 8px;
}

.mobile-account-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
}

.mobile-account-card > span {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-dark);
  color: #fff;
  font-family: ui-serif, Georgia, serif;
  font-size: 20px;
  font-weight: 800;
}

.mobile-account-card > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.mobile-account-card small,
.mobile-auth-notice {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.mobile-auth-notice {
  margin: 0 0 12px;
  padding: 0 2px;
}

.mobile-practice-categories {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mobile-practice-capability {
	display: grid;
	gap: 6px;
	margin-bottom: 12px;
	padding: 11px 12px;
	border: 1px solid #d5e4dd;
	border-radius: 14px;
	background: #f3f8f5;
}

.mobile-practice-capability > div {
	display: flex;
	align-items: center;
	gap: 7px;
	color: var(--accent-dark);
	font-size: 12px;
}

.mobile-practice-capability > div i {
	width: 7px;
	height: 7px;
	border-radius: 999px;
	background: #2f896d;
	box-shadow: 0 0 0 4px rgba(47, 137, 109, 0.1);
}

.mobile-practice-capability p {
	margin: 0;
	color: var(--muted);
	font-size: 10.5px;
	line-height: 1.55;
}

.mobile-practice-categories > button {
  min-height: 66px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: center;
  gap: 3px 6px;
  padding: 10px 11px;
  text-align: left;
}

.mobile-practice-categories > button strong {
  font-size: 13px;
}

.mobile-practice-categories > button span {
  grid-column: 1;
  color: var(--muted);
  font-size: 10px;
}

.mobile-practice-categories > button b {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  color: #99a39e;
  font-size: 20px;
  font-weight: 400;
}

.mobile-practice-categories > button em {
	grid-column: 2;
	grid-row: 1 / 3;
	align-self: center;
	padding: 3px 6px;
	border-radius: 999px;
	background: #f1e5e0;
	color: #9b6254;
	font-size: 9px;
	font-style: normal;
	font-weight: 700;
	white-space: nowrap;
}

.mobile-practice-categories > button.is-coming-soon {
	border-color: #e7e3df;
	background: #f8f7f5;
	color: #858a87;
	opacity: 1;
}

.mobile-practice-categories > button.is-coming-soon.is-selected {
	border-color: #cda99b;
	background: #fcf5f2;
	box-shadow: 0 0 0 2px rgba(178, 119, 96, 0.08);
}

.mobile-practice-categories > button.is-coming-soon span {
	color: #a16b5f;
}

.mobile-profile-actions > button {
  min-height: 68px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
}

.mobile-profile-actions > button span {
  display: grid;
  gap: 3px;
}

.mobile-profile-actions > button small {
  color: var(--muted);
  font-size: 11px;
}

.mobile-profile-actions > button b {
  color: #9aa49f;
  font-size: 22px;
  font-weight: 400;
}

.mobile-profile-actions > button > i {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--panel-soft);
}

.mobile-profile-actions > button > i::before {
  color: var(--accent-dark);
  font-style: normal;
  font-weight: 850;
}

.mobile-action-sessions::before { content: "续"; }
.mobile-action-notes::before { content: "记"; }
.mobile-action-usage::before { content: "◔"; font-size: 17px; }
.mobile-action-pricing::before { content: "¥"; font-size: 17px; }
.mobile-action-download::before { content: "↓"; font-size: 19px; }
.mobile-action-xiaohongshu::before { content: "红"; font-size: 13px; }
.mobile-action-switch::before { content: "换"; }
.mobile-action-logout::before { content: "退"; }

.mobile-profile-actions > button:disabled {
  cursor: default;
  opacity: 1;
}

.mobile-profile-actions > button:disabled > i,
.mobile-profile-actions > button:disabled strong,
.mobile-profile-actions > button:disabled b {
  color: #9b9e99;
}

.mobile-profile-actions > button.mobile-profile-danger strong,
.mobile-profile-actions > button.mobile-profile-danger i::before {
  color: #9b4637;
}

.mobile-auth-dialog,
.mobile-logout-dialog {
  width: min(420px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(49, 37, 31, 0.22);
}

.mobile-auth-dialog::backdrop,
.mobile-logout-dialog::backdrop {
  background: rgba(32, 36, 33, 0.38);
  backdrop-filter: blur(4px);
}

.mobile-auth-dialog > section {
  max-height: inherit;
  overflow: auto;
  padding: 20px;
}

.mobile-auth-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.mobile-auth-dialog header p,
.mobile-auth-dialog header h2 {
  margin: 0;
}

.mobile-auth-dialog header p {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.mobile-auth-dialog header h2,
.mobile-logout-dialog h2 {
  font-size: 20px;
}

.mobile-auth-brand {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin: 4px auto 18px;
  border-radius: 15px;
  background: var(--accent);
  color: #fff;
  font-size: 21px;
  font-weight: 800;
}

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

.mobile-auth-form > label:not(.mobile-auth-agreement) {
  display: grid;
  gap: 6px;
}

.mobile-auth-form > label > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.mobile-auth-form input[type="tel"],
.mobile-auth-form input[type="text"] {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #faf8f5;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.mobile-auth-code {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.mobile-auth-code button {
  min-height: 46px;
  padding: 8px 12px;
  border-color: #d8d3cd;
  background: #fff;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.mobile-auth-primary,
.mobile-auth-wechat {
  width: 100%;
  min-height: 46px;
  justify-content: center;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 750;
}

.mobile-auth-primary {
  margin-top: 2px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.mobile-auth-agreement {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
}

.mobile-auth-agreement input {
  margin-top: 2px;
  accent-color: var(--accent);
}

.mobile-auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 10.5px;
}

.mobile-auth-divider::before,
.mobile-auth-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.mobile-auth-wechat {
  border-color: #dce5df;
  background: #f4f8f5;
  color: #315f46;
}

.mobile-auth-wechat i {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  margin-right: 7px;
  border-radius: 50%;
  background: #2f7b4e;
  color: #fff;
  font-size: 10px;
  font-style: normal;
}

.mobile-auth-status {
  margin: 12px 0 0;
  padding: 9px 10px;
  border-radius: 10px;
  background: #f8f2ee;
  color: #7d4b3e;
  font-size: 11px;
  line-height: 1.5;
}

.mobile-logout-dialog > section {
  padding: 24px 20px 20px;
  text-align: center;
}

.mobile-logout-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin: 0 auto 13px;
  border-radius: 14px;
  background: #f8ece8;
  color: #9b4637;
  font-size: 20px;
  font-weight: 800;
}

.mobile-logout-dialog h2,
.mobile-logout-dialog p {
  margin: 0;
}

.mobile-logout-dialog p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.mobile-logout-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.mobile-logout-actions button {
  min-height: 42px;
  border-radius: 11px;
  font-weight: 700;
}

.mobile-logout-actions button:last-child {
  border-color: #a94f3a;
  background: #a94f3a;
  color: #fff;
}

@media (max-width: 760px) {
  :root {
    --bg: #f7f5ef;
    --panel: #fffdfa;
    --panel-soft: #edf3ef;
    --text: #202622;
    --muted: #707973;
    --line: #dedfd8;
    --line-strong: #c9cec8;
    --accent: #276b58;
    --accent-dark: #174b3e;
    --choice: #f7efe3;
    --choice-line: #e2c7a3;
    --guide: #eff4f1;
    --guide-line: #cadbd4;
    --shadow: 0 8px 24px rgba(35, 48, 42, 0.06);
  }

  body {
    background: var(--panel);
  }

  .app {
    width: 100%;
    height: 100dvh;
    grid-template-rows: 68px minmax(0, 1fr) 64px;
    gap: 0;
    padding: 0;
    background: var(--panel);
  }

  .topbar {
    min-height: 0;
    padding: max(8px, env(safe-area-inset-top)) 14px 8px;
    flex-direction: row;
    align-items: center;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    background: rgba(255, 253, 250, 0.96);
  }

  .topbar-brand {
    min-width: 0;
    align-items: center;
    flex-direction: row;
  }

  .brand-copy {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1px;
  }

  .brand-copy h1 {
    grid-column: auto;
    gap: 6px;
    font-size: 17px;
    line-height: 1.1;
  }

  .brand-copy h1 small {
    display: inline;
    margin-left: 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--accent-dark);
    color: #fff;
    font-family: ui-serif, Georgia, serif;
    font-size: 16px;
  }

  .session-entry {
    min-height: 20px;
    justify-self: start;
    gap: 4px;
    padding: 0 0 0 34px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
  }

  .session-entry span,
  .session-filter-chips,
  .notes-entry {
    display: none;
  }

  .session-entry strong {
    max-width: 190px;
    font-weight: 600;
  }

  .topbar-brand-actions {
    flex: 0 0 auto;
    align-items: center;
  }

  .usage-entry {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    border-color: #d6ded9;
    border-radius: 12px;
    background: #f2f5f2;
    color: var(--accent-dark);
    font-size: 11px;
    white-space: nowrap;
  }

  .new-session-entry {
    width: 36px;
    min-height: 36px;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: var(--panel-soft);
    color: var(--accent-dark);
    font-size: 0;
  }

  .new-session-entry::before {
    content: "+";
    font-size: 23px;
    font-weight: 400;
  }

  .study-workspace {
    --mobile-question-height: 44%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--mobile-question-height) 13px minmax(0, 1fr);
    gap: 0;
    overflow: hidden;
    background: var(--bg);
  }

  .question-stage {
    grid-column: 1;
    grid-row: 1;
    padding: 0;
    background: var(--panel);
  }

  .mobile-study-splitter {
    grid-column: 1;
    grid-row: 2;
    min-height: 13px;
    display: grid;
    place-items: center;
    border: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #f4f2ec;
    cursor: row-resize;
    touch-action: none;
  }

  .mobile-study-splitter i {
    width: 34px;
    height: 3px;
    border-radius: 999px;
    background: #b8bfba;
  }

  .dialogue-panel {
    grid-column: 1;
    grid-row: 3;
    grid-template-rows: minmax(0, 1fr) auto auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: var(--bg);
  }

  .study-workspace:not(.has-question) {
    grid-template-rows: minmax(230px, 0.9fr) minmax(180px, 1.1fr);
  }

  .study-workspace:not(.has-question):has(.chat:empty) {
    grid-template-rows: minmax(0, 1fr) 69px;
  }

  .study-workspace:not(.has-question) .question-stage { grid-row: 1; }
  .study-workspace:not(.has-question) .mobile-study-splitter { display: none; }
  .study-workspace:not(.has-question) .dialogue-panel { grid-row: 2; }
  .study-workspace:not(.has-question) .guide-quick-starts { display: none; }

  .study-start-card {
    min-height: 100%;
    justify-content: center;
    gap: 16px;
    padding: 22px 18px 16px;
    border: 0;
    border-radius: 0;
    background: var(--panel);
    box-shadow: none;
  }

  .study-start-copy > span {
    margin-bottom: 7px;
    color: #a46b2f;
    font-size: 10px;
  }

  .study-start-copy h2 {
    font-size: clamp(25px, 7vw, 30px);
    line-height: 1.25;
  }

  .study-start-copy p {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.55;
  }

  .study-start-actions {
    flex-wrap: wrap;
    gap: 7px;
    overflow: visible;
    padding-bottom: 3px;
    scrollbar-width: none;
  }

  .study-start-actions::-webkit-scrollbar { display: none; }

  .study-start-actions button {
    min-height: 36px;
    flex: 0 0 auto;
    padding: 7px 11px;
    border-color: #d4d9d4;
    border-radius: 999px;
    background: #f8f7f3;
    font-size: 12px;
    font-weight: 650;
  }

  .study-start-actions:not(.secondary) button {
    flex: 1 1 calc(50% - 4px);
    text-align: center;
  }

  .study-start-actions button.mobile-secondary-start {
    display: none;
  }

  .study-start-actions.secondary {
    margin-top: -8px;
    padding-top: 8px;
  }

  .study-start-actions.secondary button {
    display: block;
  }

  .dialogue-head {
    display: none;
  }

  .chat {
    grid-row: 1;
    gap: 9px;
    padding: 12px 14px 8px;
  }

  .bubble {
    max-width: 90%;
    padding: 9px 11px;
    border-radius: 13px;
    box-shadow: none;
    font-size: 13px;
    line-height: 1.55;
  }

  .bubble.assistant {
    border-color: #d9dfdb;
  }

  .bubble.user {
    background: #f3e8d7;
  }

  .guide-quick-starts {
    grid-row: 2;
    gap: 5px;
    padding: 7px 10px;
    overflow-x: auto;
    border-top: 1px solid var(--line);
    background: var(--panel);
  }

  .guide-quick-starts > span { display: none; }
  .guide-quick-starts > div { flex-wrap: nowrap; }

  .guide-quick-starts button {
    min-height: 31px;
    flex: 0 0 auto;
    border-radius: 999px;
    font-size: 11px;
  }

  .composer,
  .composer:nth-child(n) {
    grid-row: 3;
    align-self: end;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--panel);
  }

  .composer textarea {
    min-height: 42px;
    max-height: 90px;
    resize: none;
    border-radius: 13px;
    padding: 10px 11px;
    background: #f7f6f2;
    font-size: 13px;
  }

  .composer > button {
    width: 44px;
    min-width: 44px;
    min-height: 42px;
    padding: 0 7px;
    border-radius: 13px;
    font-size: 12px;
  }

  .question-card {
    min-height: 100%;
    padding: 13px 14px 22px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .question-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding-bottom: 9px;
  }

  .question-head h2 {
    margin-top: 2px;
    font-size: 16px;
  }

  .meta {
    font-size: 10px;
  }

  .question-head-actions {
    width: auto;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
  }

  .question-head .answer-status {
    display: none;
  }

  .mobile-question-layout-action {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    border-color: #d6dbd7;
    background: #f7f6f2;
    color: var(--muted);
    font-size: 10px;
  }

  .question-skip {
    min-height: 28px;
    padding: 3px 7px;
    font-size: 10px;
  }

  .material,
  .stem {
    margin-top: 11px;
    font-size: 14px;
    line-height: 1.65;
  }

  .material {
    padding: 11px;
    border-color: #d9ded9;
    background: #f2f5f2;
  }

  .choice-grid {
    gap: 8px;
    margin-top: 11px;
  }

  .choice-card {
    min-height: 44px;
    grid-template-columns: 29px minmax(0, 1fr);
    gap: 8px;
    padding: 8px 10px;
    border-color: #d9dbd6;
    border-radius: 12px;
  }

  .choice-label {
    width: 27px;
    height: 27px;
    font-size: 12px;
  }

  .choice-body { font-size: 13px; }

  .mobile-question-peek {
    min-height: 48px;
    grid-column: 1;
    grid-row: 1;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: var(--panel);
    text-align: left;
  }

  .mobile-question-peek:not([hidden]) { display: grid; }

  .mobile-question-peek span {
    color: var(--muted);
    font-size: 10px;
  }

  .mobile-question-peek strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }

  .mobile-question-peek i {
    width: 8px;
    height: 8px;
    border-top: 2px solid var(--accent);
    border-left: 2px solid var(--accent);
    transform: rotate(45deg) translateY(2px);
  }

  .study-workspace.mobile-question-collapsed {
    grid-template-rows: 48px minmax(0, 1fr);
  }

  .study-workspace.mobile-question-collapsed .question-stage,
  .study-workspace.mobile-question-collapsed .mobile-study-splitter {
    display: none;
  }

  .study-workspace.mobile-question-collapsed .dialogue-panel { grid-row: 2; }

  .study-workspace.mobile-question-focus {
    grid-template-rows: minmax(0, 1fr) 62px;
  }

  .study-workspace.mobile-question-focus .mobile-study-splitter,
  .study-workspace.mobile-question-focus .dialogue-head,
  .study-workspace.mobile-question-focus .chat,
  .study-workspace.mobile-question-focus .guide-quick-starts {
    display: none;
  }

  .study-workspace.mobile-question-focus .dialogue-panel {
    grid-row: 2;
    display: block;
  }

  .mobile-primary-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 4px 6px max(4px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 253, 250, 0.98);
  }

  .mobile-primary-nav button {
    min-height: 54px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    padding: 3px;
    border: 0;
    background: transparent;
    color: #8a918d;
    font-size: 10px;
  }

  .mobile-primary-nav button.active {
    color: var(--accent-dark);
    font-weight: 800;
  }

  .mobile-primary-nav i {
    position: relative;
    width: 19px;
    height: 19px;
    display: block;
  }

  .mobile-primary-nav i::before,
  .mobile-primary-nav i::after {
    position: absolute;
    content: "";
  }

  .mobile-nav-learn::before {
    inset: 1px 3px;
    border: 2px solid currentColor;
    border-radius: 3px;
  }
  .mobile-nav-learn::after {
    top: 5px; left: 7px; width: 5px; height: 2px;
    border-top: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
  }
  .mobile-nav-practice::before {
    inset: 1px;
    border: 2px solid currentColor;
    border-radius: 50%;
  }
  .mobile-nav-practice::after {
    top: 6px; left: 6px; width: 5px; height: 5px;
    border-radius: 50%; background: currentColor;
  }
  .mobile-nav-review::before {
    inset: 2px 3px;
    border: 2px solid currentColor;
    border-radius: 3px 3px 6px 6px;
  }
  .mobile-nav-history::before {
    inset: 2px 1px 4px 4px;
    border: 2px solid currentColor;
    border-radius: 3px;
  }
  .mobile-nav-history::after {
    left: 1px; bottom: 1px; width: 13px; height: 10px;
    border: 2px solid currentColor; border-top: 0; border-right: 0; border-radius: 0 0 0 3px;
  }
  .mobile-nav-review::after {
    top: 6px; left: 7px; width: 5px;
    border-top: 2px solid currentColor;
  }
  .mobile-nav-profile::before {
    top: 1px; left: 6px; width: 7px; height: 7px;
    border: 2px solid currentColor; border-radius: 50%;
  }
  .mobile-nav-profile::after {
    left: 3px; bottom: 0; width: 13px; height: 7px;
    border: 2px solid currentColor; border-bottom: 0; border-radius: 8px 8px 0 0;
  }

  .notes-overlay,
  .session-overlay {
    bottom: 64px;
  }

  .notes-drawer,
  .session-drawer {
    top: 68px;
    right: 0;
    bottom: 64px;
    left: 0;
    width: 100%;
    border-width: 1px 0 0;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -16px 42px rgba(25, 40, 34, 0.14);
  }

  .notes-drawer { transform: translateY(calc(100% + 64px)); }
  .session-drawer { transform: translateY(calc(100% + 64px)); }
  .notes-drawer.open,
  .session-drawer.open { transform: translateY(0); }

  .usage-dialog,
  .feedback-dialog,
  .mobile-profile-dialog,
  .mobile-practice-dialog {
    width: 100vw;
    max-width: none;
    max-height: 82dvh;
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 22px 22px 0 0;
  }

  .usage-window,
  .feedback-dialog form,
  .mobile-profile-dialog > section,
  .mobile-practice-dialog > section {
    padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  }

  .usage-card,
  .mobile-profile-actions > button,
  .mobile-practice-categories > button {
    border-radius: 14px;
    background: #fff;
  }
}

@media (max-width: 520px) {
  .feedback-categories { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .mobile-auth-dialog,
  .mobile-logout-dialog {
    width: 100vw;
    max-width: none;
    max-height: 88dvh;
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 22px 22px 0 0;
  }

  .mobile-auth-dialog > section {
    padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
  }

  .mobile-logout-dialog > section {
    padding: 24px 18px calc(20px + env(safe-area-inset-bottom));
  }
}

/* Final mobile cascade: one continuous conversation surface. */
@media (max-width: 760px) {
  .app { grid-template-rows: 64px minmax(0, 1fr); }
  .topbar {
    position: relative;
    min-height: 64px;
    justify-content: center;
    padding: max(8px, env(safe-area-inset-top)) 58px 8px;
  }
  .topbar-brand, .brand-copy { width: auto; min-width: 0; }
  .brand-copy h1 { justify-content: center; white-space: nowrap; }
  .brand-copy h1 small { display: none; }
  .session-entry {
    position: absolute;
    top: 14px;
    left: 12px;
    width: 36px;
    min-height: 36px;
    display: block;
    padding: 0;
    border: 0;
    border-radius: 11px;
    background:
      linear-gradient(var(--accent-dark), var(--accent-dark)) 10px 11px / 16px 2px no-repeat,
      linear-gradient(var(--accent-dark), var(--accent-dark)) 10px 17px / 16px 2px no-repeat,
      linear-gradient(var(--accent-dark), var(--accent-dark)) 10px 23px / 12px 2px no-repeat,
      var(--panel-soft);
  }
  .session-entry span, .session-entry strong { display: none; }
  .topbar-brand-actions { position: absolute; top: 14px; right: 10px; gap: 5px; }
  .usage-entry { min-height: 36px; padding: 0 9px; font-size: 10px; }
  .new-session-entry { width: 36px; min-height: 36px; }

  .study-workspace,
  .study-workspace:not(.has-question),
  .study-workspace:not(.has-question):has(.chat:empty),
  .study-workspace.mobile-question-collapsed,
  .study-workspace.mobile-question-focus {
    height: 100%;
    display: block;
    overflow: hidden;
    background: var(--panel);
  }
  .question-stage, .mobile-question-peek, .mobile-study-splitter, .mobile-primary-nav { display: none !important; }
  .dialogue-panel,
  .study-workspace:not(.has-question) .dialogue-panel,
  .study-workspace.mobile-question-collapsed .dialogue-panel,
  .study-workspace.mobile-question-focus .dialogue-panel {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    overflow: hidden;
    background: var(--panel);
  }
  .dialogue-panel .chat,
  .study-workspace.mobile-question-focus .chat {
    grid-row: 1;
    display: flex;
    min-height: 0;
    gap: 14px;
    padding: 16px 14px 12px;
    background: var(--panel);
  }
  .chat:has(.mobile-chat-welcome:only-child) { justify-content: center; }
  .mobile-chat-welcome {
    width: min(100%, 560px);
    height: auto;
    min-height: 0;
    flex: 0 0 auto;
    align-self: center;
    gap: 18px;
    padding: 8px 4px;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .mobile-chat-welcome .study-start-copy h2 { font-size: clamp(27px, 8vw, 34px); }
  .mobile-chat-welcome .study-start-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }
  .mobile-chat-welcome .study-start-actions button { width: 100%; min-height: 42px; white-space: normal; }
  .bubble { max-width: 88%; border: 0; box-shadow: none; }
  .bubble.assistant { padding-left: 2px; background: transparent; }
  .bubble.user { border: 1px solid #ead6b9; border-radius: 18px 18px 5px 18px; background: #f6ead8; }
  .chat-question-card {
    width: min(100%, 620px);
    min-height: 0;
    align-self: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(25, 42, 34, 0.06);
  }
  .chat-question-card.is-collapsed .material,
  .chat-question-card.is-collapsed .stem,
  .chat-question-card.is-collapsed .choice-grid { display: none; }
  .mobile-question-focus-button { display: none !important; }
  .mobile-question-collapse-button { display: inline-flex; }
  .guide-quick-starts, .study-workspace.mobile-question-focus .guide-quick-starts { grid-row: 2; display: grid; }
  .guide-quick-starts[hidden] { display: none; }
  .composer, .composer:nth-child(n), .study-workspace.mobile-question-focus .composer {
    grid-row: 3;
    align-self: end;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid #ecece7;
    background: var(--panel);
  }
  .composer textarea {
    min-height: 48px;
    max-height: 112px;
    padding: 12px 14px;
    border-color: #d9ddd9;
    border-radius: 22px;
    background: #f7f7f4;
  }
  .composer > button { width: 44px; min-width: 44px; min-height: 44px; align-self: end; border-radius: 50%; }
  .tool-debug-card, .trace-line { display: none !important; }
  .notes-overlay, .session-overlay { bottom: 0; }
  .session-drawer {
    top: 0;
    right: auto;
    bottom: 0;
    left: 0;
    width: min(340px, 88vw);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    border-width: 0 1px 0 0;
    border-radius: 0 18px 18px 0;
    transform: translateX(calc(-100% - 20px));
  }
  .session-drawer.open { transform: translateX(0); }
}

/* Chat-first visual refinement: neutral, quiet, and conversation-led. */
@media (max-width: 760px) {
  :root {
    --bg: #fbfaf7;
    --panel: #ffffff;
    --panel-soft: #f4f1ed;
    --text: #202421;
    --muted: #737773;
    --line: #e5e2dd;
    --accent: #a94f3a;
    --accent-dark: #833b2e;
    --choice: #fbfaf7;
    --choice-line: #e1ded8;
    --guide: #f8f3ef;
    --guide-line: #e6d7cf;
  }

  body, .app {
    background: #fbfaf7;
  }

  .study-workspace, .dialogue-panel, .chat {
    background: #fff;
  }

  .topbar {
    min-height: 60px;
    padding-top: max(8px, env(safe-area-inset-top));
    border-bottom-color: #ebe8e3;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
  }

  .brand-mark {
    display: none;
  }

  .brand-copy h1 {
    gap: 4px;
    color: #202421;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.015em;
  }

  .session-entry {
    background:
      linear-gradient(#343936, #343936) 10px 11px / 16px 1.5px no-repeat,
      linear-gradient(#343936, #343936) 10px 17px / 16px 1.5px no-repeat,
      linear-gradient(#343936, #343936) 10px 23px / 12px 1.5px no-repeat,
      transparent;
  }

  .session-entry:hover,
  .new-session-entry:hover,
  .usage-entry:hover {
    border-color: transparent;
    background-color: #f4f1ed;
  }

  .new-session-entry {
    border: 0;
    background: transparent;
    color: #343936;
  }

  .new-session-entry::before {
    font-size: 24px;
    font-weight: 300;
  }

  .usage-entry {
    min-width: 40px;
    justify-content: center;
    padding: 0 8px;
    border: 1px solid #e2dfda;
    border-radius: 999px;
    background: #fff;
    color: #626762;
  }

  .usage-entry span {
    display: none;
  }

  .usage-entry strong {
    font-size: 10px;
    font-weight: 700;
  }

  .dialogue-panel .chat,
  .study-workspace.mobile-question-focus .chat {
    padding: 18px 16px 14px;
  }

  .chat:has(.mobile-chat-welcome:only-child) {
    padding-bottom: 92px;
  }

  .mobile-chat-welcome {
    max-width: 420px;
    gap: 20px;
    padding: 0;
  }

  .mobile-chat-welcome .study-start-copy {
    text-align: center;
  }

  .mobile-chat-welcome .study-start-copy > span {
    display: none;
  }

  .mobile-chat-welcome .study-start-copy h2 {
    color: #202421;
    font-size: clamp(27px, 7.5vw, 32px);
    font-weight: 700;
    letter-spacing: -0.035em;
  }

  .mobile-chat-welcome .study-start-copy p {
    max-width: 310px;
    margin: 9px auto 0;
    color: #737773;
    font-size: 13px;
    line-height: 1.55;
  }

  .mobile-chat-welcome .study-start-actions {
    gap: 8px;
  }

  .mobile-chat-welcome .study-start-actions button {
    min-height: 50px;
    padding: 9px 10px;
    border: 1px solid #e4e1dc;
    border-radius: 15px;
    background: #faf8f5;
    color: #343936;
    font-size: 12px;
    font-weight: 600;
  }

  .mobile-chat-welcome .study-start-actions button:hover {
    border-color: #d8d3cd;
    background: #f4f1ed;
  }

  .bubble {
    color: #202421;
    font-size: 14px;
    line-height: 1.65;
  }

  .bubble.user {
    padding: 10px 13px;
    border: 0;
    border-radius: 19px 19px 5px 19px;
    background: #f4f1ed;
  }

  .bubble.assistant {
    max-width: 96%;
    padding: 4px 2px;
  }

  .chat-question-card {
    border-color: #e4e1dc;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.045);
  }

  .choice-label {
    background: #343936;
  }

  .choice-card:hover {
    background: #f8f6f3;
  }

  .guide-quick-starts,
  .study-workspace.mobile-question-focus .guide-quick-starts {
    padding: 6px 12px 2px;
    border: 0;
    background: #fff;
  }

  .guide-quick-starts button {
    border-color: #e4e1dc;
    background: #f8f6f3;
    color: #555b57;
  }

  .composer,
  .composer:nth-child(n),
  .study-workspace.mobile-question-focus .composer {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    margin: 4px 10px calc(9px + env(safe-area-inset-bottom));
    padding: 5px;
    border: 1px solid #dfdcd7;
    border-radius: 26px;
    background: #f5f3f0;
    box-shadow: 0 2px 10px rgba(62, 45, 38, 0.05);
  }

  .mobile-composer-more {
    width: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    display: grid;
    place-items: center;
    align-self: end;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50%;
    background: transparent !important;
    color: #343936 !important;
    font-size: 24px !important;
    font-weight: 300 !important;
  }

  .composer textarea {
    min-height: 42px;
    max-height: 112px;
    padding: 10px 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: 14px;
    line-height: 1.45;
  }

  .composer textarea:focus {
    outline: none;
  }

  .composer #sendButton {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border: 0;
    background: #a94f3a;
    color: #fff;
    font-size: 0;
  }

  .composer #sendButton::before {
    display: block;
    color: #fff;
    content: "↑";
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
  }

  .composer #sendButton.is-stop::before {
    content: "■";
    font-size: 12px;
  }

  .mobile-practice-dialog,
  .mobile-profile-dialog,
  .usage-dialog {
    border-color: #e4e1dc;
    background: #fff;
  }

  .mobile-practice-categories > button,
  .mobile-profile-actions > button,
  .usage-card {
    border-color: #e4e1dc;
    background: #faf8f5;
  }

  .session-drawer {
    background: #fbfaf7;
  }

  .session-drawer-head,
  .session-drawer-actions,
  .session-account-footer {
    background: #fbfaf7;
  }

  .session-card {
    min-height: 44px;
    border-color: transparent;
    background: transparent;
  }

  .session-list {
    grid-auto-rows: max-content;
    align-content: start;
  }

  .session-card.current {
    background: #f8ece8;
  }

  .session-card-tools summary {
    opacity: 0.52;
  }
}

/* Compact mobile reading scale: keep questions readable without turning them into oversized cards. */
@media (max-width: 760px) {
  .brand-copy h1 {
    font-size: 15px;
  }

  .dialogue-panel .chat,
  .study-workspace.mobile-question-focus .chat {
    gap: 11px;
    padding: 14px 16px 12px;
  }

  .bubble {
    font-size: 13px;
    line-height: 1.58;
  }

  .chat-question-card {
    width: 100%;
    min-height: 0;
    flex: 0 0 auto;
    align-self: stretch;
    padding: 10px 0 4px;
    border: 0;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
  }

  .chat-question-card .question-head {
    gap: 6px;
    padding-bottom: 8px;
  }

  .chat-question-card .question-head h2 {
    margin-top: 2px;
    font-size: 15px;
    line-height: 1.35;
  }

  .chat-question-card .meta {
    font-size: 9.5px;
    line-height: 1.4;
  }

  .chat-question-card .mobile-question-layout-action,
  .chat-question-card .question-skip {
    min-height: 26px;
    padding: 3px 7px;
    font-size: 9.5px;
  }

  .chat-question-card .material,
  .chat-question-card .stem {
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.68;
  }

  .chat-question-card .material {
    padding: 9px 10px;
    border-radius: 10px;
  }

  .chat-question-card .material p,
  .chat-question-card .stem p,
  .chat-question-card .choice-body p {
    margin-bottom: 7px;
  }

  .chat-question-card .choice-grid {
    gap: 7px;
    margin-top: 10px;
  }

  .chat-question-card .choice-card {
    min-height: 40px;
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 8px;
    padding: 7px 9px;
    border-radius: 11px;
  }

  .chat-question-card .choice-label {
    width: 25px;
    height: 25px;
    font-size: 11px;
  }

  .chat-question-card .choice-body {
    font-size: 12.5px;
    line-height: 1.55;
  }

  .guide-quick-starts button {
    min-height: 29px;
    padding: 4px 9px;
    font-size: 10.5px;
  }

  .composer textarea {
    font-size: 13px;
  }
}

/* Agent-led start state: intents are stable; the Agent decides the actual topic and question. */
.study-start-actions-grid {
  width: min(620px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.study-start-actions-grid button {
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid #ddd8d2;
  border-radius: 14px;
  background: #fff;
  color: #303531;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.study-start-actions-grid button:hover {
  border-color: #caa99c;
  background: #fbf6f3;
}

.study-start-actions-grid button:active {
  transform: scale(0.99);
}

.study-start-actions-grid button:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.study-start-capability {
  width: min(620px, 100%);
  color: #929894;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.study-start-capability span {
	display: inline-flex;
	align-items: center;
	margin-right: 4px;
	padding: 2px 6px;
	border-radius: 999px;
	background: #e6f1ec;
	color: #2f755f;
	font-size: 9px;
	font-weight: 750;
}

.study-start-capability i {
	margin: 0 4px;
	font-style: normal;
}

.study-start-recommendation {
  width: min(620px, 100%);
  display: grid;
  gap: 9px;
}

.study-start-primary {
  width: 100%;
  min-height: 92px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  align-items: center;
  padding: 15px 16px;
  border: 1px solid #e2d9d2;
  border-radius: 16px;
  background: #fbf7f3;
  color: var(--text);
  text-align: left;
}

.study-start-primary > span,
.study-start-primary > strong,
.study-start-primary > small {
  grid-column: 1;
}

.study-start-primary > span {
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 750;
}

.study-start-primary > strong {
  font-size: 16px;
  line-height: 1.4;
}

.study-start-primary > small {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.study-start-primary > b {
  grid-column: 2;
  grid-row: 1 / 4;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 500;
}

.study-start-primary:hover {
  border-color: #d4b9ad;
  background: #f8efea;
}

.study-start-secondary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.study-start-secondary button {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #555b57;
  font-size: 11.5px;
  font-weight: 650;
}

@media (max-width: 760px) {
  .mobile-chat-welcome {
    max-width: 430px;
    gap: 18px;
  }

  .mobile-chat-welcome .study-start-copy h2 {
    font-size: clamp(24px, 6.8vw, 29px);
    letter-spacing: -0.03em;
  }

  .mobile-chat-welcome .study-start-copy p {
    max-width: 330px;
    font-size: 12.5px;
  }

  .study-start-actions-grid {
    gap: 8px;
  }

  .study-start-actions-grid button {
    min-height: 44px;
    padding: 9px 10px;
    border-radius: 13px;
    font-size: 13px;
    font-weight: 500;
  }

  .study-start-capability {
    font-size: 10.5px;
  }

  .study-start-primary {
    min-height: 88px;
    padding: 13px 14px;
    border-radius: 15px;
  }

  .study-start-primary > strong {
    font-size: 15px;
  }

  .study-start-primary > small {
    font-size: 11px;
  }

  .study-start-secondary button {
    min-height: 38px;
    font-size: 11px;
  }

  .composer,
  .composer:nth-child(n),
  .study-workspace.mobile-question-focus .composer {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

/* Active-question workspace: the question and the coaching conversation scroll independently. */
@media (max-width: 760px) {
  .study-workspace.has-question,
  .study-workspace.has-question.mobile-question-focus {
    --mobile-question-height: 44%;
    height: 100%;
    min-height: 0;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--mobile-question-height) 12px minmax(0, 1fr);
    overflow: hidden;
    background: #fff;
  }

  .study-workspace.has-question > .question-stage {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    display: block !important;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 0 16px 12px;
    background: #fff;
    -webkit-overflow-scrolling: touch;
  }

  .study-workspace.has-question > .question-stage .chat-question-card {
    min-height: 100%;
    padding-top: 10px;
  }

  .study-workspace.has-question > .question-stage .question-head {
    position: sticky;
    top: 0;
    z-index: 3;
    padding-top: 10px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
  }

  .study-workspace.has-question > .mobile-study-splitter {
    grid-column: 1;
    grid-row: 2;
    min-height: 12px;
    display: grid !important;
    place-items: center;
    border: 0;
    border-top: 1px solid #e7e3de;
    border-bottom: 1px solid #e7e3de;
    background: #f7f4f0;
    cursor: row-resize;
    touch-action: none;
  }

  .study-workspace.has-question > .mobile-study-splitter i {
    width: 34px;
    height: 3px;
    border-radius: 999px;
    background: #bbb5ae;
  }

  .study-workspace.has-question > .dialogue-panel,
  .study-workspace.has-question.mobile-question-focus > .dialogue-panel {
    grid-column: 1;
    grid-row: 3;
    width: 100%;
    height: auto;
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    overflow: hidden;
    border-top: 0;
    background: #fff;
  }

  .study-workspace.has-question > .dialogue-panel .chat {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding-top: 10px;
    -webkit-overflow-scrolling: touch;
  }

  .study-workspace.has-question.mobile-question-collapsed {
    display: grid !important;
    grid-template-rows: 48px minmax(0, 1fr);
  }

  .study-workspace.has-question.mobile-question-collapsed > .question-stage,
  .study-workspace.has-question.mobile-question-collapsed > .mobile-study-splitter {
    display: none !important;
  }

  .study-workspace.has-question.mobile-question-collapsed > .mobile-question-peek:not([hidden]) {
    grid-column: 1;
    grid-row: 1;
    min-height: 48px;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: #fbfaf7;
    color: var(--text);
    text-align: left;
  }

  .study-workspace.has-question.mobile-question-collapsed > .mobile-question-peek span {
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
  }

  .study-workspace.has-question.mobile-question-collapsed > .mobile-question-peek strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }

  .study-workspace.has-question.mobile-question-collapsed > .mobile-question-peek i {
    width: 7px;
    height: 7px;
    border-top: 1.5px solid var(--muted);
    border-left: 1.5px solid var(--muted);
    transform: rotate(45deg) translateY(2px);
  }

  .study-workspace.has-question.mobile-question-collapsed > .dialogue-panel {
    grid-column: 1;
    grid-row: 2;
  }
}

/* Final mobile account/settings overrides; kept last so legacy dialog rules cannot win. */
@media (max-width: 760px) {
  :root {
    --bg: #f8f6f2;
    --panel: #ffffff;
    --panel-soft: #f4f1ed;
    --text: #202321;
    --muted: #727773;
    --line: #e7e1db;
    --accent: #a63830;
    --accent-dark: #7d2723;
    --choice: #fbfaf8;
    --choice-line: #e5dfd9;
    --guide: #fbefec;
    --guide-line: #ecd5d0;
  }

  body,
  .app {
    background: var(--bg);
  }

  .composer #sendButton,
  .mobile-logout-actions button:last-child {
    border-color: var(--accent);
    background: var(--accent);
  }

  .composer textarea {
    width: 100%;
    height: 40px;
    min-height: 40px;
    padding: 9px 6px;
    line-height: 20px;
  }

  .composer #sendButton {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    align-self: center;
  }

  .mobile-profile-dialog,
  .mobile-auth-dialog {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: var(--bg);
    box-shadow: none;
  }

  .mobile-profile-dialog::backdrop,
  .mobile-auth-dialog::backdrop {
    background: transparent;
    backdrop-filter: none;
  }

  .mobile-profile-dialog > .mobile-settings-page,
  .mobile-auth-dialog > section {
    width: 100%;
    height: 100dvh;
    max-height: none;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0;
    overflow: hidden;
    background: var(--bg);
  }

  .mobile-settings-head,
  .mobile-auth-head {
    min-height: calc(56px + env(safe-area-inset-top));
    display: grid !important;
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    align-items: center;
    gap: 8px;
    margin: 0 !important;
    padding: max(10px, env(safe-area-inset-top)) 14px 8px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
  }

  .mobile-settings-head h2,
  .mobile-auth-head > div {
    text-align: center;
  }

  .mobile-settings-scroll {
    min-height: 0;
    padding: 12px 16px calc(28px + env(safe-area-inset-bottom));
    overflow: auto;
  }

  .mobile-account-card {
    min-height: 74px;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 13px;
    margin: 0 0 22px;
    padding: 12px 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .mobile-account-card > span {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #96362f;
    font-size: 18px;
    font-weight: 650;
  }

  .mobile-account-card > div {
    gap: 4px;
  }

  .mobile-account-card > div strong {
    color: #1f211f;
    font-size: 16px;
    font-weight: 650;
  }

  .mobile-account-card > div small {
    color: #81847f;
    font-size: 12px;
    line-height: 1.4;
  }

  .mobile-settings-group {
    margin: 0 0 22px;
  }

  .mobile-settings-group h3 {
    margin: 0 0 7px;
    padding: 0 4px;
    color: #777a75;
    font-size: 12px;
    font-weight: 500;
  }

  .mobile-profile-actions {
    gap: 0;
    overflow: hidden;
    border: 0;
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(34, 36, 33, 0.055);
  }

  .mobile-profile-actions > button {
    min-height: 56px;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 8px 14px;
    border: 0;
    border-radius: 0;
    background: #fff;
  }

  .mobile-profile-actions > button + button {
    border-top: 1px solid #ececea;
  }

  .mobile-profile-actions > button > i {
    width: 24px;
    height: 24px;
    position: relative;
    border-radius: 0;
    background: transparent;
    color: #5b5e59;
  }

  .mobile-profile-actions > button > i::before {
    color: currentColor;
  }

  .mobile-action-notes::before {
    width: 12px;
    height: 15px;
    display: block;
    border: 1.5px solid currentColor;
    border-radius: 3px;
    content: "";
  }

  .mobile-action-notes::after {
    position: absolute;
    top: 7px;
    left: 6px;
    width: 8px;
    height: 1px;
    background: currentColor;
    box-shadow: 0 4px 0 currentColor, 0 8px 0 currentColor;
    content: "";
  }

  .mobile-action-switch::before {
    content: "⇄";
    font-size: 16px;
    font-weight: 650;
  }

  .mobile-action-logout::before {
    width: 13px;
    height: 15px;
    display: block;
    border: 1.4px solid currentColor;
    border-right: 0;
    border-radius: 3px 0 0 3px;
    content: "";
  }

  .mobile-action-logout::after {
    position: absolute;
    top: 6px;
    left: 7px;
    content: "→";
    font-size: 14px;
    line-height: 1;
  }

  .mobile-profile-actions > button strong {
    color: #242623;
    font-size: 14px;
    font-weight: 550;
  }

  .mobile-profile-actions > button small {
    margin-top: 2px;
    color: #898c87;
    font-size: 11px;
  }

  .mobile-profile-actions > button b {
    color: #a3a5a2;
    font-size: 19px;
  }

  .mobile-profile-danger {
    margin: 0;
    color: #a3322c;
  }

  .mobile-profile-actions > button.mobile-profile-danger strong,
  .mobile-profile-actions > button.mobile-profile-danger > i {
    color: #a3322c;
  }

  .mobile-settings-footnote {
    margin: 34px 0 0;
    color: #a0a29d;
    font-size: 10.5px;
    line-height: 1.65;
    text-align: center;
  }

  .mobile-auth-dialog > section {
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0;
  }

  .mobile-auth-dialog > section > :not(header) {
    width: calc(100% - 36px);
    max-width: 420px;
    justify-self: center;
  }

  .mobile-auth-brand {
    margin-top: 28px;
    background: var(--accent);
  }

  .mobile-auth-form input[type="tel"],
  .mobile-auth-form input[type="text"] {
    background: #fff;
  }

  .mobile-auth-primary {
    border-color: var(--accent);
    background: var(--accent);
  }

  .mobile-auth-status {
    background: #fbefec;
    color: var(--accent-dark);
  }

  .session-card.current {
    background: #f9ece9;
  }
}

/* The phone history panel stays a navigation sheet, not a full-width page. */
@media (max-width: 760px) {
  .session-drawer {
    top: 0;
    right: auto;
    bottom: 0;
    left: 0;
    width: min(82vw, 320px);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    border: 0;
    border-right: 1px solid #e9e6e1;
    border-radius: 0 14px 14px 0;
    background: #fbfaf7;
    box-shadow: 12px 0 32px rgba(26, 31, 28, 0.14);
    transform: translateX(calc(-100% - 12px));
  }

  .session-drawer.open { transform: translateX(0); }

  .session-drawer-head {
    min-height: 58px;
    padding: max(10px, env(safe-area-inset-top)) 12px 8px 18px;
    border-bottom: 0;
    background: #fbfaf7;
  }

  .session-drawer-head h2 {
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -0.02em;
  }

  .session-drawer-head .notes-close {
    width: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #555a56;
    font-size: 25px;
    font-weight: 300;
  }

  .session-drawer-actions {
    display: grid;
    gap: 2px;
    padding: 4px 10px 8px;
    border-bottom: 0;
    background: #fbfaf7;
  }

  .session-drawer-actions > button,
  .session-drawer-actions > button.session-new-entry,
  .session-drawer-actions > button.session-review-entry {
    width: 100%;
    margin: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #292d2a;
    text-align: left;
  }

  .session-drawer-actions > button.session-new-entry {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
    padding: 7px 10px;
    font-size: 19px;
    font-weight: 400;
  }

  .session-new-entry strong {
    font-size: 14px;
    font-weight: 600;
  }

  .session-drawer-actions > button.session-review-entry {
    min-height: 50px;
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 9px;
    row-gap: 0;
    padding: 7px 10px;
  }

  .session-review-entry > span {
    width: 24px;
    height: 24px;
    grid-row: 1 / 3;
    display: grid;
    place-items: center;
    border-radius: 0;
    background: transparent;
    color: #555a56;
  }

  .session-review-entry > span svg {
    width: 20px;
    height: 20px;
    overflow: visible;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .session-review-entry strong,
  .session-review-entry small {
    grid-column: 2;
    min-width: 0;
    text-align: left;
  }

  .session-review-entry strong {
    align-self: end;
    color: #292d2a;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
  }

  .session-review-entry small {
    align-self: start;
    overflow: hidden;
    color: #858986;
    font-size: 10.5px;
    font-weight: 400;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .session-review-entry b { display: none; }

  .session-drawer-actions > button:hover,
  .session-drawer-actions > button:active {
    background: #f1efeb;
  }
}

@media (max-width: 760px) {
  .attempt-feedback-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .attempt-feedback-window {
    height: 100dvh;
    max-height: none;
  }

  .attempt-feedback-head {
    padding: max(10px, env(safe-area-inset-top)) 14px 10px 18px;
  }

  .attempt-feedback-content {
    padding: 14px 14px calc(24px + env(safe-area-inset-bottom));
  }
}
