:root {
  --ink: #2c3a42;
  --muted: #5d6d75;
  --paper: #eef3f6;
  --panel: rgba(247, 250, 248, 0.94);
  --card: #f7faf8;
  --line: rgba(44, 58, 66, 0.12);
  --accent: #5b8fa8;
  --accent-2: #7aa88a;
  --ok: #7aa88a;
  --accent-soft: rgba(91, 143, 168, 0.14);
  --danger: #8a5a52;
  --shadow: 0 12px 32px rgba(44, 58, 66, 0.08);
  --radius: 16px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Source Sans 3", "Manrope", sans-serif;
  --shell-max: 1180px;
  --shell-gutter: 2rem;
  --content-narrow: 520px;
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scrollbar-gutter: stable;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 8% -8%, rgba(91, 143, 168, 0.16), transparent 55%),
    radial-gradient(900px 500px at 92% 0%, rgba(122, 168, 138, 0.12), transparent 50%),
    linear-gradient(160deg, #eef3f6 0%, #f4f7f5 50%, #e8eef2 100%);
  line-height: 1.55;
  overflow-x: clip;
}

.bg-glow,
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.bg-grid {
  background-image:
    linear-gradient(rgba(20, 35, 31, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 35, 31, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 80%);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(var(--shell-max), calc(100% - var(--shell-gutter)));
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 2.5rem 0 4rem;
}

.content-narrow {
  width: min(var(--content-narrow), 100%);
  max-width: var(--content-narrow);
  margin-inline: auto;
}

.auth-shell {
  display: flex;
  align-items: center;
  min-height: calc(100vh - 1rem);
  padding-top: 2rem;
  padding-bottom: 2.5rem;
}

.auth-card-wrap {
  width: min(26rem, 100%);
  animation: rise 0.7s ease both;
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-logo.brand {
  margin: 0;
  font-size: clamp(2.35rem, 8vw, 3.15rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
  animation: authLogoIn 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-logo .brand-ai {
  position: relative;
}

.auth-logo .brand-ai-a {
  text-shadow: 0 0 28px rgba(15, 122, 102, 0.35);
}

.auth-logo .brand-ai-i {
  text-shadow: 0 0 28px rgba(217, 119, 6, 0.35);
}

.auth-tagline {
  margin: 0.7rem 0 0;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  animation: rise 0.8s ease 0.12s both;
}

.auth-heading {
  text-align: center;
  margin-bottom: 1.1rem;
  animation: rise 0.75s ease 0.18s both;
}

.auth-heading h1 {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3.5vw, 1.65rem);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.auth-heading .lede {
  margin: 0 auto;
  max-width: 22rem;
  font-size: 0.98rem;
}

.auth-panel {
  animation: rise 0.8s ease 0.22s both;
}

.auth-footer-link {
  margin-top: 1rem;
  text-align: center;
}

.auth-tools {
  display: grid;
  gap: 0.7rem;
  margin-top: 1.35rem;
}

.auth-tool {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: color-mix(in srgb, var(--panel) 78%, white 22%);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

a.auth-tool:hover,
a.auth-tool:focus-visible {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  box-shadow: 0 14px 28px rgba(15, 122, 102, 0.08);
}

.auth-tool-lang {
  grid-template-columns: auto 1fr auto;
}

.auth-tool-icon {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 12px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.auth-tool-icon svg {
  width: 1.15rem;
  height: 1.15rem;
}

.auth-tool-copy {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.auth-tool-copy strong {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.auth-tool-copy span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.auth-lang-switch {
  display: inline-flex;
  padding: 0.18rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 70%, white 30%);
  border: 1px solid var(--line);
}

.auth-lang-switch a {
  min-width: 2.15rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-decoration: none;
  color: var(--muted);
}

.auth-lang-switch a.is-active {
  background: var(--accent);
  color: #fff;
}

@media (max-width: 520px) {
  .auth-tool-lang {
    grid-template-columns: auto 1fr;
  }

  .auth-lang-switch {
    grid-column: 2;
    justify-self: start;
  }
}

@keyframes authLogoIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hero {
  margin-bottom: 1.35rem;
  animation: rise 0.7s ease both;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 2.55rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
}

.brand-ai {
  display: inline-block;
  font-size: 1.34em;
  font-weight: 700;
  line-height: 0.82;
  letter-spacing: -0.045em;
  vertical-align: -0.1em;
}

.brand-ai-a {
  color: var(--accent);
}

.brand-ai-i {
  color: var(--accent-2);
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  max-width: min(100%, 36rem);
  text-wrap: balance;
}

.hero-title-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.75rem;
  max-width: min(100%, 42rem);
}

.hero-title-row h1 {
  margin: 0;
  max-width: none;
  flex: 1 1 auto;
  min-width: 0;
}

.hero-title-row .btn-icon {
  color: var(--muted);
}

.hero-title-row .btn-icon:hover,
.hero-title-row .btn-icon:focus-visible {
  color: var(--accent);
}

.hero-title-row.is-editing h1,
.hero-title-row.is-editing #renameCategoryBtn {
  display: none;
}

.category-rename-form {
  flex: 1 1 auto;
  min-width: 0;
}

.category-rename-form input {
  width: 100%;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 0.7rem;
  padding: 0.15rem 0.6rem;
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.lede {
  margin: 0;
  max-width: min(100%, 42rem);
  color: var(--muted);
  font-size: 1.05rem;
  text-wrap: pretty;
}

.site-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  width: 100%;
  min-width: 0;
  margin-bottom: 1.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  animation: rise 0.55s ease both;
}

.brand-link {
  text-decoration: none;
  color: inherit;
  flex: 0 0 auto;
  max-width: 100%;
}

.site-bar .brand {
  font-size: clamp(1.35rem, 2.6vw, 1.85rem);
  line-height: 1.05;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem 0.65rem;
  flex: 1 1 18rem;
  min-width: 0;
}

.site-nav-links,
.site-nav-account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  min-width: 0;
}

.site-nav-links {
  flex: 1 1 auto;
  justify-content: flex-end;
}

.site-nav-account {
  padding-left: 0.65rem;
  margin-left: 0.1rem;
  border-left: 1px solid var(--line);
  gap: 0.4rem;
  flex: 0 1 auto;
}

.site-nav-link {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.site-nav-link:hover {
  color: var(--ink);
  background: rgba(15, 122, 102, 0.08);
  transform: translateY(-1px);
}

.site-nav-link.is-active {
  color: #fff;
  background: var(--accent);
}

.site-nav-link.is-active:hover {
  color: #fff;
  background: #0c6554;
}

.site-nav-user {
  display: inline-flex;
  align-items: center;
  max-width: 7.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
}

.site-nav-lang {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  padding: 0.32rem 0.6rem 0.32rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-decoration: none;
  line-height: 1;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.site-nav-lang:hover {
  color: var(--accent);
  border-color: rgba(15, 122, 102, 0.35);
  background: rgba(15, 122, 102, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 122, 102, 0.12);
}

.site-nav-lang-icon {
  display: block;
  flex-shrink: 0;
  opacity: 0.9;
}

.site-nav-lang-code {
  font-variant-numeric: tabular-nums;
}

.site-nav-logout:hover {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.12);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 1.4rem 1.4rem 1.5rem;
  animation: rise 0.55s ease both;
}

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

.panel h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 600;
}

.panel-note {
  margin: 0 0 1.1rem;
  color: var(--muted);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}

.panel-head .panel-note {
  margin-bottom: 0;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

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

.field span {
  font-weight: 600;
  font-size: 0.92rem;
}

.field input[type="file"],
.field input[type="email"],
.field input[type="password"],
.field input[type="text"],
.field input[type="search"],
.field input[type="date"],
.field input[type="number"],
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  background: #fff;
  font: inherit;
  color: var(--ink);
}

.field input[type="file"] {
  padding: 0.7rem;
}

.actions,
.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.footer-actions {
  margin-top: 1.25rem;
  justify-content: space-between;
}

.panel-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-top: 1.35rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.panel-footer-stacked {
  flex-direction: column;
  align-items: stretch;
}

.panel-footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-footer-start,
.panel-footer-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.panel-footer-end {
  margin-left: auto;
}

.form-grid > .panel-footer {
  grid-column: 1 / -1;
}

.wizard-toolbar,
.download-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
}

.wizard-toolbar-label,
.download-bar-label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.wizard-toolbar-actions,
.download-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.theory-block {
  width: 100%;
}

.theory-block-label {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.theory-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.35rem;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.78rem 1.2rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.btn-sm {
  padding: 0.48rem 0.85rem;
  font-size: 0.88rem;
}

.btn-icon {
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border-radius: 0.65rem;
}

.btn-icon .icon {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
  flex-shrink: 0;
}

.btn-download {
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: 0.65rem;
  font-size: 0.88rem;
}

.btn-download .icon {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
  flex-shrink: 0;
}

.galaxy-actions .btn-icon[data-action="delete"]:hover {
  color: #b42318;
  border-color: rgba(180, 35, 24, 0.35);
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: #0c6554;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--line);
  color: var(--ink);
}

.btn.quiz-fresh {
  background: #d4891a;
  color: #fff;
}

.btn.quiz-fresh:hover {
  background: #b87312;
}

.btn.quiz-continue {
  background: #6b45b0;
  color: #fff;
}

.btn.quiz-continue:hover {
  background: #56348f;
}

#quizActionsWrap {
  justify-content: flex-start;
}

.btn.quiz-fresh,
.btn.quiz-continue {
  white-space: nowrap;
}

.btn.theory-card {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  width: 100%;
  border-radius: 16px;
  padding: 0.95rem 1rem;
  text-align: left;
  border: 1px solid rgba(15, 122, 102, 0.22);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(15, 122, 102, 0.08));
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(20, 35, 31, 0.04);
}

.btn.theory-card:hover {
  border-color: rgba(15, 122, 102, 0.4);
  background: linear-gradient(160deg, #fff, rgba(15, 122, 102, 0.14));
  box-shadow: 0 12px 28px rgba(20, 35, 31, 0.08);
}

.btn.theory-card[data-theory="sweller"] {
  border-color: rgba(217, 119, 6, 0.28);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(217, 119, 6, 0.1));
}

.btn.theory-card[data-theory="sweller"]:hover {
  border-color: rgba(217, 119, 6, 0.45);
  background: linear-gradient(160deg, #fff, rgba(217, 119, 6, 0.16));
}

.btn.theory-card[data-theory="skinner"] {
  border-color: rgba(20, 35, 31, 0.16);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(20, 35, 31, 0.05));
}

.btn.theory-card[data-theory="skinner"]:hover {
  border-color: rgba(20, 35, 31, 0.28);
  background: linear-gradient(160deg, #fff, rgba(20, 35, 31, 0.08));
}

.btn.theory-card[data-theory="lindsley"] {
  border-color: rgba(29, 106, 138, 0.28);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(29, 106, 138, 0.1));
}

.btn.theory-card[data-theory="lindsley"]:hover {
  border-color: rgba(29, 106, 138, 0.45);
  background: linear-gradient(160deg, #fff, rgba(29, 106, 138, 0.16));
}

.btn.theory-card[data-theory="paivio"] {
  border-color: rgba(180, 83, 60, 0.28);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(180, 83, 60, 0.1));
}

.btn.theory-card[data-theory="paivio"]:hover {
  border-color: rgba(180, 83, 60, 0.45);
  background: linear-gradient(160deg, #fff, rgba(180, 83, 60, 0.16));
}

.theory-card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.theory-card-sub {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.toc-tree {
  display: grid;
  gap: 0.45rem;
  max-height: min(58vh, 560px);
  overflow: auto;
  padding-right: 0.25rem;
}

.toc-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.55rem 0.75rem;
}

.toc-item.level-section {
  margin-left: 1rem;
}

.toc-item.level-subsection {
  margin-left: 2rem;
}

.toc-item label {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  cursor: pointer;
}

.toc-item input {
  margin-top: 0.25rem;
  accent-color: var(--accent);
}

.toc-title {
  font-weight: 600;
}

.toc-meta {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.result-preview {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 1.25rem 1.35rem;
  max-height: min(65vh, 720px);
  overflow: auto;
}

.prose {
  overflow-wrap: break-word;
  padding: 20px;
}

.prose h1,
.prose h2,
.prose h3 {
  font-family: var(--font-display);
  line-height: 1.25;
}

.prose h1 { font-size: 1.7rem; }
.prose h2 {
  font-size: 1.35rem;
  margin-top: 1.4rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid rgba(91, 143, 168, 0.28);
}
.prose h3 {
  font-size: 1.1rem;
  margin-top: 1.15rem;
  color: #2a4d5e;
}

.prose p,
.prose li {
  color: #243430;
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1rem 0;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.prose th {
  background: rgba(91, 143, 168, 0.16);
  color: #243430;
  font-weight: 650;
}

.prose th,
.prose td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.6rem;
  text-align: left;
}

.prose h4,
.prose h5,
.prose h6 {
  font-family: var(--font-display);
  line-height: 1.3;
  margin-top: 1rem;
}

.prose h4 { font-size: 1.02rem; }
.prose h5,
.prose h6 { font-size: 0.95rem; }

.prose ul,
.prose ol {
  padding-left: 1.25rem;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.4rem 0;
}

.prose blockquote {
  margin: 1rem 0;
  padding: 0.15rem 0 0.15rem 0.95rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.prose pre {
  overflow-x: auto;
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(44, 58, 66, 0.05);
  font-size: 0.9rem;
  line-height: 1.45;
}

.prose :not(pre) > code {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  font-size: 0.9em;
  padding: 0.08em 0.35em;
  border-radius: 6px;
  background: rgba(44, 58, 66, 0.07);
}

.prose .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.35rem 0;
}

.prose .definition,
.prose .formula,
.prose .scientific-notation,
.prose .important,
.prose .warning,
.prose .example,
.prose .feedback,
.prose .diagram,
.prose .table,
.prose .graph,
.prose .code,
.prose .note {
  margin: 1.15rem 0;
  padding: 0.85rem 1.05rem 0.9rem 1.1rem;
  border-radius: 0 14px 14px 0;
  border-left: 5px solid var(--line);
  background: #fff;
  box-shadow: 0 8px 22px rgba(44, 58, 66, 0.06);
}

.prose .definition > :first-child,
.prose .formula > :first-child,
.prose .scientific-notation > :first-child,
.prose .important > :first-child,
.prose .warning > :first-child,
.prose .example > :first-child,
.prose .feedback > :first-child,
.prose .diagram > :first-child,
.prose .table > :first-child,
.prose .graph > :first-child,
.prose .code > :first-child,
.prose .note > :first-child {
  margin-top: 0;
}

.prose .definition > :last-child,
.prose .formula > :last-child,
.prose .scientific-notation > :last-child,
.prose .important > :last-child,
.prose .warning > :last-child,
.prose .example > :last-child,
.prose .feedback > :last-child,
.prose .diagram > :last-child,
.prose .table > :last-child,
.prose .graph > :last-child,
.prose .code > :last-child,
.prose .note > :last-child {
  margin-bottom: 0;
}

.prose .definition {
  border-left-color: #2f6fad;
  background: #e8f1f8;
}

.prose .formula,
.prose .scientific-notation {
  border-left-color: #6b45b0;
  background: #f1ebf8;
}

.prose .feedback {
  border-left-color: #2f8a6a;
  background: #e6f4ee;
}

.prose .important {
  border-left-color: #d4891a;
  background: #f8f0e2;
}

.prose .warning {
  border-left-color: #c45c52;
  background: #f7ecea;
}

.prose .example {
  border-left-color: #1f9aa8;
  background: #e6f4f6;
}

.prose .diagram,
.prose .graph {
  border-left-color: #4a6d8c;
  background: #eef2f5;
}

.prose .table {
  border-left-color: #3d7a9e;
  background: #eaf3f7;
  overflow-x: auto;
}

.prose .code,
.prose .note {
  border-left-color: #5c6570;
  background: #eef0f2;
}

.prose :is(.definition, .formula, .scientific-notation, .important, .warning, .example, .feedback, .diagram, .table, .graph, .code, .note)
:is(.definition, .formula, .scientific-notation, .important, .warning, .example, .feedback, .diagram, .table, .graph, .code, .note) {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.toast {
  position: fixed;
  z-index: 40;
  left: auto;
  right: 1rem;
  bottom: var(--ff-toast-bottom, 1.25rem);
  transform: none;
  background: var(--ink);
  color: #fff;
  padding: 0.8rem 1.1rem;
  border-radius: 12px;
  max-width: min(90vw, 420px);
  box-shadow: var(--shadow);
}

.toast.is-error {
  background: var(--danger);
}

body.has-transform-jobs .toast {
  bottom: var(--ff-toast-bottom, 5.75rem);
}

.transform-jobs {
  position: fixed;
  z-index: 38;
  left: auto;
  right: 1rem;
  bottom: 1rem;
  width: min(22rem, calc(100vw - 2rem));
  display: grid;
  gap: 0.4rem;
}

.transform-jobs[hidden] {
  display: none !important;
}

.transform-jobs-head {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
}

.transform-jobs-toggle {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 14px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-weight: 650;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.transform-jobs-cancel-all {
  flex: 0 0 auto;
  align-self: center;
  box-shadow: var(--shadow);
}

.transform-jobs-pulse {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(15, 122, 102, 0.45);
  animation: transform-jobs-pulse 1.6s ease-out infinite;
  flex: 0 0 auto;
}

@keyframes transform-jobs-pulse {
  0% { box-shadow: 0 0 0 0 rgba(15, 122, 102, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(15, 122, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(15, 122, 102, 0); }
}

.transform-jobs-list {
  list-style: none;
  margin: 0;
  padding: 0.45rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  max-height: min(40vh, 18rem);
  overflow: auto;
  display: grid;
  gap: 0.35rem;
  box-shadow: var(--shadow);
}

.transform-jobs-list[hidden] {
  display: none !important;
}

.transform-jobs-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
  padding: 0.35rem 0.4rem;
  font-size: 0.88rem;
}

.transform-jobs-list .job-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.transform-jobs-list .job-status {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
}

.transform-jobs-list .job-cancel {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--danger, #b42318);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  padding: 0.15rem 0.25rem;
}

.material-section.is-converting .btn[data-section-action="convert"] {
  pointer-events: none;
  opacity: 0.72;
}

.material-card.is-converting [data-convert-all] {
  pointer-events: none;
  opacity: 0.72;
}

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

.model-caps {
  margin-top: 0.55rem;
  display: grid;
  gap: 0.4rem;
}

.cap-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.cap-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}

.cap-vision { border-color: #7eb8a0; background: #e8f6f0; }
.cap-tools { border-color: #8aa3d9; background: #eef2fb; }
.cap-thinking { border-color: #c4a46a; background: #f8f1e3; }
.cap-web_search { border-color: #9bb0c9; background: #eef4f9; }
.cap-code { border-color: #a48bc4; background: #f4eef9; }
.cap-audio { border-color: #c98b9b; background: #f9eef1; }

.cap-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: 0.15rem;
}

.cap-desc {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--muted);
}

.prompt-panel {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  padding: 0;
  margin-top: 0.25rem;
}

.prompt-panel[hidden] {
  display: none !important;
}

.prompt-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  font-weight: 650;
  user-select: none;
}

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

.prompt-chevron {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
  flex: 0 0 auto;
}

.prompt-panel[open] .prompt-chevron {
  transform: rotate(-135deg);
}

.prompt-body {
  padding: 0 1rem 1rem;
  display: grid;
  gap: 0.65rem;
}

.prompt-editor {
  width: 100%;
  min-height: 12rem;
  resize: vertical;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 0.84rem;
  line-height: 1.45;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

.prompt-editor:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
}

.prompt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.checkbox-field .checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
}

.checkbox-field input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}

.section-files {
  margin-top: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  padding: 1rem 1.1rem;
}

.section-files h3 {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.section-file {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 0.55rem;
  overflow: hidden;
}

.section-file summary {
  cursor: pointer;
  padding: 0.7rem 0.85rem;
  font-weight: 600;
}

.section-file .section-body {
  border-top: 1px solid var(--line);
  padding: 0.85rem 1rem;
  max-height: 320px;
  overflow: auto;
}

.usage-box {
  margin-top: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  padding: 1rem 1.1rem;
}

.usage-box h3 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.usage-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.5rem 0 0.75rem;
}

.usage-chip {
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  background: var(--accent-soft);
  font-size: 0.84rem;
  font-weight: 600;
}

.usage-list {
  display: grid;
  gap: 0.45rem;
  font-size: 0.9rem;
}

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

.usage-list pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  max-height: 180px;
  overflow: auto;
  font-size: 0.78rem;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(16, 28, 25, 0.42);
  backdrop-filter: blur(4px);
  display: grid;
  place-content: center;
  gap: 0.85rem;
  color: #fff;
  text-align: center;
  padding: 1rem;
}

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

.overlay-panel {
  width: min(28rem, calc(100vw - 2rem));
  background: rgba(18, 32, 30, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 1.55rem 1.4rem 1.3rem;
  box-shadow: 0 22px 56px rgba(8, 16, 14, 0.32);
}

.overlay-panel #overlayText {
  margin: 0.85rem 0 0;
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.35;
}

.overlay-subtext {
  margin: 0.45rem 0 0;
  font-size: 0.94rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.86);
}

.overlay-progress {
  display: grid;
  gap: 0.45rem;
  margin-top: 1rem;
}

.overlay-progress-track {
  height: 0.72rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.overlay-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8ef0cf, #4ecdc4 55%, #7ed0f0);
  box-shadow: 0 0 12px rgba(78, 205, 196, 0.45);
  transition: width 0.45s ease;
  position: relative;
}

.overlay-progress-fill.is-active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.42), transparent);
  animation: overlay-shimmer 1.35s ease-in-out infinite;
}

.overlay-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.82);
}

