:root {
  --bg: #f2eee4;
  --panel: rgba(255, 252, 246, 0.9);
  --panel-strong: #fffdf8;
  --ink: #1f2a24;
  --muted: #5d6b62;
  --line: rgba(31, 42, 36, 0.12);
  --accent: #1c7c54;
  --accent-strong: #12563a;
  --warn: #9b3d2e;
  --shadow: 0 18px 40px rgba(31, 42, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(28, 124, 84, 0.12), transparent 26rem),
    linear-gradient(180deg, #f8f4ea 0%, var(--bg) 100%);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

code,
pre,
textarea,
input,
select {
  font-family: "Cascadia Code", "Consolas", monospace;
}

.page-shell {
  width: min(1380px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.2rem 0 2.5rem;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  background: rgba(255, 253, 248, 0.72);
  backdrop-filter: blur(14px);
}

.brand,
.site-nav a {
  color: var(--ink);
  text-decoration: none;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  gap: 1rem;
}

.site-nav a {
  color: var(--muted);
}

.hero,
.panel,
.result-card,
.compare-panel,
.note-card,
.stat-card,
.log-entry {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
  border-radius: 1.6rem;
}

.hero-single {
  grid-template-columns: 1fr;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.lede,
.muted,
.result-meta,
.log-time,
.note-label,
.stat-label {
  color: var(--muted);
}

.note-card,
.panel,
.result-card,
.compare-panel,
.stat-card,
.log-entry {
  border-radius: 1.2rem;
}

.note-card,
.panel,
.result-card,
.compare-panel,
.log-entry {
  padding: 1rem 1.1rem;
}

.field,
.actions,
.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field span {
  font-size: 0.9rem;
  font-weight: 600;
}

.field textarea,
.field input,
.field select {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--panel-strong);
  color: var(--ink);
}

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

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 8.5rem;
  padding: 1.2rem;
  border: 2px dashed rgba(28, 124, 84, 0.25);
  border-radius: 1rem;
  background:
    linear-gradient(135deg, rgba(28, 124, 84, 0.06), rgba(255, 255, 255, 0.6)),
    var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone-active {
  border-color: rgba(28, 124, 84, 0.7);
  background:
    linear-gradient(135deg, rgba(28, 124, 84, 0.14), rgba(255, 255, 255, 0.76)),
    var(--panel-strong);
  outline: none;
  transform: translateY(-1px);
}

.drop-zone strong {
  font-size: 1rem;
}

.drop-zone span {
  color: var(--muted);
}

.drop-zone-name {
  display: inline-flex;
  max-width: 100%;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(31, 42, 36, 0.06);
  color: var(--ink) !important;
  font-size: 0.86rem;
}

.field textarea {
  resize: vertical;
}

.field-grid,
.admin-grid,
.stats-grid {
  display: grid;
  gap: 1rem;
}

.field-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.field-grid-compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-grid {
  grid-template-columns: 1.2fr 1fr;
  margin-top: 1.2rem;
}

.admin-grid-wide {
  grid-template-columns: 1.05fr 1.2fr;
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats-grid-secondary {
  margin-top: 1rem;
}

.state-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.state-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.state-details {
  border-top: 1px solid rgba(31, 42, 36, 0.08);
  padding-top: 0.85rem;
}

.stat-card-expandable {
  padding: 0;
  overflow: hidden;
}

.stat-card-details {
  padding: 0 1rem 1rem;
}

.stat-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-top: 1px solid rgba(31, 42, 36, 0.08);
}

.actions {
  margin-top: 1rem;
}

.button-primary,
.button-secondary {
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.button-small {
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
}

.button-secondary {
  background: linear-gradient(135deg, #f1dad4 0%, #e8c7bf 100%);
  color: var(--warn);
}

.results-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-top: 1.2rem;
}

.result-list,
.log-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.result-header,
.chunk-meta,
.log-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.score-pill,
.status-badge {
  white-space: nowrap;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.score-pill {
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #0f5132 100%);
}

.status-ok {
  color: #0f5132;
  background: #dff3e7;
}

.status-error {
  color: var(--warn);
  background: #f7d8d2;
}

.status-pending {
  color: #6b4c12;
  background: #f6e8bf;
}

.chunk-details {
  margin-top: 1rem;
}

.chunk-card,
.compare-block {
  margin-top: 0.8rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.55);
}

.chunk-score {
  align-self: flex-start;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(28, 124, 84, 0.12);
  color: var(--accent-strong);
  font-weight: 700;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0.9rem 0;
}

.breakdown-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.48);
}

.breakdown-item span,
.breakdown-item small {
  color: var(--muted);
}

.compare-panel-rich {
  gap: 1rem;
}

.compare-summary {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.compare-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.metric-chip {
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgba(31, 42, 36, 0.08);
  color: var(--ink);
  font-size: 0.84rem;
}

.diff-wrapper {
  overflow: auto;
  border-radius: 0.9rem;
  border: 1px solid var(--line);
  background: #f7f4ed;
}

table.diff {
  width: 100%;
  border-collapse: collapse;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.82rem;
}

.diff th,
.diff td {
  padding: 0.35rem 0.5rem;
  vertical-align: top;
}

.diff th {
  position: sticky;
  top: 0;
  background: #ece6d9;
  color: var(--ink);
}

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

.diff_next {
  width: 1%;
  color: transparent;
}

.diff_add {
  background: #dff3e7;
}

.diff_sub {
  background: #f7d8d2;
}

.diff_chg {
  background: #fff1c9;
}

pre {
  margin: 0;
  overflow: auto;
  border-radius: 0.8rem;
  padding: 0.9rem;
  background: #1b2420;
  color: #f3f0e8;
  line-height: 1.45;
}

.flash {
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 1rem;
}

.flash-error {
  color: var(--warn);
  background: #f8dfda;
  border: 1px solid rgba(155, 61, 46, 0.18);
}

.admin-form + .admin-form {
  margin-top: 1rem;
}

.admin-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.corpus-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.corpus-action-card {
  padding: 1rem;
  border: 1px solid rgba(31, 42, 36, 0.1);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.55);
}

.corpus-action-header {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  margin-bottom: 0.9rem;
}

.corpus-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.5rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(28, 124, 84, 0.12);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

.corpus-guide {
  margin-top: 1rem;
}

.guide-list {
  margin: 0.6rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.guide-list li + li {
  margin-top: 0.3rem;
}

.drop-zone-compact {
  min-height: 6.5rem;
}

.note-inline {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 0.95rem;
}

.stats-note {
  margin-top: 1rem;
}

.stat-card-muted {
  background: rgba(255, 255, 255, 0.55);
}

.repo-list,
.repo-file-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.corpus-browser,
.repo-browser-files {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.repo-browser-card,
.repo-browser-file {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.52);
}

.repo-browser-card {
  padding: 0.8rem 0.9rem;
}

.repo-browser-file {
  padding: 0.7rem 0.8rem;
}

.repo-browser-summary,
.repo-browser-file-summary {
  cursor: pointer;
  list-style: none;
}

.expand-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.expand-summary::after {
  content: '▸';
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 1rem;
  transition: transform 120ms ease;
}

details[open] > .expand-summary::after {
  transform: rotate(90deg);
}

.repo-browser-summary::-webkit-details-marker,
.repo-browser-file-summary::-webkit-details-marker {
  display: none;
}

.repo-browser-files {
  margin-top: 0.8rem;
}

.repo-browser-file pre {
  margin-top: 0.75rem;
}

.repo-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.52);
}

.repo-card-header,
.repo-file-row,
.inline-form {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
}

.repo-file-row {
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(31, 42, 36, 0.08);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.55);
}

.status-neutral {
  color: var(--muted);
  background: rgba(31, 42, 36, 0.08);
}

@media (max-width: 1024px) {
  .hero,
  .results-layout,
  .admin-grid,
  .admin-actions-grid,
  .field-grid,
  .field-grid-compact,
  .stats-grid,
  .breakdown-grid {
    grid-template-columns: 1fr;
  }
}
