:root {
  --ink: #172728;
  --ink-soft: #536263;
  --paper: #fbfaf6;
  --canvas: #eef1ed;
  --panel: #ffffff;
  --line: #dfe5df;
  --line-strong: #c9d3cc;
  --teal: #147d71;
  --teal-dark: #0c5f57;
  --teal-soft: #dff1eb;
  --amber: #d79a3d;
  --amber-soft: #fbefd9;
  --red: #c25b4b;
  --shadow: 0 18px 48px rgba(29, 48, 45, 0.10);
  --radius: 16px;
  --sidebar: 292px;
  --assistant: 340px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--canvas);
}

body {
  overflow: hidden;
}

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

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(480px, 1fr) var(--assistant);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.library-panel,
.study-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--panel);
}

.library-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 22px 18px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px 13px 13px 5px;
  color: #fff;
  background: var(--ink);
  font-family: Georgia, "Microsoft YaHei", serif;
  font-size: 22px;
  box-shadow: 0 8px 18px rgba(23, 39, 40, 0.2);
}

.brand-name {
  font-size: 17px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.brand-subtitle {
  margin-top: 2px;
  color: #778282;
  font-size: 11px;
}

.library-search {
  padding: 4px 16px 12px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: #82908f;
  background: #f6f8f5;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.search-field:focus-within {
  border-color: #73afa5;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(20, 125, 113, 0.10);
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
}

.library-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  padding: 0 16px 13px;
}

.library-tab,
.assistant-tabs button,
.view-toggle button {
  border: 0;
  cursor: pointer;
  color: #72807f;
  background: transparent;
}

.library-tab {
  padding: 7px 2px;
  border-radius: 8px;
  font-size: 12px;
}

.library-tab:hover,
.library-tab.active {
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-weight: 650;
}

.document-tree {
  flex: 1;
  overflow: auto;
  padding: 2px 12px 20px;
  scrollbar-width: thin;
}

.document-group {
  margin-bottom: 15px;
}

.group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  color: #8a9694;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.group-heading b {
  display: grid;
  min-width: 22px;
  height: 18px;
  place-items: center;
  border-radius: 9px;
  background: #edf1ee;
  font-size: 10px;
}

.document-item {
  display: grid;
  grid-template-columns: 7px 1fr;
  gap: 10px;
  width: 100%;
  margin: 2px 0;
  padding: 10px 11px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  background: transparent;
  transition: background 140ms ease, transform 140ms ease;
}

.document-item:hover {
  background: #f3f6f3;
  transform: translateX(2px);
}