@keyframes overlay-shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 1rem;
}

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

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 28, 25, 0.48);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 26rem);
  padding: 1.35rem 1.4rem 1.2rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.98), rgba(244, 248, 246, 0.96));
  box-shadow: 0 22px 48px rgba(20, 35, 31, 0.16);
}

.modal-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.25;
}

.modal-lede {
  margin: 0.45rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.modal-card .field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.modal-card .field span {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.modal-card select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  background: #fff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

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

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

@media (max-width: 900px) {
  .site-nav {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .site-nav-links {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .shell {
    --shell-gutter: 1.1rem;
    width: min(var(--shell-max), calc(100% - var(--shell-gutter)));
    padding-top: 1.25rem;
    padding-bottom: 2.25rem;
  }

  .auth-shell {
    min-height: calc(100dvh - 1rem);
    padding-top: 1.15rem;
    padding-bottom: 1.5rem;
    align-items: flex-start;
  }

  .panel-head,
  .footer-actions,
  .panel-footer,
  .panel-footer-row {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-footer-end {
    margin-left: 0;
    width: 100%;
  }

  .panel-footer-end .btn,
  .panel-footer-start .btn {
    width: 100%;
  }

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

  .site-bar {
    padding: 0.75rem;
  }

  .site-nav-account {
    padding-left: 0;
    margin-left: 0;
    border-left: 0;
    width: 100%;
  }

  .toc-item.level-section {
    margin-left: 0.5rem;
  }

  .toc-item.level-subsection {
    margin-left: 1rem;
  }
}

/* Auth / library / interactive */
.shell-narrow {
  /* Kept for markup compatibility: full shell width; use .content-narrow for forms */
  width: min(var(--shell-max), calc(100% - var(--shell-gutter)));
  max-width: var(--shell-max);
}

.shell-wide {
  /* Same width as .shell — kept for markup compatibility */
  width: min(var(--shell-max), calc(100% - var(--shell-gutter)));
  max-width: var(--shell-max);
}

.form-error {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(180, 35, 24, 0.35);
  background: #fff6f5;
  border-radius: 12px;
  color: var(--danger);
  font-weight: 600;
}

.form-success {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(15, 122, 102, 0.35);
  background: rgba(15, 122, 102, 0.08);
  border-radius: 12px;
  color: var(--accent);
  font-weight: 600;
}

.content-wide {
  width: 100%;
}

.users-table-wrap {
  overflow-x: auto;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.users-table th,
.users-table td {
  text-align: left;
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.users-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #667);
  font-weight: 600;
}

.users-table .chip {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(15, 122, 102, 0.12);
  color: var(--accent);
  vertical-align: middle;
}

.switch-form {
  margin: 0;
}

.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  user-select: none;
}

.switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.switch {
  position: relative;
  width: 2.6rem;
  height: 1.45rem;
  border-radius: 999px;
  background: #c9cdd4;
  transition: background 0.18s ease;
  flex-shrink: 0;
}

.switch.is-on {
  background: var(--accent);
}

.switch.is-disabled {
  opacity: 0.7;
}

.switch-knob {
  position: absolute;
  top: 0.18rem;
  left: 0.18rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease;
}

.switch.is-on .switch-knob {
  transform: translateX(1.15rem);
}

.switch-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.switch-locked {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.settings-section + .settings-section {
  margin-top: 1.25rem;
}

.settings-section-title {
  margin: 0 0 0.35rem;
  font-family: "Fraunces", serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.resume-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(15, 122, 102, 0.28);
  border-radius: 14px;
  background: rgba(15, 122, 102, 0.08);
}

.resume-banner[hidden] {
  display: none !important;
}

.resume-banner .panel-note {
  margin: 0.25rem 0 0;
}

.resume-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.transform-actions {
  justify-content: flex-start;
  gap: 0.65rem;
}

.library-galaxy {
  display: grid;
  gap: 1.5rem;
  animation: rise 0.55s ease both;
}

.library-galaxy[hidden] {
  display: none !important;
}

.galaxy-empty {
  text-align: center;
  padding: 2.2rem 1.4rem;
}

.galaxy-empty h3 {
  margin: 0.35rem 0 0.6rem;
  font-family: var(--font-display);
}

.galaxy-cluster {
  position: relative;
  display: grid;
  gap: 0;
  padding: 1.25rem;
  border: 1px solid rgba(15, 122, 102, 0.18);
  border-radius: 24px;
  background:
    radial-gradient(700px 280px at 12% 0%, rgba(15, 122, 102, 0.12), transparent 55%),
    radial-gradient(500px 240px at 88% 100%, rgba(217, 119, 6, 0.1), transparent 50%),
    rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.galaxy-cluster::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(15, 122, 102, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 122, 102, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at 30% 20%, black 20%, transparent 75%);
  pointer-events: none;
}

.galaxy-source {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem 1.15rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(15, 122, 102, 0.28);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
}

.galaxy-source-orb {
  position: relative;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
}

.galaxy-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(15, 122, 102, 0.35);
  animation: galaxyPulse 2.4s ease-out infinite;
}

.galaxy-core {
  position: relative;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #127a66, #0c5a4c);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 0 0 6px rgba(15, 122, 102, 0.12);
}

.galaxy-source-body h3,
.galaxy-node-card h4 {
  margin: 0.15rem 0 0.35rem;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
}

.galaxy-source-body h3 {
  font-size: 1.3rem;
}

.galaxy-node-card h4 {
  font-size: 1.12rem;
}

.galaxy-kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.galaxy-meta {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.galaxy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.galaxy-conduit {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.35rem 0 0.55rem;
  padding: 0.35rem 0.25rem;
}

.galaxy-conduit-line {
  flex: 1;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(15, 122, 102, 0.15), rgba(15, 122, 102, 0.55), rgba(217, 119, 6, 0.45));
  position: relative;
  overflow: hidden;
}

.galaxy-conduit-line::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 28%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  animation: galaxyScan 2.8s linear infinite;
}

.galaxy-conduit-label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.galaxy-outputs {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.85rem;
}

.galaxy-node {
  position: relative;
  min-width: 0;
}

.galaxy-node-beam {
  position: absolute;
  left: 50%;
  top: -0.55rem;
  width: 2px;
  height: 0.55rem;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(15, 122, 102, 0.45), rgba(15, 122, 102, 0.05));
}

.galaxy-node-card {
  height: 100%;
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.galaxy-node.is-live .galaxy-node-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(20, 35, 31, 0.08);
}

.galaxy-node.tone-adhd.is-live .galaxy-node-card {
  border-color: rgba(15, 122, 102, 0.35);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.95), rgba(15, 122, 102, 0.1));
}

.galaxy-node.tone-sweller.is-live .galaxy-node-card {
  border-color: rgba(217, 119, 6, 0.38);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.95), rgba(217, 119, 6, 0.12));
}

