:root {
  color-scheme: dark;
  --bg: #061425;
  --bg-deep: #04101e;
  --surface: #0a1b2f;
  --surface-raised: #0d2239;
  --surface-hover: #102943;
  --border: #29435e;
  --border-strong: #3e5e7d;
  --text: #eef3f7;
  --muted: #91a0b2;
  --faint: #65758a;
  --supported: #55c7ad;
  --watch: #f4ad32;
  --unsupported: #f26d6d;
  --unknown: #8291a6;
  --focus: #79aef3;
  --primary: #2e6ebb;
  --primary-hover: #3d7dca;
  --header-height: 62px;
  --footer-height: 44px;
  --radius: 7px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

body {
  overflow: hidden;
}

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

button,
select {
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 16px;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h3 {
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 650;
}

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

.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 20px;
  font-weight: 680;
  letter-spacing: -0.025em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.api-state {
  color: var(--muted);
  font-size: 12px;
}

.api-state.configured {
  color: var(--supported);
}

.auth-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.auth-controls[hidden] {
  display: none;
}

.auth-user {
  max-width: 160px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-logout {
  color: var(--text);
}

.icon-button,
.small-icon-button {
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
}

.icon-button {
  width: 34px;
  height: 34px;
}

.small-icon-button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
}

.small-icon-button svg {
  width: 17px;
  height: 17px;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 620;
}

.primary-button {
  background: var(--primary);
  border: 1px solid #477fc0;
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-hover);
}

.secondary-button {
  background: transparent;
  border: 1px solid var(--border-strong);
}

.secondary-button:hover:not(:disabled) {
  background: var(--surface-hover);
}

.primary-button svg,
.secondary-button svg {
  width: 17px;
  height: 17px;
}

.text-button {
  padding: 5px 0;
  color: #a9c9ef;
  background: transparent;
  border: 0;
  font-size: 12px;
}

.workbench {
  height: calc(100vh - var(--header-height) - var(--footer-height));
  display: grid;
  grid-template-columns: minmax(300px, 28.5%) minmax(480px, 44.5%) minmax(300px, 27%);
  background: var(--bg);
}

.input-panel,
.results-panel,
.inspector-panel {
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.input-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.results-panel {
  border-right: 1px solid var(--border);
}

.panel-scroll,
.results-scroll,
.inspector-scroll {
  height: 100%;
  overflow: auto;
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}

.panel-scroll {
  padding: 24px 20px 18px;
}

.results-scroll {
  padding: 26px 0 40px;
}

.inspector-scroll {
  padding: 26px 22px 40px;
}

.answer-input,
.source-content,
.source-title,
.expected-input,
.review-section textarea,
select {
  width: 100%;
  color: var(--text);
  background: #08192b;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.answer-input {
  min-height: 180px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

.field-help {
  margin: -4px 0 10px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.4;
}

.input-counter {
  margin-top: 7px;
  color: var(--faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.input-counter.limit {
  color: var(--unsupported);
  font-weight: 650;
}

.input-error {
  margin-bottom: 12px;
  padding: 10px 11px;
  color: #ffd3d3;
  background: rgba(242, 109, 109, 0.09);
  border: 1px solid rgba(242, 109, 109, 0.72);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.45;
}

[aria-invalid="true"] {
  border-color: var(--unsupported) !important;
  box-shadow: 0 0 0 1px rgba(242, 109, 109, 0.18);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 20px;
}

.section-heading h2,
.section-heading h3 {
  margin-bottom: 0;
}

.source-list,
.expected-list {
  display: grid;
  gap: 8px;
}

.source-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #071727;
}

.source-item[open] {
  border-color: var(--border-strong);
}

.source-item summary {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 8px;
  list-style: none;
  cursor: pointer;
}

.source-item summary::-webkit-details-marker {
  display: none;
}

.source-item summary svg {
  width: 18px;
  height: 18px;
  color: #9fb4ca;
}

.source-summary-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.remove-button {
  width: 28px;
  height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
}

.remove-button:hover {
  color: var(--unsupported);
  background: rgba(242, 109, 109, 0.08);
}

.remove-button svg {
  width: 15px;
  height: 15px;
}

.source-editor {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.source-title,
.source-content,
.expected-input {
  padding: 9px 10px;
  font-size: 13px;
}

.source-content {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.expected-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  gap: 5px;
}

.input-actions {
  flex: 0 0 auto;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-deep);
}

.mode-field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mode-notice {
  margin: -3px 0 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.mode-notice.live {
  color: var(--watch);
}

select {
  min-height: 38px;
  padding: 0 10px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1.12fr;
  gap: 10px;
}

.result-heading,
.status-summary,
.omission-section,
.warning-section {
  margin-right: 26px;
  margin-left: 26px;
}

.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.result-heading h2 {
  margin-bottom: 7px;
}

.result-heading p {
  margin-bottom: 0;
  font-size: 13px;
}

.empty-state {
  max-width: 410px;
  margin: 18vh auto 0;
  padding: 0 24px;
  text-align: center;
  color: var(--muted);
}

.empty-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  color: #6f8298;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.empty-mark svg {
  width: 30px;
  height: 30px;
}

.empty-state h3 {
  color: var(--text);
  font-size: 16px;
}

.empty-state p {
  line-height: 1.6;
}

.status-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 22px;
  padding: 20px 0 24px;
}

.status-box {
  min-width: 122px;
  min-height: 60px;
  display: grid;
  place-items: center;
  padding: 8px 18px;
  color: var(--unknown);
  border: 2px solid currentColor;
  border-radius: 5px;
  font-size: 22px;
  font-weight: 760;
  letter-spacing: 0.02em;
}

.status-box.stable {
  color: var(--supported);
}

.status-box.watch {
  color: var(--watch);
}

.status-box.alert {
  color: var(--unsupported);
}

.summary-line {
  margin-bottom: 8px;
  font-size: 17px;
  font-weight: 650;
}

.status-summary p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.claim-table {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.claim-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.75fr) minmax(118px, 0.9fr) minmax(90px, 0.68fr) minmax(150px, 1fr);
  min-height: 92px;
  border-top: 1px solid rgba(62, 94, 125, 0.62);
}

.claim-row > div {
  min-width: 0;
  padding: 18px 12px;
  line-height: 1.5;
}

.claim-row > div:first-child {
  padding-left: 26px;
}

.claim-row > div:last-child {
  padding-right: 26px;
}

.claim-header {
  min-height: 46px;
  color: #c5d0dc;
  background: var(--surface);
  border-top: 0;
  font-size: 12px;
  font-weight: 650;
}

.claim-header > div {
  padding-top: 14px;
  padding-bottom: 12px;
}

.claim-data-row {
  position: relative;
  cursor: pointer;
}

.claim-data-row:hover,
.claim-data-row.selected {
  background: var(--surface-raised);
}

.claim-data-row.selected::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--watch);
}