.document-item.active {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.type-dot {
  width: 6px;
  height: 6px;
  margin-top: 7px;
  border-radius: 50%;
  background: #98a8a5;
}

.document-item[data-type="lesson"] .type-dot { background: var(--teal); }
.document-item[data-type="review"] .type-dot { background: var(--amber); }
.document-item[data-type="homework"] .type-dot { background: #8a75bd; }
.document-item[data-type="progress"] .type-dot { background: #d76656; }
.document-item[data-type="plan"] .type-dot { background: #5088b0; }

.document-item strong {
  display: -webkit-box;
  overflow: hidden;
  color: inherit;
  font-size: 12px;
  font-weight: 590;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.document-item small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #96a09f;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-footer,
.study-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.local-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #75817f;
  font-size: 11px;
}

.library-footer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.offline-cache-button {
  position: relative;
}

.offline-cache-button > span {
  font-size: 18px;
  line-height: 1;
}

.offline-cache-button > b {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 2px solid var(--panel);
  border-radius: 999px;
  color: #fff;
  background: var(--teal);
  font-size: 8px;
  line-height: 14px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #49a987;
  box-shadow: 0 0 0 4px rgba(73, 169, 135, 0.12);
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  color: #60706e;
  background: #fff;
}

.icon-button:hover {
  border-color: #9db5b0;
  color: var(--teal-dark);
  background: #f5f9f7;
}

.workspace {
  display: flex;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  flex-direction: column;
  background:
    radial-gradient(circle at 82% 7%, rgba(213, 233, 222, 0.65), transparent 28%),
    var(--paper);
}

.site-compliance {
  position: relative;
  z-index: 2;
  display: flex;
  min-height: 34px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 16px;
  border-top: 1px solid rgba(207, 215, 207, 0.72);
  color: #84908e;
  background: rgba(251, 250, 246, 0.88);
  font-size: 10px;
  letter-spacing: 0.03em;
  backdrop-filter: blur(12px);
}

.site-compliance a {
  color: #637573;
  text-decoration: none;
  transition: color 150ms ease, transform 150ms ease;
}

.site-compliance a:hover,
.site-compliance a:focus-visible {
  color: var(--teal);
  transform: translateY(-1px);
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 12px 28px;
  border-bottom: 1px solid rgba(207, 215, 207, 0.75);
  background: rgba(251, 250, 246, 0.89);
  backdrop-filter: blur(12px);
  z-index: 10;
}

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

.document-kind {
  margin-bottom: 3px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.document-identity h1 {
  max-width: 590px;
  margin: 0;
  overflow: hidden;
  font-family: Georgia, "Noto Serif SC", "Microsoft YaHei", serif;
  font-size: 18px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 660;
  transition: transform 130ms ease, box-shadow 130ms ease, background 130ms ease;
}

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

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

.button.primary {
  color: #fff;
  background: var(--teal);
  box-shadow: 0 7px 18px rgba(20, 125, 113, 0.20);
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.secondary {
  border-color: var(--line-strong);
  color: #40504f;
  background: #fff;
}

.button.ghost {
  color: #6d7a79;
  background: transparent;
}

.button.large {
  min-height: 46px;
  padding: 0 20px;
  font-size: 13px;
}

.view-toggle {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f0f3ef;
}

.view-toggle button {
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 11px;
}

.view-toggle button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 7px rgba(24, 45, 42, 0.08);
}

.mobile-menu,
.mobile-close,
.assistant-fab {
  display: none;
}

.welcome-view {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: clamp(48px, 7vh, 84px) clamp(38px, 6vw, 90px);
}

.welcome-copy {
  max-width: 780px;
}

.eyebrow {
  margin-bottom: 18px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.23em;
}

.welcome-copy h2 {
  margin: 0;
  font-family: Georgia, "Noto Serif SC", "Microsoft YaHei", serif;
  font-size: clamp(34px, 4vw, 58px);
  font-weight: 620;
  letter-spacing: -0.035em;
  line-height: 1.18;
}

.welcome-copy p {
  max-width: 620px;
  margin: 22px 0 28px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.85;
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  max-width: 940px;
  margin-top: 62px;
}

.metric-card {
  min-height: 144px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 26px rgba(27, 47, 43, 0.04);
}

.metric-card.accent {
  color: #fff;
  border-color: var(--ink);
  background: var(--ink);
}

.metric-card.model-card {
  background: var(--amber-soft);
}

.metric-card span,
.metric-card small {
  display: block;
  color: #75817f;
  font-size: 11px;
}

.metric-card.accent span,
.metric-card.accent small {
  color: #b9cac7;
}

.metric-card strong {
  display: block;
  margin: 20px 0 8px;
  font-family: Georgia, serif;
  font-size: 29px;
  font-weight: 600;
}

.metric-card.model-card strong {
  font-family: inherit;
  font-size: 18px;
}

.workflow-strip {
  display: flex;
  max-width: 720px;
  align-items: center;
  margin-top: 38px;
  color: #526361;
}

.workflow-strip div {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.workflow-strip b {
  color: var(--teal);
  font-family: Georgia, serif;
  font-size: 12px;
}

.workflow-strip span {
  font-size: 11px;
}

.workflow-strip i {
  width: 44px;
  height: 1px;
  margin: 0 12px;
  background: #cbd5cf;
}

.document-view,
.editor-view {
  min-height: 0;
  flex: 1;
  overflow: auto;
}

.reading-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 820px);
  justify-content: center;
  gap: clamp(22px, 3vw, 42px);
  padding: 46px clamp(18px, 2.2vw, 34px) 100px;
  transition: grid-template-columns 280ms var(--ease-out), gap 280ms var(--ease-out);
}

.reading-layout.outline-collapsed {
  grid-template-columns: 42px minmax(0, 860px);
  gap: 28px;
}

.markdown-body {
  min-width: 0;
  color: #233333;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.86;
  word-break: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  scroll-margin-top: 96px;
  color: #172728;
  font-family: Georgia, "Noto Serif SC", "Microsoft YaHei", serif;
  line-height: 1.38;
}

.markdown-body h1 {
  margin: 0 0 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  font-size: 34px;
  font-weight: 620;
}

.markdown-body h2 {
  margin: 54px 0 20px;
  font-size: 25px;
  font-weight: 650;
}

.markdown-body h2::before {
  display: inline-block;
  width: 16px;
  height: 4px;
  margin: 0 10px 7px 0;
  border-radius: 3px;
  background: var(--teal);
  content: "";
}

.markdown-body h3 {
  margin: 34px 0 14px;
  font-size: 19px;
}

.markdown-body h4 {
  margin: 28px 0 12px;
  font-size: 16px;
}

.markdown-body p {
  margin: 13px 0;
}

.markdown-body a {
  color: var(--teal-dark);
  text-decoration-color: #8bbab2;
  text-underline-offset: 3px;
}

.markdown-body strong {
  color: #132524;
  font-weight: 720;
}

.markdown-body code {
  padding: 2px 6px;
  border: 1px solid #dbe3dd;
  border-radius: 5px;
  color: #a74f3f;
  background: #f2f4f0;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.88em;
}

.markdown-body pre {
  overflow: auto;
  margin: 20px 0;
  padding: 18px 20px;
  border-radius: 12px;
  color: #dce9e5;
  background: #1d2c2c;
  box-shadow: 0 10px 28px rgba(20, 36, 35, 0.12);
}

.markdown-body pre code {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font-size: 12px;
  line-height: 1.7;
}

.mermaid-diagram {
  position: relative;
  margin: 26px 0;
  overflow: hidden;
  border: 1px solid #d4e2dc;
  border-radius: 16px;
  background:
    radial-gradient(circle at 92% 0, rgba(77, 177, 154, .12), transparent 34%),
    #fbfcf9;
  box-shadow: 0 14px 36px rgba(22, 48, 43, .09);
}

.diagram-heading {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid #e0e9e4;
  color: #236b60;
  background: rgba(237, 246, 242, .72);
}

.diagram-heading span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
}

.diagram-heading span::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(20, 125, 113, .1);
  content: "";
}

.diagram-heading small {
  color: #81918c;
  font-size: 9px;
}

.diagram-heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.diagram-expand-button {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border: 1px solid #bad3cc;
  border-radius: 8px;
  cursor: pointer;
  color: #226b61;
  background: rgba(255, 255, 255, .82);
  font: inherit;
  font-size: 9px;
  font-weight: 750;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease, transform 160ms ease;
}

.diagram-expand-button b {
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
}

.diagram-expand-button:hover,
.diagram-expand-button:focus-visible {
  border-color: #397f73;
  color: #fff;
  background: #397f73;
  outline: 0;
  transform: translateY(-1px);
}

.mermaid-diagram:not([data-mermaid-state="rendered"]) .diagram-expand-button {
  visibility: hidden;
  pointer-events: none;
}

.mermaid-canvas {
  min-width: 0;
  overflow-x: auto;
  padding: 24px;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.mermaid-canvas svg {
  display: block;
  width: 100%;
  min-width: 620px;
  height: auto;
  max-width: none !important;
  margin: 0 auto;
}

.diagram-loading {
  display: grid;
  min-height: 190px;
  place-items: center;
  border-radius: 11px;
  color: #6f817c;
  background: linear-gradient(105deg, rgba(232, 241, 236, .72) 32%, rgba(250, 252, 249, .96) 46%, rgba(232, 241, 236, .72) 60%);
  background-size: 220% 100%;
  font-size: 11px;
  animation: diagram-loading 1.4s ease-in-out infinite;
}

@keyframes diagram-loading {
  to { background-position-x: -220%; }
}

.mermaid-diagram[data-mermaid-state="rendered"] .mermaid-canvas {
  animation: diagram-reveal 320ms var(--ease-out) both;
}

@keyframes diagram-reveal {
  from { opacity: 0; transform: translateY(5px); }
}

.diagram-error-message {
  margin-bottom: 5px;
  color: #a14d3d;
  font-size: 12px;
  font-weight: 750;
}

.diagram-error-message + small {
  color: #8b7772;
  font-size: 9px;
}

.mermaid-diagram[data-mermaid-state="error"] .mermaid-canvas pre {
  margin-bottom: 0;
}

body.diagram-preview-open {
  overflow: hidden !important;
}

.diagram-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 820;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 24, 21, .78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: diagram-preview-backdrop-in 180ms ease both;
}

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

.diagram-preview-shell {
  display: grid;
  width: min(1680px, 100%);
  height: min(1080px, calc(100dvh - 32px));
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .62);
  border-radius: 20px;
  background: #f6faf8;
  box-shadow: 0 35px 110px rgba(0, 0, 0, .36);
  animation: diagram-preview-shell-in 220ms var(--ease-out) both;
}

.diagram-preview-header {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 14px 10px 20px;
  border-bottom: 1px solid #d8e4df;
  background: rgba(252, 254, 253, .97);
}

.diagram-preview-title {
  min-width: 0;
}

.diagram-preview-title > span {
  display: block;
  margin-bottom: 2px;
  color: #338174;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .16em;
}

.diagram-preview-title h2 {
  display: inline;
  margin: 0 9px 0 0;
  color: #243d39;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 17px;
}

.diagram-preview-title small {
  color: #7c8f8a;
  font-size: 9px;
}

.diagram-preview-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.diagram-preview-controls button {
  display: grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  padding: 0 9px;
  border: 1px solid #c8d8d3;
  border-radius: 9px;
  cursor: pointer;
  color: #375e57;
  background: #fff;
  font: inherit;
  font-size: 16px;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.diagram-preview-controls button:hover:not(:disabled),
.diagram-preview-controls button:focus-visible {
  border-color: #41877b;
  background: #eaf5f1;
  outline: 0;
  transform: translateY(-1px);
}

.diagram-preview-controls button:disabled {
  cursor: not-allowed;
  opacity: .4;
}

.diagram-preview-controls output {
  width: 47px;
  color: #526f69;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.diagram-preview-controls .diagram-preview-fit {
  min-width: auto;
  font-size: 10px;
}

.diagram-preview-controls .diagram-preview-close {
  margin-left: 5px;
  border-color: transparent;
  color: #fff;
  background: #2d6f64;
  font-size: 21px;
}

.diagram-preview-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  cursor: grab;
  outline: none;
  overscroll-behavior: contain;
  touch-action: none;
  background-color: #eaf1ee;
  background-image:
    linear-gradient(rgba(67, 107, 98, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(67, 107, 98, .07) 1px, transparent 1px);
  background-size: 24px 24px;
  scrollbar-color: #9eb5af transparent;
}

.diagram-preview-viewport:focus-visible {
  box-shadow: inset 0 0 0 2px #4c9b8d;
}

.diagram-preview-viewport.is-panning {
  cursor: grabbing;
  user-select: none;
}

.diagram-preview-stage {
  position: relative;
  display: flex;
  min-width: 100%;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.diagram-preview-stage svg {
  display: block;
  max-width: none !important;
  flex: 0 0 auto;
  filter: drop-shadow(0 12px 24px rgba(31, 63, 56, .1));
  user-select: none;
}

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

@keyframes diagram-preview-shell-in {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
}

.markdown-body blockquote {
  margin: 22px 0;
  padding: 14px 20px;
  border-left: 4px solid var(--teal);
  border-radius: 0 10px 10px 0;
  color: #3b5753;
  background: var(--teal-soft);
}

.markdown-body blockquote p {
  margin: 0;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 25px;
}

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

.table-wrap {
  overflow-x: auto;
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.55;
}

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

.markdown-body th {
  color: #334b48;
  background: #edf4f0;
  font-size: 12px;
  font-weight: 720;
}

.markdown-body tr:last-child td {
  border-bottom: 0;
}

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

.task-item {
  list-style: none;
}

.task-item input {
  margin: 0 7px 0 -20px;
  accent-color: var(--teal);
}

.answer-form {
  position: relative;
  overflow: hidden;
  margin: 22px 0 28px;
  padding: 16px;
  border: 1px solid #bed8d1;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(223, 241, 235, 0.72), rgba(255, 255, 255, 0.9) 62%);
  box-shadow: 0 12px 30px rgba(25, 62, 54, 0.07);
}

.answer-form::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: linear-gradient(var(--teal), #69bda7);
  content: "";
}

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

.answer-form-heading {
  margin-bottom: 14px;
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 720;
}

.answer-form-heading b {
  margin-right: 5px;
}

.answer-form-heading small {
  color: #82918e;
  font-size: 9px;
  font-weight: 500;
}

.answer-form-field {
  display: block;
  margin-top: 12px;
}

.answer-form-field > span {
  display: block;
  margin-bottom: 6px;
  color: #405653;
  font-size: 11px;
  font-weight: 700;
}

.answer-control {
  width: 100%;
  border: 1px solid #c6d5d0;
  border-radius: 10px;
  outline: 0;
  padding: 10px 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  font: inherit;
  font-size: 13px;
  line-height: 1.65;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea.answer-control {
  min-height: 82px;
  resize: vertical;
}

.answer-diagram-tools {
  margin-top: 8px;
  padding: 10px 11px;
  border: 1px dashed #b9d2cb;
  border-radius: 10px;
  background: rgba(241, 248, 245, 0.78);
}

.answer-diagram-tools-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.answer-diagram-tools-heading span {
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 780;
}

.answer-diagram-tools-heading small {
  color: #788b86;
  font-size: 9px;
}

.answer-diagram-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.answer-diagram-actions button {
  min-height: 32px;
  border: 1px solid #b8d0ca;
  border-radius: 8px;
  cursor: pointer;
  padding: 5px 9px;
  color: #385e57;
  background: rgba(255, 255, 255, 0.9);
  font: inherit;
  font-size: 10px;
  font-weight: 680;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.answer-diagram-actions button:hover {
  border-color: #68a99b;
  color: var(--teal-dark);
  background: #fff;
}

.answer-diagram-actions .answer-preview-toggle {
  margin-left: auto;
  border-color: #88bdb1;
  color: var(--teal-dark);
  background: #e6f3ef;
}

.answer-diagram-actions .answer-whiteboard-toggle {
  border-color: #4f9f91;
  color: #fff;
  background: #287f72;
}

.answer-diagram-actions .answer-whiteboard-toggle:hover {
  border-color: #236e64;
  color: #fff;
  background: #236e64;
}

.answer-diagram-preview {
  overflow: hidden;
  margin-top: 10px;
  border: 1px solid #c8dbd5;
  border-radius: 12px;
  background: rgba(252, 253, 250, 0.96);
}

.answer-diagram-preview-heading {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid #dce8e4;
  color: #2d675e;
  background: rgba(235, 245, 241, 0.75);
}

.answer-diagram-preview-heading strong {
  font-size: 10px;
}

.answer-diagram-preview-heading small {
  color: #7c8d89;
  font-size: 9px;
}

.answer-diagram-preview-content {
  padding: 12px;
}

.answer-diagram-preview-content .mermaid-diagram {
  margin: 0;
  border: 0;
  border-radius: 9px;
  box-shadow: none;
}

.answer-diagram-preview-content .diagram-heading {
  min-height: 34px;
}

.answer-diagram-preview-content .mermaid-canvas {
  padding: 15px 10px;
}

.answer-diagram-empty {
  display: grid;
  min-height: 92px;
  place-items: center;
  align-content: center;
  gap: 5px;
  color: #687b76;
  text-align: center;
}

.answer-diagram-empty strong {
  color: #3e5e58;
  font-size: 11px;
}

.answer-diagram-empty span {
  font-size: 9px;
}

.homework-answer-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 720px;
  margin: 12px auto;
  border: 1px solid #cfddd9;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(33, 72, 64, 0.09);
}

.whiteboard-backdrop {
  position: fixed;
  z-index: 300;
  inset: 0;
  background: rgba(14, 33, 29, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: whiteboard-backdrop-in 180ms ease both;
}

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

.answer-whiteboard {
  position: fixed;
  z-index: 301;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  width: min(1180px, 93vw);
  min-width: 0;
  grid-template-columns: minmax(232px, 286px) minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  margin: 0;
  border: 1px solid #bcd5cf;
  border-right: 0;
  border-radius: 16px 0 0 16px;
  background: #f8fbfa;
  box-shadow: -22px 0 60px rgba(19, 45, 39, 0.26);
  transform: translateX(101%);
  transition: transform 220ms var(--ease-out), width 180ms ease;
}

.answer-whiteboard[hidden] {
  display: none;
}

.answer-whiteboard.is-open {
  transform: none;
}

.answer-whiteboard-heading {
  display: flex;
  min-height: 52px;
  grid-column: 1 / -1;
  grid-row: 1;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid #d8e7e3;
  color: #285f57;
  background: #edf6f3;
}

.answer-whiteboard-heading > div:first-child {
  display: grid;
  gap: 2px;
}

.answer-whiteboard-heading strong {
  font-size: 12px;
}

.answer-whiteboard-heading small {
  color: #718680;
  font-size: 9px;
}

.whiteboard-window-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.whiteboard-window-actions button {
  min-width: 32px;
  height: 32px;
  border: 1px solid #b6cec8;
  border-radius: 8px;
  cursor: pointer;
  padding: 4px 9px;
  color: #4c6d67;
  background: rgba(255, 255, 255, 0.8);
  font: inherit;
  font-size: 10px;
  font-weight: 700;
}

.whiteboard-window-actions [data-whiteboard-close] {
  width: 32px;
  flex: 0 0 32px;
  padding: 0;
  font-size: 18px;
}

.whiteboard-question {
  display: grid;
  min-height: 0;
  grid-column: 2;
  grid-row: 2;
  grid-template-rows: auto minmax(0, 1fr);
  margin: 12px 12px 0;
  border: 1px solid #d6e4e0;
  border-radius: 11px;
  background: #f2f8f6;
}

.whiteboard-question-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  color: #2c625a;
  font-size: 10px;
  font-weight: 750;
}

.whiteboard-question-heading button {
  flex: 0 0 auto;
  min-height: 26px;
  border: 1px solid #c3d9d3;
  border-radius: 7px;
  cursor: pointer;
  padding: 3px 9px;
  color: #40716a;
  background: rgba(255, 255, 255, 0.8);
  font: inherit;
  font-size: 9px;
  font-weight: 700;
}

.whiteboard-question-body {
  overflow: auto;
  max-height: 23vh;
  padding: 0 11px 9px;
  color: #33504b;
  font-size: 12px;
  line-height: 1.72;
}

.whiteboard-question-body > *:first-child {
  margin-top: 0;
}

.whiteboard-question-body > *:last-child {
  margin-bottom: 0;
}

.answer-whiteboard.question-collapsed .whiteboard-question-body {
  display: none;
}

.whiteboard-toolbar {
  display: grid;
  overflow: auto;
  min-width: 0;
  grid-column: 1;
  grid-row: 2 / 5;
  align-content: start;
  gap: 9px;
  padding: 10px 12px;
  border-right: 1px solid #dde9e6;
  background: rgba(255, 255, 255, 0.84);
}

.whiteboard-tool-group,
.whiteboard-action-group,
.whiteboard-style-group {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.whiteboard-tool-row {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 3px;
}

.whiteboard-tool-row > span {
  color: #6d817c;
  font-size: 9px;
  font-weight: 780;
}

.whiteboard-toolbar button {
  min-height: 32px;
  border: 1px solid #c3d4d0;
  border-radius: 8px;
  cursor: pointer;
  padding: 5px 9px;
  color: #435f59;
  background: #fff;
  font: inherit;
  font-size: 10px;
  font-weight: 680;
}

.whiteboard-toolbar button:hover,
.whiteboard-toolbar button.active {
  border-color: #4e9e90;
  color: #176f63;
  background: #e8f5f1;
}

.whiteboard-toolbar button:disabled {
  cursor: not-allowed;
  opacity: .46;
}

.whiteboard-style-group {
  align-items: stretch;
  flex-direction: column;
  padding: 7px 8px;
  border: 1px solid #e0eae7;
  border-radius: 9px;
  background: #f7faf9;
}

.whiteboard-style-group label {
  display: inline-flex;
  width: 100%;
  min-width: 0;
  min-height: 30px;
  align-items: center;
  gap: 5px;
  color: #657a75;
  font-size: 9px;
  font-weight: 680;
}

.whiteboard-style-group .whiteboard-label-control {
  align-items: stretch;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 3px;
}

.whiteboard-style-group input[type="text"] {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  border: 1px solid #c9d8d4;
  border-radius: 7px;
  padding: 4px 8px;
  color: #243d38;
  background: #fff;
  font: inherit;
  font-size: 10px;
}

.whiteboard-style-group input[type="color"] {
  width: 34px;
  height: 30px;
  border: 1px solid #c9d8d4;
  border-radius: 7px;
  padding: 2px;
  background: #fff;
}

.whiteboard-style-group input[type="range"] {
  flex: 1 1 auto;
  width: 76px;
  min-width: 0;
}

.whiteboard-style-group select {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 30px;
  border: 1px solid #c9d8d4;
  border-radius: 7px;
  padding: 3px 7px;
  color: #38534d;
  background: #fff;
  font: inherit;
  font-size: 9px;
}

.whiteboard-action-group {
  padding-top: 1px;
}

.whiteboard-action-group > [data-whiteboard-zoom-value] {
  min-width: 42px;
  color: #55706a;
  font-size: 9px;
  font-weight: 750;
  text-align: center;
}

.whiteboard-action-separator {
  width: 1px;
  height: 24px;
  margin: 0 3px;
  background: #d8e5e1;
}

/* The grid belongs to the canvas itself: anything outside it is not drawable. */
.whiteboard-canvas-shell {
  display: flex;
  overflow: auto;
  height: auto;
  min-height: 0;
  grid-column: 2;
  grid-row: 3;
  margin: 12px 12px 4px;
  padding: 14px;
  border: 1px solid #cbdad7;
  border-radius: 11px;
  background: #e7eeec;
}

.whiteboard-canvas-shell canvas {
  display: block;
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  height: auto;
  /* Auto margins center the page but collapse to 0 once it overflows and scrolls. */
  margin: auto;
  border-radius: 3px;
  outline: 0;
  background-color: #fff;
  background-image:
    linear-gradient(#edf2f1 1px, transparent 1px),
    linear-gradient(90deg, #edf2f1 1px, transparent 1px),
    linear-gradient(#dce6e3 1px, transparent 1px),
    linear-gradient(90deg, #dce6e3 1px, transparent 1px);
  background-size:
    var(--whiteboard-grid, 20px) var(--whiteboard-grid, 20px),
    var(--whiteboard-grid, 20px) var(--whiteboard-grid, 20px),
    var(--whiteboard-grid-major, 100px) var(--whiteboard-grid-major, 100px),
    var(--whiteboard-grid-major, 100px) var(--whiteboard-grid-major, 100px);
  box-shadow: 0 6px 20px rgba(23, 52, 46, 0.16), 0 0 0 1px #c2d3cf;
  touch-action: none;
}

.whiteboard-canvas-shell canvas[data-tool="select"] {
  cursor: grab;
}

.whiteboard-canvas-shell canvas:not([data-tool="select"]) {
  cursor: crosshair;
}

.whiteboard-canvas-shell canvas:focus {
  box-shadow: inset 0 0 0 3px rgba(33, 145, 126, 0.24);
}

.whiteboard-hint {
  grid-column: 2;
  grid-row: 4;
  margin: 3px 13px 9px;
  color: #748782;
  font-size: 9px;
}

.whiteboard-footer {
  display: flex;
  min-height: 54px;
  grid-column: 1 / -1;
  grid-row: 5;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-top: 1px solid #dde9e6;
  background: rgba(250, 252, 251, 0.94);
}

.whiteboard-footer span {
  color: #647873;
  font-size: 9px;
}

.whiteboard-footer span.error {
  color: #ae4237;
}

body.whiteboard-drawer-open {
  overflow: hidden !important;
}

/* `.workspace` isolates its stacking context, so lift it past the side panels. */
body.whiteboard-drawer-open .workspace {
  z-index: 310;
  overflow: visible;
}

body.whiteboard-drawer-open #document-view,
body.whiteboard-drawer-open .reading-layout,
body.whiteboard-drawer-open #markdown-content,
body.whiteboard-drawer-open .answer-form:has(.answer-whiteboard:not([hidden])) {
  overflow: visible;
}

/* `.document-view` is its own stacking context, so keep it above the floating buttons. */
body.whiteboard-drawer-open #document-view {
  z-index: 100;
}

.answer-whiteboard.fullscreen {
  width: 100vw;
  border-left: 0;
  border-radius: 0;
  grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
}

@media (prefers-reduced-motion: reduce) {
  .answer-whiteboard {
    transition: none;
  }

  .whiteboard-backdrop {
    animation: none;
  }
}

@media (max-width: 980px) {
  .answer-whiteboard,
  .answer-whiteboard.fullscreen {
    width: 100vw;
    border-left: 0;
    border-radius: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  }

  .answer-whiteboard .whiteboard-question {
    grid-column: 1;
    grid-row: 2;
    margin: 10px 10px 0;
  }

  .answer-whiteboard .whiteboard-question-body {
    max-height: 18vh;
  }

  .answer-whiteboard .whiteboard-toolbar {
    max-height: 34vh;
    grid-column: 1;
    grid-row: 3;
    border-right: 0;
    border-bottom: 1px solid #dde9e6;
  }

  .answer-whiteboard .whiteboard-tool-row {
    grid-template-columns: 62px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
  }

  .answer-whiteboard .whiteboard-style-group {
    align-items: center;
    flex-direction: row;
  }

  .answer-whiteboard .whiteboard-style-group label {
    width: auto;
  }

  .answer-whiteboard .whiteboard-style-group .whiteboard-label-control {
    align-items: center;
    flex: 1 1 260px;
    flex-direction: row;
    gap: 5px;
  }

  .answer-whiteboard .whiteboard-canvas-shell {
    grid-column: 1;
    grid-row: 4;
  }

  .answer-whiteboard .whiteboard-hint {
    grid-column: 1;
    grid-row: 5;
  }

  .answer-whiteboard .whiteboard-footer {
    grid-column: 1;
    grid-row: 6;
  }
}

.answer-control:focus {
  border-color: #58a899;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(20, 125, 113, 0.11);
}

.choice-answer {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto;
  gap: 10px;
}

.choice-options {
  display: flex;
  align-items: stretch;
  gap: 5px;
}

.choice-options button {
  width: 38px;
  border: 1px solid #c7d7d2;
  border-radius: 9px;
  cursor: pointer;
  color: #566b67;
  background: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  font-weight: 750;
  transition:
    color 150ms ease,
    border-color 150ms ease,
    background 150ms ease,
    transform 200ms var(--ease-spring);
}

.choice-options button:hover {
  border-color: #78aea4;
  color: var(--teal-dark);
  transform: translateY(-2px);
}

.choice-options button.active {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
  box-shadow: 0 6px 14px rgba(20, 125, 113, 0.2);
}

.answer-form-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(167, 194, 187, 0.5);
}

.answer-save-status {
  color: #84938f;
  font-size: 9px;
}

.answer-form.dirty .answer-save-status {
  color: #a36a1e;
  font-weight: 650;
}

.homework-progress {
  --homework-progress: 0%;
  position: sticky;
  top: 14px;
  z-index: 12;
  overflow: hidden;
  margin: 0 0 30px;
  border: 1px solid rgba(151, 190, 179, 0.72);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(242, 250, 247, 0.96), rgba(255, 253, 248, 0.94));
  box-shadow: 0 15px 40px rgba(24, 61, 54, 0.12);
  backdrop-filter: blur(18px);
  transition: border-color 220ms ease, box-shadow 220ms ease, transform 220ms ease;
}

.homework-progress::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--teal), #67c0a9);
  content: "";
}

.homework-progress.is-complete {
  border-color: rgba(76, 168, 133, 0.75);
  box-shadow: 0 17px 44px rgba(34, 123, 91, 0.16);
}

.homework-progress.is-complete::before {
  background: linear-gradient(180deg, #2f9f74, #80c978);
}

.homework-progress-main {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 12px 18px;
}

.homework-progress-ring {
  position: relative;
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--teal) var(--homework-progress), #dbe9e3 0);
  box-shadow: inset 0 0 0 1px rgba(20, 125, 113, 0.08);
  transition: background 260ms ease;
}

.homework-progress-ring::after {
  position: absolute;
  inset: 5px;
  border-radius: inherit;
  background: #f8fbf8;
  content: "";
}

.homework-progress-ring span {
  position: relative;
  z-index: 1;
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 800;
}

.homework-progress-copy {
  min-width: 0;
}

.homework-progress-kicker {
  display: block;
  margin-bottom: 1px;
  color: #6b8a82;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.homework-progress-copy strong {
  display: block;
  overflow: hidden;
  color: #17332e;
  font-size: 14px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.homework-progress-copy small {
  display: block;
  overflow: hidden;
  margin-top: 1px;
  color: #758a85;
  font-size: 9px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.homework-progress-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.homework-progress-count {
  display: flex;
  align-items: baseline;
  color: #71847f;
  font-size: 12px;
  white-space: nowrap;
}

.homework-progress-count b {
  color: var(--teal-dark);
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 650;
}

.homework-progress-count i {
  margin: 0 3px;
  color: #a5b3af;
  font-style: normal;
}

.homework-progress-count small {
  margin-left: 2px;
  font-size: 9px;
}

.homework-progress-actions button,
.homework-missing-list button {
  border: 1px solid #afd0c6;
  cursor: pointer;
  color: #12665c;
  background: rgba(255, 255, 255, 0.84);
  font: inherit;
  transition:
    color 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 180ms ease,
    transform 200ms var(--ease-spring);
}

.homework-progress-actions button {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.homework-progress-actions button span {
  display: inline-block;
  margin-left: 4px;
  transition: transform 180ms ease;
}

.homework-progress-actions button:hover:not(:disabled),
.homework-missing-list button:hover {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
  box-shadow: 0 8px 18px rgba(20, 125, 113, 0.2);
  transform: translateY(-2px);
}

.homework-progress-actions button:hover:not(:disabled) span {
  transform: translateX(3px);
}

.homework-progress-actions button:disabled {
  cursor: default;
  border-color: #a8d8c2;
  color: #257857;
  background: #e4f4eb;
}

.homework-progress-track {
  height: 3px;
  background: rgba(166, 194, 185, 0.28);
}

.homework-progress-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, var(--teal), #59bda1, var(--amber));
  box-shadow: 0 0 8px rgba(20, 125, 113, 0.25);
  transition: width 300ms var(--ease-out);
}

.homework-missing {
  border-top: 1px solid rgba(167, 195, 187, 0.42);
}

.homework-missing summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 8px 18px;
  cursor: pointer;
  color: #647b75;
  font-size: 9px;
  font-weight: 700;
  list-style: none;
  transition: color 160ms ease, background 160ms ease;
}

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

.homework-missing summary:hover {
  color: var(--teal-dark);
  background: rgba(223, 241, 235, 0.5);
}

.homework-missing summary b {
  color: #8aa09a;
  font-size: 12px;
  transition: transform 180ms ease;
}

.homework-missing[open] summary b {
  transform: rotate(180deg);
}

.homework-missing-list {
  display: flex;
  max-height: 150px;
  flex-wrap: wrap;
  gap: 7px;
  overflow: auto;
  padding: 4px 16px 13px 18px;
}

.homework-missing-list button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 9px;
  line-height: 1.2;
}

.homework-missing-list button b {
  color: inherit;
  font-size: 10px;
}

.homework-missing-list button small {
  color: #9a6a2e;
  font-size: 8px;
}

.homework-missing-list button:hover small {
  color: rgba(255, 255, 255, 0.78);
}

.answer-form {
  scroll-margin-top: 132px;
}

.answer-question-status {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 8px;
  padding: 2px 7px;
  border: 1px solid #e5c69d;
  border-radius: 999px;
  color: #9a6320;
  background: #fff8ec;
  font-size: 8px;
  font-style: normal;
  font-weight: 750;
  vertical-align: middle;
}

.answer-form.answer-complete .answer-question-status {
  border-color: #a8d7c1;
  color: #277653;
  background: #eaf7ef;
}

.answer-form.answer-attention {
  animation: answer-attention 900ms var(--ease-out);
}

@keyframes answer-attention {
  0%, 100% { box-shadow: 0 12px 30px rgba(25, 62, 54, 0.07); }
  35% {
    border-color: var(--amber);
    box-shadow: 0 0 0 5px rgba(215, 154, 61, 0.16), 0 17px 36px rgba(25, 62, 54, 0.12);
    transform: translateY(-2px);
  }
}

@media (max-width: 520px) {
  .answer-form {
    padding: 14px;
  }

  .answer-form-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .answer-diagram-tools-heading,
  .answer-diagram-preview-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .answer-diagram-actions button {
    min-height: 40px;
    flex: 1 1 calc(50% - 6px);
  }

  .answer-diagram-actions .answer-preview-toggle,
  .answer-diagram-actions .answer-whiteboard-toggle {
    margin-left: 0;
    flex-basis: 100%;
  }

  .answer-whiteboard-heading,
  .whiteboard-footer {
    align-items: flex-start;
  }

  .answer-whiteboard-heading {
    flex-direction: column;
  }

  .whiteboard-window-actions {
    width: 100%;
    justify-content: space-between;
  }

  .answer-whiteboard .whiteboard-tool-row {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 3px;
  }

  .whiteboard-tool-group button,
  .whiteboard-action-group button {
    min-height: 40px;
    flex: 1 1 calc(25% - 6px);
  }

  .answer-whiteboard .whiteboard-style-group {
    align-items: stretch;
    flex-direction: column;
  }

  .answer-whiteboard .whiteboard-style-group label,
  .answer-whiteboard .whiteboard-style-group .whiteboard-label-control,
  .whiteboard-style-group input[type="text"] {
    width: 100%;
    flex: 0 0 auto;
  }

  .whiteboard-footer {
    flex-direction: column;
  }

  .whiteboard-footer .button {
    width: 100%;
  }

  .answer-whiteboard .whiteboard-toolbar {
    max-height: 34vh;
  }

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

  .choice-options button {
    min-height: 36px;
    flex: 1;
  }

  .homework-progress {
    top: 8px;
    margin-bottom: 22px;
    border-radius: 14px;
  }

  .homework-progress-main {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
    padding: 11px 12px 10px 15px;
  }

  .homework-progress-ring,
  .homework-progress-copy small,
  .homework-progress-count {
    display: none;
  }

  .homework-progress-copy strong {
    font-size: 12px;
  }

  .homework-progress-actions {
    gap: 0;
  }

  .homework-progress-actions button {
    height: 32px;
    padding: 0 9px;
  }

  .homework-missing-list {
    max-height: 126px;
  }
}

.outline-panel {
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 140px);
  overflow: auto;
  padding-right: 17px;
  border-right: 1px solid var(--line);
  transition: padding 220ms ease, border-color 220ms ease;
}

.outline-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.outline-toggle {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  color: #60706e;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 4px 12px rgba(24, 45, 42, 0.05);
  transition:
    color 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    transform 240ms var(--ease-spring);
}

.outline-toggle:hover {
  border-color: #9db5b0;
  color: var(--teal-dark);
  background: #fff;
  transform: translateX(-2px);
}

.outline-toggle span {
  font-size: 18px;
  line-height: 1;
}

.outline-collapsed .outline-panel {
  overflow: visible;
  padding-right: 6px;
}

.outline-collapsed .outline-heading {
  justify-content: center;
}

.outline-collapsed .outline-label,
.outline-collapsed .outline-panel nav {
  display: none;
}

.outline-collapsed .outline-toggle:hover {
  transform: translateX(2px);
}

.outline-label,
.pane-label {
  margin-bottom: 13px;
  color: #8a9693;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.outline-heading .outline-label {
  margin-bottom: 0;
}

.outline-panel a {
  display: block;
  margin: 4px 0;
  padding: 5px 7px;
  border-radius: 6px;
  color: #72807f;
  font-size: 10px;
  line-height: 1.45;
  text-decoration: none;
}

.outline-panel a.level-3 {
  padding-left: 17px;
}

.outline-panel a:hover {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.source-view {
  overflow: auto;
  margin: 0;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #293b3a;
  background: #fff;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.72;
  white-space: pre-wrap;
}

.editor-view {
  padding: 20px 24px 24px;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 34px;
  color: #71807e;
  font-size: 10px;
}

.editing-pill {
  margin-right: 9px;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-weight: 700;
}

.editor-grid {
  display: grid;
  height: calc(100% - 34px);
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.editor-pane,
.preview-pane {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  padding-top: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.pane-label {
  padding: 0 16px;
}

#markdown-editor {
  width: 100%;
  min-height: 0;
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  padding: 4px 18px 24px;
  color: #243635;
  background: #fff;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.72;
  tab-size: 2;
}

.preview-pane {
  background: var(--paper);
}

.preview-pane .markdown-body {
  overflow: auto;
  padding: 3px 22px 40px;
}

.markdown-body.compact {
  font-size: 13px;
}

.markdown-body.compact h1 {
  font-size: 26px;
}

.markdown-body.compact h2 {
  margin-top: 34px;
  font-size: 21px;
}

.study-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-left: 1px solid var(--line);
  z-index: 20;
}

.study-header {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  padding: 21px 20px 15px;
}

.study-kicker {
  color: var(--teal);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.study-header h2 {
  margin: 5px 0 0;
  font-family: Georgia, "Noto Serif SC", "Microsoft YaHei", serif;
  font-size: 19px;
  font-weight: 620;
}

.assistant-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0 20px;
  padding: 3px;
  border-radius: 10px;
  background: #eef2ef;
}

.assistant-tabs button {
  padding: 8px;
  border-radius: 8px;
  font-size: 11px;
}

.assistant-tabs button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 8px rgba(28, 47, 44, 0.08);
  font-weight: 700;
}

.assistant-section {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 18px 20px;
}

.assistant-section form > label,
.mode-row label {
  display: block;
  margin-bottom: 8px;
  color: #667572;
  font-size: 10px;
  font-weight: 650;
}

.assistant-input {
  position: relative;
}

.assistant-input textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: 0;
  padding: 12px 42px 12px 12px;
  color: var(--ink);
  background: #fbfcfa;
  font-size: 12px;
  line-height: 1.6;
}

.assistant-input textarea:focus {
  border-color: #70aaa0;
  box-shadow: 0 0 0 3px rgba(20, 125, 113, 0.10);
}

.assistant-input button {
  position: absolute;
  right: 8px;
  bottom: 9px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  color: #fff;
  background: var(--teal);
}

.assistant-input button:disabled {
  cursor: not-allowed;
  background: #a9b5b2;
}

.search-tip {
  margin: 8px 2px 16px;
  color: #98a19f;
  font-size: 9px;
}

.assistant-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-assistant {
  display: grid;
  min-height: 170px;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: #9aa6a3;
  text-align: center;
}

.empty-assistant span {
  font-family: Georgia, serif;
  font-size: 28px;
  color: #a6bdb7;
}

.empty-assistant p {
  max-width: 210px;
  margin: 0;
  font-size: 10px;
  line-height: 1.6;
}

.result-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  background: #fff;
  transition: border-color 130ms ease, transform 130ms ease;
}

.result-card:hover {
  border-color: #8db4ad;
  transform: translateY(-1px);
}

.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.result-type {
  padding: 3px 6px;
  border-radius: 6px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 8px;
  font-weight: 750;
}

.result-path {
  overflow: hidden;
  color: #9aa4a2;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card strong {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 6px;
  font-size: 11px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.result-card p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: #657472;
  font-size: 9px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.model-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f7f8f6;
}

.status-light {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ba7a5;
}

.model-status.online .status-light {
  background: #3fa57c;
  box-shadow: 0 0 0 4px rgba(63, 165, 124, 0.13);
}

.model-status.offline .status-light {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(215, 154, 61, 0.13);
}

.model-status strong,
.model-status small {
  display: block;
}

.model-status strong {
  font-size: 10px;
}

.model-status small {
  margin-top: 2px;
  color: #83908e;
  font-size: 8px;
}

.mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 8px;
}

