:root {
  color-scheme: light;
  --ink: #101416;
  --muted: #5a646b;
  --line: #d7dde1;
  --paper: #fbfcfb;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --true: #137a3d;
  --mixed: #9a6500;
  --false: #bb1d2c;
  --pending: #111827;
  --shadow: 0 20px 50px rgba(18, 33, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 8%, rgba(15, 118, 110, 0.14), transparent 24rem),
    linear-gradient(135deg, #eef4f1 0%, #f7f2ea 48%, #edf3f7 100%);
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: var(--accent-strong);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 26px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 6vw, 4.8rem);
  line-height: 0.92;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.15rem;
}

.status-pill {
  min-width: 132px;
  padding: 10px 14px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
  text-align: center;
  font-weight: 750;
  box-shadow: 0 8px 24px rgba(15, 118, 110, 0.08);
}

.workspace {
  border: 1px solid rgba(16, 20, 22, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.workspace {
  min-height: 640px;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mic-button,
.ghost-button,
select {
  min-height: 44px;
  border-radius: 8px;
}

.mic-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.mic-icon {
  width: 13px;
  height: 22px;
  border: 2px solid currentColor;
  border-radius: 10px;
  position: relative;
}

.mic-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 18px;
  height: 10px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 12px 12px;
  transform: translateX(-50%);
}

.mic-button.listening {
  background: #bb1d2c;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

select {
  padding: 0 36px 0 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.ghost-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 750;
}

.editor-wrap {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  overflow: hidden;
}

.sentence-editor {
  width: 100%;
  height: 100%;
  min-height: 500px;
  padding: 22px;
  overflow: auto;
  outline: none;
  color: var(--pending);
  font-size: clamp(1.05rem, 2vw, 1.38rem);
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}

.statement-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 38%);
  align-items: start;
  gap: 12px;
  width: 100%;
  margin: 0 0 0.4em;
}

.statement-row.has-answer {
  position: relative;
}

.statement-row.has-answer::before {
  content: "";
  align-self: start;
  justify-self: stretch;
  grid-column: 1 / 3;
  grid-row: 1;
  height: 1px;
  margin-top: 1.06em;
  background: linear-gradient(90deg, transparent 0%, rgba(16, 20, 22, 0.16) 42%, rgba(16, 20, 22, 0.16) 100%);
  pointer-events: none;
}

.sentence-editor:empty::before {
  content: attr(data-placeholder);
  color: #89949b;
}

.sentence {
  color: var(--pending);
  border-radius: 5px;
  display: inline;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 0.22em;
  transition: color 160ms ease, background-color 160ms ease;
  position: relative;
  z-index: 1;
  background-clip: padding-box;
}

.sentence.checking {
  color: var(--pending);
  background:
    linear-gradient(90deg, rgba(17, 24, 39, 0.04), rgba(15, 118, 110, 0.2), rgba(17, 24, 39, 0.04));
  background-size: 220% 100%;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.08);
  animation: checking-sweep 1.25s ease-in-out infinite;
}

.sentence.true {
  color: var(--true);
}

.sentence.unchecked {
  color: var(--pending);
  background: rgba(90, 100, 107, 0.1);
}

.sentence.error {
  color: var(--pending);
  background: rgba(187, 29, 44, 0.08);
  box-shadow: 0 0 0 2px rgba(187, 29, 44, 0.1);
}

.status-icon {
  width: 1.05em;
  height: 1.05em;
  margin-left: 0.28em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  top: -0.05em;
  background: var(--true);
  color: #fff;
  font-size: 0.62em;
  font-weight: 900;
  line-height: 1;
  vertical-align: middle;
}

.status-icon-true {
  border-radius: 50%;
  background: var(--true);
  color: #fff;
}

.status-icon-false {
  width: 0;
  height: 0;
  border-left: 0.62em solid transparent;
  border-right: 0.62em solid transparent;
  border-bottom: 1.08em solid var(--false);
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 0.58em;
  overflow: visible;
}

.status-icon-false::after {
  content: "!";
  position: absolute;
  left: -0.17em;
  top: 0.35em;
  color: #fff;
  font-size: 0.8em;
  font-weight: 950;
}

