:root {
  color-scheme: dark;
  --bg: #1b1815;
  --pane: #151210;
  --card: #242019;
  --card-soft: #201c16;
  --text: #f1ece3;
  --muted: #a89f93;
  --border: #37312a;
  --accent: #93c47d;
  --accent-strong: #a8d68f;
  --accent-tint: #283020;
  --accent-ink: #17210f;
  --brand-r-dot: var(--text);
  --ok: #a3cf7a;
  --fel: #e59b7c;
  --radius: 18px;
  --radius-sm: 10px;
  --radius-control: 10px;
  --radius-tag: 6px;
  --font-display: "Literata", ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.14);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #faf5ec;
  --pane: #f1ebdf;
  --card: #fffdf8;
  --card-soft: #fbf6ec;
  --text: #2a251f;
  --muted: #786f63;
  --border: #e2d8c8;
  --accent: #4a7c3a;
  --accent-strong: #3d6a2f;
  --accent-tint: #e6efdc;
  --accent-ink: #ffffff;
  --brand-r-dot: var(--bg);
  --ok: #4a7c3a;
  --fel: #b4553a;
  --shadow: 0 22px 50px rgba(76, 60, 39, 0.12);
  --shadow-soft: 0 8px 22px rgba(76, 60, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", "Segoe UI", ui-rounded, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-strong);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.18;
}

h1 {
  font-size: clamp(2rem, 3.2vw, 2.8rem);
}

h2 {
  font-size: 1.4rem;
}

p {
  margin: 0;
}

strong {
  font-weight: 600;
}

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.9em;
}

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

.topbar,
.shell,
.footer {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px clamp(18px, 4vw, 48px);
}

.brand {
  display: inline-flex;
  align-items: center;
  width: 100%;
  color: var(--text);
}

.brand:hover {
  color: var(--text);
}

.brand-title {
  display: inline-flex;
  align-items: baseline;
  color: var(--text);
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}

.brand-letter--r {
  color: var(--accent);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topnav > a {
  color: var(--muted);
  font-weight: 600;
}

.topnav > a:hover {
  color: var(--text);
}

.icon-button {
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.icon-button:hover {
  background: var(--card-soft);
  color: var(--text);
}

[data-theme="dark"] .theme-label-light,
[data-theme="light"] .theme-label-dark {
  display: none;
}

.shell {
  padding-bottom: 40px;
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 12px clamp(18px, 4vw, 48px) 56px;
}

.page--narrow {
  width: min(820px, 100%);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.page-head > div {
  display: grid;
  gap: 8px;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
}

.lede {
  max-width: 62ch;
  color: var(--muted);
}

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

.hint {
  color: var(--muted);
  font-size: 0.86rem;
}

.error-text {
  color: var(--fel);
  font-size: 0.92rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-soft);
}

.empty {
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 32px;
}

.empty--inline {
  padding: 18px 0 0;
}

.flash {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto 18px;
  padding: 13px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-soft);
  font-weight: 600;
}

.flash--success {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--ok);
}

.flash--error {
  border-color: color-mix(in srgb, var(--fel) 50%, var(--border));
  color: var(--fel);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--card-soft);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
}

.button:hover {
  border-color: var(--border);
  background: var(--card);
  color: var(--text);
}

.button--primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}

.button--primary:hover {
  background: var(--accent-strong);
  color: var(--accent-ink);
}

.button--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.button--ghost:hover {
  border-color: var(--border);
  background: var(--card-soft);
  color: var(--text);
}

/* Header actions use the same outlined chip style as the chat top bar. */
.main-head .button--ghost {
  border-color: var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
}

.main-head .button--ghost:hover {
  border-color: var(--accent);
  background: var(--card);
  color: var(--accent);
}

.chat-settings-button {
  gap: 7px;
}