.mode-row label {
  margin: 0;
}

.mode-row select {
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  padding: 6px 8px;
  color: #51605e;
  background: #fff;
  font-size: 9px;
}

.answer-card {
  padding: 14px;
  border: 1px solid #cae0da;
  border-radius: 12px;
  background: #f5faf7;
}

.answer-card .markdown-body {
  font-size: 10px;
  line-height: 1.72;
}

.answer-card .markdown-body h1,
.answer-card .markdown-body h2,
.answer-card .markdown-body h3 {
  margin: 14px 0 8px;
  font-family: inherit;
  font-size: 12px;
}

.answer-card .markdown-body h2::before {
  display: none;
}

.source-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.source-chip {
  border: 1px solid #bfd7d1;
  border-radius: 7px;
  cursor: pointer;
  padding: 4px 6px;
  color: var(--teal-dark);
  background: #fff;
  font-size: 8px;
}

.index-summary span,
.index-summary small {
  display: block;
}

.index-summary span {
  color: #4d5d5a;
  font-size: 9px;
  font-weight: 650;
}

.index-summary small {
  margin-top: 2px;
  color: #94a09e;
  font-size: 8px;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 9px;
}

.loading-card {
  min-height: 78px;
  border-radius: 11px;
  background: linear-gradient(90deg, #f0f3f0 25%, #f8faf8 50%, #f0f3f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}

.skeleton-list {
  padding: 5px;
}

.skeleton-list span {
  display: block;
  height: 44px;
  margin: 7px 0;
  border-radius: 10px;
  background: linear-gradient(90deg, #eff2ef 25%, #f8faf8 50%, #eff2ef 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}

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

.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  z-index: 700;
  flex-direction: column;
  gap: 8px;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 11px 14px;
  border: 1px solid #cdd8d1;
  border-radius: 11px;
  color: #253735;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  font-size: 11px;
  animation: toast-in 180ms ease-out;
}

.toast.error {
  border-color: #e4b8ae;
  color: #7e352c;
}

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

.mobile-overlay {
  display: none;
}

@media (max-width: 1280px) {
  :root {
    --sidebar: 270px;
    --assistant: 310px;
  }

  .reading-layout,
  .reading-layout.outline-collapsed {
    grid-template-columns: minmax(0, 760px);
    gap: 0;
  }

  .outline-panel {
    display: none;
  }

  .overview-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .study-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 92vw);
    transform: translateX(105%);
    box-shadow: -20px 0 50px rgba(22, 42, 39, 0.18);
    transition: transform 200ms ease;
  }

  .study-panel.open {
    transform: translateX(0);
  }

  .mobile-close {
    display: grid;
  }

  .assistant-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: grid;
    width: 48px;
    height: 48px;
    z-index: 18;
    place-items: center;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    background: var(--teal);
    box-shadow: 0 10px 26px rgba(20, 125, 113, 0.3);
  }

  .mobile-overlay.visible {
    position: fixed;
    inset: 0;
    display: block;
    z-index: 19;
    background: rgba(23, 39, 40, 0.28);
    backdrop-filter: blur(2px);
  }

  .study-panel.open {
    z-index: 21;
  }
}

