:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --surface: #ffffff;
  --surface-soft: #eef4ec;
  --ink: #17201b;
  --muted: #5f6d66;
  --line: #d8dfd8;
  --teal: #0f766e;
  --teal-dark: #0b4f4a;
  --indigo: #384982;
  --amber: #b7791f;
  --rose: #b23a48;
  --green: #52713c;
  --shadow: 0 16px 40px rgba(23, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
}

a {
  color: var(--teal-dark);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

button,
input {
  font: inherit;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.10), transparent 44%),
    linear-gradient(180deg, #ffffff, #f2f6ef);
}

.header-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 26px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3.7vw, 4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.lede {
  max-width: 760px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 86px);
  gap: 10px;
  align-self: end;
  margin: 0;
}

.stats div {
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.stats dt {
  color: var(--muted);
  font-size: 0.78rem;
}

.stats dd {
  margin: 2px 0 0;
  font-size: 1.45rem;
  font-weight: 800;
}

.shell {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  margin: 18px auto 42px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toc-panel {
  position: sticky;
  top: 16px;
  align-self: start;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 16px;
}

.panel-title,
.search-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

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

.toc a {
  display: block;
  padding: 8px 9px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.91rem;
  line-height: 1.35;
  text-decoration: none;
}

.toc a:hover,
.toc a:focus-visible {
  background: var(--surface-soft);
  outline: none;
}

.content {
  min-width: 0;
}

.control-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
}

.search-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
}

.search-input:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(15, 118, 110, 0.18);
}

.tag-filters,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-button,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.tag-button {
  cursor: pointer;
}

.tag-button[aria-pressed="true"] {
  border-color: rgba(15, 118, 110, 0.38);
  background: #ddf0ec;
  color: var(--teal-dark);
}

.problem-grid {
  display: grid;
  gap: 16px;
}

.problem-card {
  scroll-margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.problem-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.problem-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.problem-title {
  margin: 0;
  font-size: clamp(1.28rem, 2vw, 1.85rem);
  line-height: 1.22;
  letter-spacing: 0;
}

.source-link {
  align-self: start;
  white-space: nowrap;
  padding: 7px 10px;
  border: 1px solid rgba(15, 118, 110, 0.32);
  border-radius: 8px;
  background: #eef8f5;
  color: var(--teal-dark);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
}

.problem-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 18px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  align-content: start;
}

.figure {
  display: grid;
  gap: 8px;
  margin: 0;
}

.figure-frame {
  display: grid;
  place-items: center;
  min-height: 220px;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8f5;
  overflow: hidden;
}

.figure-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.figure figcaption {
  color: var(--muted);
  font-size: 0.82rem;
}

