:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef2f5;
  --text: #1d2733;
  --muted: #66727f;
  --line: #dce2e8;
  --accent: #0b6b5a;
  --accent-soft: #e4f2ee;
  --warn: #b06a00;
  --warn-soft: #fff3dc;
  --danger: #b23b3b;
  --danger-soft: #fbe7e7;
  --shadow: 0 8px 24px rgba(20, 35, 50, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  line-height: 1.6;
}

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

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: inline-grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

h1 + p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-note {
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  align-items: start;
}

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

.input-panel {
  padding: 20px;
  position: sticky;
  top: 24px;
}

.result-panel {
  min-height: 520px;
  padding: 22px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-title h2,
.result h3 {
  margin: 0;
  font-size: 16px;
}

.muted {
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field > span {
  color: var(--muted);
  font-size: 13px;
}

textarea,
input,
select {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.params-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary-button:hover {
  background: #085647;
}

.primary-button svg,
.empty-state svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.examples-label {
  width: 100%;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 13px;
}

.examples button {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13px;
}

.examples button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 30px;
  height: 30px;
  color: var(--muted);
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.status.not_found {
  background: var(--warn-soft);
  color: var(--warn);
}

.status.partial {
  background: #e7edf4;
  color: #38617f;
}

.answer-block,
.compliance-block,
.inference-block,
.tables-block,
.illustrations-block {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
}

.answer-block {
  background: #fbfcfd;
}

.answer-block h3,
.compliance-block h3,
.inference-block h3,
.tables-block h3,
.illustrations-block h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.answer-block p,
.compliance-block p,
.inference-block p,
.tables-block p {
  margin: 0;
}

.tables-block {
  background: #fbfcfd;
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 12px;
}

.table-wrap:last-child {
  margin-bottom: 0;
}

.table-caption {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13px;
}

.table-wrap th,
.table-wrap td {
  padding: 7px 9px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  background: #fff;
}

.table-wrap th {
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 700;
}

.illustrations-block {
  background: #fbfcfd;
}

.illustration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.illustration-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.illustration-card img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 120px;
  object-fit: cover;
  background: #fff;
  cursor: zoom-in;
}

.illustration-card figcaption {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(12, 18, 25, 0.92);
}

.lightbox[hidden] {
  display: none;
}

.lightbox-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 94vw;
  max-height: 92vh;
  margin: 0;
}

#lightbox-img {
  display: block;
  max-width: 92vw;
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

.lightbox-figure figcaption {
  max-width: 92vw;
  color: #d7dee5;
  font-size: 13px;
  text-align: center;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.lightbox-close:hover,
.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox-close svg,
.lightbox-nav svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lightbox-close {
  top: 18px;
  right: 18px;
}

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-nav.prev {
  left: 18px;
}

.lightbox-nav.next {
  right: 18px;
}

.compliance-block {
  background: #fbfcfd;
}

.compliance-grid {
  display: flex;
  gap: 32px;
  margin-bottom: 8px;
}

.compliance-grid div {
  display: flex;
  flex-direction: column;
}

.compliance-grid strong {
  font-size: 16px;
}

.inference-block {
  background: var(--warn-soft);
  border-color: #efd39d;
}

.confidence {
  display: inline-flex;
  margin-top: 8px;
  color: var(--warn);
  font-size: 12px;
}

.sources {
  margin-top: 8px;
}

.source-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 10px;
  background: #fff;
}

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

.source-id {
  font-weight: 800;
  color: var(--accent);
}

.source-meta {
  color: var(--muted);
  font-size: 12px;
}

.mandatory {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
}

.source-text {
  margin: 0;
  color: #3a4652;
  font-size: 14px;
  white-space: pre-wrap;
}

.loading {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .input-panel {
    position: static;
  }

  .topbar {
    padding: 14px;
  }

  .topbar-note {
    display: none;
  }
}

@media (max-width: 480px) {
  .params-grid {
    grid-template-columns: 1fr;
  }

  .compliance-grid {
    flex-direction: column;
    gap: 8px;
  }
}

.feedback-block {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 18px;
  background: var(--surface-soft);
}

.feedback-block h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.feedback-block > p {
  margin: 0 0 10px;
}

.feedback-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.feedback-actions button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.feedback-actions button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.feedback-block textarea {
  margin-bottom: 10px;
  background: #fff;
}

.feedback-submit {
  min-height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.feedback-submit:disabled {
  opacity: 0.55;
  cursor: default;
}

.feedback-status {
  margin: 10px 0 0;
  font-size: 13px;
}

.feedback-status.ok {
  color: var(--accent);
}

.feedback-status.error {
  color: var(--danger);
}