@media (max-width: 720px) {
  body {
    overflow: auto;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .library-panel {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 88vw);
    transform: translateX(-105%);
    box-shadow: 20px 0 50px rgba(22, 42, 39, 0.18);
    transition: transform 200ms ease;
  }

  .library-panel.open {
    transform: translateX(0);
    z-index: 22;
  }

  .workspace {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .workspace-header {
    min-height: 68px;
    padding: 10px 14px;
  }

  .mobile-menu {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
  }

  .document-identity h1 {
    max-width: 44vw;
    font-size: 14px;
  }

  .view-toggle {
    display: none !important;
  }

  .button {
    min-height: 34px;
    padding: 0 10px;
  }

  #edit-button span,
  #save-button span {
    display: none;
  }

  .welcome-view {
    padding: 50px 22px 90px;
  }

  .welcome-copy h2 {
    font-size: 36px;
  }

  .overview-grid {
    grid-template-columns: 1fr 1fr;
    margin-top: 42px;
  }

  .metric-card {
    min-height: 128px;
    padding: 15px;
  }

  .workflow-strip {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .workflow-strip i {
    width: 1px;
    height: 14px;
    margin: 0 0 0 11px;
  }

  .reading-layout {
    padding: 32px 21px 90px;
  }

  .markdown-body {
    font-size: 14px;
  }

  .markdown-body h1 {
    font-size: 28px;
  }

  .markdown-body h2 {
    font-size: 22px;
  }

  .editor-view {
    padding: 12px;
  }

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

  .preview-pane {
    display: none;
  }
}

/* Motion and interaction layer */

:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.16, 1.35, 0.3, 1);
}