.button--quiet-danger {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.button--quiet-danger:hover {
  border-color: color-mix(in srgb, var(--fel) 45%, var(--border));
  background: transparent;
  color: var(--fel);
}

.button--danger {
  border-color: color-mix(in srgb, var(--fel) 55%, var(--border));
  background: transparent;
  color: var(--fel);
}

.button--danger:hover {
  border-color: var(--fel);
  color: var(--fel);
}

.button--small {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.84rem;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-tag);
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.pill--quiet {
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.status--ready {
  color: var(--ok);
}

.status--ready::before {
  background: var(--ok);
}

.status--building,
.status--pending {
  color: var(--accent);
}

.status--building::before,
.status--pending::before {
  background: var(--accent);
}

.status--failed {
  color: var(--fel);
}

.status--failed::before {
  background: var(--fel);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.project-card {
  display: grid;
  gap: 10px;
  padding: 22px;
  color: var(--text);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.project-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.project-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.86rem;
}

.project-card h2 {
  font-size: 1.35rem;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.86rem;
}

.stat-row strong {
  color: var(--text);
}

.form {
  display: grid;
  gap: 22px;
  padding: 26px;
}

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

.field label,
.field legend {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

fieldset.field {
  margin: 0;
  padding: 0;
  border: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="url"],
input[type="file"],
input[type="search"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--card-soft);
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

input[type="file"] {
  color: var(--muted);
  font-size: 0.84rem;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 140ms var(--ease), color 140ms var(--ease);
}

input[type="file"]::file-selector-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

input::placeholder,
textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 75%, transparent);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

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

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

.toggle-list {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--card-soft);
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.toggle-row:last-child {
  border-bottom: 0;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  flex: none;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.toggle-row strong {
  display: block;
  font-weight: 600;
}

.toggle-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
}

.choice {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--card-soft);
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.choice input {
  justify-self: start;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.choice__title {
  font-weight: 600;
}

.choice__desc {
  color: var(--muted);
  font-size: 0.83rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(0, 2.2fr) minmax(290px, 1fr);
  gap: 20px;
  align-items: start;
  padding: 0 clamp(18px, 4vw, 48px) 56px;
}

.rail,
.panel {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 16px;
}

.back-link {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.back-link:hover {
  color: var(--text);
}

.project-summary {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.project-summary h1 {
  font-size: clamp(1.7rem, 2.2vw, 2.2rem);
}

.facts {
  display: grid;
  gap: 8px;
  margin: 4px 0;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.facts > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.facts dt {
  color: var(--muted);
  font-size: 0.84rem;
}

.facts dd {
  margin: 0;
  font-weight: 600;
}

.content {
  display: grid;
  gap: 26px;
  min-width: 0;
}

.content > .card {
  padding: 26px;
}

.section {
  display: grid;
  gap: 12px;
}

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

.section-head > div {
  display: grid;
  gap: 4px;
}

.section-head h2 {
  font-size: 1.2rem;
}

.stack {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.stack > .button {
  justify-self: start;
}

.disclosure {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.disclosure summary {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.disclosure summary:hover {
  color: var(--accent-strong);
}

.material-list {
  display: grid;
  gap: 12px;
}

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

.material + .material {
  border-top: 1px solid var(--border);
}

.material.card {
  padding: 16px 20px;
}

.material__body {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.material__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.material__head strong {
  overflow-wrap: anywhere;
  font-weight: 600;
}

.kind {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.excerpt {
  color: var(--muted);
  font-size: 0.88rem;
}

.panel > .card {
  padding: 22px;
}

.concept-list,
.part-list {
  display: grid;
  gap: 14px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.part-list {
  gap: 12px;
  margin-top: 12px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
}

.concept {
  display: grid;
  gap: 7px;
}

.concept__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.concept p {
  color: var(--muted);
  font-size: 0.9rem;
}

.concept--part .concept__head strong {
  font-weight: 600;
}

.difficulty {
  flex: none;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
}

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

.chip {
  display: inline-flex;
  max-width: 100%;
  padding: 2px 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-tag);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part-group {
  padding-left: 2px;
}

.recent-questions {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.link-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}

.question-card {
  display: grid;
  gap: 20px;
  padding: 24px;
}

.question-prompt {
  font-size: 1.25rem;
  line-height: 1.6;
}

.option-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--card-soft);
}

.option__letter {
  display: grid;
  width: 24px;
  height: 24px;
  flex: none;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.answer {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
}

.flashcard-back {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
}

.flashcard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.flashcard-actions form {
  flex: 1 1 150px;
  margin: 0;
}

.flashcard-actions .button {
  width: 100%;
}

.solution {
  margin-top: 14px;
  color: var(--muted);
}

.question-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.question-actions form {
  margin: 0;
}

.chat-workspace {
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(0, 2.4fr) minmax(270px, 1fr);
  gap: 18px;
  align-items: start;
  padding: 0 clamp(18px, 4vw, 48px) 40px;
}

.chat-rail,
.chat-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.chat-center {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: calc(100vh - 150px);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-soft);
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.chat-head h1 {
  font-size: 1.5rem;
}

.chat-head__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.chat-feed-wrap {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  background: var(--bg);
}

.chat-feed {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  background: transparent;
}

/* The canvas fills the visible feed and the dot grid is shifted by the
   feed's scroll position, so the pattern moves with the messages. */
.chat-matrix {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  background-image: radial-gradient(
    circle at center,
    var(--matrix-dot-color, color-mix(in srgb, var(--text) 4%, transparent)) 0,
    var(--matrix-dot-color, color-mix(in srgb, var(--text) 4%, transparent)) var(--matrix-dot, 1.2px),
    transparent calc(var(--matrix-dot, 1.2px) + 0.2px)
  );
  background-size: var(--matrix-spacing, 20px) var(--matrix-spacing, 20px);
  background-position: 0 0;
  transition: opacity 600ms var(--ease);
}

.chat-matrix.is-ready {
  opacity: 1;
}

.chat-feed__inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 720px;
  margin: 0 auto;
}

.chat-me {
  align-self: flex-end;
  max-width: 85%;
  padding: 10px 16px;
  border-radius: 14px 14px 4px 14px;
  background: var(--accent-tint);
}

.chat-me--correct {
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--ok) 70%, transparent);
}

.chat-me--wrong {
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--fel) 75%, transparent);
}

.chat-me--ungraded {
  box-shadow: 0 0 0 1px var(--border);
}

.answer-state {
  position: absolute;
  top: -8px;
  left: -8px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.answer-state--correct {
  background: var(--ok);
  color: var(--bg);
}

.answer-state--wrong {
  background: var(--fel);
  color: var(--bg);
}

.answer-state--ungraded {
  border: 1px solid var(--border);
  background: var(--card-soft);
  color: var(--muted);
}

.chat-ai {
  display: grid;
  align-self: flex-start;
  gap: 8px;
  max-width: 100%;
}

.chat-ai--question {
  align-self: stretch;
  width: 100%;
  max-width: 100%;
}

.chat-move {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 6px;
  padding: 0;
  background: none;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
}

.chat-move::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.chat-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.web-citation,
.chat-markdown a.web-citation {
  padding: 0 2px;
  border-radius: 6px;
  background: transparent;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--muted) 24%, transparent);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-color 140ms var(--ease), box-shadow 140ms var(--ease);
}

.web-citation:hover,
.chat-markdown a.web-citation:hover {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, var(--border));
  color: inherit;
  text-decoration: none;
}

.web-citation__icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 3px;
  border-radius: 2px;
  object-fit: contain;
  vertical-align: -2px;
}

.source-preview {
  position: fixed;
  z-index: 80;
  max-width: 420px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 60vh;
  overflow-y: auto;
}

.source-preview strong {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.source-preview p {
  margin: 0;
}

.chat-text {
  line-height: 1.7;
}

.question-card--chat {
  gap: 16px;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: none;
}

.chat-composer {
  padding: 8px 24px 16px;
  border-top: 1px solid var(--border);
  background: var(--pane);
}

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

.chat-options form,
.chat-actions form {
  margin: 0;
}

.answer-option {
  display: flex;
  width: 100%;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--card-soft);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease);
}

.answer-option:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: var(--card);
}

.answer-option:hover .option__letter {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  color: var(--accent);
}

.blank-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 24px;
  margin: 0 3px;
  padding: 0 9px;
  border-bottom: 2px solid var(--accent);
  border-radius: 7px 7px 2px 2px;
  background: var(--accent-tint);
  color: var(--accent);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  vertical-align: 1px;
  transition: background-color 140ms var(--ease), box-shadow 140ms var(--ease);
}

.blank-slot:hover,
.blank-slot:focus-visible {
  background: color-mix(in srgb, var(--accent) 20%, var(--card));
  box-shadow: 0 0 0 1px var(--accent);
  outline: none;
}

.blank-slot--static {
  cursor: default;
  opacity: 0.72;
}

.blank-hint {
  position: fixed;
  z-index: 90;
  max-width: 270px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.8rem;
  line-height: 1.4;
  pointer-events: none;
}

.section-link {
  color: var(--muted);
  font-size: 0.75rem;
  text-decoration: none;
}

.section-link:hover {
  color: var(--accent);
}

.answer-result--correct {
  color: var(--ok);
}

.answer-result--wrong {
  color: var(--fel);
}

.answer-result--dont_know,
.answer-result--ungraded {
  color: var(--muted);
}

.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.chip-button.is-active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-tint);
  color: var(--accent);
}

