/* Learning and reading surfaces share the platform tokens with a calmer density. */
.knowledge-page, .learning-page, .learning-task-page { --ui-content-density: comfortable; }

/* Catalogue visual system -------------------------------------------------
   Keep the library in the same platform shell as the rest of Reservoir Lab. */
.knowledge-shell {
  width: min(var(--platform-content-width, 1360px), 100%);
  margin: 0 auto 60px;
}
.knowledge-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(390px, .85fr);
  align-items: end;
  gap: clamp(24px, 4vw, 54px);
  padding: clamp(26px, 3vw, 40px);
  border: 1px solid var(--color-border);
  border-radius: 30px;
}
.knowledge-hero h1 {
  max-width: 760px;
  margin: 8px 0 10px;
  color: var(--color-text-primary);
  font-size: clamp(32px, 3.7vw, 46px);
  line-height: 1.04;
}
.knowledge-hero p { max-width: 720px; color: var(--color-text-secondary); font-size: 15px; line-height: 1.65; }
.knowledge-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}
.knowledge-hero-actions .btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 9px 13px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-text-primary);
  background: var(--color-surface-secondary);
  box-shadow: none;
  text-decoration: none;
}
.knowledge-hero-actions .btn:hover { border-color: var(--color-accent); color: var(--color-accent-active); background: var(--color-accent-soft); transform: none; }
.knowledge-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: 19px;
  background: var(--color-surface-secondary);
}
.knowledge-search-field { display: grid; grid-column: 1 / -1; gap: 7px; min-width: 0; color: var(--color-text-secondary); font-size: 11px; font-weight: 800; }
.knowledge-search .knowledge-search-field input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  box-sizing: border-box;
  padding: 11px 13px;
  border: 1px solid var(--color-border-strong);
  border-radius: 12px;
  color: var(--color-control-text, var(--color-text-primary));
  background: var(--color-control-bg);
  font: inherit;
}
.knowledge-search .knowledge-search-field input::placeholder { color: var(--color-control-placeholder, var(--color-text-muted)); }
.knowledge-search .knowledge-search-field input:focus { border-color: var(--color-accent); box-shadow: var(--shadow-focus); outline: none; }
.knowledge-search > .btn { min-height: 42px; padding-inline: 20px; border-radius: 12px; }
.knowledge-continue {
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  background: var(--color-surface-glass);
  box-shadow: var(--shadow-small);
}
.knowledge-material-section > header { margin: 0 4px 15px; }
.knowledge-material-section > header h2 { color: var(--color-page-text-primary, var(--color-text-primary)); }
.knowledge-course-card,
.knowledge-lecture-card { border: 1px solid var(--color-border); box-shadow: var(--shadow-small); }
.knowledge-course-card:hover,
.knowledge-lecture-card:hover { border-color: var(--color-accent); box-shadow: var(--shadow-card); }

@media (max-width: 980px) {
  .knowledge-hero { grid-template-columns: 1fr; align-items: start; }
}

@media (max-width: 600px) {
  .knowledge-search { grid-template-columns: 1fr; }
  .knowledge-search-mode,
  .knowledge-search > .btn { width: 100%; }
  .knowledge-search-mode button { flex: 1; }
}

/* Legacy global form rules make radio/checkbox controls full-width. Knowledge
   exercises always use a compact selector followed by the answer text. */
.knowledge-options label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}
.knowledge-options input[type="radio"],
.knowledge-options input[type="checkbox"] {
  width: 18px !important;
  min-width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  accent-color: var(--color-accent);
}
.knowledge-options input[type="radio"]:focus,
.knowledge-options input[type="checkbox"]:focus { box-shadow: none; }
.knowledge-options label > span { min-width: 0; line-height: 1.45; }