* {
  scrollbar-width: thin;
  scrollbar-color: #b8c7c2 transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 10px;
  background: #b8c7c2;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: #82a49d;
  background-clip: padding-box;
}

.brand {
  cursor: default;
}

.brand-mark {
  position: relative;
  overflow: hidden;
  transition:
    transform 420ms var(--ease-spring),
    box-shadow 300ms ease,
    border-radius 300ms ease;
}

.brand-mark::after {
  position: absolute;
  inset: -70% -40%;
  background: linear-gradient(
    110deg,
    transparent 34%,
    rgba(255, 255, 255, 0.32) 48%,
    transparent 62%
  );
  content: "";
  transform: translateX(-65%) rotate(10deg);
  transition: transform 650ms var(--ease-out);
}

.brand:hover .brand-mark {
  border-radius: 7px 15px 7px 15px;
  transform: translateY(-2px) rotate(-5deg) scale(1.05);
  box-shadow: 0 14px 28px rgba(23, 39, 40, 0.26);
}

.brand:hover .brand-mark::after {
  transform: translateX(65%) rotate(10deg);
}

.search-field:hover {
  border-color: #b3c7c1;
  background: #fff;
}

.document-item {
  position: relative;
  overflow: hidden;
  animation: item-rise 420ms var(--ease-out) backwards;
  animation-delay: min(calc(var(--item-index, 0) * 18ms), 240ms);
  transition:
    background 180ms ease,
    transform 240ms var(--ease-spring),
    box-shadow 180ms ease,
    color 180ms ease;
}

.document-item:hover {
  box-shadow: 0 8px 22px rgba(28, 59, 53, 0.08);
  transform: translateX(5px);
}

.type-dot {
  transition: transform 220ms var(--ease-spring), box-shadow 220ms ease;
}

.document-item:hover .type-dot,
.document-item.active .type-dot {
  box-shadow: 0 0 0 4px rgba(20, 125, 113, 0.12);
  transform: scale(1.28);
}

.icon-button {
  transition:
    color 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    transform 240ms var(--ease-spring),
    box-shadow 180ms ease;
}

.icon-button:hover {
  box-shadow: 0 7px 18px rgba(23, 55, 49, 0.10);
  transform: translateY(-2px) rotate(4deg);
}

.workspace {
  --pointer-x: 78%;
  --pointer-y: 8%;
  position: relative;
  background:
    radial-gradient(
      circle at var(--pointer-x) var(--pointer-y),
      rgba(202, 235, 222, 0.76),
      transparent 29%
    ),
    var(--paper);
  isolation: isolate;
}

.workspace::before,
.workspace::after {
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  pointer-events: none;
  content: "";
  filter: blur(4px);
}

.workspace::before {
  top: 8%;
  right: 7%;
  width: 230px;
  height: 230px;
  border: 1px solid rgba(20, 125, 113, 0.09);
  background: rgba(223, 241, 235, 0.38);
  animation: ambient-float 12s ease-in-out infinite;
}

.workspace::after {
  right: 30%;
  bottom: 5%;
  width: 130px;
  height: 130px;
  border: 1px solid rgba(215, 154, 61, 0.09);
  background: rgba(251, 239, 217, 0.36);
  animation: ambient-float 15s ease-in-out -5s infinite reverse;
}

.workspace-header,
.welcome-view,
.document-view,
.editor-view {
  position: relative;
  z-index: 1;
}

.workspace-header {
  overflow: hidden;
}

.reading-progress {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--teal), #52b59a, var(--amber));
  box-shadow: 0 0 10px rgba(20, 125, 113, 0.35);
  opacity: 0;
  transform-origin: left center;
  transition: width 100ms linear, opacity 220ms ease;
}

.reading-progress.visible {
  opacity: 1;
}

.button {
  position: relative;
  overflow: hidden;
  transition:
    transform 180ms var(--ease-spring),
    box-shadow 180ms ease,
    background 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button::after {
  position: absolute;
  top: -80%;
  left: -60%;
  width: 45%;
  height: 260%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.35),
    transparent
  );
  content: "";
  pointer-events: none;
  transform: rotate(18deg);
  transition: left 600ms var(--ease-out);
}

.button:hover::after {
  left: 125%;
}

.button.primary:hover {
  box-shadow: 0 12px 25px rgba(20, 125, 113, 0.28);
}

.welcome-copy > * {
  animation: hero-rise 720ms var(--ease-out) backwards;
}

.welcome-copy > :nth-child(1) { animation-delay: 40ms; }
.welcome-copy > :nth-child(2) { animation-delay: 100ms; }
.welcome-copy > :nth-child(3) { animation-delay: 180ms; }
.welcome-copy > :nth-child(4) { animation-delay: 250ms; }