.claim-text {
  display: flex;
  gap: 10px;
}

.claim-index {
  flex: 0 0 auto;
  color: var(--muted);
}

.coverage-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 680;
}

.coverage-label::before {
  content: "";
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.coverage-label.supported {
  color: var(--supported);
}

.coverage-label.partial {
  color: var(--watch);
}

.coverage-label.not-supported {
  color: var(--unsupported);
}

.coverage-label.unknown {
  color: var(--unknown);
}

.source-cell,
.reason-cell {
  color: #bec8d4;
  font-size: 12px;
}

.source-cell {
  font-variant-numeric: tabular-nums;
}

.omission-section,
.warning-section {
  padding-top: 24px;
}

.omission-section .section-heading {
  margin-top: 0;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border);
}

.omission-rows {
  display: grid;
}

.omission-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(41, 67, 94, 0.55);
}

.omission-row p {
  margin-bottom: 0;
  color: #c6d0da;
  line-height: 1.45;
}

.warning-section {
  color: #d7b775;
}

.warning-section ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.6;
}

.risk-notes-section ul {
  margin: 0;
  padding-left: 20px;
  color: #c8d2dc;
  line-height: 1.55;
}

.risk-notes-section li + li {
  margin-top: 5px;
}

.inspector-empty {
  margin-top: 32px;
  padding: 18px 0;
  color: var(--muted);
  line-height: 1.6;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.inspector-section {
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--border);
}

.inspector-section:first-child {
  padding-top: 0;
}

.boxed-text,
blockquote {
  margin: 0;
  padding: 11px 12px;
  color: #d5dde6;
  background: #08192b;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  line-height: 1.5;
}

blockquote {
  border-left: 3px solid var(--watch);
}

.inspector-label-row {
  display: grid;
  gap: 10px;
}

.inspector-label-row select {
  margin-bottom: 8px;
}

