:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-soft: #eef4ee;
  --text: #18211d;
  --muted: #68746d;
  --line: #d9e0d8;
  --green: #2f6b4f;
  --green-dark: #1f4d39;
  --coral: #c45f4a;
  --blue: #356f8c;
  --gold: #d7a928;
  --ink-soft: #26312c;
  --shadow: 0 18px 40px rgba(24, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
}

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

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border-radius: 8px;
  background: var(--green-dark);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}

.brand h1,
.brand p,
.panel h2,
.panel p,
.section-heading h2,
.section-heading p,
.verification-rail h2 {
  margin: 0;
}

.brand h1 {
  font-size: 24px;
  line-height: 1.15;
}

.brand p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 14px;
}

.build-proof {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  white-space: nowrap;
  font-size: 12px;
}

.build-proof strong {
  color: var(--green-dark);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 24px;
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.workspace {
  min-width: 0;
}

.control-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ownership-proof {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 18px;
  align-items: stretch;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(31, 77, 57, 0.28);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #eef4ee 100%);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--coral);
  font-size: 12px;
  font-weight: 700;
}

.ownership-proof h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}

.ownership-proof h2 strong {
  color: var(--green-dark);
}

.ownership-proof p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.ownership-proof dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.ownership-proof dl div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 10px;
}

.ownership-proof dt,
.ownership-proof dd {
  margin: 0;
}

.ownership-proof dt {
  color: var(--muted);
  font-size: 12px;
}

.ownership-proof dd {
  margin-top: 4px;
  color: var(--ink-soft);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.control-group {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.control-label {
  color: var(--muted);
  font-size: 12px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segment {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-soft);
  padding: 0 12px;
  cursor: pointer;
}

.segment[aria-selected="true"] {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.primary,
.secondary {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
}

.primary {
  border: 1px solid var(--green-dark);
  background: var(--green-dark);
  color: #fff;
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
}

.primary:focus-visible,
.secondary:focus-visible,
.segment:focus-visible,
.listing-card:focus-visible {
  outline: 3px solid rgba(53, 111, 140, 0.34);
  outline-offset: 2px;
}

.scoreband {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.metric {
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 34px;
  line-height: 1;
  color: var(--green-dark);
}

.split-area,
.schema-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

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

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel h2,
.section-heading h2,
.verification-rail h2 {
  font-size: 18px;
  line-height: 1.25;
}

.panel p,
.section-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.panel-heading > span,
.section-heading > span {
  flex: 0 0 auto;
  color: var(--green-dark);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.query-list {
  display: grid;
  gap: 10px;
}

.query-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: 12px;
  align-items: center;
  min-height: 60px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfa;
}

.query-text {
  min-width: 0;
  line-height: 1.35;
}

.query-text strong {
  display: block;
  font-size: 14px;
}

.query-text span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.query-status {
  justify-self: end;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  color: #fff;
  background: var(--coral);
}

.query-status.good {
  background: var(--green);
}

.query-status.mid {
  background: var(--blue);
}

.answer-panel {
  display: grid;
  grid-template-rows: auto 1fr;
}

.answer-box {
  min-height: 282px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(238, 244, 238, 0.8), rgba(255, 255, 255, 0)),
    #fbfcfa;
  border: 1px solid var(--line);
  padding: 16px;
}

.answer-box h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.answer-box p {
  margin: 0 0 12px;
  color: var(--ink-soft);
  line-height: 1.55;
  font-size: 14px;
}

.answer-box ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  line-height: 1.55;
  font-size: 14px;
}

.listing-section {
  margin-top: 18px;
}

.listing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.listing-card {
  display: grid;
  grid-template-rows: 156px minmax(185px, auto);
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  padding: 0;
}

.listing-card[aria-pressed="true"] {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.14);
}

.listing-card img {
  width: 100%;
  height: 156px;
  object-fit: cover;
  display: block;
}

.listing-copy {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.listing-copy h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

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

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tags span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 7px;
  background: #fbfcfa;
  color: var(--ink-soft);
  font-size: 12px;
}

.code-preview {
  height: 392px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101815;
  color: #e8f1ec;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.report-panel {
  display: grid;
  grid-template-rows: auto 1fr;
}

#reportText {
  width: 100%;
  min-height: 392px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink-soft);
  background: #fbfcfa;
  line-height: 1.5;
  font-size: 13px;
}

.verification-rail {
  position: sticky;
  top: 102px;
  align-self: start;
  padding: 18px;
}

.verification-rail h2 {
  margin-bottom: 14px;
}

.verification-rail ol {
  display: grid;
  gap: 14px;
  margin: 0;
  padding-left: 22px;
}

.verification-rail li {
  padding-left: 4px;
}

.verification-rail strong,
.verification-rail span {
  display: block;
}

.verification-rail strong {
  font-size: 14px;
  margin-bottom: 4px;
}

.verification-rail span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .verification-rail {
    position: static;
  }
}

@media (max-width: 900px) {
  .topbar,
  .control-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .build-proof {
    align-items: flex-start;
  }

  .scoreband,
  .ownership-proof,
  .split-area,
  .schema-area,
  .listing-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    width: 100%;
  }

  .primary,
  .secondary {
    flex: 1 1 0;
  }
}

@media (max-width: 560px) {
  .topbar,
  .app-shell {
    padding: 16px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
    font-size: 13px;
  }

  .brand h1 {
    font-size: 20px;
  }

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

  .query-status {
    justify-self: start;
  }
}