.welcome-copy h2 {
  text-wrap: balance;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.metric-card {
  position: relative;
  overflow: hidden;
  animation: card-rise 650ms var(--ease-out) backwards;
  transition:
    transform 360ms var(--ease-spring),
    box-shadow 280ms ease,
    border-color 280ms ease;
}

.metric-card:nth-child(1) { animation-delay: 180ms; }
.metric-card:nth-child(2) { animation-delay: 240ms; }
.metric-card:nth-child(3) { animation-delay: 300ms; }
.metric-card:nth-child(4) { animation-delay: 360ms; }

.metric-card::after {
  position: absolute;
  top: -60px;
  right: -60px;
  width: 120px;
  height: 120px;
  border: 1px solid rgba(20, 125, 113, 0.10);
  border-radius: 50%;
  background: rgba(223, 241, 235, 0.28);
  content: "";
  transition: transform 500ms var(--ease-spring);
}

.metric-card:hover {
  border-color: #acc8c0;
  box-shadow: 0 20px 45px rgba(26, 58, 52, 0.12);
  transform: translateY(-7px) scale(1.015);
}

.metric-card:hover::after {
  transform: translate(-18px, 18px) scale(1.3);
}

.workflow-strip {
  animation: hero-rise 720ms 420ms var(--ease-out) backwards;
}

.document-view.page-enter .markdown-body > :nth-child(-n+12) {
  animation: content-rise 500ms var(--ease-out) backwards;
}

.document-view.page-enter .markdown-body > :nth-child(2) { animation-delay: 35ms; }
.document-view.page-enter .markdown-body > :nth-child(3) { animation-delay: 70ms; }
.document-view.page-enter .markdown-body > :nth-child(4) { animation-delay: 105ms; }
.document-view.page-enter .markdown-body > :nth-child(5) { animation-delay: 140ms; }
.document-view.page-enter .markdown-body > :nth-child(n+6) { animation-delay: 175ms; }

.markdown-body a {
  transition: color 150ms ease, background 150ms ease;
}

.markdown-body a:hover {
  color: #084b45;
  background: rgba(223, 241, 235, 0.7);
}

.markdown-body blockquote {
  transition: transform 220ms var(--ease-out), box-shadow 220ms ease;
}

.markdown-body blockquote:hover {
  box-shadow: 0 10px 28px rgba(20, 125, 113, 0.10);
  transform: translateX(4px);
}

.table-wrap {
  transition: box-shadow 220ms ease, border-color 220ms ease;
}

.table-wrap:hover {
  border-color: #b4ccc5;
  box-shadow: 0 12px 30px rgba(27, 54, 50, 0.08);
}

.outline-panel a {
  transition:
    color 160ms ease,
    background 160ms ease,
    transform 200ms var(--ease-spring);
}

.outline-panel a:hover {
  transform: translateX(4px);
}

.editor-pane,
.preview-pane {
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 240ms var(--ease-out);
}

.editor-pane:focus-within,
.preview-pane:hover {
  border-color: #9fbeb6;
  box-shadow: 0 14px 34px rgba(25, 55, 50, 0.09);
  transform: translateY(-2px);
}

.assistant-tabs button {
  transition:
    color 180ms ease,
    background 180ms ease,
    transform 220ms var(--ease-spring);
}

.assistant-tabs button:hover {
  color: var(--teal-dark);
  transform: translateY(-1px);
}

.result-card {
  position: relative;
  overflow: hidden;
  animation: result-rise 400ms var(--ease-out) backwards;
  animation-delay: calc(var(--result-index, 0) * 55ms);
  transition:
    border-color 180ms ease,
    transform 260ms var(--ease-spring),
    box-shadow 220ms ease;
}

.result-card::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: linear-gradient(var(--teal), #64baa2);
  content: "";
  opacity: 0;
  transform: scaleY(0.2);
  transition: opacity 180ms ease, transform 260ms var(--ease-spring);
}

.result-card:hover {
  box-shadow: 0 13px 28px rgba(22, 59, 52, 0.11);
  transform: translateY(-4px) translateX(2px);
}

.result-card:hover::before {
  opacity: 1;
  transform: scaleY(1);
}

.model-status.online .status-light {
  animation: status-pulse 2.4s ease-in-out infinite;
}

.back-to-top {
  position: absolute;
  right: 24px;
  bottom: 24px;
  display: grid;
  width: 40px;
  height: 40px;
  z-index: 12;
  place-items: center;
  border: 1px solid rgba(20, 125, 113, 0.2);
  border-radius: 12px;
  cursor: pointer;
  color: #fff;
  background: rgba(20, 125, 113, 0.9);
  box-shadow: 0 10px 26px rgba(20, 125, 113, 0.24);
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(0.8);
  transition:
    opacity 200ms ease,
    transform 300ms var(--ease-spring),
    background 180ms ease;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.back-to-top:hover {
  background: var(--teal-dark);
  transform: translateY(-3px) scale(1.06);
}

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

@keyframes card-rise {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes result-rise {
  from {
    opacity: 0;
    transform: translateY(9px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes ambient-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(-24px, 18px, 0) scale(1.08);
  }
}

@keyframes status-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 4px rgba(63, 165, 124, 0.13);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(63, 165, 124, 0.03);
  }
}

@media (max-width: 980px) {
  .assistant-fab {
    animation: status-pulse 2.8s ease-in-out infinite;
  }

  .back-to-top {
    bottom: 84px;
  }
}

@media (max-width: 720px) {
  .back-to-top {
    position: fixed;
    right: 18px;
  }
}

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

  .workspace::before,
  .workspace::after {
    display: none;
  }
}

/* Theme switcher */

html {
  color-scheme: light;
}

.theme-toggle {
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 50%;
}

.theme-toggle span {
  display: block;
  line-height: 1;
}

.theme-toggle.switching span {
  animation: theme-icon-pop 420ms var(--ease-spring);
}

@keyframes theme-icon-pop {
  0% {
    opacity: 0;
    transform: rotate(-70deg) scale(0.35);
  }
  100% {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

html[data-theme="dark"] {
  --ink: #e8f0ed;
  --ink-soft: #a8b8b3;
  --paper: #101816;
  --canvas: #0a100f;
  --panel: #121c1a;
  --line: #293733;
  --line-strong: #3b4d48;
  --teal: #4fc4ae;
  --teal-dark: #7bd8c5;
  --teal-soft: #193a34;
  --amber: #e0aa54;
  --amber-soft: #392d1b;
  --red: #ef8f7d;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  color-scheme: dark;
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  background: var(--canvas);
}

html[data-theme="dark"] .library-panel,
html[data-theme="dark"] .study-panel {
  background: var(--panel);
}

html[data-theme="dark"] .brand-mark {
  color: #10201d;
  background: #dceae6;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.36);
}

html[data-theme="dark"] .brand-subtitle,
html[data-theme="dark"] .library-tab,
html[data-theme="dark"] .assistant-tabs button,
html[data-theme="dark"] .view-toggle button,
html[data-theme="dark"] .local-note,
html[data-theme="dark"] .workflow-strip,
html[data-theme="dark"] .editor-toolbar,
html[data-theme="dark"] .search-tip,
html[data-theme="dark"] .model-status small,
html[data-theme="dark"] .index-summary small {
  color: #8fa09c;
}

html[data-theme="dark"] .search-field {
  color: #8fa09c;
  background: #17221f;
}

html[data-theme="dark"] .search-field:hover,
html[data-theme="dark"] .search-field:focus-within {
  border-color: #55736c;
  background: #1b2825;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #71827e;
}

html[data-theme="dark"] .group-heading,
html[data-theme="dark"] .outline-label,
html[data-theme="dark"] .pane-label {
  color: #7e908b;
}

html[data-theme="dark"] .group-heading b,
html[data-theme="dark"] .assistant-tabs,
html[data-theme="dark"] .view-toggle {
  background: #1b2724;
}

html[data-theme="dark"] .document-item:hover {
  background: #192724;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
}

html[data-theme="dark"] .document-item small,
html[data-theme="dark"] .result-path {
  color: #71827e;
}

html[data-theme="dark"] .library-footer,
html[data-theme="dark"] .study-footer {
  background: rgba(18, 28, 26, 0.94);
}

html[data-theme="dark"] .icon-button,
html[data-theme="dark"] .outline-toggle,
html[data-theme="dark"] .button.secondary,
html[data-theme="dark"] .view-toggle button.active,
html[data-theme="dark"] .assistant-tabs button.active,
html[data-theme="dark"] .mode-row select {
  color: #d7e2de;
  background: #1a2724;
}

html[data-theme="dark"] .icon-button:hover,
html[data-theme="dark"] .outline-toggle:hover,
html[data-theme="dark"] .button.secondary:hover {
  border-color: #527068;
  color: var(--teal-dark);
  background: #20302c;
}

html[data-theme="dark"] .button.ghost {
  color: #a0b0ac;
}

html[data-theme="dark"] .button.primary,
html[data-theme="dark"] .assistant-input button,
html[data-theme="dark"] .assistant-fab {
  color: #071310;
}

html[data-theme="dark"] .workspace {
  background:
    radial-gradient(
      circle at var(--pointer-x) var(--pointer-y),
      rgba(36, 91, 78, 0.46),
      transparent 31%
    ),
    var(--paper);
}

html[data-theme="dark"] .workspace::before {
  border-color: rgba(79, 196, 174, 0.08);
  background: rgba(30, 77, 67, 0.18);
}

html[data-theme="dark"] .workspace::after {
  border-color: rgba(224, 170, 84, 0.08);
  background: rgba(93, 66, 27, 0.16);
}

html[data-theme="dark"] .workspace-header {
  border-bottom-color: rgba(50, 68, 63, 0.82);
  background: rgba(16, 24, 22, 0.9);
}

html[data-theme="dark"] .site-compliance {
  border-top-color: rgba(50, 68, 63, 0.82);
  color: #758681;
  background: rgba(16, 24, 22, 0.9);
}

html[data-theme="dark"] .site-compliance a {
  color: #9eb4ae;
}

html[data-theme="dark"] .welcome-copy h2 {
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
}

html[data-theme="dark"] .metric-card {
  border-color: #2d3d39;
  background: rgba(23, 34, 31, 0.86);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.18);
}

html[data-theme="dark"] .metric-card.accent {
  color: #e8f2ee;
  border-color: #31554c;
  background: #173029;
}

html[data-theme="dark"] .metric-card.model-card {
  background: #312719;
}

html[data-theme="dark"] .metric-card span,
html[data-theme="dark"] .metric-card small {
  color: #91a19d;
}

html[data-theme="dark"] .metric-card.accent span,
html[data-theme="dark"] .metric-card.accent small {
  color: #a7c3bb;
}

html[data-theme="dark"] .metric-card::after {
  border-color: rgba(79, 196, 174, 0.1);
  background: rgba(38, 83, 73, 0.2);
}

html[data-theme="dark"] .metric-card:hover {
  border-color: #48675f;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .workflow-strip i {
  background: #3c4b47;
}

html[data-theme="dark"] .markdown-body {
  color: #c7d3cf;
}

html[data-theme="dark"] .markdown-body h1,
html[data-theme="dark"] .markdown-body h2,
html[data-theme="dark"] .markdown-body h3,
html[data-theme="dark"] .markdown-body h4,
html[data-theme="dark"] .markdown-body strong {
  color: #edf4f1;
}

html[data-theme="dark"] .markdown-body a {
  color: #79d4c1;
  text-decoration-color: #397b6d;
}

html[data-theme="dark"] .markdown-body a:hover {
  color: #a0eadb;
  background: rgba(38, 91, 80, 0.48);
}

html[data-theme="dark"] .markdown-body code {
  border-color: #3b4945;
  color: #f1a58f;
  background: #1d2825;
}

html[data-theme="dark"] .markdown-body pre {
  color: #d8e7e2;
  background: #09100f;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .markdown-body pre code {
  color: inherit;
  background: transparent;
}

html[data-theme="dark"] .mermaid-diagram {
  border-color: #334b45;
  background:
    radial-gradient(circle at 92% 0, rgba(75, 190, 164, .11), transparent 34%),
    #111b19;
  box-shadow: 0 16px 38px rgba(0, 0, 0, .3);
}

html[data-theme="dark"] .diagram-heading {
  border-color: #30433e;
  color: #84d6c4;
  background: rgba(25, 47, 41, .76);
}

html[data-theme="dark"] .diagram-heading small {
  color: #829690;
}

html[data-theme="dark"] .diagram-expand-button {
  border-color: #45675e;
  color: #a5dfd1;
  background: rgba(27, 50, 44, .9);
}

html[data-theme="dark"] .diagram-expand-button:hover,
html[data-theme="dark"] .diagram-expand-button:focus-visible {
  border-color: #72c9b5;
  color: #10201c;
  background: #72c9b5;
}

html[data-theme="dark"] .diagram-preview-shell,
html[data-theme="dark"] .diagram-preview-header {
  border-color: #385149;
  color: #cadbd6;
  background: #111c19;
}

html[data-theme="dark"] .diagram-preview-title h2 {
  color: #e0ede9;
}

html[data-theme="dark"] .diagram-preview-title small {
  color: #879b95;
}

html[data-theme="dark"] .diagram-preview-controls button {
  border-color: #3d5951;
  color: #b6d9d0;
  background: #1a2a26;
}

html[data-theme="dark"] .diagram-preview-controls button:hover:not(:disabled),
html[data-theme="dark"] .diagram-preview-controls button:focus-visible {
  border-color: #68b7a6;
  background: #254139;
}

html[data-theme="dark"] .diagram-preview-controls output {
  color: #aac4bd;
}

html[data-theme="dark"] .diagram-preview-controls .diagram-preview-close {
  color: #10201c;
  background: #78c8b6;
}

html[data-theme="dark"] .diagram-preview-viewport {
  background-color: #0c1513;
  background-image:
    linear-gradient(rgba(119, 178, 163, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(119, 178, 163, .08) 1px, transparent 1px);
}

html[data-theme="dark"] .diagram-loading {
  color: #94aaa4;
  background: linear-gradient(105deg, #172420 32%, #22332e 46%, #172420 60%);
  background-size: 220% 100%;
}

html[data-theme="dark"] .diagram-error-message {
  color: #f0a294;
}

html[data-theme="dark"] .diagram-error-message + small {
  color: #aa918b;
}

html[data-theme="dark"] .markdown-body blockquote {
  color: #b8cec8;
  background: #17332d;
}

html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .source-view,
html[data-theme="dark"] .editor-pane,
html[data-theme="dark"] .result-card {
  background: #151f1d;
}

html[data-theme="dark"] .markdown-body th {
  color: #d2e2dd;
  background: #1d302b;
}

html[data-theme="dark"] .outline-panel a,
html[data-theme="dark"] .result-card p {
  color: #92a49f;
}

html[data-theme="dark"] .source-view,
html[data-theme="dark"] #markdown-editor {
  color: #cad7d3;
  background: #111a18;
}

html[data-theme="dark"] .preview-pane {
  background: #101816;
}

html[data-theme="dark"] .assistant-input textarea {
  color: var(--ink);
  background: #15201d;
}

html[data-theme="dark"] .assistant-input textarea:focus {
  border-color: #4d8175;
  box-shadow: 0 0 0 3px rgba(79, 196, 174, 0.12);
}

html[data-theme="dark"] .empty-assistant,
html[data-theme="dark"] .index-summary span {
  color: #8fa09c;
}

html[data-theme="dark"] .empty-assistant span {
  color: #638b81;
}

html[data-theme="dark"] .result-card:hover,
html[data-theme="dark"] .table-wrap:hover,
html[data-theme="dark"] .editor-pane:focus-within,
html[data-theme="dark"] .preview-pane:hover {
  border-color: #4b7268;
  box-shadow: 0 13px 30px rgba(0, 0, 0, 0.25);
}

html[data-theme="dark"] .answer-form {
  border-color: #31574e;
  background:
    linear-gradient(135deg, rgba(24, 58, 50, 0.82), rgba(18, 29, 26, 0.94) 64%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

html[data-theme="dark"] .answer-form-heading {
  color: #87dfcc;
}

html[data-theme="dark"] .answer-form-heading small,
html[data-theme="dark"] .answer-save-status {
  color: #879a95;
}

html[data-theme="dark"] .answer-form-field > span {
  color: #c1d4ce;
}

html[data-theme="dark"] .answer-control,
html[data-theme="dark"] .choice-options button {
  border-color: #3b514b;
  color: #d6e2de;
  background: rgba(13, 22, 19, 0.8);
}

html[data-theme="dark"] .answer-control:focus {
  border-color: #559b8c;
  background: #111c19;
  box-shadow: 0 0 0 3px rgba(79, 196, 174, 0.13);
}

html[data-theme="dark"] .answer-diagram-tools {
  border-color: #3a5b53;
  background: rgba(19, 40, 35, 0.75);
}

html[data-theme="dark"] .answer-diagram-tools-heading span,
html[data-theme="dark"] .answer-diagram-preview-heading,
html[data-theme="dark"] .answer-diagram-empty strong {
  color: #91d9c9;
}

html[data-theme="dark"] .answer-diagram-tools-heading small,
html[data-theme="dark"] .answer-diagram-preview-heading small,
html[data-theme="dark"] .answer-diagram-empty {
  color: #879b95;
}

html[data-theme="dark"] .answer-diagram-actions button {
  border-color: #46645d;
  color: #bad4cd;
  background: rgba(14, 25, 22, 0.9);
}

html[data-theme="dark"] .answer-diagram-actions button:hover,
html[data-theme="dark"] .answer-diagram-actions .answer-preview-toggle {
  border-color: #5e9b8d;
  color: #9ee5d5;
  background: #18332c;
}

html[data-theme="dark"] .answer-diagram-actions .answer-whiteboard-toggle,
html[data-theme="dark"] .answer-diagram-actions .answer-whiteboard-toggle:hover {
  border-color: #61b6a5;
  color: #071612;
  background: #74cfbb;
}

html[data-theme="dark"] .answer-diagram-preview {
  border-color: #3a554e;
  background: rgba(13, 23, 20, 0.92);
}

html[data-theme="dark"] .answer-diagram-preview-heading {
  border-color: #344a44;
  background: rgba(25, 49, 42, 0.78);
}

html[data-theme="dark"] .homework-answer-image {
  border-color: #3b544e;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .answer-whiteboard {
  border-color: #36574f;
  background: #111d19;
  box-shadow: -22px 0 60px rgba(0, 0, 0, 0.46);
}

html[data-theme="dark"] .whiteboard-backdrop {
  background: rgba(3, 12, 10, 0.58);
}

html[data-theme="dark"] .answer-whiteboard-heading,
html[data-theme="dark"] .whiteboard-toolbar,
html[data-theme="dark"] .whiteboard-footer {
  border-color: #304a44;
  background: #182a25;
}

html[data-theme="dark"] .answer-whiteboard-heading {
  color: #8fd7c7;
}

html[data-theme="dark"] .answer-whiteboard-heading small,
html[data-theme="dark"] .whiteboard-hint,
html[data-theme="dark"] .whiteboard-footer span {
  color: #82958f;
}

html[data-theme="dark"] .whiteboard-canvas-shell {
  border-color: #304a44;
  background: #0d1714;
}

html[data-theme="dark"] .whiteboard-canvas-shell canvas {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px #40605a;
}

html[data-theme="dark"] .whiteboard-question {
  border-color: #304a44;
  background: #15241f;
}

html[data-theme="dark"] .whiteboard-question-heading {
  color: #8fd7c7;
}

html[data-theme="dark"] .whiteboard-question-heading button {
  border-color: #405b54;
  color: #c0d5cf;
  background: #101b18;
}

html[data-theme="dark"] .whiteboard-question-body {
  color: #b3c6c1;
}

html[data-theme="dark"] .whiteboard-window-actions button,
html[data-theme="dark"] .whiteboard-toolbar button,
html[data-theme="dark"] .whiteboard-style-group input,
html[data-theme="dark"] .whiteboard-style-group select {
  border-color: #405b54;
  color: #c0d5cf;
  background: #101b18;
}

html[data-theme="dark"] .whiteboard-toolbar button:hover,
html[data-theme="dark"] .whiteboard-toolbar button.active {
  border-color: #5fac9c;
  color: #96e2d1;
  background: #1a3931;
}

html[data-theme="dark"] .whiteboard-style-group {
  border-color: #304a43;
  background: #14231f;
}

html[data-theme="dark"] .whiteboard-style-group label {
  color: #91a49f;
}

html[data-theme="dark"] .whiteboard-tool-row > span,
html[data-theme="dark"] .whiteboard-action-group > [data-whiteboard-zoom-value] {
  color: #91a49f;
}

html[data-theme="dark"] .whiteboard-action-separator {
  background: #39534c;
}

html[data-theme="dark"] .whiteboard-footer span.error {
  color: #f29689;
}

html[data-theme="dark"] .choice-options button:hover {
  border-color: #5d8e82;
  color: #9ce6d6;
  background: #1a2c27;
}

html[data-theme="dark"] .choice-options button.active {
  border-color: var(--teal);
  color: #071310;
  background: var(--teal);
}

html[data-theme="dark"] .answer-form-footer {
  border-top-color: rgba(73, 105, 96, 0.55);
}

html[data-theme="dark"] .answer-form.dirty .answer-save-status {
  color: #e0aa54;
}

html[data-theme="dark"] .homework-progress {
  border-color: #365e54;
  background:
    linear-gradient(135deg, rgba(22, 48, 42, 0.97), rgba(22, 31, 28, 0.96));
  box-shadow: 0 17px 42px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .homework-progress.is-complete {
  border-color: #3f8269;
}

html[data-theme="dark"] .homework-progress-ring {
  background: conic-gradient(var(--teal) var(--homework-progress), #30453f 0);
}

html[data-theme="dark"] .homework-progress-ring::after {
  background: #172622;
}

html[data-theme="dark"] .homework-progress-ring span,
html[data-theme="dark"] .homework-progress-count b {
  color: #8de0ce;
}

html[data-theme="dark"] .homework-progress-kicker,
html[data-theme="dark"] .homework-progress-copy small,
html[data-theme="dark"] .homework-progress-count {
  color: #829c95;
}

html[data-theme="dark"] .homework-progress-copy strong {
  color: #e7f1ee;
}

html[data-theme="dark"] .homework-progress-actions button,
html[data-theme="dark"] .homework-missing-list button {
  border-color: #426a60;
  color: #92ddcd;
  background: rgba(17, 31, 27, 0.88);
}

html[data-theme="dark"] .homework-progress-actions button:hover:not(:disabled),
html[data-theme="dark"] .homework-missing-list button:hover {
  border-color: var(--teal);
  color: #071310;
  background: var(--teal);
}

html[data-theme="dark"] .homework-progress-actions button:disabled {
  border-color: #3d6755;
  color: #8bd5b5;
  background: #18382c;
}

html[data-theme="dark"] .homework-progress-track {
  background: rgba(74, 103, 94, 0.38);
}

html[data-theme="dark"] .homework-missing {
  border-top-color: rgba(66, 99, 90, 0.58);
}

html[data-theme="dark"] .homework-missing summary {
  color: #8da19b;
}

html[data-theme="dark"] .homework-missing summary:hover {
  color: #a4e8d9;
  background: rgba(35, 70, 61, 0.52);
}

html[data-theme="dark"] .homework-missing-list button small {
  color: #d5a65d;
}

html[data-theme="dark"] .answer-question-status {
  border-color: #765b32;
  color: #e3b66e;
  background: #332a1d;
}

html[data-theme="dark"] .answer-form.answer-complete .answer-question-status {
  border-color: #376f58;
  color: #83d2ad;
  background: #183528;
}

html[data-theme="dark"] .model-status {
  background: #17211f;
}

html[data-theme="dark"] .answer-card {
  border-color: #315b51;
  background: #142a25;
}

html[data-theme="dark"] .source-chip {
  border-color: #3e6d62;
  color: #86dbc9;
  background: #172a25;
}

html[data-theme="dark"] .loading-card {
  background: linear-gradient(90deg, #182320 25%, #23322e 50%, #182320 75%);
  background-size: 200% 100%;
}

html[data-theme="dark"] .skeleton-list span {
  background: linear-gradient(90deg, #17221f 25%, #22312d 50%, #17221f 75%);
  background-size: 200% 100%;
}

html[data-theme="dark"] .toast {
  border-color: #41554f;
  color: #d8e4e0;
  background: rgba(22, 33, 30, 0.97);
}

html[data-theme="dark"] .toast.error {
  border-color: #744c44;
  color: #f0aa9d;
}

html[data-theme="dark"] .mobile-menu {
  color: #dce7e3;
  background: #192521;
}

html[data-theme="dark"] .mobile-overlay.visible {
  background: rgba(2, 7, 6, 0.62);
}

html[data-theme="dark"] * {
  scrollbar-color: #465d57 transparent;
}

html[data-theme="dark"] *::-webkit-scrollbar-thumb {
  background: #465d57;
  background-clip: padding-box;
}

html[data-theme="dark"] *::-webkit-scrollbar-thumb:hover {
  background: #5d7a73;
  background-clip: padding-box;
}

/* iPhone installation and offline-reading state */
.offline-manager {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(15, 31, 29, .46);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.offline-manager-card {
  width: min(480px, 100%);
  padding: 25px;
  border: 1px solid rgba(255, 255, 255, .68);
  border-radius: 24px;
  background: rgba(251, 250, 246, .96);
  box-shadow: 0 34px 100px rgba(15, 35, 31, .27);
  animation: offline-manager-in 260ms cubic-bezier(.2, .8, .2, 1) both;
}

.offline-manager-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.offline-manager-card > header span {
  color: var(--teal);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .2em;
}

.offline-manager-card h2 {
  margin: 5px 0 0;
  font: 650 28px Georgia, "Noto Serif SC", "Microsoft YaHei", serif;
}

.offline-manager-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 18px;
  margin-top: 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, .78);
}

.offline-manager-count {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 94px;
}

.offline-manager-count > strong {
  color: var(--teal-dark);
  font: 700 38px Georgia, serif;
}

.offline-manager-count span {
  color: var(--ink-soft);
  font-size: 11px;
}

.offline-manager-summary > div:last-child {
  display: grid;
  gap: 5px;
}

.offline-manager-summary > div:last-child > strong {
  font-size: 13px;
}

.offline-manager-summary small,
.offline-manager-note,
.offline-cache-current {
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.55;
}

.offline-cache-track {
  height: 6px;
  margin: 18px 2px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e9e4;
}

.offline-cache-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #5cc2ad);
  transition: width 220ms ease;
}

.offline-cache-current {
  min-height: 18px;
  margin: 9px 2px 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.offline-manager-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.offline-manager-actions .button {
  min-height: 46px;
}

.offline-manager-note {
  display: block;
  margin-top: 15px;
  text-align: center;
}

body.modal-open {
  overflow: hidden !important;
}

@keyframes offline-manager-in {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
}

.offline-banner,
.ios-install-tip {
  position: fixed;
  z-index: 120;
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  color: #eff8f5;
  background: rgba(16, 38, 36, .94);
  box-shadow: 0 18px 52px rgba(9, 28, 25, .28);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.offline-banner {
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  gap: 10px;
  max-width: calc(100vw - 28px);
  padding: 9px 14px 9px 10px;
  border-radius: 999px;
  transform: translateX(-50%);
  animation: pwa-tip-rise 260ms cubic-bezier(.2, .8, .2, 1) both;
}

.offline-banner > span {
  display: grid;
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #17312d;
  background: #9be3d2;
  font-weight: 900;
}

.offline-banner div,
.ios-install-tip > div:nth-child(2) {
  display: grid;
  gap: 2px;
}

.offline-banner strong,
.ios-install-tip strong {
  font-size: 12px;
}

.offline-banner small,
.ios-install-tip small {
  color: #b9ccc6;
  font-size: 10px;
  line-height: 1.45;
}

.ios-install-tip {
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  gap: 12px;
  width: min(390px, calc(100vw - 36px));
  padding: 13px 42px 13px 13px;
  border-radius: 17px;
  animation: pwa-tip-rise 340ms cubic-bezier(.2, .8, .2, 1) both;
}

.ios-install-icon {
  display: grid !important;
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px 12px 12px 5px;
  color: #17312d;
  background: #9be3d2;
  font: 700 21px Georgia, "Microsoft YaHei", serif;
}

.ios-install-tip b {
  color: #9be3d2;
  font-size: 15px;
}

.ios-install-tip button {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 29px;
  height: 29px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #b9ccc6;
  background: transparent;
  font-size: 19px;
}

.ios-install-tip button:hover {
  color: #fff;
  background: rgba(255, 255, 255, .08);
}

body.offline-mode .pulse-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(215, 154, 61, .13);
}

body.offline-mode .answer-form textarea:disabled,
body.offline-mode .answer-form input:disabled,
body.offline-mode .answer-form button:disabled {
  cursor: not-allowed;
  opacity: .72;
}

html[data-theme="dark"] .offline-manager-card {
  border-color: rgba(145, 185, 173, .18);
  color: #e2ece8;
  background: rgba(20, 31, 28, .97);
}

html[data-theme="dark"] .offline-manager-summary {
  border-color: #354842;
  background: rgba(29, 44, 40, .78);
}

html[data-theme="dark"] .offline-manager-count > strong {
  color: #8fd6c4;
}

html[data-theme="dark"] .offline-cache-track {
  background: #33443f;
}

@keyframes pwa-tip-rise {
  from { opacity: 0; transform: translateY(12px); }
}

.offline-banner {
  animation-name: offline-tip-rise;
}

@keyframes offline-tip-rise {
  from { opacity: 0; transform: translate(-50%, -10px); }
}

@media (max-width: 720px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  .mermaid-diagram {
    margin: 22px -2px;
    border-radius: 13px;
  }

  .diagram-heading {
    padding: 0 13px;
  }

  .mermaid-canvas {
    padding: 18px 13px;
  }

  .mermaid-canvas svg {
    min-width: 620px;
  }

  .diagram-heading small {
    display: none;
  }

  .diagram-preview-modal {
    padding: 0;
  }

  .diagram-preview-shell {
    width: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .diagram-preview-header {
    min-height: 58px;
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 8px 8px 12px;
  }

  .diagram-preview-title > span,
  .diagram-preview-title small {
    display: none;
  }

  .diagram-preview-title h2 {
    font-size: 14px;
  }

  .diagram-preview-controls {
    gap: 4px;
  }

  .diagram-preview-controls button {
    min-width: 32px;
    height: 32px;
    padding: 0 7px;
  }

  .diagram-preview-controls output {
    width: 38px;
    font-size: 9px;
  }

  .diagram-preview-controls .diagram-preview-fit {
    font-size: 0;
  }

  .diagram-preview-controls .diagram-preview-fit::after {
    font-size: 14px;
    content: "⊡";
  }

  .diagram-preview-controls .diagram-preview-close {
    margin-left: 1px;
  }

  button,
  input,
  textarea,
  select {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(20, 125, 113, .14);
  }

  input,
  textarea,
  select {
    font-size: 16px;
  }

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

  .site-compliance {
    min-height: calc(34px + env(safe-area-inset-bottom));
    padding: 7px calc(12px + env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }

  .workspace-header {
    position: sticky;
    top: 0;
    min-height: calc(64px + env(safe-area-inset-top));
    padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 8px calc(10px + env(safe-area-inset-left));
  }

  .document-identity {
    flex: 1;
    min-width: 0;
    gap: 9px;
  }

  .document-identity > div {
    min-width: 0;
  }

  .document-identity h1 {
    max-width: none;
  }

  .header-actions {
    flex: 0 0 auto;
    gap: 5px;
  }

  .icon-button,
  .mobile-menu,
  .mobile-close,
  .library-tab,
  .assistant-tabs button {
    min-width: 44px;
    min-height: 44px;
  }

  .button {
    min-height: 44px;
  }

  .document-item {
    min-height: 52px;
  }

  .answer-form textarea,
  .answer-form input,
  .editor-pane textarea {
    font-size: 16px;
  }

  .library-panel,
  .study-panel {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    -webkit-overflow-scrolling: touch;
  }

  .toast-stack {
    right: 14px;
    bottom: max(84px, calc(env(safe-area-inset-bottom) + 70px));
  }

  .offline-banner {
    top: max(8px, env(safe-area-inset-top));
  }

  .offline-banner small {
    display: none;
  }

  .assistant-fab {
    right: calc(16px + env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: 54px;
    height: 54px;
  }

  .back-to-top {
    right: calc(16px + env(safe-area-inset-right));
    bottom: calc(84px + env(safe-area-inset-bottom));
    width: 46px;
    height: 46px;
  }

  .offline-manager {
    align-items: end;
    padding: max(12px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .offline-manager-card {
    width: 100%;
    padding: 21px 17px max(18px, env(safe-area-inset-bottom));
    border-radius: 22px;
  }

  .offline-manager-summary {
    gap: 12px;
    padding: 15px;
  }

  .offline-manager-actions {
    grid-template-columns: 1fr;
  }

  .offline-cache-current {
    white-space: normal;
  }
}

/* Authentication and cloud-sync status */
body.auth-checking .app-shell,
body.auth-required .app-shell {
  visibility: hidden;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 32px 18px 72px;
  background:
    radial-gradient(circle at 18% 18%, rgba(94, 207, 179, 0.22), transparent 28%),
    radial-gradient(circle at 82% 78%, rgba(225, 168, 79, 0.18), transparent 30%),
    linear-gradient(135deg, #102624, #182f2c 52%, #0b1c1b);
}

.auth-compliance {
  position: absolute;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 18px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: rgba(193, 218, 211, 0.62);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.auth-compliance a {
  color: rgba(220, 239, 234, 0.78);
  text-decoration: none;
  transition: color 150ms ease, transform 150ms ease;
}

.auth-compliance a:hover,
.auth-compliance a:focus-visible {
  color: #9be3d2;
  transform: translateY(-1px);
}

.login-atmosphere,
.login-atmosphere i {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-atmosphere {
  overflow: hidden;
}

.login-atmosphere i {
  inset: auto;
  width: 340px;
  height: 340px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 48% 52% 62% 38%;
  animation: login-orbit 18s linear infinite;
}

.login-atmosphere i:nth-child(1) {
  top: -150px;
  right: 8%;
}

.login-atmosphere i:nth-child(2) {
  bottom: -210px;
  left: 3%;
  width: 480px;
  height: 480px;
  animation-direction: reverse;
  animation-duration: 24s;
}

.login-atmosphere i:nth-child(3) {
  top: 38%;
  left: 19%;
  width: 96px;
  height: 96px;
  background: rgba(255, 255, 255, 0.025);
  animation-duration: 12s;
}

@keyframes login-orbit {
  to { transform: rotate(360deg); }
}

.login-card {
  position: relative;
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  color: #eff8f5;
  background: rgba(12, 30, 28, 0.76);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(22px);
  animation: login-rise 420ms cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes login-rise {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 30px;
}

.login-brand span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px 13px 13px 5px;
  color: #17312d;
  background: #9be3d2;
  font: 700 21px Georgia, "Microsoft YaHei", serif;
}

.login-brand b {
  letter-spacing: .12em;
}

.login-copy > span {
  color: #8bcabc;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .22em;
}

.login-copy h1 {
  margin: 8px 0 6px;
  color: #fff;
  font: 650 34px Georgia, "Microsoft YaHei", serif;
}

.login-copy p {
  margin: 0 0 28px;
  color: #afc3be;
  font-size: 14px;
}

.login-card label {
  display: block;
  margin: 14px 0 7px;
  color: #d7e7e2;
  font-size: 12px;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(201, 232, 224, 0.2);
  border-radius: 12px;
  outline: 0;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.login-card input:focus {
  border-color: #75cbb8;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 4px rgba(117, 203, 184, 0.13);
}

.login-submit {
  width: 100%;
  min-height: 49px;
  margin-top: 22px;
  justify-content: center;
  background: #86d9c6 !important;
  color: #12302b !important;
}

.login-submit span {
  transition: transform 160ms ease;
}

.login-submit:hover span {
  transform: translateX(4px);
}

.login-card > small {
  display: block;
  margin-top: 15px;
  color: #859b96;
  text-align: center;
  font-size: 11px;
}

.login-error {
  margin: 12px 0 -8px;
  padding: 10px 12px;
  border: 1px solid rgba(238, 135, 116, 0.32);
  border-radius: 10px;
  color: #ffc0b5;
  background: rgba(125, 48, 38, 0.22);
  font-size: 12px;
}

.account-control,
.cloud-sync-pill {
  display: flex;
  align-items: center;
}

.account-control {
  gap: 7px;
  margin-left: 2px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.account-control > span {
  max-width: 100px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
}

.cloud-sync-pill {
  gap: 7px;
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.62);
  font-size: 10px;
}

.cloud-sync-pill > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9da9a6;
}

.cloud-sync-pill.syncing > span,
.cloud-sync-pill.pending > span {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(215, 154, 61, .13);
  animation: status-pulse 1.5s ease-in-out infinite;
}

.cloud-sync-pill.synced > span {
  background: var(--teal);
}

.cloud-sync-pill.error > span,
.cloud-sync-pill.conflict > span {
  background: var(--red);
}

html[data-theme="dark"] .cloud-sync-pill {
  border-color: #354842;
  color: #b9ccc6;
  background: rgba(21, 33, 30, .82);
}

html[data-theme="dark"] .account-control {
  border-color: #354842;
}

html[data-theme="dark"] .account-control > span {
  color: #b9ccc6;
}

@media (max-width: 1180px) {
  .cloud-sync-pill b,
  .account-control > span {
    display: none;
  }

  .cloud-sync-pill {
    width: 31px;
    justify-content: center;
    padding: 0;
  }
}

@media (max-width: 520px) {
  .auth-gate {
    align-items: start;
    padding-top: max(36px, env(safe-area-inset-top));
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  .login-card {
    padding: 27px 22px;
    border-radius: 20px;
  }

  .login-copy h1 {
    font-size: 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-atmosphere i,
  .login-card {
    animation: none;
  }
}

/* Model switcher: secrets stay server-side; the browser only receives a status flag. */
.model-config-trigger {
  gap: 6px;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 10px;
}

.model-config-trigger > span {
  color: var(--teal);
}

.model-config-trigger > b {
  font-size: 10px;
}

.model-config-modal {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(13, 27, 25, .62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: model-backdrop-in 180ms ease both;
}

.model-config-card {
  display: flex;
  width: min(780px, 100%);
  max-height: min(880px, calc(100vh - 48px));
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .52);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 34px 100px rgba(7, 24, 21, .3);
  animation: model-card-in 260ms cubic-bezier(.2, .8, .2, 1) both;
}

.model-config-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 25px 27px 20px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 86% -30%, rgba(80, 181, 157, .17), transparent 45%),
    var(--panel);
}

.model-config-header > div > span {
  color: var(--teal);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .18em;
}

.model-config-header h2 {
  margin: 5px 0 4px;
  font-family: Georgia, "Noto Serif SC", "Microsoft YaHei", serif;
  font-size: 24px;
}

.model-config-header p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
}

.transport-warning {
  margin: 18px 27px 0;
  padding: 11px 13px;
  border: 1px solid rgba(215, 154, 61, .35);
  border-radius: 11px;
  color: #7a541a;
  background: var(--amber-soft);
}

.transport-warning strong,
.transport-warning span {
  display: block;
}

.transport-warning strong {
  font-size: 11px;
}

.transport-warning span {
  margin-top: 3px;
  font-size: 9px;
}

.model-config-scroll {
  min-height: 0;
  overflow: auto;
  padding: 21px 27px 5px;
  scrollbar-gutter: stable;
}

.model-config-section {
  margin: 0 0 17px;
  padding: 0 0 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.model-config-section legend {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  padding: 0;
}

.model-config-section legend b {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 9px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 9px;
}

.model-config-section legend span {
  font-size: 13px;
  font-weight: 780;
}

.model-config-section legend small {
  margin-left: auto;
  color: #899491;
  font-size: 9px;
}

.model-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

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

.model-field-wide {
  grid-column: 1 / -1;
}

.model-field > span {
  color: #657370;
  font-size: 9px;
  font-weight: 720;
}

.model-field > span i {
  margin-left: 6px;
  color: #919c99;
  font-style: normal;
  font-weight: 500;
}

.model-field input,
.model-field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: 0;
  padding: 0 11px;
  color: var(--ink);
  background: #fbfcfa;
  font-size: 11px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.model-field input:focus,
.model-field select:focus {
  border-color: #6ca99c;
  box-shadow: 0 0 0 3px rgba(20, 125, 113, .1);
}

.secret-input {
  position: relative;
}

.secret-input input {
  padding-right: 58px;
}

.secret-input > button {
  position: absolute;
  top: 6px;
  right: 6px;
  min-height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 9px;
  font-weight: 720;
}

.clear-secret {
  justify-self: start;
  padding: 0;
  border: 0;
  cursor: pointer;
  color: var(--red);
  background: transparent;
  font-size: 9px;
}

.clear-secret.pending {
  color: var(--amber);
  font-weight: 750;
}

.provider-note {
  min-height: 16px;
  margin: 10px 1px 0;
  color: #85918e;
  font-size: 9px;
  line-height: 1.6;
}

.model-storage-note {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 0 20px;
  padding: 12px 13px;
  border-radius: 12px;
  color: var(--ink-soft);
  background: #f2f6f3;
}

.model-storage-note > span {
  color: var(--teal);
  font-size: 21px;
}

.model-storage-note p,
.model-storage-note strong,
.model-storage-note small {
  display: block;
  margin: 0;
}

.model-storage-note strong {
  font-size: 10px;
}

.model-storage-note small {
  margin-top: 2px;
  color: #85918e;
  font-size: 9px;
}

.model-config-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 27px max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.model-config-actions > span {
  color: #83908d;
  font-size: 9px;
}

.model-config-actions > div {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

html[data-theme="dark"] .model-config-card,
html[data-theme="dark"] .model-config-header,
html[data-theme="dark"] .model-config-actions {
  border-color: #32443f;
  background-color: #111b19;
}

html[data-theme="dark"] .model-config-section {
  border-color: #30413d;
}

html[data-theme="dark"] .model-field input,
html[data-theme="dark"] .model-field select {
  border-color: #3a4d47;
  color: #e2ece8;
  background: #172421;
}

html[data-theme="dark"] .model-storage-note {
  color: #c1d1cc;
  background: #172522;
}

html[data-theme="dark"] .transport-warning {
  color: #f0c77c;
  background: rgba(117, 78, 24, .25);
}

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

@keyframes model-card-in {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
}

@media (max-width: 720px) {
  .model-config-trigger {
    width: 36px;
    min-height: 36px;
    justify-content: center;
    padding: 0;
  }

  .model-config-trigger > b {
    display: none;
  }

  .model-config-modal {
    align-items: end;
    padding: 0;
  }

  .model-config-card {
    width: 100%;
    max-height: calc(100dvh - max(10px, env(safe-area-inset-top)));
    border-radius: 22px 22px 0 0;
  }

  .model-config-header {
    padding: 20px 18px 16px;
  }

  .model-config-header h2 {
    font-size: 21px;
  }

  .transport-warning {
    margin: 13px 18px 0;
  }

  .model-config-scroll {
    padding: 18px 18px 4px;
  }

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

  .model-field-wide {
    grid-column: auto;
  }

  .model-config-section legend small,
  .model-config-actions > span {
    display: none;
  }

  .model-config-actions {
    justify-content: flex-end;
    padding: 13px 18px max(13px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .model-config-modal,
  .model-config-card,
  .diagram-preview-modal,
  .diagram-preview-shell,
  .diagram-loading,
  .mermaid-diagram[data-mermaid-state="rendered"] .mermaid-canvas {
    animation: none;
  }
}