.history-filter__count {
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.75rem;
}

.answer-history {
  display: grid;
  gap: 8px;
}

.answer-history__row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--card-soft);
}

.answer-history__state {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.answer-history__row--correct .answer-history__state {
  border-color: color-mix(in srgb, var(--ok) 55%, var(--border));
  color: var(--ok);
}

.answer-history__row--wrong .answer-history__state {
  border-color: color-mix(in srgb, var(--fel) 55%, var(--border));
  color: var(--fel);
}

.answer-history__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  color: var(--muted);
  font-size: 0.75rem;
}

.answer-history__prompt {
  margin-top: 6px;
  color: var(--text);
  line-height: 1.5;
}

.answer-history__answer {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.question-signal-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

.question-signal-summary details {
  max-width: 100%;
}

.question-signal-summary summary {
  cursor: pointer;
}

.question-signal-summary p {
  margin: 6px 0 0;
  color: var(--text);
}

.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-input input {
  flex: 1;
  min-width: 0;
}

.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chat-actions--next {
  margin-top: 0;
}

.chat-actions--inline {
  margin: -6px 0 8px;
  padding: 0;
}

.chip-button {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
}

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

.chip-button--danger {
  color: var(--muted);
}

.chip-button--danger:hover {
  border-color: color-mix(in srgb, var(--fel) 45%, var(--border));
  color: var(--fel);
}

.chat-complete {
  display: grid;
  gap: 10px;
}

.progress {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.progress__track,
.bar__track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.progress__track i,
.bar__track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 400ms ease;
}

.mastery-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.pattern-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.pattern-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.pattern-item span {
  overflow-wrap: anywhere;
}

.pattern-item em {
  flex: none;
  color: var(--muted);
  font-style: normal;
  font-weight: 500;
}

.bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  font-size: 0.82rem;
}

.bar em,
.pattern-item em,
.progress-percent {
  font-variant-numeric: tabular-nums;
}

.bar span {
  overflow-wrap: anywhere;
}

.bar em {
  color: var(--muted);
  font-style: normal;
}

.bar__track {
  grid-column: 1 / 3;
}

.option--correct {
  border-color: color-mix(in srgb, var(--ok) 55%, var(--border));
  background: color-mix(in srgb, var(--ok) 12%, var(--card-soft));
}

.option--wrong {
  border-color: color-mix(in srgb, var(--fel) 55%, var(--border));
  background: color-mix(in srgb, var(--fel) 12%, var(--card-soft));
}

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

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

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(18px, 4vw, 48px) 28px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
}

.ai-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

@media (max-width: 1100px) {
  .workspace,
  .chat-workspace {
    grid-template-columns: 1fr;
  }

  .rail,
  .panel {
    position: static;
  }

  .rail {
    order: -1;
  }

  .chat-center {
    height: auto;
    min-height: 70vh;
    order: -1;
  }

  .chat-rail {
    order: 0;
  }
}

