:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --border: #dce0e2;
  --text: #1b3139;
  --muted: #5a6f77;
  --accent: #222f40;
  --accent-soft: #dfe7ef;
  --success: #17844f;
  --warn: #d95b36;
  --warn-soft: rgba(217, 91, 54, 0.12);
  --shadow: none;
  --radius-lg: 0;
  --radius-md: 0;
  --radius-sm: 0;
  --mono: "SFMono-Regular", "SF Mono", "Menlo", "Monaco", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scrollbar-width: none;
}

html::-webkit-scrollbar {
  width: 0;
  height: 0;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 20px 24px 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 16px 22px;
  margin: 0 auto 20px;
  width: 100%;
  max-width: 1480px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: #ffffff;
  box-shadow: var(--shadow);
}

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

.brand-title,
.eyebrow,
.lede,
.upload-subtitle,
.error-text {
  margin: 0;
}

.brand-title {
  font-weight: 600;
  font-size: 1.2rem;
}

.nav {
  display: flex;
  gap: 10px;
}

.nav-link,
.primary-button,
.upload-zone {
  border: 0;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.nav-link {
  padding: 12px 18px;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.nav-link.is-active,
.nav-link:hover {
  color: var(--text);
  background: transparent;
}

.nav-link.is-active {
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 8px;
  text-decoration-thickness: 1.5px;
}

.page {
  max-width: 1480px;
  margin: 0 auto;
  padding-top: 0;
}

.page-demo-empty {
  min-height: calc(100vh - 140px);
  display: block;
}

.home-stage {
  min-height: auto;
  display: block;
  padding-top: 0;
}

.home-stage .comparison-block {
  width: 100%;
  margin-bottom: 0;
}

.home-benchmark {
  margin-top: 20px;
  padding-bottom: 12px;
}

.home-benchmark .benchmark-section {
  margin-bottom: 0;
}

.comparison-block,
.benchmark-section,
.upload-shell,
.loading-shell,
.fatal-error {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lede {
  max-width: 760px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  font-weight: 700;
}

.primary-button {
  padding: 15px 22px;
  border-radius: 0;
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}

.primary-button:hover,
.upload-zone:hover,
.nav-link:hover {
  transform: none;
}

.comparison-block {
  padding: 16px;
  border-radius: 0;
  margin-bottom: 0;
}

.comparison-headline {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.comparison-headline.is-minimal {
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
}

.comparison-headline h2,
.benchmark-section h2,
.section-heading h3 {
  margin: 0;
  letter-spacing: -0.04em;
}

.sample-switcher {
  display: grid;
  grid-template-columns: 36px auto 36px;
  align-items: center;
  gap: 18px;
}

.sample-switcher h2 {
  text-align: center;
}

.sample-nav {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.sample-nav:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(60, 72, 88, 0.22);
}

.sample-nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.comparison-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.csv-panel,
.benchmark-shell,
.upload-shell {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.csv-panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.panel-header h3 {
  margin: 4px 0 0;
  font-size: 1.2rem;
}

.status-pill {
  padding: 10px 14px;
  border-radius: 0;
  font-size: 0.84rem;
  font-weight: 700;
}

.status-pill.is-success {
  color: var(--success);
  background: rgba(23, 132, 79, 0.14);
}

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

.csv-shell {
  overflow: auto;
  max-height: 580px;
  border-top: 1px solid var(--border);
}

.source-shell {
  position: relative;
}

.csv-table,
.benchmark-table {
  width: 100%;
  border-collapse: collapse;
}

.csv-table th,
.csv-table td,
.benchmark-table th,
.benchmark-table td {
  padding: 12px 14px;
  border-right: 1px solid rgba(127, 140, 156, 0.12);
  border-bottom: 1px solid rgba(127, 140, 156, 0.12);
  vertical-align: top;
}

.csv-table th,
.benchmark-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3f7;
  text-align: left;
  font-size: 0.87rem;
}

.csv-table td {
  font-family: var(--mono);
  font-size: 0.87rem;
  line-height: 1.4;
  min-width: 140px;
}

.line-number {
  width: 62px;
  min-width: 62px;
  text-align: center;
  color: var(--muted);
  background: rgba(242, 245, 249, 0.88);
}

.csv-row.is-flagged {
  background: linear-gradient(90deg, rgba(217, 91, 54, 0.06), rgba(217, 91, 54, 0.02));
}

.cell-highlight {
  background: linear-gradient(180deg, rgba(217, 91, 54, 0.18), rgba(217, 91, 54, 0.1));
  color: #8a2b18;
  font-weight: 600;
}

.cell-highlight-fixed {
  background: linear-gradient(180deg, rgba(23, 132, 79, 0.16), rgba(23, 132, 79, 0.08));
  color: #136744;
  font-weight: 600;
}

.cell-muted {
  background: rgba(217, 91, 54, 0.05);
}

.raw-source {
  min-width: 100%;
  width: max-content;
  padding: 0;
}

.raw-line {
  display: block;
  border-bottom: 1px solid rgba(127, 140, 156, 0.08);
  position: relative;
}

.raw-line:last-child {
  border-bottom: 0;
}

.raw-line-header {
  background: #eef3f7;
}

.raw-line-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 128px 12px 14px;
}

.raw-line-copy,
.expandable-text {
  min-width: 0;
}

.raw-line-copy .expandable-text,
.csv-table td .expandable-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.raw-line-copy .expandable-text span,
.csv-table td .expandable-text span {
  font-family: var(--mono);
  font-size: 0.87rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  color: inherit;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.raw-line-copy .expandable-text span {
  -webkit-line-clamp: 1;
}

.raw-line-copy .expandable-text {
  width: 100%;
  flex-direction: row;
  align-items: baseline;
  gap: 10px;
}

.raw-line-copy .expandable-text span {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  white-space: nowrap;
  word-break: normal;
  text-overflow: ellipsis;
}

.raw-line-copy .expandable-text.is-expanded {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.raw-line-copy .expandable-text.is-expanded span {
  white-space: pre-wrap;
  word-break: break-word;
  text-overflow: clip;
}

.raw-line-copy .expandable-text.is-expanded span,
.csv-table td .expandable-text.is-expanded span {
  display: block;
  overflow: visible;
}

.inline-toggle {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.4;
  cursor: pointer;
}

.inline-toggle:hover {
  color: var(--text);
}

.raw-line.is-flagged {
  background: linear-gradient(90deg, rgba(217, 91, 54, 0.1), rgba(217, 91, 54, 0.03));
}

.raw-line.is-flagged .raw-line-body {
  box-shadow: inset 3px 0 0 var(--warn);
}

.raw-line-header .raw-line-body {
  min-height: 40px;
  align-items: center;
  padding-top: 8px;
  padding-bottom: 8px;
}

.raw-line-header .expandable-text span {
  font-weight: 700;
  white-space: nowrap;
  word-break: normal;
  display: block;
  overflow: visible;
}

.raw-badge {
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: 0;
  background: rgba(217, 91, 54, 0.12);
  color: var(--warn);
  font-size: 0.76rem;
  line-height: 1;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.raw-line-meta {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.source-note-overlay {
  position: absolute;
  right: 14px;
  bottom: calc(100% - 10px);
  z-index: 5;
  width: min(420px, calc(100% - 28px));
  margin: 0;
  padding: 10px 14px;
  border: 1px solid rgba(217, 91, 54, 0.16);
  background: rgba(255, 251, 249, 0.98);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  pointer-events: none;
}

.source-note-label {
  display: inline-block;
  margin-bottom: 4px;
  color: var(--warn);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-note-overlay p {
  margin: 0;
  color: #7a3a28;
  font-size: 0.83rem;
  line-height: 1.45;
}

.source-note-overlay::after {
  content: "";
  position: absolute;
  right: 26px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: rgba(250, 236, 231, 0.94);
  border-right: 1px solid rgba(217, 91, 54, 0.16);
  border-bottom: 1px solid rgba(217, 91, 54, 0.16);
  transform: rotate(45deg);
}


.benchmark-section {
  padding: 34px;
  border-radius: var(--radius-lg);
  margin-bottom: 30px;
}

.section-heading.is-centered {
  text-align: center;
  margin-bottom: 18px;
}

.benchmark-shell {
  max-width: 860px;
  margin: 0 auto;
  overflow: hidden;
}

.benchmark-table td:first-child,
.benchmark-table th:first-child {
  font-weight: 700;
}

.upload-shell {
  width: 100%;
  min-height: min(72vh, 780px);
  padding: 24px;
  margin-bottom: 0;
  display: flex;
}

.upload-zone {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  border: 1.5px dashed rgba(24, 33, 47, 0.18);
  border-radius: 0;
  background: rgba(248, 250, 252, 0.96);
}

.upload-zone.is-dragging {
  border-color: var(--accent);
  background: rgba(223, 231, 239, 0.8);
}

.upload-zone.is-disabled {
  cursor: default;
  border-style: solid;
}

.upload-title {
  font-size: 1.3rem;
  font-weight: 700;
}

.upload-subtitle,
.error-text {
  color: var(--muted);
}

.error-text {
  margin-top: 12px;
  color: var(--warn);
}

.empty-state,
.loading-shell,
.fatal-error {
  padding: 40px;
  border-radius: 0;
}

@media (max-width: 1120px) {
  .topbar,
  .comparison-headline {
    flex-direction: column;
    align-items: stretch;
  }

  .comparison-grid {
    grid-template-columns: 1fr;
  }

}

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

  .topbar {
    border-radius: 0;
  }

  .nav {
    flex-wrap: wrap;
  }
}