.knowledge-task-model-toggle { margin: 14px 8px 14px 0; }
.knowledge-model-library-link { display: inline-flex; margin-top: 0; text-decoration: none; }
.knowledge-model-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 18px;
  margin-top: 22px;
}
.knowledge-model-library-card {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 18px;
  min-height: 190px;
  padding: 18px;
  border-radius: 24px;
  color: var(--color-text-primary);
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease;
}
.knowledge-model-library-card:hover { transform: translateY(-2px); border-color: var(--color-accent); }
.knowledge-model-library-card img { width: 128px; height: 128px; align-self: center; border-radius: 16px; object-fit: contain; background: var(--color-surface-secondary); }
.knowledge-model-library-card small { color: var(--color-accent); font-weight: 800; }
.knowledge-model-library-card h2 { margin: 7px 0 8px; font-size: 20px; line-height: 1.25; }
.knowledge-model-library-card p { margin: 0 0 13px; color: var(--color-text-secondary); line-height: 1.5; }
.knowledge-model-library-card span { color: var(--color-text-muted); font-size: 13px; font-weight: 700; }
.knowledge-model-detail-hero { align-items: stretch; }
.knowledge-model-example-image { width: min(34%, 390px); max-height: 280px; border-radius: 20px; object-fit: contain; background: var(--color-surface-secondary); }
.knowledge-standalone-model { width: min(1120px, 100%); margin: 22px auto 0; }
.knowledge-interactive-model {
  margin: 8px 0 18px;
  padding: clamp(16px, 2vw, 26px);
  border: 1px solid var(--color-border-strong);
  border-radius: 22px;
  background: var(--color-surface-secondary);
  color: var(--color-text-primary);
}
.knowledge-interactive-model > header h4 { margin: 5px 0 7px; font-size: clamp(20px, 2vw, 27px); }
.knowledge-interactive-model > header p { margin: 0 0 18px; color: var(--color-text-secondary); }
.knowledge-model-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.knowledge-model-field {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 15px;
  background: var(--color-surface);
}
.knowledge-model-field > span { color: var(--color-text-secondary); font-weight: 700; }
.knowledge-model-input-row { display: grid; grid-template-columns: minmax(90px, 1fr) 108px auto; align-items: center; gap: 9px; }
.knowledge-model-input-row.number-only { grid-template-columns: minmax(100px, 180px) auto; }
.knowledge-model-input-row input[type="range"] { width: 100%; accent-color: var(--color-accent); }
.knowledge-model-number { width: 100%; min-width: 0; padding: 8px 9px; border: 1px solid var(--color-border-strong); border-radius: 9px; background: var(--color-control-bg); color: var(--color-text-primary); font-weight: 800; text-align: right; }
.knowledge-model-input-row > span { color: var(--color-text-muted); }
.knowledge-model-given { margin: 2px 0 16px; padding: 13px; border: 1px solid var(--color-border); border-radius: 15px; background: var(--color-surface); }
.knowledge-model-given > strong { display: block; margin-bottom: 9px; color: var(--color-text-primary); }
.knowledge-model-given > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 7px; }
.knowledge-model-given span { display: flex; justify-content: space-between; gap: 10px; padding: 7px 9px; border-radius: 9px; background: var(--color-surface-secondary); color: var(--color-text-secondary); font-size: 12px; }
.knowledge-model-given b { font-weight: 700; }
.knowledge-model-given em { color: var(--color-text-primary); font-style: normal; font-weight: 800; white-space: nowrap; }
.knowledge-model-actions { display: flex; gap: 10px; margin-top: 16px; }
.knowledge-model-form.loading { opacity: .72; pointer-events: none; }
.knowledge-model-error { min-height: 20px; margin-top: 9px; color: var(--color-danger); font-weight: 700; }
.knowledge-model-loading { color: var(--color-text-secondary); }
.knowledge-model-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 8px; }
.knowledge-model-results article { padding: 13px; border: 1px solid var(--color-border); border-radius: 15px; background: var(--color-surface); }
.knowledge-model-results span { display: block; min-height: 36px; color: var(--color-text-secondary); font-size: 13px; }
.knowledge-model-results strong { display: block; margin-top: 6px; color: var(--color-text-primary); font-size: 20px; }
.knowledge-model-placeholder { grid-column: 1/-1; margin: 0; color: var(--color-text-secondary); }
.knowledge-model-chart { margin: 18px 0 0; padding: 12px; border: 1px solid var(--color-border); border-radius: 17px; background: var(--chart-canvas-bg); }
.knowledge-model-chart figcaption { margin-bottom: 8px; color: var(--color-text-primary); font-weight: 800; }
.knowledge-model-chart svg { display: block; width: 100%; max-height: 330px; overflow: visible; }
.knowledge-model-chart svg text { fill: var(--chart-text); font-size: 11px; }
.knowledge-model-chart svg line { stroke: var(--chart-axis); stroke-width: 1.5; }
.knowledge-model-chart svg .chart-tick line { stroke: var(--chart-grid); stroke-width: 1; }
.knowledge-model-chart svg .chart-tick text { fill: var(--chart-text-muted); }
.knowledge-model-chart svg .chart-axis-label { fill: var(--chart-text); font-size: 12px; font-weight: 700; }
.knowledge-model-chart svg .chart-category { font-size: 9px; }
.knowledge-model-chart svg polyline { fill: none; stroke: var(--color-accent); stroke-width: 3; stroke-linejoin: round; }
.knowledge-model-chart svg circle, .knowledge-model-chart svg rect { fill: var(--color-accent); }
.knowledge-model-sensitivity { margin-top: 18px; padding: 16px; border: 1px solid var(--color-border-strong); border-radius: 18px; background: var(--color-surface); }
.knowledge-model-sensitivity.loading { opacity: .72; pointer-events: none; }
.knowledge-model-sensitivity > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.knowledge-model-sensitivity h5 { margin: 4px 0 0; color: var(--color-text-primary); font-size: 20px; }
.knowledge-sensitivity-controls { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto; align-items: end; gap: 12px; }
.knowledge-sensitivity-controls label { display: grid; gap: 7px; }
.knowledge-sensitivity-controls label > span { color: var(--color-text-secondary); font-size: 13px; font-weight: 700; }
.knowledge-sensitivity-controls select { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--color-border-strong); border-radius: 10px; background: var(--color-control-bg); color: var(--color-text-primary); font-weight: 700; }
.knowledge-sensitivity-note { margin: 11px 0 0; color: var(--color-text-muted); font-size: 13px; }
.knowledge-sensitivity-error { min-height: 20px; margin-top: 8px; color: var(--color-danger); font-weight: 700; }
.knowledge-sensitivity-visual .knowledge-model-chart { margin-top: 4px; }
.knowledge-exercise.completed { border-color: var(--color-success); box-shadow: inset 3px 0 0 var(--color-success); }
.knowledge-reader-footer [hidden] { display: none !important; }
.knowledge-completion { display: grid; justify-items: center; gap: 7px; }
.knowledge-completion p { max-width: 340px; min-height: 18px; margin: 0; color: var(--color-danger); font-size: 12px; font-weight: 700; text-align: center; }
.knowledge-toc nav .knowledge-practice-link { margin-top: 7px; border-top: 1px solid var(--color-divider); border-radius: 0 0 12px 12px; }

