:root {
  color-scheme: light;
  --bg: #f8fafd;
  --card: #f8fafd;
  --ink: #202124;
  --muted: #5f6368;
  --line: #dadce0;
  --soft: #f1f3f4;
  --blue: #1a73e8;
  --blue-dark: #1558b0;
  --green: #188038;
  --yellow: #f9ab00;
  --red: #d93025;
  --shadow: 0 18px 44px rgba(60, 64, 67, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: white;
  cursor: pointer;
  font-weight: 760;
  min-height: 48px;
  padding: 0 18px;
  touch-action: manipulation;
}

button:hover {
  background: var(--blue-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.secondary {
  background: #e8f0fe;
  color: var(--blue-dark);
}

button.danger {
  background: #fce8e6;
  color: var(--red);
}

button.ghost {
  min-height: 38px;
  padding: 0 14px;
}

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

h1 {
  font-size: 36px;
  letter-spacing: 0;
  line-height: 0.98;
}

h2 {
  font-size: 22px;
  letter-spacing: 0;
  line-height: 1.15;
}

h3 {
  font-size: 17px;
  letter-spacing: 0;
  line-height: 1.25;
}

.shell {
  margin: 0 auto;
  max-width: 960px;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(96px + env(safe-area-inset-bottom));
  width: 100%;
}

.app-header {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

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

.app-logo {
  border-radius: 16px;
  flex: 0 0 auto;
  height: 52px;
  width: 52px;
}

.eyebrow {
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.subtitle {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
  margin-top: 8px;
  max-width: 640px;
}

.status {
  align-self: start;
  background: transparent;
  border: 1px solid rgba(218, 220, 224, 0.9);
  border-radius: 999px;
  color: var(--muted);
  display: inline-block;
  font-size: 10px;
  font-weight: 750;
  justify-self: start;
  max-width: 100%;
  overflow: hidden;
  padding: 6px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabbar {
  align-items: center;
  background: rgba(248, 250, 253, 0.96);
  border: 1px solid var(--line);
  border-radius: 24px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 10px 28px rgba(60, 64, 67, 0.16);
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, 1fr);
  left: 14px;
  padding: 6px;
  position: fixed;
  right: 14px;
  z-index: 30;
  backdrop-filter: blur(18px);
}

.tab {
  background: transparent;
  color: var(--muted);
  border-radius: 18px;
  min-height: 48px;
  padding: 0 10px;
  width: 100%;
}

.tab:hover,
.tab.active {
  background: #e8f0fe;
  color: var(--blue-dark);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.quiz-active {
  background: var(--card);
}

.quiz-active .shell {
  max-width: none;
  padding: calc(14px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom));
}

.quiz-active .app-header,
.quiz-active .tabbar,
.quiz-active .journey-switcher,
.quiz-active .home-card,
.quiz-active #activeTitle,
.quiz-active #activeSummary,
.quiz-active .metrics,
.quiz-active .actions {
  display: none;
}

.quiz-active .learn-grid {
  max-width: none;
}

.quiz-active .panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.quiz-active .quiz-area {
  min-height: auto;
}

.quiz-active .question-card {
  background: var(--card);
  border-radius: 0;
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  min-height: auto;
  padding: 8px 2px calc(14px + env(safe-area-inset-bottom));
}

.learn-grid,
.notes-grid,
.quiz-history-layout {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  margin: 0 auto;
  min-width: 0;
}

.learn-grid {
  max-width: 560px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  min-width: 0;
  padding: 16px;
}

.main-panel,
.detail-panel {
  min-height: 0;
  min-width: 0;
}

.focus-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  display: grid;
  gap: 14px;
  padding: 0;
}

.compat-hidden {
  display: none;
}

.panel-header {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.back-button {
  background: transparent;
  color: var(--blue-dark);
  font-size: 14px;
  min-height: 0;
  padding: 0 0 10px;
}

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

.icon-button {
  background: var(--soft);
  color: var(--ink);
  min-height: 42px;
  padding: 0;
  width: 42px;
}

.add-note-button {
  color: var(--blue-dark);
  font-size: 24px;
  line-height: 1;
}

.note-menu {
  position: relative;
}

.note-menu[hidden] {
  display: none;
}

.note-menu summary {
  align-items: center;
  background: var(--soft);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-weight: 850;
  height: 42px;
  justify-content: center;
  list-style: none;
  width: 42px;
}

.note-menu summary::-webkit-details-marker {
  display: none;
}

.note-menu button {
  box-shadow: 0 12px 28px rgba(60, 64, 67, 0.18);
  position: absolute;
  right: 0;
  top: 48px;
  white-space: nowrap;
  z-index: 20;
}

.study-controls {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 22px;
  display: grid;
  gap: 1px;
  overflow: hidden;
}

.journey-switcher,
.focus-switcher {
  background: transparent;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
}

.journey-switcher label,
.focus-switcher label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}

.focus-switcher {
  border-top: 1px solid var(--line);
  margin-top: 0;
}

.focus-switcher[hidden] {
  display: none;
}

.study-controls select {
  background-color: transparent;
  border: 0;
  border-radius: 0;
  font-size: 16px;
  min-height: 28px;
  padding: 0 28px 0 0;
}

.notes-list,
.history-list,
.attempt-list {
  display: grid;
  gap: 10px;
}

.backup-box {
  border: 1px dashed var(--line);
  border-radius: 18px;
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
}

.backup-box strong {
  display: block;
  font-size: 14px;
}

.backup-box p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  margin-top: 4px;
}

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

.backup-actions button {
  min-height: 40px;
  padding-inline: 14px;
}

.stack-panel .notes-list {
  display: flex;
  margin: 0 -2px;
  overflow-x: auto;
  padding: 2px 2px 4px;
  scroll-snap-type: x mandatory;
}

.stack-panel .note-card {
  flex: 0 0 min(78vw, 280px);
  scroll-snap-align: start;
}

.note-card,
.history-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  min-height: 0;
  padding: 14px;
  text-align: left;
  width: 100%;
}

.note-card {
  align-items: flex-start;
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.history-row {
  display: block;
}

.note-card-copy {
  display: block;
  min-width: 0;
}

.note-status-dot {
  background: #bdc1c6;
  border-radius: 999px;
  height: 10px;
  margin-top: 3px;
  width: 10px;
}

.note-status-dot.ready {
  background: var(--green);
}

.note-status-dot.pending {
  animation: status-pulse 1.2s ease-in-out infinite;
  background: var(--blue);
}

.note-status-dot.saved {
  background: var(--yellow);
}

.note-row {
  display: block;
}

.note-row.active .note-card {
  background: #e8f0fe;
  border-color: #aecbfa;
}

.note-card strong,
.history-row strong {
  display: block;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.note-card-copy > span,
.history-row small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.3;
  margin-top: 5px;
}

.note-understanding {
  align-self: center;
  color: var(--blue-dark);
  font-size: 15px;
  line-height: 1;
}

.library-panel .panel-header {
  align-items: center;
}

.library-panel .panel-header h2,
.editor-panel .panel-header h2 {
  font-size: 28px;
}

.home-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  display: grid;
  gap: 18px;
  padding: 22px;
}

.home-overview {
  align-items: stretch;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.42fr);
}

.home-copy {
  align-content: start;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.home-copy h2 {
  font-size: clamp(32px, 4vw, 46px);
  line-height: 1.05;
}

.home-label {
  color: var(--blue);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.2;
}

.status-banner {
  align-items: flex-start;
  background: #e8f0fe;
  border: 1px solid #aecbfa;
  border-radius: 18px;
  color: var(--blue-dark);
  display: flex;
  gap: 10px;
  padding: 12px;
}

.status-banner[hidden] {
  display: none;
}

.status-banner strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.status-banner p {
  color: #3c4043;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  margin-top: 3px;
}

.status-dot {
  animation: status-pulse 1.2s ease-in-out infinite;
  background: var(--blue);
  border-radius: 999px;
  flex: 0 0 auto;
  height: 10px;
  margin-top: 3px;
  width: 10px;
}

@keyframes status-pulse {
  0%, 100% {
    opacity: 0.35;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

.home-progress {
  background: var(--soft);
  border-radius: 22px;
  align-content: end;
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 22px;
}

.home-progress > div > span {
  display: block;
  font-size: 42px;
  font-weight: 850;
  line-height: 1;
}

.home-progress p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.home-progress p span {
  display: inline;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.actions,
.result-actions,
.form-actions,
.quiz-nav {
  align-items: stretch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0 18px;
}

.home-card > .actions {
  align-items: center;
  flex-direction: row;
  justify-content: flex-start;
  margin: 0;
}

.home-card > .actions button {
  min-width: 164px;
  width: auto;
}

.focus-panel > .actions {
  margin-top: 0;
}

.actions button,
.result-actions button,
.form-actions button,
.quiz-nav button {
  max-width: 100%;
  width: 100%;
}

.quiz-area {
  display: grid;
  gap: 12px;
}

.empty,
.error {
  background: var(--soft);
  border-radius: 18px;
  color: var(--muted);
  font-weight: 650;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 16px;
}

.error {
  color: #a33a2d;
}

.prep-line,
.grading-state {
  align-items: flex-start;
  background: #e8f0fe;
  border: 1px solid #aecbfa;
  border-radius: 18px;
  color: var(--blue-dark);
  display: flex;
  gap: 10px;
  padding: 12px;
}

.prep-line strong,
.grading-state strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.prep-line > div,
.grading-state > div {
  min-width: 0;
  width: 100%;
}

.prep-line p,
.grading-state p {
  color: #3c4043;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  margin-top: 3px;
}

.grading-state {
  background: var(--soft);
  border-color: var(--line);
  color: var(--ink);
}

.prep-progress {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.prep-progress > div:first-child {
  align-items: baseline;
  display: flex;
  gap: 6px;
}

.prep-progress > div:first-child span:first-child {
  color: var(--blue-dark);
  font-size: 18px;
  font-weight: 850;
  line-height: 1;
}

.prep-progress > div:first-child span:last-child {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.prep-progress-track {
  background: rgba(26, 115, 232, 0.14);
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

.prep-progress-track span {
  background: linear-gradient(90deg, var(--blue), var(--green));
  border-radius: inherit;
  display: block;
  height: 100%;
  transition: width 300ms ease;
}

.question-card,
.result-card,
.attempt-card {
  background: var(--soft);
  border-radius: 20px;
  padding: 16px;
}

.skeleton-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  display: grid;
  gap: 18px;
  padding: 18px;
}

.skeleton-header,
.skeleton-footer {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.skeleton-footer {
  align-items: flex-start;
  display: grid;
  justify-content: stretch;
}

.skeleton-footer strong {
  color: var(--ink);
  font-size: 15px;
}

.skeleton-footer span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.skeleton-line,
.skeleton-pill,
.skeleton-option {
  animation: skeleton-pulse 1.15s ease-in-out infinite;
  background: linear-gradient(90deg, #eef1f6 0%, #f8fafd 45%, #eef1f6 100%);
  background-size: 220% 100%;
  border-radius: 999px;
  display: block;
}

.skeleton-line {
  height: 14px;
  width: 52%;
}

.skeleton-line.tiny {
  width: 88px;
}

.skeleton-line.title {
  height: 34px;
  width: 76%;
}

.skeleton-line.wide {
  height: 18px;
  width: 92%;
}

.skeleton-pill {
  height: 28px;
  width: 96px;
}

.skeleton-options {
  display: grid;
  gap: 10px;
}

.skeleton-option {
  border-radius: 16px;
  height: 58px;
  width: 100%;
}

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

.question-topline {
  align-items: flex-start;
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 800;
  gap: 4px;
  grid-template-columns: minmax(0, 1fr) auto;
  line-height: 1.25;
  margin-bottom: 8px;
}

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

.hierarchy {
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.prompt {
  font-size: 22px;
  font-weight: 850;
  line-height: 1.2;
  margin-bottom: 14px;
  overflow-wrap: anywhere;
}

.quiz-active .prompt {
  font-size: clamp(24px, 7vw, 36px);
  margin: 8px 0 22px;
}

.choices {
  display: grid;
  gap: 8px;
}

.quiz-active .choices {
  align-content: start;
  gap: 12px;
  padding-bottom: 16px;
}

.choice {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  line-height: 1.25;
  min-height: 54px;
  text-align: left;
  white-space: normal;
  width: 100%;
}

.quiz-active .choice {
  border-radius: 18px;
  font-size: 17px;
  min-height: 64px;
  padding: 16px;
}

.choice.selected {
  background: #e8f0fe;
  border-color: var(--blue);
}

.result-card h2,
.session-heading h2 {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 8px;
}

.memory-evidence {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  gap: 5px;
  margin-top: 14px;
  padding: 12px;
}

.memory-evidence strong {
  color: var(--blue-dark);
  font-size: 13px;
}

.memory-evidence span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.note-form {
  display: grid;
  gap: 10px;
}

.manual-note-fields {
  display: grid;
  gap: 10px;
}

.manual-note-fields[hidden] {
  display: none;
}

.note-coach-box {
  background: #e8f0fe;
  border: 1px solid #aecbfa;
  border-radius: 18px;
  color: var(--blue-dark);
  display: grid;
  gap: 8px;
  padding: 14px 16px;
}

.note-coach-box[hidden] {
  display: none;
}

.note-coach-box strong {
  font-size: 14px;
}

.note-coach-box ul {
  color: var(--ink);
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
}

.note-coach-box li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

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

.source-chooser[hidden] {
  display: none;
}

.source-option {
  background: var(--soft);
  border: 1px solid transparent;
  border-radius: 16px;
  color: var(--muted);
  display: grid;
  gap: 3px;
  min-height: 70px;
  padding: 10px;
  text-align: left;
}

.source-option.active {
  background: #e8f0fe;
  border-color: #aecbfa;
  color: var(--blue-dark);
}

.source-option span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
}

.source-option small {
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
}

.math-box,
.book-box {
  background: #fef7e0;
  border: 1px solid #fdd663;
  border-radius: 18px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.book-box {
  background: #e6f4ea;
  border-color: #a8dab5;
}

.math-box[hidden],
.book-box[hidden] {
  display: none;
}

.math-box strong,
.book-box strong {
  color: #8a5a00;
  font-size: 13px;
}

.book-box strong {
  color: var(--green);
}

.math-box p,
.book-box p {
  color: #3c4043;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

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

.math-template-card,
.book-template-card {
  background: var(--bg);
  border: 1px solid #fdd663;
  border-radius: 14px;
  color: var(--ink);
  display: grid;
  gap: 4px;
  min-height: 0;
  padding: 12px;
  text-align: left;
  width: 100%;
}

.book-template-card {
  border-color: #a8dab5;
}

.math-template-card span,
.book-template-card span {
  font-size: 14px;
  font-weight: 850;
}

.math-template-card small,
.book-template-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.summary-box {
  background: #e8f0fe;
  border: 1px solid #aecbfa;
  border-radius: 18px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.summary-box[hidden] {
  display: none;
}

.summary-box span {
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 850;
}

.summary-box p {
  color: #3c4043;
  font-size: 14px;
  line-height: 1.4;
}

.wiki-box {
  background: var(--soft);
  border: 0;
  border-radius: 18px;
  display: none;
  gap: 12px;
  margin-top: 6px;
  padding: 12px;
}

.note-editor-new .wiki-box:not([hidden]) {
  display: grid;
}

.wiki-box[open] {
  background: #e8f0fe;
}

.wiki-box summary {
  align-items: center;
  color: var(--blue-dark);
  cursor: pointer;
  display: flex;
  font-size: 14px;
  font-weight: 800;
  justify-content: space-between;
  list-style: none;
}

.wiki-box summary::-webkit-details-marker {
  display: none;
}

.wiki-box summary small {
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 850;
}

.wiki-box[open] summary {
  margin-bottom: 10px;
}

.wiki-search,
.wiki-result {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.wiki-results {
  display: grid;
  gap: 8px;
}

.wiki-result {
  align-items: start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
}

.wiki-result p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  margin-top: 4px;
}

input,
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  outline: none;
  padding: 13px;
  width: 100%;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
  font-weight: 750;
  min-height: 48px;
  overflow: hidden;
  padding-right: 34px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

textarea {
  min-height: 260px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.14);
}

.history-row {
  align-items: flex-start;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.history-row b {
  color: var(--blue-dark);
  font-size: 22px;
  line-height: 1;
}

.session-detail {
  display: grid;
  gap: 14px;
}

.attempt-card {
  border-left: 4px solid var(--yellow);
}

.attempt-card.correct {
  border-left-color: var(--green);
}

.attempt-card h3 {
  margin-bottom: 12px;
}

dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

dl div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  margin-bottom: 4px;
  text-transform: uppercase;
}

dd {
  line-height: 1.35;
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 420px) {
  .shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .panel {
    border-radius: 20px;
    padding: 14px;
  }

  .app-header {
    margin-bottom: 12px;
  }

  .prompt {
    font-size: 20px;
  }
}

@media (max-width: 759px) {
  .shell {
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  .home-card {
    background: transparent;
    border: 0;
    border-radius: 0;
    align-content: start;
    box-shadow: none;
    gap: 12px;
    min-height: 0;
    padding: 0;
  }

  .home-overview {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
  }

  .home-copy h2 {
    font-size: 27px;
    line-height: 1.08;
    max-width: 12ch;
  }

  .home-copy .muted {
    display: -webkit-box;
    font-size: 14px;
    line-height: 1.38;
    max-height: calc(1.38em * 3);
    min-height: calc(1.38em * 3);
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .home-progress {
    background: transparent;
    border-top: 1px solid var(--line);
    border-radius: 0;
    display: flex;
    align-items: end;
    gap: 14px;
    min-height: auto;
    padding: 14px 0 0;
  }

  .home-progress > div > span {
    font-size: 36px;
  }

  .home-progress > .muted {
    font-size: 13px;
    line-height: 1.15;
    margin: 0 0 6px;
    white-space: nowrap;
  }

  .app-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  .brand-lockup {
    gap: 8px;
  }

  .app-logo {
    border-radius: 10px;
    height: 34px;
    width: 34px;
  }

  h1 {
    font-size: 30px;
  }

  .subtitle {
    display: none;
  }

  .status {
    font-size: 9px;
    max-width: 24vw;
    padding: 4px 7px;
  }

  .study-controls {
    border-radius: 20px;
  }

  .journey-switcher,
  .focus-switcher {
    gap: 4px;
    padding: 11px 12px;
  }

  .journey-switcher label,
  .focus-switcher label {
    font-size: 10px;
  }

  .study-controls select {
    font-size: 14px;
    min-height: 28px;
  }

  .actions {
    margin: 2px 0 0;
  }

  .actions button {
    min-height: 54px;
  }

  .status-banner {
    border-radius: 16px;
  }

  .notes-grid {
    align-items: start;
  }

  .library-editor .library-panel {
    display: none;
  }

  body:not(.library-editor) .editor-panel {
    display: none;
  }

  .library-panel,
  .editor-panel {
    border: 0;
    border-radius: 0;
    padding: 4px 0 0;
  }

  .notes-grid {
    gap: 0;
  }

  .library-panel .panel-header,
  .editor-panel .panel-header {
    padding-inline: 2px;
  }

  .library-panel .panel-header {
    margin-bottom: 12px;
  }

  .library-panel .panel-header h2,
  .editor-panel .panel-header h2 {
    font-size: 24px;
    line-height: 1.08;
  }

  .library-panel .panel-header .muted,
  .editor-panel .panel-header .muted {
    font-size: 13px;
    margin-top: 3px;
  }

  .note-card,
  .history-row {
    border-radius: 16px;
    padding: 18px;
  }

  .source-chooser {
    grid-template-columns: 1fr;
  }

  .source-option {
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 56px;
  }

  .source-option small {
    text-align: right;
  }

  textarea {
    min-height: 46vh;
  }

  body:not(.history-detail) .quiz-history-layout .detail-panel {
    display: none;
  }

  .history-detail .quiz-history-layout .history-panel {
    display: none;
  }

  .quiz-history-layout .history-panel,
  .quiz-history-layout .detail-panel {
    border: 0;
    border-radius: 0;
    padding: 4px 0 0;
  }

  .quiz-active .shell {
    padding: calc(10px + env(safe-area-inset-top)) 16px calc(10px + env(safe-area-inset-bottom));
  }

  .quiz-active .question-card {
    padding-top: 4px;
  }

  .quiz-active .prompt {
    font-size: clamp(24px, 7vw, 32px);
    margin: 8px 0 18px;
  }

  .quiz-active .choices {
    gap: 10px;
    padding-bottom: 8px;
  }

  .quiz-active .choice {
    min-height: 58px;
    padding: 14px 16px;
  }

  .quiz-nav {
    background: var(--bg);
    margin: 6px -2px 0;
    padding-top: 8px;
  }

  .quiz-nav .muted {
    display: none;
  }
}

@media (min-width: 760px) {
  .shell {
    padding: 28px 18px 56px;
  }

  .app-header {
    align-items: flex-end;
    display: flex;
    gap: 18px;
    justify-content: space-between;
  }

  h1 {
    font-size: 48px;
  }

  .app-logo {
    height: 58px;
    width: 58px;
  }

  .subtitle {
    font-size: 18px;
  }

  .tabbar {
    background: #eef1f6;
    border: 0;
    box-shadow: none;
    display: inline-flex;
    left: auto;
    margin: 26px 0 16px;
    padding: 4px;
    position: static;
    right: auto;
    width: auto;
  }

  .tab {
    min-height: 38px;
    padding-inline: 18px;
    width: auto;
  }

  .back-button {
    display: none;
  }

  .quiz-active .shell {
    max-width: 900px;
    padding: 28px 18px;
  }

  .quiz-active .question-card {
    min-height: calc(100vh - 56px);
    padding: 22px 10px;
  }

  .actions,
  .result-actions,
  .form-actions,
  .quiz-nav {
    align-items: center;
    flex-direction: row;
  }

  .actions button,
  .result-actions button,
  .form-actions button,
  .quiz-nav button {
    width: auto;
  }

  .wiki-search {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .wiki-result {
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (min-width: 980px) {
  .shell {
    width: min(960px, calc(100vw - 32px));
  }

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

  .quiz-history-layout {
    grid-template-columns: 340px minmax(0, 1fr);
  }

  .notes-grid {
    grid-template-columns: 340px minmax(0, 1fr);
  }

  .main-panel,
  .detail-panel {
    min-height: 560px;
  }

  .stack-panel .notes-list {
    display: grid;
    margin: 0;
    overflow: visible;
    padding: 0;
  }

  .stack-panel .note-card {
    flex-basis: auto;
  }

  textarea {
    min-height: 320px;
  }
}