.status-icon-false {
  color: transparent;
}

.status-icon-mixed {
  border-radius: 50%;
  background: #f6b63d;
  color: #251700;
}

.sentence.mixed {
  color: var(--mixed);
  background: rgba(255, 196, 87, 0.17);
}

.sentence.false {
  color: var(--false);
  background: rgba(255, 115, 115, 0.13);
}

.inline-answer {
  position: relative;
  z-index: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 5px solid var(--mixed);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 0.72em;
  line-height: 1.35;
  box-shadow: 0 8px 22px rgba(18, 33, 38, 0.08);
}

.inline-answer.checking {
  padding: 8px 10px;
  border-left-color: var(--pending);
  color: var(--muted);
  font-weight: 800;
}

.inline-answer.true {
  border-left-color: var(--true);
}

.inline-answer.false,
.inline-answer.error {
  border-left-color: var(--false);
}

.inline-answer.unchecked {
  border-left-color: var(--muted);
}

.inline-answer summary {
  min-width: 0;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}

.inline-answer summary::-webkit-details-marker {
  display: none;
}

.inline-answer summary::after {
  content: "+";
  margin-left: auto;
  color: var(--muted);
  font-weight: 900;
}

.inline-answer[open] summary::after {
  content: "-";
}

.answer-label {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(154, 101, 0, 0.12);
  color: var(--mixed);
  font-size: 0.78em;
  font-weight: 900;
  white-space: nowrap;
}

.inline-answer.true .answer-label {
  background: rgba(19, 122, 61, 0.12);
  color: var(--true);
}

.inline-answer.false .answer-label,
.inline-answer.error .answer-label {
  background: rgba(187, 29, 44, 0.12);
  color: var(--false);
}

.inline-answer.unchecked .answer-label {
  background: rgba(90, 100, 107, 0.12);
  color: var(--muted);
}

.answer-short {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-body {
  padding: 0 10px 10px;
}

.answer-body p {
  margin-bottom: 8px;
  color: var(--muted);
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  background: var(--pending);
}

.dot.true { background: var(--true); }
.dot.mixed { background: #f6b63d; }
.dot.false { background: var(--false); }

@keyframes checking-sweep {
  0% {
    background-position: 120% 0;
  }

  50% {
    background-position: 0 0;
  }

  100% {
    background-position: -120% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sentence.checking {
    animation: none;
    background: rgba(15, 118, 110, 0.15);
  }
}

.results-panel {
  min-height: 320px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.facts-list {
  display: grid;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.fact-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--mixed);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

.fact-card.true {
  border-left-color: var(--true);
}

.fact-card.unchecked {
  border-left-color: var(--muted);
}

.fact-card.error {
  border-left-color: var(--false);
}

.fact-card.false {
  border-left-color: var(--false);
}

.fact-status {
  width: fit-content;
  margin-bottom: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(154, 101, 0, 0.12);
  color: var(--mixed);
  font-size: 0.74rem;
  font-weight: 850;
}

.fact-card.true .fact-status {
  background: rgba(19, 122, 61, 0.12);
  color: var(--true);
}

.fact-card.false .fact-status {
  background: rgba(187, 29, 44, 0.12);
  color: var(--false);
}

.fact-card.unchecked .fact-status {
  background: rgba(90, 100, 107, 0.12);
  color: var(--muted);
}

.fact-card.error .fact-status {
  background: rgba(187, 29, 44, 0.12);
  color: var(--false);
}

.fact-card h3 {
  margin: 0 0 8px;
  font-size: 0.92rem;
  line-height: 1.3;
}

.fact-parent {
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.fact-card p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.source-link {
  font-size: 0.88rem;
  font-weight: 800;
}

.sr-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 720px);
    padding: 16px 0;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .workspace {
    min-height: 560px;
    padding: 12px;
  }

  .sentence-editor {
    min-height: 430px;
    padding: 16px;
  }

  .statement-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .statement-row.has-answer::before {
    display: none;
  }

  .inline-answer {
    font-size: 0.78em;
  }
}