/* Lecture MVP: native simple PPTX objects, visual fallback for complex slides. */
.knowledge-hero-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.knowledge-material-section { margin-top: 28px; scroll-margin-top: 24px; }
.knowledge-material-section > header { margin: 0 4px 14px; }
.knowledge-material-section > header h2 { margin: 5px 0 0; color: var(--color-page-text-primary, var(--color-text-primary)); }
.knowledge-lecture-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 18px; }
.knowledge-lecture-card { display: flex; min-height: 220px; flex-direction: column; padding: 22px; border-radius: 24px; color: var(--color-text-primary); text-decoration: none; transition: transform .18s ease, border-color .18s ease; }
.knowledge-lecture-card:hover { transform: translateY(-2px); border-color: var(--color-accent); }
.knowledge-lecture-card > div { display: flex; align-items: center; gap: 10px; color: var(--color-text-muted); font-weight: 700; }
.knowledge-lecture-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; background: var(--color-accent-soft); color: var(--color-accent); font-size: 23px; }
.knowledge-lecture-card h3 { margin: 17px 0 8px; font-size: 22px; }
.knowledge-lecture-card p { flex: 1; margin: 0 0 18px; color: var(--color-text-secondary); line-height: 1.5; }
.knowledge-lecture-card strong { color: var(--color-accent); }
.knowledge-search-results a small { color: var(--color-accent); font-size: 10px; font-weight: 900; letter-spacing: .1em; }

