:root {
  color-scheme: light;
  font-family: "Instrument Sans", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #192b2d;
  background: #f7f8f5;
  --muted: #536566;
  --line: #dce4df;
  --paper: #fff;
  --subtle: #f3f7f5;
  --accent: #235d58;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
[hidden] { display: none !important; }
.shell { width: min(100% - 40px, 1120px); margin: clamp(52px, 18vh, 160px) auto 0; }
.shell:has(.messages:not(:empty)) { margin-top: clamp(28px, 7vh, 64px); }
.intro { margin-bottom: 28px; text-align: center; }
h1 { margin: 0 0 10px; font-size: clamp(1.75rem, 4vw, 2.65rem); line-height: 1.25; font-weight: 700; }
.intro p { max-width: 34rem; margin: 0 auto; color: var(--muted); font-size: .95rem; line-height: 1.65; }
.panel { overflow: hidden; background: var(--paper); border: 1px solid #cbdad4; border-radius: 16px; box-shadow: 0 3px 12px #193f350a; }
.panel:focus-within { border-color: #8eb5a9; }
.conversation { max-height: min(56vh, 650px); overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
.conversation:not(:has(.messages:not(:empty), [role="status"]:not([hidden]), [role="alert"]:not([hidden]))) { display: none; }
.example-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; width: min(100%, 840px); margin: 18px auto 0; }
.example-group { padding: 13px 10px 9px; background: #fcfdfb; border: 1px solid var(--line); border-radius: 12px; }
.example-group h2 { margin: 0 4px 4px; color: var(--accent); font-size: .87rem; font-weight: 700; }
.example { display: block; width: 100%; min-height: 36px; padding: 6px 4px; text-align: left; line-height: 1.45; color: #344849; background: transparent; border: 1px solid transparent; border-radius: 5px; font-size: .83rem; }
.example:hover, .example:focus-visible { background: #edf5f0; }

.project-overview { display: grid; gap: 28px; width: min(100%, 840px); margin: 46px auto 0; padding-top: 26px; border-top: 1px solid var(--line); }
.project-overview h2 { margin: 0 0 10px; color: var(--accent); font-size: 1.05rem; }
.project-overview p, .project-overview ul { margin: 0; color: var(--muted); font-size: .875rem; line-height: 1.7; }
.project-overview p { max-width: 40rem; }
.project-overview ul { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 24px; padding: 0; list-style: none; }
.project-overview strong { display: block; margin-bottom: 2px; color: var(--accent); }
.project-background-details { margin-top: 10px; font-size: .875rem; }
.project-background-details summary { width: fit-content; padding: 6px 0; cursor: pointer; color: var(--accent); font-weight: 600; }
.background-story { margin-top: 10px; }
.background-story p + p { margin-top: 14px; }
.background-story .background-sources { display: flex; flex-wrap: wrap; gap: 3px 16px; margin-top: 5px; font-size: .8rem; }
.background-sources a { color: var(--accent); text-underline-offset: .18em; }

.composer { padding: 14px 16px; }
.conversation:has(.messages:not(:empty)) + .composer { border-top: 1px solid var(--line); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.compose-row { display: flex; align-items: stretch; gap: 9px; }
.compose-row textarea { width: 100%; min-width: 0; min-height: 72px; margin: 0; padding: 10px 8px; resize: vertical; line-height: 1.5; color: inherit; background: var(--paper); border: 0; border-radius: 7px; font-size: 1rem; }
.compose-row textarea::placeholder { color: var(--muted); }
.send { align-self: flex-end; min-height: 44px; padding: 0 17px; color: #fff; white-space: nowrap; background: var(--accent); border: 1px solid var(--accent); border-radius: 7px; font-weight: 650; }
.send:hover { background: #184944; }
:focus-visible { outline: 2px solid #438f80; outline-offset: 3px; }
.footer-note { margin: 18px 1px 24px; text-align: center; color: var(--muted); font-size: .77rem; line-height: 1.6; }

.messages { display: grid; gap: 14px; }
.turn { max-width: 100%; border-radius: 9px; overflow-wrap: anywhere; }
.turn-name { margin: 0 0 5px; color: var(--muted); font-size: .76rem; font-weight: 700; }
.question-turn { width: fit-content; max-width: min(100%, 680px); justify-self: end; padding: 9px 13px; background: #eaf0f8; }
.question-turn p:last-child { margin: 0; white-space: pre-wrap; line-height: 1.65; }
.answer-turn { padding: 12px 14px; background: var(--subtle); border: 1px solid var(--line); }
.thinking { margin: 2px 0 12px; padding: 4px 10px; border-inline-start: 2px solid #c8d2ce; color: #646f6d; font-size: .86rem; line-height: 1.6; }
.thinking summary { cursor: pointer; font-weight: 600; }
.thinking-body { max-height: 12rem; margin-top: 6px; overflow-y: auto; white-space: pre-wrap; }
.answer-body { color: #121212; font-size: .95rem; line-height: 1.72; }
.streaming-text { white-space: pre-wrap; }
.answer-body > :first-child { margin-top: 0; }
.answer-body p, .answer-body ul, .answer-body ol { margin: 0 0 .55em; }
.answer-body ul, .answer-body ol { padding-inline-start: 1.5em; }
.answer-body h3 { margin: 12px 0 4px; font-size: 1rem; }
.answer-body table { width: 100%; margin: 8px 0; border-collapse: collapse; text-align: left; font-size: .9em; }
.answer-body th, .answer-body td { padding: 5px 8px; border: 1px solid var(--line); }
.answer-body th { background: #eaf0f8; }
.citation { padding: 0 4px; color: var(--accent); font-size: .8em; text-decoration: none; white-space: nowrap; border: 1px solid #bec9d9; border-radius: 4px; }
.sources { display: grid; gap: 9px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.sources h4 { margin: 0; font-size: .86rem; }
.source-card { display: grid; gap: 6px; padding: 10px; color: var(--muted); background: var(--paper); border: 1px solid var(--line); border-radius: 7px; font-size: .83rem; }
.source-card:target { outline: 2px solid #56759e; }
.source-card p { margin: 0; white-space: pre-wrap; }
.source-card summary { cursor: pointer; }
.source-card details p { max-height: 200px; overflow: auto; margin-top: 6px; }
.source-figure { display: block; width: fit-content; max-width: 100%; }
.source-figure img { display: block; width: auto; max-width: 100%; max-height: 420px; height: auto; border: 1px solid var(--line); border-radius: 4px; object-fit: contain; }
.work-status { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; color: var(--muted); font-size: .88rem; }
.work-status span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .28; } }
.error-message { margin: 10px 0 0; padding: 8px 10px; color: #802912; background: #fbede2; border-radius: 5px; font-size: .86rem; }

@media (max-width: 650px) {
  .shell { width: calc(100% - 28px); }
  .intro { margin-bottom: 18px; }
  .example-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .project-overview { gap: 22px; margin-top: 34px; padding-top: 20px; }
  .project-overview ul { grid-template-columns: 1fr; }
  .project-overview strong { display: inline; margin: 0 .6em 0 0; }
  .composer, .conversation { padding: 12px; }
  .conversation { max-height: none; }
  .send { padding-inline: 13px; }
  .answer-turn { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) { .work-status span { animation: none; } }