.source-reference {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.review-section {
  display: grid;
  gap: 9px;
}

.review-section h3 {
  margin-bottom: 1px;
}

.review-section textarea {
  min-height: 74px;
  padding: 9px 10px;
  resize: vertical;
  line-height: 1.45;
}

.save-review {
  justify-self: start;
  min-height: 36px;
}

.metadata-section dl {
  display: grid;
  gap: 9px;
  margin: 0;
}

.metadata-section dl div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(41, 67, 94, 0.52);
}

.metadata-section dt {
  color: var(--muted);
}

.metadata-section dd {
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.app-footer {
  height: var(--footer-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  color: #9dacbd;
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.app-footer svg {
  width: 18px;
  height: 18px;
}

.footer-version {
  margin-left: auto;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.history-drawer {
  position: fixed;
  z-index: 20;
  inset: var(--header-height) auto var(--footer-height) 0;
  width: min(420px, 92vw);
  padding: 20px;
  overflow: auto;
  background: #071727;
  border-right: 1px solid var(--border-strong);
  box-shadow: 18px 0 48px rgba(0, 0, 0, 0.28);
  transform: translateX(-104%);
  transition: transform 180ms ease;
}

.history-drawer.open {
  transform: translateX(0);
}

.drawer-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.drawer-heading h2 {
  margin-bottom: 0;
}

.history-list {
  display: grid;
}

.history-item {
  padding: 14px 4px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 40;
  right: 20px;
  bottom: 62px;
  max-width: 420px;
  padding: 11px 14px;
  color: var(--text);
  background: #132b45;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: var(--unsupported);
}

.login-page {
  min-height: 100vh;
  overflow: auto;
  background:
    radial-gradient(circle at 50% 5%, rgba(46, 110, 187, 0.18), transparent 36rem),
    var(--bg-deep);
}

.login-shell {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.login-card {
  width: min(100%, 420px);
  padding: 36px;
  background: rgba(10, 27, 47, 0.96);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

.login-brand {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  color: #fff;
  background: var(--primary);
  border: 1px solid #5289c9;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.login-kicker {
  margin-bottom: 8px;
  color: var(--supported);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-card h1 {
  margin-bottom: 10px;
  font-size: 27px;
}

.login-intro,
.login-boundary {
  color: var(--muted);
  line-height: 1.55;
}

.login-intro {
  margin-bottom: 26px;
}

.login-card form {
  display: grid;
  gap: 9px;
}

.login-card label {
  margin-top: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.login-card input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--text);
  background: var(--bg-deep);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
}

.login-submit {
  width: 100%;
  margin-top: 16px;
}

.login-error {
  margin: 8px 0 0;
  padding: 10px 12px;
  color: #ffd0d0;
  background: rgba(242, 109, 109, 0.1);
  border: 1px solid rgba(242, 109, 109, 0.55);
  border-radius: 5px;
}

.login-boundary {
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.login-footer {
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-size: 12px;
}

@media (max-width: 1180px) {
  .workbench {
    grid-template-columns: minmax(300px, 36%) minmax(0, 64%);
    overflow: auto;
  }

  .results-panel {
    border-right: 0;
  }

  .inspector-panel {
    grid-column: 2;
    border-top: 1px solid var(--border);
  }

  .inspector-scroll {
    height: auto;
    min-height: 520px;
  }
}

@media (max-width: 780px) {
  body {
    overflow: auto;
  }

  .app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0 12px;
  }

  .brand {
    font-size: 16px;
  }

  .api-state {
    display: none;
  }

  .auth-user {
    display: none;
  }

  .auth-controls {
    padding-left: 0;
    border-left: 0;
  }

  .header-actions .secondary-button {
    width: 38px;
    padding: 0;
    font-size: 0;
  }

  .workbench {
    height: auto;
    display: block;
  }

  .input-panel,
  .results-panel,
  .inspector-panel {
    border: 0;
    border-bottom: 1px solid var(--border);
  }

  .panel-scroll,
  .results-scroll,
  .inspector-scroll {
    height: auto;
    overflow: visible;
  }

  .input-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
  }

  .claim-header {
    display: none;
  }

  .claim-row {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 14px 18px;
  }

  .claim-row > div,
  .claim-row > div:first-child,
  .claim-row > div:last-child {
    padding: 5px 0;
  }

  .claim-data-row.selected::before {
    width: 4px;
  }

  .app-footer {
    min-height: var(--footer-height);
    height: auto;
    padding: 10px 14px;
  }

  .login-card {
    padding: 28px 22px;
  }
}

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