.knowledge-lecture-reader { display: grid; grid-template-columns: 280px minmax(0, 1fr); align-items: start; gap: 22px; }
.lecture-toc { position: sticky; top: 22px; max-height: calc(100vh - 44px); overflow: auto; }
.lecture-toc h2 { margin: 16px 0 13px; color: var(--color-text-primary); font-size: 17px; line-height: 1.3; }
.lecture-toc nav { display: grid; gap: 5px; }
.lecture-toc nav a { display: grid; grid-template-columns: 31px minmax(0, 1fr); align-items: start; gap: 8px; padding: 9px; border-radius: 11px; color: var(--color-text-secondary); font-size: 12px; font-weight: 750; line-height: 1.35; text-decoration: none; }
.lecture-toc nav a span { display: grid; width: 27px; height: 27px; place-items: center; border-radius: 9px; background: var(--color-surface-secondary); color: var(--color-text-muted); font-size: 10px; }
.lecture-toc nav a.active { background: var(--color-accent-soft); color: var(--color-accent); }
.lecture-toc nav a.active span { background: var(--color-accent); color: var(--color-on-accent, #fff); }
.lecture-page-content { min-width: 0; }
.lecture-hero { margin-bottom: 18px; }
.lecture-hero-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.lecture-sections { display: grid; gap: 22px; }
.lecture-section { padding: clamp(16px, 2.5vw, 28px); border-radius: 26px; scroll-margin-top: 20px; transition: border-color .2s ease, box-shadow .2s ease; }
.lecture-section.search-target { border-color: var(--color-accent); box-shadow: 0 0 0 4px var(--color-accent-soft); }
.lecture-section > header { margin-bottom: 16px; }
.lecture-section > header span { color: var(--color-accent); font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.lecture-section > header h2 { margin: 5px 0 0; color: var(--color-text-primary); font-size: clamp(20px, 2vw, 28px); }
.lecture-canvas { position: relative; width: 100%; aspect-ratio: var(--lecture-ratio); overflow: hidden; border: 1px solid var(--color-border); border-radius: 20px; background: var(--color-surface-secondary); }
.lecture-element { position: absolute; min-width: 1px; min-height: 1px; }
.lecture-text { overflow: hidden; padding: clamp(3px, .5vw, 8px); color: var(--color-text-primary); font-size: clamp(8px, 1.15vw, 17px); line-height: 1.28; }
.lecture-text p { margin: 0 0 .38em; }
.lecture-text .lecture-bullet { padding-left: 1.1em; }
.lecture-text .lecture-bullet::before { content: '•'; float: left; margin-left: -1em; color: var(--color-accent); }
.lecture-text .level-2 { padding-left: 1.8em; }
.lecture-image { padding: 0; overflow: hidden; border: 0; border-radius: 8px; background: transparent; cursor: zoom-in; }
.lecture-image img { width: 100%; height: 100%; object-fit: contain; }
.lecture-table { overflow: auto; padding: 3px; color: var(--color-text-primary); font-size: clamp(7px, .9vw, 13px); }
.lecture-table table { width: 100%; height: 100%; border-collapse: collapse; background: var(--color-surface); }
.lecture-table th, .lecture-table td { padding: .35em .5em; border: 1px solid var(--color-border); text-align: left; }
.lecture-table th { background: var(--color-accent-soft); color: var(--color-text-primary); }
.lecture-line { border-top: 2px solid var(--color-border-strong); }
.lecture-shape { border: 1px solid var(--color-border-strong); border-radius: 10px; background: var(--color-surface); opacity: .55; }
.lecture-fallback { display: block; width: min(100%, 1180px); margin: 0 auto; padding: 0; overflow: hidden; border: 1px solid var(--color-border); border-radius: 20px; background: var(--color-surface-secondary); cursor: zoom-in; }
.lecture-fallback img { display: block; width: 100%; height: auto; }
.lecture-fallback-warning { margin: 11px 0 0; color: var(--color-warning, #b87919); font-size: 12px; font-weight: 700; }
.lecture-lightbox { width: min(94vw, 1500px); max-width: none; max-height: 94vh; padding: 42px 14px 14px; border: 1px solid var(--color-border-strong); border-radius: 22px; background: var(--color-surface); }
.lecture-lightbox::backdrop { background: rgba(3, 16, 23, .78); }
.lecture-lightbox img { display: block; width: 100%; max-height: calc(94vh - 60px); object-fit: contain; }
.lecture-lightbox > button { position: absolute; top: 8px; right: 10px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--color-surface-secondary); color: var(--color-text-primary); font-size: 22px; cursor: pointer; }

body.lecture-presenting { overflow: hidden; }
.lecture-presentation[hidden] { display: none !important; }
.lecture-presentation { position: fixed; inset: 0; z-index: 1000; display: grid; grid-template: auto minmax(0, 1fr) auto / minmax(58px, 7vw) minmax(0, 1fr) minmax(58px, 7vw); min-width: 100vw; min-height: 100vh; color: #edf8fb; background: #071820; }
.lecture-presentation > header { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 70px; padding: 12px clamp(18px, 3vw, 46px); border-bottom: 1px solid rgba(176, 223, 232, .18); background: rgba(11, 35, 45, .96); }
.lecture-presentation > header > div { display: flex; align-items: center; gap: 14px; min-width: 0; }
.lecture-presentation > header strong { overflow: hidden; font-size: clamp(16px, 1.45vw, 24px); text-overflow: ellipsis; white-space: nowrap; }
.lecture-presentation > header span { flex: none; color: #83dce1; font-size: 13px; font-weight: 850; letter-spacing: .08em; }
.lecture-presentation > header .btn { color: #eaf8fa; border-color: rgba(176, 223, 232, .32); background: rgba(255, 255, 255, .06); }
.lecture-presentation-stage { grid-column: 2; display: grid; min-width: 0; min-height: 0; place-items: center; padding: 20px 0; overflow: hidden; }
.lecture-presentation-stage .lecture-fallback { width: auto; max-width: 100%; max-height: 100%; border-radius: 8px; border-color: rgba(176, 223, 232, .25); background: #fff; box-shadow: 0 24px 70px rgba(0, 0, 0, .42); cursor: default; }
.lecture-presentation-stage .lecture-fallback img { width: auto; max-width: 100%; max-height: calc(100vh - 142px); object-fit: contain; }
.lecture-presentation-stage .lecture-canvas { width: min(100%, calc((100vh - 142px) * var(--lecture-ratio))); max-height: calc(100vh - 142px); border-radius: 8px; background: var(--color-surface-secondary); box-shadow: 0 24px 70px rgba(0, 0, 0, .42); }
.lecture-presentation-arrow { align-self: center; justify-self: center; display: grid; width: clamp(42px, 4.5vw, 66px); height: clamp(58px, 7vw, 92px); place-items: center; border: 1px solid rgba(176, 223, 232, .2); border-radius: 18px; color: #dff7f8; background: rgba(255, 255, 255, .055); font: 300 clamp(34px, 4vw, 58px)/1 sans-serif; cursor: pointer; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.lecture-presentation-arrow:hover:not(:disabled) { border-color: #38c9ca; background: rgba(33, 185, 187, .18); transform: scale(1.04); }
.lecture-presentation-arrow:disabled { opacity: .18; cursor: default; }
.lecture-presentation-arrow.previous { grid-column: 1; }
.lecture-presentation-arrow.next { grid-column: 3; }
.lecture-presentation > footer { grid-column: 1 / -1; display: flex; justify-content: center; gap: 28px; min-height: 38px; padding: 9px 20px; color: rgba(224, 245, 247, .58); font-size: 11px; }

@media (max-width: 760px) {
  .knowledge-model-library-card { grid-template-columns: 1fr; }
  .knowledge-model-library-card img { width: 100%; height: 170px; }
  .knowledge-model-example-image { width: 100%; max-height: 240px; }
  .knowledge-model-library-card { grid-template-columns: 1fr; }
  .knowledge-model-library-card img { width: 100%; height: 170px; }
  .knowledge-model-example-image { width: 100%; max-height: 240px; }
  .knowledge-model-inputs { grid-template-columns: 1fr; }
  .knowledge-model-input-row { grid-template-columns: minmax(80px, 1fr) 90px auto; }
  .knowledge-model-chart svg text { font-size: 9px; }
  .knowledge-model-actions { flex-wrap: wrap; }
  .knowledge-sensitivity-controls { grid-template-columns: 1fr; }
  .knowledge-completion { width: 100%; }
  .knowledge-lecture-reader { grid-template-columns: 1fr; }
  .lecture-toc { position: fixed; inset: 82px 14px auto; z-index: 35; display: none; max-height: calc(100vh - 110px); }
  .lecture-toc.open { display: block; }
  .knowledge-lecture-reader > .knowledge-toc-toggle { display: inline-flex; position: sticky; top: 8px; z-index: 34; justify-self: start; }
  .lecture-section { padding: 13px; border-radius: 20px; }
  .lecture-text { font-size: clamp(6px, 2vw, 11px); }
  .lecture-hero-actions { justify-content: flex-start; margin-top: 12px; }
  .lecture-presentation { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .lecture-presentation > header { align-items: flex-start; padding: 9px 12px; }
  .lecture-presentation > header > div:last-child { gap: 5px; }
  .lecture-presentation > header .btn { padding: 8px 10px; font-size: 11px; }
  .lecture-presentation-arrow { width: 36px; height: 54px; border-radius: 12px; }
  .lecture-presentation > footer { display: none; }
}


/* Smart knowledge search --------------------------------------------------
   No empty result skeleton: the interface shows one processing state and
   appends real answer blocks as they become available. */
.knowledge-page { overflow-x: hidden; }
.knowledge-shell.smart-search-active { width: min(1240px, calc(100% - 32px)); min-width: 0; overflow-x: clip; }
.knowledge-shell.smart-search-active .knowledge-material-section,
.knowledge-shell.smart-search-active .knowledge-continue { display: none !important; }

/* During search the catalogue hero becomes a compact persistent search row
   instead of keeping the large library introduction above every answer. */
.knowledge-shell.smart-search-active .knowledge-hero {
  min-width: 0;
  min-height: 0;
  padding: 10px 12px;
  border-radius: 18px;
  justify-content: flex-end;
}
.knowledge-shell.smart-search-active .knowledge-hero > div { display: none; }
.knowledge-shell.smart-search-active .knowledge-search {
  width: min(760px, 100%);
  min-width: 0;
  margin-left: auto;
}
.knowledge-shell.smart-search-active .knowledge-search input { min-width: 0; }

#knowledgeSearchResults { min-width: 0; max-width: 100%; }
.knowledge-smart-answer { width: min(1080px, 100%); min-width: 0; max-width: 100%; margin: 18px auto 0; }
.knowledge-smart-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; margin: 0 2px 12px; color: var(--color-text-muted); font-size: 13px; font-weight: 750; }
.knowledge-smart-toolbar a { color: var(--color-accent); text-decoration: none; }
.knowledge-smart-toolbar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-smart-status { display: flex; align-items: center; gap: 14px; width: fit-content; max-width: 100%; padding: 14px 17px; border-radius: 17px; }
.knowledge-smart-status-copy { min-width: 0; flex: 1; }
.knowledge-smart-status strong { display: block; color: var(--color-text-primary); font-size: 15px; }
.knowledge-smart-status p { margin: 3px 0 0; color: var(--color-text-secondary); font-size: 14px; }
.knowledge-smart-status.error { border-color: var(--color-danger); }
.knowledge-smart-status.error .knowledge-smart-spinner,
.knowledge-smart-status.stopped .knowledge-smart-spinner { animation: none; opacity: .55; }
.knowledge-smart-cancel {
  flex: none;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: 10px;
  background: var(--color-surface-secondary);
  color: var(--color-text-primary);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.knowledge-smart-cancel:hover { border-color: var(--color-accent); color: var(--color-accent); }
.knowledge-smart-cancel[hidden] { display: none; }
.knowledge-smart-spinner { width: 20px; height: 20px; flex: none; border: 2px solid var(--color-border-strong); border-top-color: var(--color-accent); border-radius: 50%; animation: knowledge-smart-spin .8s linear infinite; }
@keyframes knowledge-smart-spin { to { transform: rotate(360deg); } }

.knowledge-smart-header { margin: 26px 0 14px; min-width: 0; }
.knowledge-smart-header .soft-label { color: var(--color-accent); }
.knowledge-smart-header h1 { max-width: 980px; margin: 6px 0 0; color: var(--color-page-text-primary, var(--color-text-primary)); font-family: "Nunito Sans", sans-serif; font-size: clamp(30px, 4vw, 46px); line-height: 1.1; overflow-wrap: anywhere; }
.knowledge-smart-blocks { display: grid; min-width: 0; max-width: 100%; gap: 16px; margin-top: 16px; }
.knowledge-smart-stream-item,
.knowledge-smart-blocks > * { min-width: 0; max-width: 100%; }
.knowledge-smart-blocks > * { opacity: 0; transform: translateY(7px); transition: opacity .2s ease, transform .2s ease; }
.knowledge-smart-blocks > *.visible { opacity: 1; transform: none; }

.knowledge-smart-summary,
.knowledge-smart-section,
.knowledge-smart-table-block,
.knowledge-smart-visual,
.knowledge-smart-empty { min-width: 0; max-width: 100%; padding: clamp(20px, 2.5vw, 28px); border-radius: 23px; }

/* Accent is semantic rather than theme-specific: every theme receives the
   same visual hierarchy through its own --color-accent token. */
.knowledge-smart-summary { box-shadow: inset 4px 0 0 var(--color-accent); }
.knowledge-smart-summary p { max-width: 920px; margin: 0; color: var(--color-text-primary); font-size: clamp(17px, 1.6vw, 20px); font-weight: 560; line-height: 1.7; }

.knowledge-smart-fact-group { display: grid; min-width: 0; gap: 8px; }
.knowledge-smart-facts { display: grid; min-width: 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); gap: 12px; }
.knowledge-smart-fact { position: relative; min-width: 0; padding: 19px 20px 20px; overflow: hidden; border-radius: 20px; }
.knowledge-smart-fact::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--color-accent); }
.knowledge-smart-fact > span:first-child { display: block; min-height: 0; color: var(--color-accent); font-size: 13px; font-weight: 800; line-height: 1.45; }
.knowledge-smart-fact strong { display: block; margin-top: 8px; color: var(--color-text-primary); font-size: clamp(20px, 2vw, 26px); line-height: 1.25; overflow-wrap: anywhere; }

.knowledge-smart-section { position: relative; }
.knowledge-smart-section::before { content: ""; position: absolute; top: 25px; left: 0; width: 4px; height: 34px; border-radius: 0 4px 4px 0; background: var(--color-accent); }
.knowledge-smart-section h2,
.knowledge-smart-table-block h2,
.knowledge-smart-related h2 { margin: 0 0 13px; color: var(--color-text-primary); font-size: clamp(21px, 2.2vw, 28px); line-height: 1.25; }
.knowledge-smart-section p { max-width: 940px; margin: 0; color: var(--color-text-secondary); font-size: clamp(16px, 1.15vw, 17.5px); line-height: 1.72; overflow-wrap: anywhere; }
.knowledge-smart-section ul { display: grid; gap: 10px; max-width: 940px; margin: 17px 0 0; padding-left: 22px; color: var(--color-text-primary); font-size: clamp(16px, 1.1vw, 17px); }
.knowledge-smart-section li { padding-left: 5px; line-height: 1.62; }
.knowledge-smart-section li::marker { color: var(--color-accent); font-size: 1.15em; }

.knowledge-smart-visual { margin: 0; overflow: hidden; }
.knowledge-smart-visual figcaption { margin-bottom: 14px; color: var(--color-text-primary); font-size: clamp(17px, 1.4vw, 20px); font-weight: 800; line-height: 1.35; }
.knowledge-smart-image-button { display: grid; width: 100%; min-width: 0; max-width: 100%; padding: 0; place-items: center; overflow: hidden; border: 1px solid var(--color-border); border-radius: 17px; background: var(--color-surface-secondary); cursor: zoom-in; }
.knowledge-smart-image-button img { display: block; width: auto; max-width: 100%; height: auto; max-height: min(680px, 72vh); object-fit: contain; }

.knowledge-smart-table-block { overflow: hidden; }
.knowledge-smart-table-block > header { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.knowledge-smart-table-scroll { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; border: 1px solid var(--color-border); border-radius: 15px; }
.knowledge-smart-table-scroll table { width: max(100%, 780px); max-width: none; border-collapse: collapse; background: var(--color-surface); }
.knowledge-smart-table-scroll th,
.knowledge-smart-table-scroll td { max-width: 420px; padding: 11px 13px; border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); color: var(--color-text-secondary); font-size: 13.5px; line-height: 1.52; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.knowledge-smart-table-scroll th { position: sticky; top: 0; z-index: 1; background: var(--color-surface-secondary); color: var(--color-text-primary); font-weight: 850; }
.knowledge-smart-table-scroll tbody tr:hover td { background: var(--color-accent-soft); }

/* Sources are deliberately quiet until requested. One collapsed control per
   content block replaces repeated non-clickable "fragment 123" captions. */
.knowledge-smart-sources { width: fit-content; max-width: 100%; margin-top: 14px; color: var(--color-text-muted); font-size: 12px; }
.knowledge-smart-fact-group > .knowledge-smart-sources { margin: 0 4px; }
.knowledge-smart-sources summary { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 10px; color: var(--color-text-muted); background: var(--color-surface-secondary); font-weight: 750; cursor: pointer; list-style: none; user-select: none; }
.knowledge-smart-sources summary::-webkit-details-marker { display: none; }
.knowledge-smart-sources summary::before { content: "↗"; color: var(--color-accent); font-weight: 900; }
.knowledge-smart-sources summary b { display: grid; min-width: 19px; height: 19px; padding: 0 5px; place-items: center; border-radius: 999px; color: var(--color-accent); background: var(--color-accent-soft); font-size: 10px; }
.knowledge-smart-sources[open] { width: 100%; }
.knowledge-smart-source-list { display: grid; width: min(760px, 100%); gap: 8px; margin-top: 9px; }
.knowledge-smart-source-list > p { margin: 0; color: var(--color-text-muted); font-size: 12px; }
.knowledge-smart-source-item { padding: 12px 13px; border: 1px solid var(--color-border); border-radius: 13px; background: var(--color-surface-secondary); }
.knowledge-smart-source-item > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.knowledge-smart-source-item strong { color: var(--color-text-primary); font-size: 13px; }
.knowledge-smart-source-item span { flex: none; color: var(--color-text-muted); font-size: 10px; }
.knowledge-smart-source-item p { margin: 7px 0 0; color: var(--color-text-secondary); font-size: 12.5px; line-height: 1.55; }
.knowledge-smart-source-item a { display: inline-block; margin-top: 8px; color: var(--color-accent); font-size: 12px; font-weight: 800; text-decoration: none; }
.knowledge-smart-source-item a:hover { text-decoration: underline; }

.knowledge-smart-related { padding: 12px 2px 0; }
.knowledge-smart-related > div { display: flex; flex-wrap: wrap; gap: 8px; }
.knowledge-smart-related button { padding: 9px 13px; border: 1px solid var(--color-border-strong); border-radius: 999px; color: var(--color-text-secondary); background: var(--color-surface); font: inherit; font-size: 13px; font-weight: 750; cursor: pointer; }
.knowledge-smart-related button:hover { border-color: var(--color-accent); color: var(--color-accent); background: var(--color-accent-soft); }

.knowledge-smart-lightbox { width: min(94vw, 1500px); max-width: none; max-height: 94vh; padding: 44px 14px 14px; border: 1px solid var(--color-border-strong); border-radius: 22px; background: var(--color-surface); }
.knowledge-smart-lightbox::backdrop { background: rgba(3, 16, 23, .78); }
.knowledge-smart-lightbox img { display: block; width: 100%; max-height: calc(94vh - 62px); object-fit: contain; }
.knowledge-smart-lightbox > button { position: absolute; top: 8px; right: 10px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--color-surface-secondary); color: var(--color-text-primary); font-size: 22px; cursor: pointer; }

@media (max-width: 760px) {
  .knowledge-shell.smart-search-active { width: min(100% - 18px, 1240px); }
  .knowledge-shell.smart-search-active .knowledge-hero { padding: 9px; }
  .knowledge-shell.smart-search-active .knowledge-search { width: 100%; }
  .knowledge-smart-answer { margin-top: 12px; }
  .knowledge-smart-toolbar { align-items: flex-start; flex-direction: column; gap: 5px; }
  .knowledge-smart-summary,.knowledge-smart-section,.knowledge-smart-table-block,.knowledge-smart-visual,.knowledge-smart-empty { padding: 18px; border-radius: 19px; }
  .knowledge-smart-section::before { top: 20px; height: 30px; }
  .knowledge-smart-facts { grid-template-columns: 1fr; }
  .knowledge-smart-image-button img { max-height: 470px; }
  .knowledge-smart-table-scroll th,.knowledge-smart-table-scroll td { font-size: 12.5px; }
}

/* ===== Gold search V3: Fast / Smart + technical content model ===== */
.knowledge-search-mode {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--color-border-strong);
  border-radius: 13px;
  background: var(--color-surface-secondary);
}
.knowledge-search-mode button {
  min-height: 34px;
  padding: 6px 11px;
  border: 0;
  border-radius: 10px;
  color: var(--color-text-muted);
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}
.knowledge-search-mode button.active {
  color: var(--color-text-primary);
  background: var(--color-surface);
  box-shadow: 0 1px 7px rgba(7, 30, 40, .12);
}
.knowledge-smart-toolbar .knowledge-search-mode { margin-left: auto; }
.knowledge-shell.smart-search-active .knowledge-search { width: min(940px, 100%); }
.knowledge-shell.smart-search-active .knowledge-search .knowledge-search-mode { flex: none; }

.knowledge-smart-kicker {
  margin-bottom: 6px;
  color: var(--color-accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
}
.knowledge-smart-visual > p,
.knowledge-smart-table-block > header p {
  max-width: 900px;
  margin: -4px 0 14px;
  color: var(--color-text-secondary);
  font-size: 14px;
  line-height: 1.55;
}

.knowledge-smart-formula-card {
  min-width: 0;
  max-width: 100%;
  padding: clamp(20px, 2.5vw, 28px);
  border-radius: 23px;
  overflow: hidden;
}
.knowledge-smart-formula-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.knowledge-smart-formula-card h2 {
  margin: 0;
  color: var(--color-text-primary);
  font-size: clamp(20px, 2vw, 26px);
  line-height: 1.3;
}
.knowledge-smart-formula-card header span {
  display: block;
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 750;
}
.knowledge-smart-formula-expression {
  display: flex;
  width: 100%;
  min-height: 92px;
  margin: 18px 0 14px;
  padding: 18px 22px;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  background: var(--color-surface-secondary);
}
.knowledge-smart-formula-expression img {
  display: block;
  width: auto;
  min-width: 160px;
  max-width: min(100%, 760px);
  height: clamp(44px, 5vw, 68px);
  object-fit: contain;
}
.knowledge-smart-formula-fallback {
  margin: 18px 0 14px;
  padding: 18px;
  border-radius: 14px;
  background: var(--color-surface-secondary);
  color: var(--color-text-primary);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 17px;
  overflow-x: auto;
}
.knowledge-smart-formula-description {
  max-width: 900px;
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 15.5px;
  line-height: 1.65;
}
.knowledge-smart-formula-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 18px;
  margin: 16px 0 0;
}
.knowledge-smart-formula-legend > div {
  display: grid;
  grid-template-columns: minmax(34px, auto) 1fr;
  gap: 9px;
  align-items: baseline;
}
.knowledge-smart-formula-legend dt {
  color: var(--color-text-primary);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 15px;
  font-weight: 850;
}
.knowledge-smart-formula-legend dd {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 13.5px;
  line-height: 1.45;
}

/* Wide technical tables should scroll rather than squeeze seven columns into
   one viewport. Each column gets real reading width, so text cannot overlap. */
.knowledge-smart-table-scroll table {
  width: max(100%, calc(var(--knowledge-table-cols, 4) * 190px));
  min-width: max(100%, calc(var(--knowledge-table-cols, 4) * 190px));
  table-layout: auto;
}
.knowledge-smart-table-scroll th,
.knowledge-smart-table-scroll td {
  min-width: 150px;
  max-width: 320px;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}
.knowledge-smart-table-scroll th:nth-child(n+5),
.knowledge-smart-table-scroll td:nth-child(n+5) { min-width: 220px; }

.knowledge-smart-tasks { min-width: 0; padding-top: 6px; }
.knowledge-smart-tasks > h2 {
  margin: 0 0 12px;
  color: var(--color-text-primary);
  font-size: clamp(22px, 2.2vw, 29px);
}
.knowledge-smart-tasks > div { display: grid; gap: 10px; }
.knowledge-smart-task {
  min-width: 0;
  padding: 0;
  border-radius: 18px;
  overflow: hidden;
}
.knowledge-smart-task > summary {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  color: var(--color-text-primary);
  cursor: pointer;
  list-style: none;
}
.knowledge-smart-task > summary::-webkit-details-marker { display: none; }
.knowledge-smart-task > summary span {
  min-width: 0;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.4;
}
.knowledge-smart-task > summary em {
  flex: none;
  color: var(--color-accent);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}
.knowledge-smart-task[open] > summary { border-bottom: 1px solid var(--color-border); }
.knowledge-smart-task-body { padding: 17px 18px 19px; }
.knowledge-smart-task-body > p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 14.5px;
  line-height: 1.68;
  white-space: pre-wrap;
}
.knowledge-smart-task-attachment { margin: 16px 0 0; }
.knowledge-smart-task-attachment figcaption {
  margin-bottom: 8px;
  color: var(--color-text-primary);
  font-size: 13px;
  font-weight: 800;
}
.knowledge-smart-task-attachment.formula {
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface-secondary);
  text-align: center;
}
.knowledge-smart-task-attachment.formula img {
  width: auto;
  max-width: 100%;
  height: 48px;
  object-fit: contain;
}

@media (max-width: 760px) {
  .knowledge-search-mode { width: 100%; }
  .knowledge-search-mode button { flex: 1; }
  .knowledge-smart-toolbar .knowledge-search-mode { margin-left: 0; }
  .knowledge-smart-formula-card { padding: 18px; border-radius: 19px; }
  .knowledge-smart-formula-expression { min-height: 76px; padding: 14px; }
  .knowledge-smart-formula-expression img { min-width: 120px; height: 46px; }
}

@media (max-width: 620px) {
  .knowledge-smart-status { width: 100%; align-items: flex-start; flex-wrap: wrap; }
  .knowledge-smart-cancel { margin-left: 34px; }
}

/* Lite edition: ranked lexical search results. */
.knowledge-search-results { width: min(1040px, 100%); margin: 18px auto 0; padding: clamp(18px, 3vw, 28px); border-radius: 24px; }
.knowledge-search-results > header { padding-bottom: 10px; border-bottom: 1px solid var(--color-divider); }
.knowledge-search-results > header h2 { margin: 5px 0 4px; color: var(--color-text-primary); }
.knowledge-search-results > header p { margin: 0; color: var(--color-text-secondary); }
.knowledge-search-results > a { display: block; padding: 18px 4px; border-bottom: 1px solid var(--color-divider); color: inherit; text-decoration: none; }
.knowledge-search-results > a:last-child { border-bottom: 0; }
.knowledge-search-results > a h3 { margin: 6px 0; color: var(--color-text-primary); font-size: 18px; }
.knowledge-search-results > a p { margin: 0 0 8px; color: var(--color-text-secondary); line-height: 1.55; }
.knowledge-search-results > a strong { color: var(--color-accent); font-size: 12px; }