.details {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.chat-thread {
  display: grid;
  gap: 16px;
}

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

.chat-role {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.user-turn {
  justify-items: end;
}

.user-turn .chat-role {
  padding-right: 8px;
}

.user-turn .chat-bubble {
  width: fit-content;
  max-width: min(680px, 100%);
  border-color: rgba(15, 118, 110, 0.25);
  background: #e8f3ef;
}

.gemini-turn .chat-bubble {
  background: #ffffff;
}

.chat-bubble {
  width: 100%;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  overflow-wrap: break-word;
}

.chat-bubble h3,
.chat-bubble h4 {
  margin: 1.05rem 0 0.45rem;
  line-height: 1.28;
  letter-spacing: 0;
}

.chat-bubble h3:first-child,
.chat-bubble h4:first-child,
.chat-bubble p:first-child {
  margin-top: 0;
}

.chat-bubble h3 {
  color: var(--teal-dark);
  font-size: 1.08rem;
}

.chat-bubble h4 {
  color: #36443d;
  font-size: 0.98rem;
}

.chat-bubble p {
  margin: 0.68rem 0;
}

.chat-bubble blockquote {
  margin: 0.85rem 0;
  padding: 0.1rem 0 0.1rem 0.9rem;
  border-left: 3px solid rgba(15, 118, 110, 0.26);
  color: #37443d;
}

.chat-bubble ul,
.chat-bubble ol {
  margin: 0.65rem 0;
  padding-left: 1.35rem;
}

.chat-bubble li + li {
  margin-top: 0.28rem;
}

.chat-bubble mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}

.chat-bubble mjx-container[display="true"] {
  margin: 0.75rem 0;
}

.chat-bubble .table-wrap {
  margin: 0.85rem 0;
}

.chat-bubble .math-display {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.conversation-shot {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: auto;
}

.conversation-shot img {
  display: block;
  width: 100%;
  height: auto;
}

.summary {
  margin: 0;
  color: #39443e;
}

.long-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.long-section h3 {
  margin: 0 0 8px;
  color: var(--teal-dark);
  font-size: 0.92rem;
  line-height: 1.35;
}

.long-section p {
  margin: 0;
}

.long-section p + p {
  margin-top: 8px;
}

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

.info-box {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.info-box h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.3;
}

.info-box p,
.info-box ul {
  margin: 0;
}

.info-box ul {
  padding-left: 1.05rem;
}

.info-box li + li {
  margin-top: 4px;
}

.result-box {
  border-color: rgba(183, 121, 31, 0.42);
  background: #fff7e7;
}

.result-box h3 {
  color: #8c5a16;
}

.note-box {
  border-color: rgba(56, 73, 130, 0.25);
  background: #f2f4fb;
}

.note-box h3 {
  color: var(--indigo);
}

.dialogue-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.gemini-rendered-list {
  display: grid;
  gap: 18px;
}

.gemini-rendered-turn,
.gemini-rendered-turn .share-turn-viewer,
.gemini-rendered-turn user-query,
.gemini-rendered-turn user-query-content,
.gemini-rendered-turn model-response,
.gemini-rendered-turn message-content,
.gemini-rendered-turn .model-response-text,
.gemini-rendered-turn .markdown,
.gemini-rendered-turn ms-cmark-node {
  display: block;
  min-width: 0;
}

.gemini-rendered-turn {
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.gemini-rendered-turn:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.gemini-rendered-turn user-query {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 18px;
}

.gemini-rendered-turn .user-query-container {
  max-width: min(680px, 100%);
}

.gemini-rendered-turn .query-text,
.gemini-rendered-turn .user-query-bubble-with-background {
  display: block;
  border-radius: 18px;
  background: #edf4f1;
  color: var(--ink);
}

.gemini-rendered-turn .query-text {
  padding: 10px 14px;
}

.gemini-rendered-turn .query-text p,
.gemini-rendered-turn .query-text-line {
  margin: 0;
}

.gemini-rendered-turn model-response {
  color: var(--ink);
}

.gemini-rendered-turn message-content,
.gemini-rendered-turn .model-response-text {
  max-width: 100%;
}

.gemini-rendered-turn h1,
.gemini-rendered-turn h2,
.gemini-rendered-turn h3,
.gemini-rendered-turn h4 {
  margin: 1.15em 0 0.45em;
  line-height: 1.28;
  letter-spacing: 0;
}

.gemini-rendered-turn h3 {
  font-size: 1.1rem;
}

.gemini-rendered-turn h4 {
  font-size: 1rem;
}

.gemini-rendered-turn p {
  margin: 0.72em 0;
}

.gemini-rendered-turn ul,
.gemini-rendered-turn ol {
  margin: 0.65em 0;
  padding-left: 1.45rem;
}

.gemini-rendered-turn li + li {
  margin-top: 0.32em;
}

.gemini-rendered-turn table {
  min-width: 680px;
  margin: 12px 0;
}

.gemini-rendered-turn .table-container,
.gemini-rendered-turn rich-table,
.gemini-rendered-turn .table-wrapper {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.gemini-rendered-turn svg,
.gemini-rendered-turn img {
  max-width: 100%;
  height: auto;
}

.gemini-rendered-turn math,
.gemini-rendered-turn .katex,
.gemini-rendered-turn .math,
.gemini-rendered-turn latex-js,
.gemini-rendered-turn ms-math {
  max-width: 100%;
  overflow-x: auto;
}

.gemini-rendered-turn button,
.gemini-rendered-turn mat-icon,
.gemini-rendered-turn .response-footer,
.gemini-rendered-turn .copy-button,
.gemini-rendered-turn .feedback-container,
.gemini-rendered-turn .sources-container,
.gemini-rendered-turn .mat-mdc-tooltip-trigger,
.gemini-rendered-turn .cdk-visually-hidden {
  display: none !important;
}

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

.dialogue-turn {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 8px;
  background: #ffffff;
}

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

.message-text p {
  margin: 0;
}

.message-text p + p {
  margin-top: 8px;
}

.speaker {
  display: inline-flex;
  justify-content: center;
  min-height: 28px;
  padding: 3px 8px;
  border-radius: 8px;
  background: #e6f2ef;
  color: var(--teal-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.source-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

thead th {
  background: #edf3ee;
  color: #354139;
  font-size: 0.78rem;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
}

.site-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer:empty {
  display: none;
}

@media (max-width: 920px) {
  .header-grid,
  .shell,
  .problem-body,
  .problem-head,
  .info-grid {
    grid-template-columns: 1fr;
  }

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

  .toc-panel {
    position: static;
    max-height: none;
  }

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

  .source-link {
    justify-self: start;
  }
}

@media (max-width: 560px) {
  .header-grid,
  .shell,
  .site-footer {
    width: min(100% - 20px, 1180px);
  }

  .stats,
  .toc {
    grid-template-columns: 1fr;
  }

  .problem-head,
  .problem-body {
    padding: 14px;
  }

  .figure-frame {
    min-height: 180px;
  }

  .dialogue-turn {
    grid-template-columns: 1fr;
  }

  .speaker {
    justify-self: start;
  }
}