.galaxy-node.tone-skinner.is-live .galaxy-node-card {
  border-color: rgba(20, 35, 31, 0.22);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.95), rgba(20, 35, 31, 0.06));
}

.galaxy-node.tone-lindsley.is-live .galaxy-node-card {
  border-color: rgba(29, 106, 138, 0.38);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.95), rgba(29, 106, 138, 0.12));
}

.galaxy-node.tone-paivio.is-live .galaxy-node-card {
  border-color: rgba(180, 83, 60, 0.38);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.95), rgba(180, 83, 60, 0.12));
}

.galaxy-node.is-pending .galaxy-node-card {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.45);
  opacity: 0.88;
}

.galaxy-node.is-pending .galaxy-kicker {
  color: var(--muted);
}

@keyframes galaxyPulse {
  0% { transform: scale(0.85); opacity: 0.85; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

@keyframes galaxyScan {
  from { transform: translateX(-20%); }
  to { transform: translateX(380%); }
}

@media (max-width: 860px) {
  .galaxy-outputs {
    grid-template-columns: 1fr;
  }

  .galaxy-node-beam {
    display: none;
  }

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

@media (min-width: 560px) and (max-width: 860px) {
  .galaxy-outputs {
    grid-template-columns: 1fr 1fr;
  }
}

.upload-preview {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.88rem;
  line-height: 1.5;
  max-height: 65vh;
  overflow: auto;
  margin: 0;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.exercise-widget {
  position: relative;
  margin: 1.1rem 0;
  padding: 1rem 1.05rem;
  border-left: 3px solid var(--accent);
  background: rgba(15, 122, 102, 0.06);
  border-radius: 0 12px 12px 0;
}

.exercise-frame {
  border-left-color: var(--accent-2);
  background: rgba(217, 119, 6, 0.07);
}

.exercise-question {
  margin: 0 0 0.75rem;
  font-weight: 600;
}

.exercise-question > :first-child,
.exercise-info > :first-child,
.sprint-item-prompt > :first-child {
  margin-top: 0;
}

.exercise-question > :last-child,
.sprint-item-prompt > :last-child {
  margin-bottom: 0;
}

.exercise-widget img,
.exercise-choice img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.55rem 0;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.exercise-choice span {
  min-width: 0;
  flex: 1;
  line-height: 1.45;
}

.exercise-choice span > :first-child,
.exercise-choice span p {
  margin-top: 0;
}

.exercise-choice span > :last-child,
.exercise-choice span p {
  margin-bottom: 0;
}

.exercise-info {
  margin-bottom: 0.85rem;
}

.exercise-info > :first-child {
  margin-top: 0;
}

.exercise-choices {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.exercise-choice {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  cursor: pointer;
  font-weight: 500;
}

.exercise-choice > input[type="radio"] {
  flex: 0 0 auto;
  width: 1.05rem;
  height: 1.05rem;
  margin: 0.22em 0 0;
  accent-color: var(--accent);
}

[data-quiz-exam="1"] .exercise-widget > .exercise-check {
  display: none !important;
}

.exercise-input {
  display: block;
  width: min(100%, 28rem);
  margin-bottom: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  background: #fff;
}

.exercise-feedback {
  margin-top: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  font-weight: 600;
}

.exercise-feedback.is-correct {
  background: rgba(15, 122, 102, 0.14);
  color: #0c6554;
}

.exercise-feedback.is-wrong {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

.exercise-feedback.is-warn {
  background: rgba(217, 119, 6, 0.14);
  color: #92400e;
}

.exercise-nested {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
}

.exercise-sprint {
  border-left-color: #1d6a8a;
  background: rgba(29, 106, 138, 0.07);
}

.sprint-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-bottom: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sprint-timer {
  color: #1d6a8a;
}

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

.sprint-stage {
  display: grid;
  gap: 0.75rem;
  justify-items: start;
}

.sprint-item-prompt {
  margin: 0;
  font-weight: 600;
}

.app-body {
  min-height: 100vh;
}

.app-frame {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.app-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 1.25rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #d7e6ef;
  border-right: 1px solid #b4cddc;
}

.sidebar-brand {
  font-size: 1.35rem;
  margin-bottom: 0.15rem;
}

.sidebar-welcome {
  margin: 0 0 0.15rem;
  padding: 0 0.15rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.tone-blue {
  --tone-bg: #e8f1f8;
  --tone-bg-hot: #d5e6f3;
  --tone-edge: #2f6fad;
  --tone-line: #b7cfe0;
}

.tone-green {
  --tone-bg: #e6f4ee;
  --tone-bg-hot: #d3ecdf;
  --tone-edge: #2f8a6a;
  --tone-line: #b5d9c8;
}

.tone-purple {
  --tone-bg: #f1ebf8;
  --tone-bg-hot: #e5daf3;
  --tone-edge: #6b45b0;
  --tone-line: #d0c0e4;
}

.tone-sand {
  --tone-bg: #f8f0e2;
  --tone-bg-hot: #f0e3cc;
  --tone-edge: #d4891a;
  --tone-line: #e3d0a8;
}

.tone-teal {
  --tone-bg: #e6f4f6;
  --tone-bg-hot: #d2eaee;
  --tone-edge: #1f9aa8;
  --tone-line: #b3d6dc;
}

.tone-rose {
  --tone-bg: #f7ecea;
  --tone-bg-hot: #efddd9;
  --tone-edge: #c45c52;
  --tone-line: #e0c4c0;
}

.add-course-card,
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card.tone-blue,
.card.tone-green,
.card.tone-purple,
.card.tone-sand,
.card.tone-teal,
.card.tone-rose {
  background: var(--tone-bg);
  border-color: var(--tone-line);
  border-left: 5px solid var(--tone-edge);
}

.add-course-card {
  display: grid;
  gap: 0.25rem;
  text-align: left;
  padding: 1rem 1.1rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.add-course-card:hover,
.category-card:hover,
.courses-nav-card.is-active {
  background: var(--tone-bg-hot, var(--accent-soft));
}

.add-course-kicker,
.card-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.add-course-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.courses-nav-card {
  text-decoration: none;
}

.sidebar-spacer { flex: 1; }

.sidebar-footer {
  display: grid;
  gap: 0.35rem;
  padding: 0.55rem;
  background: #e8f1f8;
  border: 1px solid #b7cfe0;
  border-left: 5px solid #2f6fad;
  border-radius: var(--radius);
}

.sidebar-link {
  color: var(--ink);
  text-decoration: none;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
}

.sidebar-link.is-active,
.sidebar-link:hover {
  background: #d5e6f3;
}

.app-main {
  padding: 1.75rem 2rem 3rem;
  max-width: 960px;
}

.app-mobile-bar,
.app-nav-backdrop {
  display: none;
}

.app-nav-toggle {
  appearance: none;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(247, 250, 248, 0.92);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.app-nav-toggle-bars,
.app-nav-toggle-bars::before,
.app-nav-toggle-bars::after {
  display: block;
  width: 1.15rem;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

.app-nav-toggle-bars {
  position: relative;
}

.app-nav-toggle-bars::before,
.app-nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
}

.app-nav-toggle-bars::before {
  top: -6px;
}

.app-nav-toggle-bars::after {
  top: 6px;
}

body.is-nav-open .app-nav-toggle-bars {
  background: transparent;
}

body.is-nav-open .app-nav-toggle-bars::before {
  top: 0;
  transform: rotate(45deg);
}

body.is-nav-open .app-nav-toggle-bars::after {
  top: 0;
  transform: rotate(-45deg);
}

.section-card-grid,
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
}

.section-card {
  display: grid;
  gap: 0.25rem;
  text-align: left;
  padding: 1rem 1.1rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.section-card.level-section {
  box-shadow: none;
}

.section-card.level-subsection {
  box-shadow: none;
  opacity: 0.96;
}

.section-card.is-selected,
.section-card:hover {
  background: var(--accent-soft);
}

.section-card.is-selected {
  border-color: var(--accent);
}

.category-card {
  position: relative;
  display: block;
  padding: 0;
  text-decoration: none;
  color: inherit;
}

.category-card-link {
  display: block;
  padding: 1.15rem 2.7rem 1.15rem 1.2rem;
  text-decoration: none;
  color: inherit;
}

.category-card h2 {
  margin: 0.35rem 0 0.4rem;
  font-size: 1.2rem;
}

.category-card-delete {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 1;
}

.empty-card {
  padding: 1.5rem;
}

.material-rows {
  display: grid;
  gap: 0.85rem;
}

.material-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1.1rem 1.25rem;
  align-items: center;
}

.material-info h2 {
  margin: 0 0 0.3rem;
  font-size: 1.1rem;
}

.material-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.btn-danger {
  color: #9b2335;
  border-color: rgba(155, 35, 53, 0.28);
}

.btn-danger:hover {
  background: rgba(155, 35, 53, 0.08);
}

.material-cards {
  display: grid;
  gap: 0.9rem;
}

.material-card {
  padding: 0;
  overflow: hidden;
}

.material-card-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.05rem 1.2rem;
  cursor: pointer;
}

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

.material-card-toggle {
  width: 1.4rem;
  height: 1.4rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--tone-bg-hot, var(--accent-soft));
  position: relative;
}

.material-card-toggle::before {
  content: '';
  position: absolute;
  inset: 0.42rem 0.38rem 0.42rem 0.52rem;
  border-style: solid;
  border-width: 0.28rem 0 0.28rem 0.38rem;
  border-color: transparent transparent transparent var(--tone-edge, var(--accent));
}

.material-card[open] .material-card-toggle::before {
  inset: 0.52rem 0.38rem 0.32rem;
  border-width: 0.38rem 0.28rem 0 0.28rem;
  border-color: var(--tone-edge, var(--accent)) transparent transparent transparent;
}

.material-card-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.material-card-heading h2 {
  margin: 0;
  font-size: 1.12rem;
}

.material-card-heading .card-meta {
  margin: 0.25rem 0 0;
}

.material-card-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}

.material-card-summary .btn {
  flex: 0 0 auto;
  margin-left: 0;
}

@media (max-width: 720px) {
  .material-card-summary {
    flex-wrap: wrap;
  }

  .material-card-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
}

.material-card-body {
  border-top: 1px solid var(--line);
  padding: 0.35rem 0.6rem 0.85rem;
}

.material-sections {
  list-style: none;
  margin: 0;
  padding: 0;
}

.material-section {
  margin: 0;
}

.material-section .material-sections {
  margin-left: 0.85rem;
  padding-left: 0.7rem;
  border-left: 1px solid var(--line);
}

.material-section-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  padding: 0.7rem 0.55rem;
  border-radius: 12px;
}

.material-section-row:hover {
  background: var(--accent-soft);
}

.material-section-info {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
  flex: 1 1 220px;
}

.material-section-info strong {
  font-size: 1rem;
}

.material-section-info .section-status {
  display: inline-block;
  margin-right: 0.35rem;
  font-size: 0.95rem;
  line-height: 1;
  vertical-align: middle;
}

.section-status.is-mastered {
  color: #c9a227;
}

.section-status.is-completed {
  color: var(--accent);
}

.section-status.is-continue {
  color: var(--muted);
}

.section-status.is-fresh {
  color: var(--line);
}

.material-section.is-locked > .material-section-row {
  opacity: 0.72;
}

.material-section.is-locked > .material-section-row:hover {
  background: transparent;
}

.material-section.is-locked .material-section-info strong {
  color: var(--muted);
}

.section-lock-hint {
  margin: 0.15rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.section-status.is-locked {
  color: var(--muted);
}

.progress-meta .review-badge {
  display: inline-block;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #7a4a00;
  background: rgba(255, 193, 7, 0.22);
  border: 1px solid rgba(255, 193, 7, 0.45);
}

.section-est-time {
  display: block;
  margin: 0.2rem 0 0;
}

.pomodoro-meter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.pomodoro-tomato {
  display: block;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  filter: drop-shadow(0 1px 1px rgba(120, 24, 12, 0.28));
}

.tomato-body-empty {
  fill: #f4d4cc;
}

.tomato-body-full {
  fill: #e5392b;
}

.tomato-shine {
  fill: #ff8a7a;
  opacity: 0.55;
}

.tomato-outline {
  fill: none;
  stroke: #9e2418;
  stroke-width: 1.8;
}

.tomato-stem {
  fill: none;
  stroke: #2d6b32;
  stroke-width: 2.6;
  stroke-linecap: round;
}

.tomato-leaf-l { fill: #3cb054; }
.tomato-leaf-r { fill: #248a38; }
.tomato-leaf-c { fill: #1f7a30; }
.tomato-leaf-bl { fill: #46c05c; }
.tomato-leaf-br { fill: #2d8f40; }

.material-section-info .section-est-time {
  margin: 0.18rem 0 0.05rem;
}

.material-section-info .card-kicker {
  font-size: 0.72rem;
}

.material-section-info .progress-meta {
  margin: 0.15rem 0 0;
}

.material-section .material-actions {
  margin-top: 0;
}

.progress-track {
  height: 10px;
  background: rgba(91, 143, 168, 0.15);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--ok));
}

.progress-meta {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.settings-card {
  padding: 1.2rem 1.3rem 1.25rem;
  margin-bottom: 1rem;
}

.settings-card[hidden] {
  display: none !important;
}

.settings-card:target {
  display: block !important;
}

.settings-page .hero {
  margin-bottom: 1rem;
}

.settings-jump {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.25rem;
}

.settings-jump-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
  min-height: 6.1rem;
  padding: 1.05rem 1.15rem 1.1rem;
  border-radius: 16px;
  text-decoration: none;
  color: var(--ink);
  background: var(--tone-bg, #fff);
  border: 1px solid var(--tone-line, var(--line));
  border-left: 6px solid var(--tone-edge, var(--accent));
  box-shadow: var(--shadow);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.settings-jump-title {
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.settings-jump-item:hover,
.settings-jump-item.is-active {
  background: var(--tone-bg-hot, var(--accent-soft));
  transform: translateY(-1px);
}

.settings-jump-item.is-active {
  box-shadow: 0 0 0 3px var(--tone-line, var(--accent-soft));
}

.settings-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem 1rem;
  margin-bottom: 1rem;
}

.settings-card-head .card-kicker {
  color: var(--tone-edge, var(--muted));
  font-weight: 750;
}

.settings-card-head h2 {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.settings-card-note {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.settings-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}

.settings-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  line-height: 1.3;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.settings-jump-item .settings-badge {
  font-size: 0.84rem;
  padding: 0.26rem 0.7rem;
}

button.settings-badge {
  appearance: none;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 750;
  cursor: pointer;
}

button.settings-badge:hover {
  filter: brightness(0.97);
}

.settings-badge.is-ok {
  background: #d8f0e4;
  border-color: #8ec9ae;
  color: #1f6b4c;
}

.settings-badge.is-warn {
  background: #f8ead2;
  border-color: #e0c08a;
  color: #8a5a12;
}

.settings-badge.is-off {
  background: #eceff2;
  border-color: #cfd6dc;
  color: #5d6d75;
}

.settings-badge.is-danger {
  background: #f8e4e7;
  border-color: #e0a8b2;
  color: #9b2335;
}

.settings-badge.is-info {
  background: #e4eef8;
  border-color: #b7cfe0;
  color: #2f6fad;
}

.settings-badge.is-key {
  background: #e8f1f8;
  border-color: #b7cfe0;
  color: #2f6fad;
}

.settings-badge.is-muted {
  background: rgba(255, 255, 255, 0.65);
  border-color: var(--line);
  color: var(--muted);
}

.settings-badge.is-admin {
  background: #eee6f7;
  border-color: #cbbce3;
  color: #5b3d96;
}

.settings-badge.is-method {
  background: #e6f4ee;
  border-color: #b5d9c8;
  color: #2f8a6a;
}

.settings-fields {
  display: grid;
  gap: 0.9rem;
}

.settings-fields .field select {
  padding: 0.35rem 0.7rem;
  line-height: 1.2;
  min-height: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
}

.settings-llm-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.9rem;
  align-items: end;
}

.settings-llm-pair .field {
  min-width: 0;
}

.settings-fields .settings-llm-pair,
.settings-fields .model-caps {
  grid-column: 1 / -1;
}

@media (max-width: 719px) {
  .settings-llm-pair {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

.settings-key-fields {
  display: grid;
  gap: 0.65rem;
}

.settings-key-field {
  display: grid;
  gap: 0.28rem;
  margin: 0;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.settings-key-field span {
  font-size: 0.88rem;
  font-weight: 650;
}

.settings-key-field.is-current {
  border-color: #b7cfe0;
  background: #e8f1f8;
  box-shadow: 0 0 0 1px #b7cfe0;
}

.settings-fields-stack {
  grid-template-columns: 1fr;
}

.settings-users-policy {
  margin-bottom: 0.85rem;
}

.settings-actions {
  display: flex;
  justify-content: flex-start;
}

.settings-choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.settings-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.settings-preset {
  appearance: none;
  border: 1px solid var(--tone-line, var(--line));
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.48rem 0.8rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.settings-preset:hover {
  background: var(--tone-bg-hot, var(--accent-soft));
}

.settings-preset.is-active {
  background: var(--tone-edge, var(--accent));
  border-color: var(--tone-edge, var(--accent));
  color: #fff;
}

.settings-choice-custom {
  width: 5.4rem;
}

.settings-choice-custom input {
  width: 100%;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 0.48rem 0.4rem;
}

.settings-card .field-hint {
  margin: 0;
}

.settings-card .btn.primary {
  background: var(--tone-edge, var(--accent));
}

.settings-card .btn.primary:hover {
  background: var(--tone-edge, var(--accent));
  filter: brightness(0.92);
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  cursor: pointer;
  font-weight: 650;
  width: fit-content;
}

.settings-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.settings-toggle-ui {
  position: relative;
  width: 2.7rem;
  height: 1.5rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #c5ccd1;
  transition: background 0.18s ease;
}

.settings-toggle-ui::after {
  content: "";
  position: absolute;
  top: 0.18rem;
  left: 0.18rem;
  width: 1.14rem;
  height: 1.14rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease;
}

.settings-toggle input:checked + .settings-toggle-ui {
  background: var(--tone-edge, var(--ok));
}

.settings-toggle input:checked + .settings-toggle-ui::after {
  transform: translateX(1.18rem);
}

.settings-toggle input:focus-visible + .settings-toggle-ui {
  outline: 2px solid var(--tone-edge, var(--accent));
  outline-offset: 3px;
}

.settings-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 0.55rem;
}

.settings-fieldset > legend {
  font-weight: 750;
  margin-bottom: 0.15rem;
}

.settings-radio {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--tone-line, var(--line));
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.settings-radio:hover {
  background: var(--tone-bg-hot, var(--accent-soft));
}

.settings-radio input {
  margin-top: 0.2rem;
  flex: 0 0 auto;
}

.settings-radio-body {
  display: grid;
  gap: 0.12rem;
}

.settings-radio-body strong {
  font-size: 0.98rem;
}

.settings-users {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.settings-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.7rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--tone-line, var(--line));
}

.settings-user-avatar {
  width: 2.15rem;
  height: 2.15rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--tone-bg-hot, var(--accent-soft));
  color: var(--tone-edge, var(--accent));
  font-weight: 800;
  font-size: 0.95rem;
}

.settings-user-meta {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
  flex: 1 1 auto;
}

.settings-user-meta strong {
  font-size: 0.98rem;
}

.settings-user-meta span {
  color: var(--muted);
  font-size: 0.84rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-user-toggle,
.settings-user-delete {
  margin: 0;
}

.settings-user-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex: 0 0 auto;
}

@media (min-width: 720px) {
  .settings-fields {
    grid-template-columns: 1fr 1fr;
  }

  .settings-fields .field-wide,
  .settings-fields .settings-key-fields,
  .settings-fields .settings-actions,
  .settings-fields .settings-toggle {
    grid-column: 1 / -1;
  }

  .settings-fields-stack {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .settings-card-head {
    flex-direction: column;
  }

  .settings-badges {
    justify-content: flex-start;
  }

  .settings-jump {
    grid-template-columns: 1fr;
  }

  .settings-jump-item {
    min-height: 0;
  }

  .settings-user {
    flex-wrap: wrap;
  }

  .settings-user-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .usage-toolbar .field,
  .logs-toolbar .field,
  .analytics-range .field {
    min-width: 0;
    flex: 1 1 100%;
  }

  .progress-course-head {
    flex-wrap: wrap;
  }

  .category-grid,
  .section-card-grid {
    grid-template-columns: 1fr;
  }

  .settings-card {
    padding: 1rem 0.95rem 1.05rem;
  }

  .modal-card {
    width: min(460px, calc(100% - 1.25rem));
    padding: 1.1rem 1rem 1.15rem;
  }

  .log-tabs {
    width: 100%;
    border-radius: 16px;
  }
}

.usage-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1.1rem;
}

.usage-toolbar .field {
  min-width: 140px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 1.1rem;
}

.stat {
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.stat b {
  display: block;
  font-size: 1.25rem;
}

.stat span {
  color: var(--muted);
  font-size: 0.85rem;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1.1rem;
}

.mini-table th,
.mini-table td {
  text-align: left;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--line);
}

.event {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.5rem;
}

.event-title {
  font-weight: 600;
}

.event-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.log-list {
  display: grid;
  gap: 0.55rem;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.75rem 0.9rem;
}

.log-meta {
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}

.log-msg {
  font-weight: 700;
}

.consent-text {
  line-height: 1.6;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.88rem;
}

.crumb {
  margin: 0 0 0.35rem;
}

.crumb a { color: var(--accent); }

.study-text {
  white-space: pre-wrap;
  font: inherit;
}

body.is-study-focus {
  overflow: hidden;
}

.study-focus {
  position: fixed;
  inset: 0;
  z-index: 28;
  display: grid;
  place-items: center;
  padding: 1.1rem 1.15rem 1.25rem;
}

.study-focus-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 16, 18, 0.72);
  backdrop-filter: blur(16px) saturate(0.55);
  -webkit-backdrop-filter: blur(16px) saturate(0.55);
}

.study-focus-stage {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: calc(100vh - 2.2rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.75rem;
}

.study-focus-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  min-height: 3.2rem;
}

.study-focus-close {
  flex: 0 0 auto;
  background: rgba(247, 250, 248, 0.92);
  color: var(--ink);
}

.study-pomo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-left: auto;
  padding: 0.25rem 0.7rem 0.25rem 0.25rem;
  border-radius: 999px;
  background: rgba(247, 250, 248, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 10px 28px rgba(8, 16, 14, 0.18);
  color: var(--ink);
}

.study-pomo[hidden] {
  display: none !important;
}

.study-pomo-visual {
  display: grid;
  place-items: center;
}

.study-pomo .pomodoro-tomato-live {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  filter: drop-shadow(0 2px 3px rgba(120, 24, 12, 0.28));
}

.study-pomo-meta {
  display: grid;
  gap: 0.08rem;
  padding-right: 0.35rem;
  min-width: 8.5rem;
}

.study-pomo-time {
  margin: 0;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  font-size: 1.02rem;
  line-height: 1.2;
}

.study-pomo-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
  max-width: 16rem;
}

.study-pomo.is-complete .pomodoro-tomato-live {
  filter: drop-shadow(0 0 10px rgba(229, 57, 43, 0.45));
}

.study-pomo.is-over {
  border-color: rgba(229, 57, 43, 0.35);
}

.study-pomo.is-over .study-pomo-hint {
  color: #9e2418;
}

.study-focus .study-card {
  overflow: auto;
  max-height: 100%;
  padding: 1.25rem 1.4rem 1.6rem;
  box-shadow: 0 28px 64px rgba(8, 16, 14, 0.28);
}

.study-focus .study-card.prose {
  padding: 1.25rem 1.4rem 1.6rem;
}

.study-card.is-framed.has-study-steps {
  isolation: isolate;
}

.study-step {
  position: relative;
  margin: 0 -0.35rem;
  padding: 0.85rem 0.85rem 0.35rem;
  border-radius: 16px;
  transition: filter 0.28s ease, opacity 0.28s ease, transform 0.28s ease;
}

.study-card.is-framed.has-study-steps .study-step:not(.is-current) {
  filter: blur(6px);
  opacity: 0.34;
  pointer-events: none;
  user-select: none;
}

.study-card.is-framed.has-study-steps .study-step.is-current {
  z-index: 2;
  filter: none;
  opacity: 1;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 10px 28px rgba(8, 16, 14, 0.08);
}

.study-card.is-framed.has-study-steps.is-complete .study-step {
  filter: none;
  opacity: 1;
  pointer-events: auto;
  background: transparent;
  box-shadow: none;
}

.study-step-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.55rem;
  margin: 0.7rem 0 0.35rem;
}

.study-step-skip {
  color: var(--muted);
}

.exercise-retry {
  margin-top: 0.65rem;
}

.review-due-card {
  margin-bottom: 1.25rem;
  padding: 1.25rem 1.4rem 1.35rem;
}

.review-due-card h2 {
  margin: 0 0 0.45rem;
}

.review-due-card .lede {
  margin: 0 0 0.9rem;
}

.review-due-card .btn {
  margin-top: 0;
}

.review-list {
  display: grid;
  gap: 1rem;
}

.review-list-item .btn {
  margin-top: 0.75rem;
}

.hero-compact {
  margin-bottom: 1rem;
}

.math-display {
  margin: 0.75rem 0;
  overflow-x: auto;
}

.study-step-meta {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.study-focus #quizHost,
.study-focus .quiz-host {
  padding: 0;
}

.study-focus .quiz-host > .exercise-widget:first-child,
.study-focus #quizHost > .exercise-widget:first-child {
  margin-top: 0;
}

.study-focus .study-card > .footer-actions {
  margin-top: 1.15rem;
  margin-bottom: 0;
  padding-top: 0.15rem;
}

.study-focus .study-card > .panel-note {
  margin: 0 0 1rem;
}

.app-dialog {
  z-index: 80;
  padding: 1.15rem;
}

.app-dialog .modal-backdrop {
  background: rgba(16, 28, 25, 0.46);
  backdrop-filter: blur(8px);
}

.app-dialog .modal-card {
  width: min(100%, 24.5rem);
  padding: 1.45rem 1.45rem 1.25rem;
  animation: rise 0.2s ease;
  text-align: center;
}

.app-dialog-mark {
  width: 2.6rem;
  height: 2.6rem;
  margin: 0 auto 0.75rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
}

.app-dialog-mark svg {
  width: 1.25rem;
  height: 1.25rem;
}

.app-dialog.is-confirm .app-dialog-mark {
  color: var(--accent-2);
  background: rgba(122, 168, 138, 0.18);
}

.app-dialog.is-danger .app-dialog-mark,
.app-dialog.is-danger .modal-card {
  border-color: rgba(138, 90, 82, 0.28);
}

.app-dialog.is-danger .app-dialog-mark {
  color: var(--danger);
  background: rgba(138, 90, 82, 0.14);
}

.app-dialog .modal-card h2 {
  font-size: 1.28rem;
}

.app-dialog .modal-lede {
  margin: 0.45rem 0 1.2rem;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
  text-wrap: pretty;
}

.app-dialog .modal-actions {
  justify-content: center;
  flex-wrap: wrap;
}

.app-dialog .modal-actions .btn {
  min-width: 7.5rem;
}

.app-dialog .btn.primary.btn-danger {
  color: #fff;
  background: #8a5a52;
  border-color: transparent;
}

.app-dialog .btn.primary.btn-danger:hover {
  filter: brightness(1.06);
}

body.is-app-dialog-open {
  overflow: hidden;
}

.study-focus-heading {
  margin: 0 0 1rem;
}

.study-focus-heading h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  line-height: 1.25;
}

.study-focus-heading .lede {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

@media (max-width: 720px) {
  .study-focus {
    padding: max(0.5rem, env(safe-area-inset-top)) 0.55rem max(0.65rem, env(safe-area-inset-bottom));
    place-items: stretch;
  }

  .study-focus-stage {
    max-height: calc(100vh - 1.3rem);
    max-height: calc(100dvh - 1.3rem);
  }

  .study-focus-bar {
    flex-wrap: wrap;
  }

  .study-pomo {
    width: 100%;
    margin-left: 0;
  }

  .study-pomo-meta {
    min-width: 0;
    flex: 1;
  }
}

.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(44, 58, 66, 0.28);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(460px, calc(100% - 2rem));
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem 1.4rem;
  box-shadow: var(--shadow);
}

.switch, .checkbox-row {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

@media (max-width: 860px) {
  html {
    scrollbar-gutter: auto;
  }

  .app-frame {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  html.has-mobile-nav .app-frame {
    z-index: auto;
  }

  html.has-mobile-nav .app-mobile-bar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 34;
    align-items: center;
    gap: 0.65rem;
    min-height: 3.4rem;
    padding: max(0.45rem, env(safe-area-inset-top)) max(0.85rem, env(safe-area-inset-right)) 0.45rem max(0.85rem, env(safe-area-inset-left));
    background: #d7e6ef;
    border-bottom: 1px solid #b4cddc;
  }

  html.has-mobile-nav .app-mobile-brand {
    font-size: 1.2rem;
    min-width: 0;
    flex: 1 1 auto;
  }

  html.has-mobile-nav .app-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 32;
    background: rgba(44, 58, 66, 0.32);
  }

  html.has-mobile-nav .app-nav-backdrop[hidden] {
    display: none !important;
  }

  html.has-mobile-nav .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 33;
    width: min(var(--sidebar-width), calc(100vw - 3.25rem));
    height: 100vh;
    height: 100dvh;
    overflow: auto;
    overscroll-behavior: contain;
    padding-top: max(1.25rem, env(safe-area-inset-top));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    padding-left: max(1rem, env(safe-area-inset-left));
    border-right: 1px solid #b4cddc;
    border-bottom: 0;
    transform: translateX(-110%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.22s ease, visibility 0.22s ease;
  }

  html.has-mobile-nav body.is-nav-open {
    overflow: hidden;
  }

  html.has-mobile-nav body.is-nav-open .app-sidebar {
    transform: none;
    visibility: visible;
    pointer-events: auto;
    box-shadow: 12px 0 32px rgba(44, 58, 66, 0.16);
  }

  html.has-mobile-nav .app-main {
    padding: 1.15rem 1.15rem 2.5rem;
  }

  html.has-mobile-nav body.is-study-focus .app-mobile-bar,
  html.has-mobile-nav body.is-study-focus .app-nav-backdrop {
    display: none !important;
  }

  html.has-mobile-nav body.is-study-focus .app-sidebar {
    transform: translateX(-110%);
    visibility: hidden;
    box-shadow: none;
  }

  .material-row {
    grid-template-columns: 1fr;
  }

  .material-section-row {
    align-items: stretch;
  }

  .material-section .material-actions {
    width: 100%;
  }

  .field input[type="email"],
  .field input[type="password"],
  .field input[type="text"],
  .field input[type="search"],
  .field input[type="date"],
  .field input[type="number"],
  .field select,
  .exercise-input,
  .category-rename-form input {
    font-size: 16px;
  }

  .prose table,
  .logs-table-wrap,
  .users-table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .exercise-choice > input[type="radio"] {
    width: 1.2rem;
    height: 1.2rem;
  }

  .sidebar-link,
  .sidebar-tour-btn {
    min-height: 2.6rem;
    display: flex;
    align-items: center;
  }

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

  .prose table {
    display: block;
    overflow-x: auto;
  }
}

.app-main:has(.logs-page) {
  max-width: 1180px;
}

.log-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1rem;
  padding: 0.3rem;
  width: fit-content;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.log-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 650;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
}

.log-tab:hover {
  color: var(--ink);
  background: rgba(91, 143, 168, 0.1);
}

.log-tab.is-active {
  color: #fff;
  background: var(--accent);
}

.logs-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.85rem;
}

.logs-toolbar .field {
  min-width: 150px;
  flex: 1 1 150px;
}

.logs-toolbar .field-narrow {
  min-width: 90px;
  flex: 0 1 110px;
}

.logs-export {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.logs-table-wrap {
  overflow-x: auto;
  max-height: 70vh;
}

.logs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.logs-table th,
.logs-table td {
  text-align: left;
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.logs-table th {
  position: sticky;
  top: 0;
  background: #f7faf8;
  z-index: 1;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.logs-sort {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  letter-spacing: inherit;
  text-transform: inherit;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}

.logs-sort:hover,
.logs-sort.is-sorted {
  color: var(--ink);
}

.logs-table tbody tr.logs-row {
  cursor: pointer;
}

.logs-table tbody tr.logs-row:hover,
.logs-table tbody tr.logs-row.is-open {
  background: rgba(91, 143, 168, 0.08);
}

.logs-target {
  display: grid;
  gap: 0.12rem;
  min-width: 11rem;
  max-width: 22rem;
}

.logs-target-course {
  font-weight: 650;
  line-height: 1.25;
}

.logs-target-item {
  color: var(--muted, #5b6b66);
  font-size: 0.84rem;
  line-height: 1.3;
}

.log-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.log-chip.is-action {
  background: rgba(122, 168, 138, 0.16);
  color: #3f6b4d;
}

.log-chip.is-page {
  background: rgba(91, 143, 168, 0.16);
  color: #3d6478;
}

.log-chip.is-error {
  background: rgba(138, 90, 82, 0.16);
  color: var(--danger);
}

.log-chip.is-warning {
  background: rgba(196, 140, 60, 0.18);
  color: #8a5a18;
}

.log-chip.is-info {
  background: var(--accent-soft);
  color: var(--accent);
}

.log-chip.is-debug {
  background: rgba(44, 58, 66, 0.08);
  color: var(--muted);
}

.logs-msg {
  display: inline-block;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.logs-req {
  font-size: 0.78rem;
  color: var(--muted);
}

.logs-json {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8rem;
  color: #243430;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
}

.logs-empty {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.logs-detail-row td {
  background: rgba(238, 243, 246, 0.7);
}

.progress-kpis h2,
.progress-courses > h2 {
  margin: 0 0 0.85rem;
  font-size: 1.15rem;
}

.progress-mix {
  margin-top: 0.4rem;
}

.progress-mix h3 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
}

.progress-mix-body {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 1.2rem;
  align-items: center;
}

.progress-mix-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.progress-mix-legend li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
}

.progress-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  flex: 0 0 auto;
}

.progress-courses {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.2rem;
}

.analytics-overview {
  display: grid;
  gap: 0.9rem;
}

.analytics-overview > h2 {
  margin-bottom: 0.15rem;
}

.analytics-overview .analytics-kpi-group {
  padding: 0.9rem 1rem 1rem;
  border-radius: 16px;
  background: var(--tone-bg, rgba(255, 255, 255, 0.55));
  border: 1px solid var(--tone-line, var(--line));
  border-left: 5px solid var(--tone-edge, var(--accent));
}

.analytics-overview .analytics-kpi-group h3 {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--tone-edge, var(--muted));
}

.analytics-overview .analytics-kpi-group .stats {
  margin-bottom: 0;
}

.analytics-overview .analytics-kpi-group .stat {
  background: var(--tone-bg-hot, var(--accent-soft));
}

.analytics-overview .analytics-stat-ok {
  background: #d8f0e4;
}

.analytics-overview .analytics-stat-warn {
  background: #f8ead2;
}

.analytics-overview .analytics-stat-off {
  background: #eceff2;
}

.analytics-overview .analytics-stat-study {
  background: #d3ecdf;
}

.analytics-overview .analytics-stat-quiz {
  background: #e5daf3;
}

.analytics-overview .analytics-stat-browse {
  background: #d5e6f3;
}

.analytics-overview .analytics-kpi-mix {
  margin-top: 0;
}

@media (min-width: 900px) {
  .analytics-overview {
    grid-template-columns: 1fr 1fr;
  }

  .analytics-overview > h2,
  .analytics-overview .analytics-kpi-group.tone-blue,
  .analytics-overview .analytics-kpi-mix {
    grid-column: 1 / -1;
  }
}

.analytics-charts {
  grid-template-columns: 1fr;
}

.analytics-range {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem 1.1rem;
  margin-top: 0.85rem;
}

.analytics-range .field {
  min-width: 160px;
  margin: 0;
}

.analytics-range .btn {
  margin-bottom: 0.15rem;
}

.analytics-range [hidden] {
  display: none !important;
}

.analytics-range-window {
  margin: 0;
  min-width: min(100%, 22rem);
}

.analytics-range-kicker {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}

.analytics-range-window strong {
  display: block;
  font-weight: 650;
  line-height: 1.35;
}

.analytics-hours {
  grid-column: 1 / -1;
}

.analytics-purge {
  margin-top: 1.35rem;
}

.analytics-purge .analytics-range {
  margin-top: 0.35rem;
}

.analytics-purge .btn-danger {
  margin-bottom: 0.15rem;
}

.analytics-hours-legend {
  margin-top: 0.85rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

@media (min-width: 960px) {
  .analytics-charts {
    grid-template-columns: 1fr 1fr;
  }
}

.progress-course {
  padding: 1.15rem 1.25rem 1.3rem;
}

.progress-course-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.progress-course h3 {
  margin: 0.2rem 0 0;
  font-size: 1.2rem;
}

.progress-course-total {
  margin: 0;
  font-weight: 700;
  font-size: 1.15rem;
  white-space: nowrap;
}

.progress-course .progress-meta {
  margin: 0.35rem 0 0.85rem;
  color: var(--muted);
}

.progress-course-chart {
  position: relative;
  width: 100%;
}

@media (max-width: 720px) {
  .progress-mix-body {
    grid-template-columns: 1fr;
  }
}

.sidebar-diamonds {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: fit-content;
  margin: 0 0.15rem;
  padding: 0.28rem 0.7rem 0.28rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(247, 250, 248, 0.9);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}

.sidebar-diamonds:hover,
.sidebar-diamonds.is-active {
  background: #e8f1f8;
  border-color: #b7cfe0;
}

.sidebar-diamond-icon {
  width: 1.05rem;
  height: 1.05rem;
  color: var(--accent);
}

.level-meter {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.45rem 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.level-meter-track {
  display: block;
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(44, 58, 66, 0.12);
  overflow: hidden;
}

.level-meter-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  max-width: 100%;
}

.category-level {
  max-width: 14rem;
}

.quiz-reward-card {
  position: relative;
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(230, 244, 238, 0.7);
}

.quiz-reward-card.is-mastered {
  border-color: rgba(201, 162, 39, 0.55);
  background: rgba(255, 248, 220, 0.75);
}

.quiz-reward-note {
  margin: 0 0 0.55rem;
  font-weight: 600;
}

.quiz-reward-card [data-role="back"] {
  margin-top: 0.75rem;
}

.reward-burst {
  position: absolute;
  left: 50%;
  top: 0.8rem;
  width: 0;
  height: 0;
  pointer-events: none;
}

.reward-spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0.9;
  animation: reward-pop 0.7s ease-out forwards;
}

.reward-xp {
  position: absolute;
  right: 0.8rem;
  top: 0.55rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-2);
  animation: reward-xp-rise 0.8s ease-out forwards;
}

@keyframes reward-pop {
  0% { transform: translate(0, 0) scale(1); opacity: 0.9; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

@keyframes reward-xp-rise {
  0% { transform: translateY(4px); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translateY(-10px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .reward-spark {
    display: none;
  }
  .reward-xp {
    animation: none;
    opacity: 1;
  }
}

.store-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.store-status-card {
  padding: 1rem 1.1rem;
}

.store-status-value {
  margin: 0.35rem 0 0.2rem;
  font-size: 1.45rem;
  font-weight: 700;
}

.store-status-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.store-active {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1.1rem;
}

.store-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: #e6f4ee;
  border: 1px solid #b5d9c8;
  font-size: 0.85rem;
  font-weight: 600;
}

.store-course {
  margin: 0 0 0.85rem;
  max-width: 22rem;
}

.store-section-title {
  margin: 1.1rem 0 0.7rem;
  font-size: 1.05rem;
}

.store-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

.store-item {
  padding: 1rem 1.1rem;
  display: grid;
  gap: 0.35rem;
}

.store-item h3 {
  margin: 0;
  font-size: 1.05rem;
}

.store-item p {
  margin: 0 0 0.4rem;
  color: var(--muted);
}

.store-item .btn {
  justify-self: start;
}

.store-next {
  margin: 1rem 0 0;
  color: var(--muted);
}

.store-empty-items {
  margin: 0;
  color: var(--muted);
}

.store-level {
  max-width: 22rem;
  margin-bottom: 0.4rem;
}

@media (max-width: 720px) {
  .store-status,
  .store-grid {
    grid-template-columns: 1fr;
  }
}

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

  .study-pomo .pomodoro-tomato-live {
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
  }

  .toast {
    left: auto;
    right: 0.75rem;
    bottom: var(--ff-toast-bottom, max(1rem, env(safe-area-inset-bottom)));
    width: min(22rem, calc(100vw - 1.5rem));
    max-width: none;
    transform: none;
  }

  body.has-transform-jobs .toast {
    bottom: var(--ff-toast-bottom, calc(5.5rem + env(safe-area-inset-bottom)));
  }

  .transform-jobs {
    right: 0.75rem;
    left: auto;
    bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .add-course-card,
  .settings-card,
  .material-card-summary {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }
}

.sidebar-tour-btn {
  appearance: none;
  border: 0;
  background: #d5e6f3;
  width: 100%;
  text-align: left;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.sidebar-tour-btn:hover,
.sidebar-tour-btn[aria-expanded="true"] {
  background: #c5dced;
}

.tour-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

.tour-mask {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  background: transparent;
}

.tour-hole {
  position: fixed;
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(44, 58, 66, 0.42);
  outline: 2px solid #5b8fa8;
  pointer-events: none;
  transition: top 0.18s ease, left 0.18s ease, width 0.18s ease, height 0.18s ease;
}

.tour-panel {
  position: fixed;
  z-index: 2;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  width: min(26.5rem, calc(100vw - 1.5rem));
  max-height: min(78vh, 40rem);
  overflow: hidden;
  background: var(--card);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.tour-panel-head {
  flex: 0 0 auto;
  padding: 1.05rem 1.2rem 0.55rem;
}

.tour-panel-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0.85rem 1.2rem 1.25rem;
  scrollbar-gutter: stable;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 0.85rem,
    #000 calc(100% - 1.15rem),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 0.85rem,
    #000 calc(100% - 1.15rem),
    transparent 100%
  );
}

.tour-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.tour-panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.28rem;
  line-height: 1.25;
}

.tour-panel h3 {
  margin: 0 0 0.3rem;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.tour-block {
  margin: 0 0 0.85rem;
}

.tour-block p,
.tour-copy p {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.tour-copy p:last-child {
  margin-bottom: 0.85rem;
}

.tour-missing {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.7rem;
  background: #eef3f6;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.tour-refs ul {
  margin: 0;
  padding-left: 1.1rem;
}

.tour-refs li {
  margin: 0 0 0.35rem;
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--muted);
}

.tour-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  flex: 0 0 auto;
  margin: 0;
  padding: 0.85rem 1.15rem 1.05rem;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.tour-actions-spacer {
  flex: 1;
}

@media (max-width: 860px) {
  .tour-panel {
    left: 0.75rem !important;
    right: 0.75rem;
    width: auto;
    top: auto !important;
    bottom: 0.75rem;
    transform: none !important;
    max-height: 58vh;
  }
}

.la-quality {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.la-quality-flag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.la-section {
  margin: 0 0 2.25rem;
}

.la-section > h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 1rem;
}

.la-section-outcomes > h2 {
  font-size: 1.55rem;
}

.la-grid {
  display: grid;
  gap: 1rem;
}

.la-grid-2,
.la-grid-3 {
  grid-template-columns: 1fr;
}

@media (min-width: 800px) {
  .la-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
  .la-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.la-card {
  padding: 1.15rem 1.25rem 1.2rem;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  background: var(--card);
}

.la-card h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
}

.la-value {
  margin: 0.35rem 0 0;
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.15;
}

.la-card.is-empty .la-value {
  font-size: 1.5rem;
  color: var(--muted);
}

.la-n,
.la-trend {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.la-chart {
  position: relative;
  height: 160px;
  margin-top: 0.75rem;
}

.la-card-featured {
  padding: 1.4rem 1.35rem 1.45rem;
}

.la-card-featured .la-value {
  font-size: 2.25rem;
}

.la-section-outcomes .la-card-featured {
  border-color: rgba(91, 143, 168, 0.28);
}

.la-warn {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.la-meaning {
  margin-top: 0.85rem;
}

.la-meaning summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9rem;
}

.la-meaning p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.la-usage {
  margin: 0 0 2rem;
  padding: 1rem 1.15rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.la-usage > summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 1.05rem;
}

.la-usage .analytics-kpi-group,
.la-usage .analytics-charts {
  margin-top: 1rem;
}

@media (max-width: 799px) {
  .la-value {
    font-size: 1.7rem;
  }
  .la-chart {
    height: 140px;
  }
}