@media (max-width: 760px) {
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .choice-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .chat-feed {
    padding: 14px;
  }

  .chat-head {
    padding: 14px;
  }

  .chat-composer {
    padding: 12px;
  }

  .chat-me {
    max-width: 92%;
  }

  .material {
    flex-direction: column;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* App shell inspired by prototype/chat-session.html */
html,
body {
  height: 100%;
}

body {
  overflow: hidden;
  font-size: 15px;
}

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 280px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 16px 12px;
  overflow-y: auto;
  background: var(--pane);
}

.sidebar--left {
  border-right: 1px solid var(--border);
}

.sidebar--right {
  gap: 24px;
  padding: 20px 16px;
  border-left: 1px solid var(--border);
}

.sidebar .brand {
  padding: 0 0 8px 4px;
}

.sidebar .brand-mark {
  width: 38px;
  height: 38px;
}

.new-project {
  justify-content: flex-start;
  width: 100%;
  border-color: var(--border);
  background: var(--card-soft);
}

.side-label,
.side-section .side-label {
  margin: 16px 6px 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
}

.project-nav {
  display: grid;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.nav-item:hover {
  color: var(--text);
  background: var(--card-soft);
}

.nav-item.is-active {
  color: var(--text);
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--border);
}

.nav-item > span {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.nav-item small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item b {
  flex: none;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.nav-sub {
  display: grid;
  gap: 2px;
  margin: 0 0 4px 12px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.nav-item--small {
  padding: 6px 8px;
  font-size: 0.78rem;
}

.nav-item--settings {
  color: var(--accent);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding: 12px 4px 0;
  border-top: 1px solid var(--border);
}

.icon-button--small {
  padding: 4px 6px;
  font-size: 0.74rem;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.main-head {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.main-head h1 {
  font-size: 1.65rem;
  letter-spacing: -0.015em;
}

.main-head small {
  color: var(--muted);
  font-size: 0.8rem;
}

.main-head .eyebrow {
  margin-bottom: 2px;
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.main-body {
  flex: 1;
  min-height: 0;
  padding: 24px 24px 40px;
  overflow-y: auto;
}

.main-body__inner {
  display: grid;
  gap: 16px;
  width: min(780px, 100%);
  margin: 0 auto;
}

.main-body .card {
  padding: 24px;
}

.chat-view {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.chat-view .chat-feed {
  min-height: 0;
}

.sidebar--right .side-section {
  display: grid;
  gap: 8px;
}

.side-text {
  color: var(--muted);
  font-size: 0.86rem;
}

.grade {
  display: flex;
  align-items: center;
  gap: 14px;
}

.grade strong {
  display: block;
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.grade small {
  color: var(--muted);
  font-size: 0.7rem;
}

.sidebar--right .mastery-list {
  margin-top: 0;
}

.sidebar--right .bar {
  font-size: 0.76rem;
}

.sidebar--right .bar__track {
  height: 4px;
}

.sidebar--right .bar__track i {
  background: color-mix(in srgb, var(--muted) 55%, var(--border));
}

.sidebar--right .bar:first-child .bar__track i {
  background: var(--accent);
}

.side-section--footer {
  gap: 8px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.flash--shell {
  width: auto;
  margin: 10px 20px 0;
  padding: 10px 14px;
  font-size: 0.86rem;
}

.welcome-card {
  display: grid;
  gap: 12px;
  justify-items: start;
}

.welcome-card h3 {
  font-size: 1.1rem;
}

.welcome-card--quiet {
  background: var(--card-soft);
}

.step-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.start-card {
  display: grid;
  gap: 16px;
}

.session-list {
  display: grid;
  gap: 0;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background-color 140ms var(--ease);
}

.session-item:hover {
  background: var(--card-soft);
  color: var(--text);
}

.session-item span {
  display: grid;
  gap: 2px;
}

.session-item strong {
  font-weight: 600;
}

.session-item small {
  color: var(--muted);
  font-size: 0.76rem;
}

.session-item em {
  font-style: normal;
}

.session-item__link {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
  color: inherit;
}

.session-item__chevron {
  flex: none;
  color: var(--muted);
}

.session-item:hover .session-item__chevron {
  color: var(--text);
}

.session-item__delete {
  flex: none;
  margin: 0;
}

.danger-card {
  border-color: color-mix(in srgb, var(--fel) 35%, var(--border));
}

.progress-card {
  display: grid;
  gap: 18px;
  padding: 28px !important;
}

.progress-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.progress-head > div {
  flex: 1;
}

.progress-spinner {
  width: 22px;
  height: 22px;
  flex: none;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: pluggassistent-spin 1s linear infinite;
}

.progress-percent {
  color: var(--accent);
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: 1.4rem;
  font-weight: 600;
}

.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.progress-bar--large {
  height: 12px;
}

.progress-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 450ms ease;
}

.progress-error {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--fel) 45%, var(--border));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--fel) 8%, var(--card-soft));
}

.progress-error[hidden] {
  display: none;
}

.mobile-tabs {
  display: none;
}

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

@media (max-width: 1000px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .sidebar,
  .main {
    display: none;
  }

  .app[data-tab="projects"] .sidebar--left,
  .app[data-tab="chat"] .main,
  .app[data-tab="stats"] .sidebar--right {
    display: flex;
  }

  .sidebar--left,
  .sidebar--right {
    border: 0;
  }

  .sidebar--right {
    overflow-y: auto;
  }

  .main-head {
    min-height: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px 12px;
  }

  .head-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 4px;
  }

  .main-body {
    padding: 16px 16px 32px;
  }

  .flash--shell {
    margin: 8px 16px 0;
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--border);
    background: var(--pane);
  }

  .mobile-tabs button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 0 10px;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
  }

  .mobile-tabs button svg {
    width: 18px;
    height: 18px;
  }

  .mobile-tabs button.is-active {
    color: var(--accent);
  }

  .chat-feed {
    padding: 16px;
  }

  .chat-composer {
    padding: 8px 16px 14px;
  }

  .chat-me {
    max-width: 92%;
  }

  .main-head h1 {
    font-size: 1.35rem;
  }

  .head-actions .button {
    min-height: 34px;
    padding: 6px 10px;
  }
}

/* Rich AI replies */
.chat-markdown {
  line-height: 1.7;
}

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

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

.chat-markdown p {
  margin: 0 0 0.7em;
}

.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3,
.chat-markdown h4 {
  margin: 0.9em 0 0.35em;
  font-size: 1.05rem;
}

.chat-markdown h1 {
  font-size: 1.25rem;
}

.chat-markdown ul,
.chat-markdown ol {
  margin: 0.4em 0 0.8em;
  padding-left: 1.4em;
}

.chat-markdown li {
  margin: 0.2em 0;
}

.chat-markdown pre {
  position: relative;
  margin: 0.7em 0;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}

.chat-markdown pre.has-copy {
  padding-top: 34px;
}

.chat-markdown pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.86rem;
}

.chat-markdown pre code.hljs {
  overflow: visible;
  padding: 0;
  background: transparent;
}

.code-copy {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 1;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease);
}

