:root {
  color-scheme: light;
  --ink: #13211c;
  --muted: #66736d;
  --paper: #f4f1e9;
  --paper-deep: #e9e4d8;
  --card: #fbfaf6;
  --green: #0d5548;
  --green-bright: #147864;
  --lime: #c7db82;
  --orange: #df6f3e;
  --line: rgba(19, 33, 28, 0.16);
  --shadow: 0 20px 55px rgba(24, 45, 38, 0.12);
  font-family:
    Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system,
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(19, 33, 28, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(19, 33, 28, 0.035) 1px, transparent 1px), var(--paper);
  background-size: 42px 42px;
}

button,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 96px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 15px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
}

.brand-mark span {
  position: absolute;
  width: 18px;
  height: 1px;
  background: var(--ink);
  transform-origin: center;
}

.brand-mark span:nth-child(2) {
  transform: rotate(60deg);
}

.brand-mark span:nth-child(3) {
  transform: rotate(-60deg);
}

.brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: 0.13em;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 5px rgba(223, 111, 62, 0.12);
}

.status-dot.online {
  background: var(--green-bright);
  box-shadow: 0 0 0 5px rgba(20, 120, 100, 0.12);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.7fr);
  gap: 48px;
  padding: 80px 0 72px;
}

.hero-copy {
  max-width: 860px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.eyebrow-line {
  width: 72px;
  height: 1px;
  background: var(--green);
}

.hero h1 {
  max-width: 810px;
  margin: 22px 0 26px;
  font-family: "Iowan Old Style", "Noto Serif TC", "Songti TC", serif;
  font-size: clamp(54px, 6.3vw, 92px);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.hero-copy > p {
  max-width: 630px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  letter-spacing: 0.02em;
  line-height: 1.9;
}

.system-card {
  align-self: end;
  overflow: hidden;
  background: var(--green);
  color: white;
  box-shadow: var(--shadow);
}

.system-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.live-badge {
  padding: 5px 8px;
  color: var(--ink);
  background: var(--lime);
  font-size: 9px;
}

.system-card dl {
  margin: 0;
  padding: 8px 22px 14px;
}

.system-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.system-card dl div:last-child {
  border: 0;
}

.system-card dt {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}

.system-card dd {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-align: right;
}

.query-workspace {
  position: relative;
  margin-bottom: 70px;
  border: 1px solid var(--ink);
  background: var(--card);
  box-shadow: 12px 12px 0 var(--paper-deep);
}

.mode-tabs {
  display: flex;
  border-bottom: 1px solid var(--ink);
}

.mode-tab {
  min-width: 190px;
  padding: 16px 24px;
  border: 0;
  border-right: 1px solid var(--ink);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.mode-tab.active {
  color: white;
  background: var(--green);
}

.tab-index {
  margin-right: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  opacity: 0.65;
}

.query-form {
  padding: 30px;
}

.query-form > label {
  display: block;
  margin-bottom: 18px;
  font-family: "Iowan Old Style", "Noto Serif TC", serif;
  font-size: 23px;
  font-weight: 600;
}

.query-title-visual {
  display: flex;
  align-items: baseline;
  gap: 0.18em;
}

.flip-words {
  position: relative;
  display: inline-grid;
  width: 4.25em;
  height: 1.25em;
  overflow: hidden;
  color: var(--green);
  perspective: 420px;
  vertical-align: -0.18em;
}

.flip-words > span {
  grid-area: 1 / 1;
  opacity: 0;
  transform: translateY(55%) rotateX(-82deg);
  transform-origin: 50% 50% -0.45em;
  animation: flip-word 12s cubic-bezier(0.55, 0.08, 0.25, 1) infinite;
  will-change: transform, opacity;
}

.flip-words > span:nth-child(2) {
  animation-delay: -9s;
}

.flip-words > span:nth-child(3) {
  animation-delay: -6s;
}

.flip-words > span:nth-child(4) {
  animation-delay: -3s;
}

@keyframes flip-word {
  0%,
  20% {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }

  25% {
    opacity: 0;
    transform: translateY(-55%) rotateX(82deg);
  }

  25.01%,
  95% {
    opacity: 0;
    transform: translateY(55%) rotateX(-82deg);
  }

  100% {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

.query-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  border: 1px solid var(--line);
  background: white;
}

.query-input-row:focus-within {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

textarea {
  width: 100%;
  min-height: 88px;
  padding: 20px;
  resize: vertical;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
  line-height: 1.7;
}

textarea::placeholder {
  color: #98a19d;
}

.query-input-row > button {
  display: flex;
  min-width: 230px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 22px;
  border: 0;
  color: white;
  background: var(--orange);
  cursor: pointer;
  font-weight: 700;
}

.query-input-row > button:hover {
  background: #c95e31;
}

.query-input-row > button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.submit-arrow {
  font-size: 22px;
  font-weight: 400;
}

.query-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 18px;
  color: var(--muted);
  font-size: 11px;
}

.query-footer strong {
  color: var(--ink);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestions button {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
}

.suggestions button:hover {
  border-color: var(--green);
  background: rgba(13, 85, 72, 0.06);
}

.result-section {
  padding: 48px 0 74px;
  border-top: 1px solid var(--line);
}

.result-header,
.citation-panel-head,
.answer-card-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-kicker,
.answer-card-label,
.citation-panel-head {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.result-header h2 {
  margin: 8px 0 0;
  font-family: "Iowan Old Style", "Noto Serif TC", serif;
  font-size: 38px;
}

.result-meta {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.loading-state {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-top: 28px;
  padding: 36px;
  border: 1px solid var(--line);
  background: var(--card);
}

.loading-state p {
  margin: 7px 0 0;
  color: var(--muted);
}

.atlas-loader {
  position: relative;
  width: 56px;
  height: 56px;
  animation: spin 2.8s linear infinite;
}

.atlas-loader span {
  position: absolute;
  inset: 25px 4px;
  height: 1px;
  background: var(--green);
}

.atlas-loader span:nth-child(2) {
  transform: rotate(60deg);
}

.atlas-loader span:nth-child(3) {
  transform: rotate(-60deg);
}

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

.error-state {
  margin-top: 28px;
  padding: 20px 22px;
  border-left: 4px solid var(--orange);
  background: rgba(223, 111, 62, 0.1);
  line-height: 1.7;
}

.answer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.75fr);
  gap: 24px;
  margin-top: 28px;
}

.answer-card {
  min-height: 300px;
  padding: 30px;
  background: var(--green);
  color: white;
  box-shadow: var(--shadow);
}

.answer-card-label {
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.66);
}

.answer-text {
  padding-top: 24px;
  font-size: 16px;
  line-height: 1.95;
}

.answer-text h3 {
  margin: 0 0 14px;
  font-family: "Iowan Old Style", "Noto Serif TC", serif;
  font-size: 23px;
}

.answer-text p,
.answer-text ol,
.answer-text ul {
  margin: 0 0 18px;
}

.answer-text ol,
.answer-text ul {
  padding-left: 1.5em;
}

.answer-text li + li {
  margin-top: 8px;
}

.answer-text a {
  color: var(--lime);
  text-decoration-color: rgba(199, 219, 130, 0.55);
  text-underline-offset: 0.18em;
}

.answer-text a:hover {
  text-decoration-color: currentColor;
}

.answer-text .citation-marker {
  display: inline-grid;
  min-width: 1.85em;
  min-height: 1.85em;
  margin-inline: 0.12em;
  place-items: center;
  border: 1px solid rgba(199, 219, 130, 0.72);
  border-radius: 999px;
  color: var(--green);
  background: var(--lime);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72em;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  vertical-align: 0.15em;
}

.answer-text .citation-marker:hover,
.answer-text .citation-marker:focus-visible {
  color: white;
  background: var(--orange);
  border-color: var(--orange);
  outline: none;
}

.citation-panel {
  border: 1px solid var(--line);
  background: var(--card);
}

.citation-panel-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.citation-panel-head span:last-child {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
}

.citation-list {
  max-height: 520px;
  overflow: auto;
}

.citation-item {
  display: block;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.citation-item:hover {
  background: rgba(13, 85, 72, 0.05);
}

.citation-index {
  display: block;
  margin-bottom: 9px;
  color: var(--orange);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.citation-item strong {
  display: block;
  font-size: 14px;
  line-height: 1.55;
}

.citation-item p {
  display: -webkit-box;
  margin: 9px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.empty-citations {
  padding: 24px 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.principles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.principles article {
  min-height: 230px;
  padding: 34px;
  border-right: 1px solid var(--ink);
}

.principles article:last-child {
  border-right: 0;
}

.principle-number {
  color: var(--orange);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.principles h2 {
  margin: 42px 0 13px;
  font-family: "Iowan Old Style", "Noto Serif TC", serif;
  font-size: 24px;
}

.principles p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  padding: 26px 0 38px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

@media (max-width: 920px) {
  .page-shell {
    padding: 0 24px;
  }

  .hero,
  .answer-layout {
    grid-template-columns: 1fr;
  }

  .system-card {
    max-width: 520px;
  }

  .hero h1 {
    font-size: clamp(50px, 8vw, 72px);
  }

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

  .query-input-row > button {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 0 16px;
  }

  .topbar {
    min-height: 82px;
  }

  .topbar-meta {
    font-size: 0;
  }

  .hero {
    gap: 36px;
    padding: 54px 0;
  }

  .hero h1 {
    font-size: 48px;
  }

  .mode-tab {
    min-width: 0;
    flex: 1;
    padding: 14px;
  }

  .query-form {
    padding: 20px;
  }

  .query-footer,
  footer {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .principles article {
    min-height: 190px;
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .principles article:last-child {
    border-bottom: 0;
  }

  .principles h2 {
    margin-top: 28px;
  }
}

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

  .flip-words > span {
    opacity: 0;
    transform: none;
  }

  .flip-words > span:first-child {
    opacity: 1;
  }
}