.chat-markdown pre:hover .code-copy,
.code-copy:focus-visible {
  opacity: 1;
}

.code-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (hover: none) {
  .code-copy {
    opacity: 1;
  }
}

.mermaid-diagram {
  margin: 0.8em 0;
  padding: 14px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-soft);
  text-align: center;
}

.mermaid-diagram svg {
  max-width: 100%;
  height: auto;
}

.mermaid-diagram--error {
  text-align: left;
}

.mermaid-diagram--error pre {
  margin: 0;
}

.diagram {
  margin: 0.9em 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--card-soft);
}

.diagram__title {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.diagram__flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

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

.diagram__node {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.4;
}

.diagram__node--effect {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-tint);
  font-weight: 600;
}

.diagram__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.diagram__timeline {
  position: relative;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0 0 0 18px;
  border-left: 2px solid var(--border);
  list-style: none;
}

.diagram__timeline li {
  position: relative;
}

.diagram__timeline li::before {
  position: absolute;
  top: 7px;
  left: -24px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--card-soft);
  content: "";
}

.diagram__time {
  display: block;
  color: var(--text);
  font-weight: 600;
  font-size: 0.86rem;
}

.diagram__events {
  display: grid;
  gap: 2px;
  margin-top: 3px;
}

.diagram__event {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.diagram__steps {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.diagram__step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.45;
}

.diagram__step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}

.diagram__comparison {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 9px;
}

.diagram__column {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
}

.diagram__column h4 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 0.82rem;
}

.diagram__column ul {
  margin: 0;
  padding-left: 1.1em;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.diagram__caption {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.5;
}

.diagram__item-text {
  min-width: 0;
}

.diagram__cite {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 5px;
  border: 1px solid var(--muted);
  border-radius: 50%;
  background: transparent;
  cursor: help;
  vertical-align: 2px;
}

.diagram__cite:hover,
.diagram__cite:focus-visible {
  border-color: var(--accent);
  background: var(--accent);
}

.source-conflicts {
  margin: 0.9em 0 0.4em;
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, var(--fel) 38%, var(--border));
  border-radius: var(--radius-control);
  background: color-mix(in srgb, var(--fel) 7%, var(--card-soft));
}

.source-conflicts__title {
  margin: 0 0 9px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.source-conflict + .source-conflict {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.source-conflict__topic {
  margin: 0 0 7px;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.4;
}

.source-conflict__positions {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.source-conflict__position {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.source-conflict__text {
  min-width: 0;
}

.diagram__cycle-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.diagram__cycle-step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.45;
}

.diagram__cycle-return {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
}

.diagram__decision {
  display: grid;
  gap: 10px;
}

.diagram__decision-question {
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: var(--accent-tint);
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.45;
}

.diagram__decision-label {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
}

.diagram__decision-branches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.diagram__branch {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
}

.diagram__branch-label {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 600;
}

.diagram__branch-outcome {
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.4;
}

@media (max-width: 600px) {
  .diagram__flow {
    grid-template-columns: 1fr;
  }

  .diagram__arrow {
    transform: rotate(90deg);
  }
}

.chat-markdown blockquote {
  margin: 0.7em 0;
  padding-left: 12px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}

.chat-markdown table {
  width: 100%;
  margin: 0.7em 0;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.chat-markdown th,
.chat-markdown td {
  padding: 7px 9px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.chat-markdown th {
  background: var(--card-soft);
  font-weight: 600;
}

.chat-markdown tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--card-soft) 55%, transparent);
}

.chat-markdown a {
  color: var(--accent);
  text-decoration: underline;
}

.chat-markdown hr {
  margin: 1em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.chat-thinking {
  max-width: 100%;
}

.thinking-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-soft);
}

.thinking-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.chat-input--main {
  margin-bottom: 8px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 13, 11, 0.72);
  backdrop-filter: blur(4px);
}

.loading-overlay[hidden] {
  display: none;
}

.loading-overlay__card {
  display: grid;
  gap: 16px;
  width: min(380px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.loading-overlay__card p {
  color: var(--muted);
  text-align: center;
}

.loading-indeterminate {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.loading-indeterminate i {
  display: block;
  width: 35%;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  animation: pluggassistent-loading-slide 1.1s ease-in-out infinite;
}

@keyframes pluggassistent-loading-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(330%);
  }
}

/* Messaging-style bubbles and floating composer */
.chat-ai {
  align-self: flex-start;
  max-width: min(85%, 640px);
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
}

.chat-ai--question {
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.chat-ai .chat-move {
  margin-bottom: 2px;
}

.chat-ai .chips {
  margin-top: 2px;
}

.chat-thinking {
  max-width: min(85%, 560px);
}

.chat-thinking,
.chat-waiting {
  animation: pluggassistent-thinking-in 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.is-leaving {
  opacity: 0 !important;
  transition: opacity 220ms ease;
}

@keyframes pluggassistent-thinking-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-thinking .thinking-card {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.chat-actions--composer {
  flex-wrap: nowrap;
  margin: 0 0 8px;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.chat-actions--composer::-webkit-scrollbar {
  display: none;
}

.chat-actions--composer form {
  flex: none;
  margin: 0;
}

.chat-input--main {
  padding: 4px 4px 4px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
}

.chat-input--main input {
  min-height: 36px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.chat-input--main input:focus {
  border: 0;
  box-shadow: none;
}

.send-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: none;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 140ms var(--ease);
}

.send-button:hover {
  background: var(--accent-strong);
}

.chip-button {
  flex: none;
  background: var(--card);
  box-shadow: var(--shadow-soft);
}

.chip-button--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.chip-button--primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: var(--accent-ink);
}

.chat-composer__hint {
  margin: 6px 4px 0;
}

.chat-waiting {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.progress-card[data-ai-job] .progress-bar i,
.progress-card[data-knowledge-map-progress] .progress-bar i,
.chat-thinking .progress-bar i {
  animation: pluggassistent-progress-pulse 1.6s ease-in-out infinite;
}

.progress-elapsed {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@keyframes pluggassistent-progress-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

@media (prefers-reduced-motion: reduce) {
  .progress-card[data-ai-job] .progress-bar i,
  .progress-card[data-knowledge-map-progress] .progress-bar i,
  .chat-thinking .progress-bar i {
    animation: none;
  }
}

/* Bookmarks and question footer */
.chat-me,
.chat-ai {
  position: relative;
}

.chat-me {
  padding-right: 64px;
}

.chat-ai:not(.chat-ai--question) {
  padding-right: 34px;
}

.message-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.message-actions .bookmark-form {
  position: static;
}

.bookmark-form {
  position: absolute;
  top: 6px;
  right: 6px;
  margin: 0;
}

.question-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.question-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.question-card__head .bookmark-form {
  position: static;
}

.bookmark-button,
.revert-button {
  display: grid;
  padding: 2px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  place-items: center;
  cursor: pointer;
  transition: color 140ms var(--ease);
}

.bookmark-button:hover,
.bookmark-button.is-bookmarked,
.revert-button:hover {
  color: var(--accent);
}

.question-card__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.question-card__footer form {
  margin: 0;
}

.chip-button--elaborate {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  color: var(--accent);
}

.chip-button--elaborate:hover {
  background: var(--accent-tint);
  color: var(--accent);
}

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

.bookmark-link {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-soft);
  color: var(--text);
  font-size: 0.78rem;
}

.bookmark-link:hover {
  border-color: var(--accent);
  color: var(--text);
}

.bookmark-link span:last-child {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-kind {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
}

.nav-new-chat {
  margin: 2px 0 4px;
}

.nav-new-chat__button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.nav-new-chat__button:hover {
  background: var(--card-soft);
  color: var(--accent);
}

.head-actions form {
  margin: 0;
}

/* Minimal in-chat thinking indicator */
.thinking-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.86rem;
}

.chat-thinking .thinking-line {
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 12px;
}

.thinking-matrix {
  display: grid;
  width: max-content;
  flex: none;
  grid-template-columns: repeat(4, 4px);
  grid-auto-rows: 4px;
  gap: 4px;
  margin-top: 3px;
}

.thinking-matrix i {
  display: block;
  border-radius: 50%;
  background: var(--border);
  transition: background-color 120ms linear;
}

.thinking-matrix i.is-gap {
  visibility: hidden;
}

.thinking-matrix[data-state="idle"] i.is-center {
  background: var(--accent);
}

.thinking-matrix[data-state="thinking"] i {
  animation: rotvux-matrix-pulse 1200ms ease-in-out infinite;
  animation-delay: calc(var(--d, 0) * 1ms);
}

.thinking-matrix[data-state="complete"] i {
  background: var(--accent);
}

@keyframes rotvux-matrix-pulse {
  0%,
  45%,
  100% {
    background-color: var(--border);
  }
  15% {
    background-color: var(--accent);
  }
}

.thinking-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.thinking-status {
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.35;
  transition:
    opacity 120ms var(--ease),
    transform 120ms var(--ease),
    filter 120ms var(--ease);
}

.thinking-status.is-swapping {
  opacity: 0;
  filter: blur(1.5px);
  transform: translateY(3px);
}

.thinking-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

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

@media (prefers-reduced-motion: reduce) {
  .thinking-matrix[data-state="thinking"] i {
    animation: none;
  }

  .thinking-matrix[data-state="thinking"] i.is-center {
    background: var(--accent);
  }

  .thinking-status.is-swapping {
    opacity: 1;
    filter: none;
    transform: none;
  }
}

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

.thinking-dots i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pluggassistent-thinking 1.2s ease-in-out infinite;
}

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

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

@keyframes pluggassistent-thinking {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes pluggassistent-thinking-fade {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

@keyframes pluggassistent-message-in {
  from {
    opacity: 0;
    transform: translateY(10px);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes pluggassistent-message-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.message-enter {
  animation: pluggassistent-message-in 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.type-char,
.type-whole {
  opacity: 0;
  animation: pluggassistent-type-in 220ms ease-out forwards;
}

@keyframes pluggassistent-type-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .message-enter,
  .chat-thinking,
  .chat-waiting {
    animation: pluggassistent-message-fade 300ms ease-out both;
  }

  .type-char,
  .type-whole {
    animation-duration: 160ms;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thinking-dots i {
    animation: pluggassistent-thinking-fade 1.8s ease-in-out infinite;
  }
}

.lava-lamp {
  margin: 0 auto 6px;
  color: var(--accent);
  font: 0.68rem/1.15 ui-monospace, "SFMono-Regular", Menlo, monospace;
  text-align: center;
  white-space: pre;
  opacity: 0.8;
}

/* Wider reading surface for math-heavy replies */
.chat-feed__inner {
  max-width: 860px;
}

.chat-ai {
  max-width: min(92%, 760px);
}

.chat-ai--question {
  max-width: 100%;
}

.chat-ai--feedback {
  max-width: min(97%, 840px);
}

.chat-ai--follow-up {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.chips form {
  margin: 0;
}

.chip--button {
  background: transparent;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

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

.chip--elaborate {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  color: var(--accent);
}

.chip--elaborate:hover {
  background: var(--accent-tint);
  color: var(--accent);
}

.chat-markdown .katex {
  font-size: 1.28em;
}

.chat-markdown .math-tex--display {
  display: block;
  max-width: 100%;
  margin: 0.75em 0;
  padding: 0.12em 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.chat-markdown .math-tex--display .katex-display {
  margin: 0.45em 0;
}

@media (max-width: 760px) {
  .chat-ai {
    max-width: 100%;
  }

  .chat-ai--feedback {
    max-width: 100%;
  }

  .chat-markdown .katex {
    font-size: 1.22em;
  }

  .question-card--chat {
    gap: 10px;
    padding: 12px;
  }

  .question-card--chat .option-list {
    gap: 4px;
  }

  .question-card--chat .answer-option {
    min-height: 38px;
    padding: 6px 12px;
  }

  .question-prompt {
    font-size: 1.15rem;
  }

  .chat-actions--inline {
    gap: 4px;
    margin: 0;
  }

  .chat-actions--inline .chip-button {
    padding: 6px 10px;
  }
}

@media (max-width: 360px) {
  .question-card--chat {
    gap: 8px;
    padding: 8px;
  }

  .question-card--chat .option-list {
    gap: 4px;
  }

  .question-card--chat .answer-option {
    min-height: 34px;
    padding: 4px 10px;
  }
}

/* Keep math legible in question cards and options too */
.question-prompt .katex,
.option .katex,
.answer-option .katex,
.answer .katex {
  font-size: 1.2em;
}

.question-prompt .katex-display,
.option .katex-display {
  max-width: 100%;
  margin: 0.55em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Photo answer upload in the chat composer */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-input-row .chat-input--main {
  flex: 1;
  min-width: 0;
}

/* Cards that live directly in the chat feed need their own padding */
.chat-feed__inner > .card {
  padding: 22px;
}

@media (max-width: 760px) {
  .chat-feed__inner > .card {
    padding: 16px;
  }
}

/* Chat tools: scan, file import and phone upload */
.chat-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.chat-tools form {
  margin: 0;
}

.chat-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
}

.chat-tool:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-tool input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.chat-tool svg {
  flex: none;
}

.math-tool-icon {
  font-family: ui-serif, Georgia, serif;
  font-size: 1rem;
  line-height: 1;
}

.math-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-soft);
}

.math-toolbar[hidden] {
  display: none;
}

.math-key {
  min-width: 34px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

.math-key:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.composer-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

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

.composer-status--phone {
  flex-wrap: wrap;
  justify-content: flex-start;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-soft);
  color: var(--text);
}

.composer-status--phone.is-error {
  border-color: var(--fel);
  color: var(--fel);
}

.composer-status--phone.is-error .thinking-dots {
  display: none;
}

.composer-status__close {
  margin-left: auto;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.composer-status__close:hover {
  color: var(--accent);
}

.chat-input {
  align-items: flex-end;
}

.chat-input--main textarea {
  flex: 1;
  width: auto;
  min-width: 0;
  min-height: 36px;
  max-height: 240px;
  padding: 8px 0;
  overflow-y: auto;
  border: 0;
  background: transparent;
  box-shadow: none;
  line-height: 1.45;
  resize: none;
}

.chat-input--main textarea:focus {
  border: 0;
  box-shadow: none;
}

/* Phone QR modal */
.phone-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  padding: 20px;
  place-items: center;
  background: rgba(10, 8, 6, 0.72);
  backdrop-filter: blur(4px);
}

.phone-modal[hidden] {
  display: none;
}

.phone-modal__card {
  position: relative;
  display: grid;
  width: min(360px, 100%);
  justify-items: center;
  gap: 12px;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
}

.phone-modal__card h2 {
  margin: 0;
}

.confirm-modal__card {
  width: min(460px, 100%);
  justify-items: stretch;
  text-align: left;
}

.confirm-modal__card h2 {
  font-size: 1.25rem;
  line-height: 1.3;
}

.confirm-modal__preview {
  max-height: 150px;
  margin: 0;
  padding: 12px 14px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--card-soft);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.confirm-modal__preview:empty {
  display: none;
}

.confirm-modal__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.phone-modal__close {
  position: absolute;
  top: 8px;
  right: 10px;
  padding: 2px 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.phone-modal__close:hover {
  color: var(--accent);
}

.phone-modal__qr {
  display: grid;
  min-height: 220px;
  padding: 8px;
  place-items: center;
  border-radius: 12px;
  background: #fff;
}

.phone-modal__qr canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.phone-modal__url {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.72rem;
}

.phone-modal__status {
  margin: 0;
  color: var(--accent);
  font-weight: 600;
}

/* Transcript review before scanned text is inserted into the composer */
.transcript-modal__card {
  width: min(520px, 100%);
  justify-items: stretch;
  text-align: left;
}

.transcript-modal__card h2 {
  margin: 0;
}

.transcript-modal__text {
  width: 100%;
  min-height: 150px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-soft);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
}

.transcript-modal__text:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-tint);
  outline-offset: 2px;
}

.transcript-modal__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.material__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.material__actions form {
  margin: 0;
}

/* Auth and billing */

.auth-body {
  display: flex;
  min-height: 100vh;
  margin: 0;
  padding: 24px;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
}

.auth-shell {
  display: grid;
  width: min(480px, 100%);
  gap: 18px;
  margin: 0 auto;
  padding: 34px 0 48px;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: var(--text);
  font-family: "Literata", Georgia, serif;
  font-size: 1.2rem;
  font-weight: 600;
  text-decoration: none;
}

.auth-brand__mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
}

.auth-card {
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow-soft, 0 18px 45px rgba(0, 0, 0, 0.18));
}

.auth-card__head {
  display: grid;
  gap: 6px;
  margin-bottom: 20px;
}

.auth-card__head h1 {
  margin: 0;
  font-size: 1.65rem;
  line-height: 1.2;
}

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

.auth-card .form {
  padding: 0;
}

.button--wide {
  width: 100%;
}

.auth-radio,
.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.4;
}

[hidden] {
  display: none !important;
}

.auth-radio input,
.auth-check input {
  width: auto;
  margin-top: 2px;
  accent-color: var(--accent);
}

.auth-check {
  margin: 2px 0 4px;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  font-size: 0.88rem;
}

.auth-links--center {
  justify-content: center;
  margin-top: 10px;
}

.auth-dev-link {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  text-align: center;
}

.auth-dev-link a {
  color: var(--accent);
}

.auth-links a,
.auth-switch a {
  color: var(--accent);
}

.auth-switch {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.auth-note,
.auth-foot {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
}

.auth-note {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.auth-foot {
  margin: 0;
}

.auth-errors {
  margin: 0;
  padding-left: 1.1em;
}

.auth-notice {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-soft);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.auth-notice p {
  margin: 0;
}

.account-foot {
  display: grid;
  gap: 4px;
  padding: 0 2px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  font-size: 0.78rem;
}

.account-email {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.account-link {
  width: fit-content;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.account-link--button {
  text-align: left;
}

.paywall-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--fel) 42%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--fel) 8%, var(--card-soft));
  color: var(--text);
  font-size: 0.88rem;
}

.plan-card {
  display: grid;
  gap: 18px;
}

.plan-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.plan-card__head h2 {
  margin: 4px 0 0;
  font-size: 1.35rem;
}

.plan-price {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.plan-price strong {
  color: var(--accent);
  font-size: 1.7rem;
  line-height: 1;
}

.plan-price span {
  color: var(--muted);
  font-size: 0.78rem;
}

.plan-features {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text);
  font-size: 0.92rem;
}

.plan-features li::before {
  margin-right: 8px;
  color: var(--accent);
  content: "✓";
}

.plan-status {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-soft);
  font-size: 0.88rem;
}

.plan-status span {
  color: var(--muted);
}

.plan-status strong {
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 560px) {
  .auth-body {
    padding: 14px;
  }

  .auth-shell {
    padding-top: 18px;
  }

  .auth-card {
    padding: 20px;
  }

  .plan-price {
    justify-items: start;
  }
}

/* Home dashboard */

.home-continue {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.home-continue h2 {
  margin: 4px 0 6px;
  font-size: 1.5rem;
}

.home-continue p {
  margin: 0;
}

/* Plan comparison */

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.plan-current {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.plan-current h2 {
  margin: 4px 0 6px;
}

.plan-current p {
  margin: 0;
}

.plan-card.is-current {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.plan-card--featured {
  background: color-mix(in srgb, var(--accent) 5%, var(--card));
}

.plan-badge {
  display: inline-flex;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

/* Profile and usage */

.profile-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.profile-summary h2 {
  margin: 4px 0 6px;
}

.profile-summary p {
  margin: 0;
}

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

.usage-card {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--card-soft);
}

.usage-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.usage-card__head strong {
  color: var(--text);
  font-size: 0.95rem;
}

.usage-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.usage-track i {
  display: block;
  width: calc(var(--v) * 100%);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.usage-table {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
}

.usage-table__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 90px;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.86rem;
}

.usage-table__row:last-child {
  border-bottom: 0;
}

.usage-table__head {
  background: var(--card-soft);
  color: var(--text);
  font-weight: 600;
}

.profile-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.profile-facts div {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-soft);
}

.profile-facts span {
  color: var(--muted);
  font-size: 0.78rem;
}

.profile-facts strong {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.profile-delete-form {
  display: grid;
  gap: 12px;
  max-width: 360px;
}

.profile-delete-form > .button {
  justify-self: start;
}

@media (max-width: 560px) {
  .usage-table__row {
    grid-template-columns: minmax(0, 1fr) 64px 64px;
  }
}
