:root {
  color-scheme: dark;
  --bg: #232627;
  --bg-deep: #151819;
  --surface: #1b1e1f;
  --surface-raised: #202425;
  --surface-soft: #292e2f;
  --surface-editor: #111516;
  --ink: #f2f6f6;
  --ink-soft: #c8d0d0;
  --muted: #909b9c;
  --teal-bright: #b9f8f6;
  --teal: #1fd9d4;
  --teal-dark: #05827d;
  --teal-deep: #045c59;
  --border: #424a4b;
  --border-soft: #343b3c;
  --border-teal: rgba(31, 217, 212, 0.48);
  --warning: #e6b84a;
  --danger: #e47e78;
  --shadow: rgba(0, 0, 0, 0.34);
  --focus: rgba(185, 248, 246, 0.22);
  font-family: "Segoe UI Variable", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 16px;
}

/*
 * Tagged table of contents
 * [TOC:foundation] Tokens, reset, document background, and base controls
 * [TOC:brand] App shell, header, logo, and typography
 * [TOC:workspace] Project loading, summary metrics, and status rail
 * [TOC:report] Report actions, notices, editor surface, and local-only note
 * [TOC:responsive] Motion preferences and responsive layout
 */

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg-deep);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% -8%, rgba(31, 217, 212, 0.075), transparent 30rem),
    linear-gradient(150deg, #272b2c 0%, var(--bg) 46%, #1b1e1f 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.12;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.025) 4px),
    repeating-linear-gradient(90deg, transparent 0 5px, rgba(0, 0, 0, 0.025) 6px);
  pointer-events: none;
}

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

button {
  min-height: 42px;
  border: 1px solid var(--border-teal);
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--teal-bright);
  background: rgba(15, 32, 32, 0.72);
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    box-shadow 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

button:not(.primary-button):not(:disabled):hover {
  border-color: var(--teal);
  color: #ffffff;
  background: rgba(5, 130, 125, 0.28);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

button:focus-visible,
.report-output:focus-visible {
  outline: 2px solid var(--teal-bright);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--focus);
}

button:disabled {
  border-color: var(--border-soft);
  color: #748081;
  background: #252a2b;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

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

h1 {
  margin-bottom: 14px;
  font-size: clamp(2.15rem, 4.5vw, 3.5rem);
  font-weight: 650;
  line-height: 1;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 0;
  color: var(--teal);
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

h3 {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 500;
}

code,
.report-output,
.export-note {
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
}

code {
  color: var(--teal-bright);
}

.app-shell {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  padding: 38px 0 32px;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 34px;
  min-height: 166px;
  padding: 10px 56px 32px;
}

.app-logo {
  width: 112px;
  height: 112px;
  flex: 0 0 auto;
  border-radius: 25px;
  box-shadow: 0 20px 38px rgba(0, 0, 0, 0.42), 0 0 28px rgba(31, 217, 212, 0.09);
}

.brand-copy p {
  max-width: 780px;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 1.06rem;
  line-height: 1.6;
}

.panel,
.status-panel {
  border: 1px solid var(--border);
  background: linear-gradient(140deg, rgba(27, 30, 31, 0.98), rgba(24, 28, 29, 0.96));
  box-shadow: 0 18px 48px var(--shadow), inset 0 1px rgba(255, 255, 255, 0.025);
}

.panel {
  border-radius: 16px;
}

.project-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(420px, 0.9fr);
  margin-bottom: 10px;
  overflow: hidden;
}

.load-project-region,
.summary-region {
  min-width: 0;
  padding: 26px 30px;
}

.summary-region {
  border-left: 1px solid var(--border);
  background: rgba(12, 16, 17, 0.16);
}

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 20px;
}

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

.section-heading p::before {
  content: "· ";
  color: var(--teal-dark);
}

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

.import-button {
  display: flex;
  align-items: center;
  gap: 15px;
  min-height: 96px;
  padding: 17px 20px;
  text-align: left;
}

.import-button-primary {
  background: linear-gradient(135deg, rgba(5, 130, 125, 0.31), rgba(15, 32, 32, 0.78));
}

.import-button svg {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  fill: rgba(31, 217, 212, 0.16);
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.import-button span,
.import-button strong,
.import-button small {
  display: block;
}

.import-button strong {
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 600;
}

.import-button small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.helper-text {
  margin: 14px 2px 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 28px;
}

.summary-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px 12px;
  min-width: 0;
  padding: 8px 0;
  border-bottom: 1px solid rgba(66, 74, 75, 0.48);
}

.summary-card:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.summary-value {
  grid-column: 2;
  grid-row: 1;
  color: var(--teal-bright);
  font-size: 1rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.summary-card-stacked-value {
  grid-template-columns: minmax(0, 1fr);
}

.summary-card-stacked-value .summary-value {
  grid-column: 1;
  grid-row: 2;
  margin-top: 1px;
  font-size: 0.82rem;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.summary-card-stacked-value .summary-detail {
  grid-row: 3;
}

.summary-detail {
  grid-column: 1 / -1;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

#project-summary[data-project-name=""] .summary-detail {
  display: none;
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 58px;
  margin-bottom: 10px;
  padding: 10px 28px;
  border-radius: 12px;
}

.status-indicator {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid var(--teal);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(31, 217, 212, 0.06);
}

body[data-app-status="loading"] .status-indicator,
body[data-app-status="exporting"] .status-indicator {
  border-top-color: transparent;
  animation: status-spin 800ms linear infinite;
}

body[data-app-status="ready"] .status-indicator {
  border-color: var(--teal-bright);
  background: var(--teal-dark);
}

body[data-app-status="error"] .status-indicator {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(228, 126, 120, 0.08);
}

.status-panel h2 {
  margin-bottom: 3px;
  font-size: 0.8rem;
}

.status-panel p {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.report-panel {
  padding: 24px 28px 18px;
}

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

.panel-header p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.panel-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.action-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.secondary-button,
.primary-button {
  min-width: 128px;
}

.primary-button:not(:disabled) {
  color: #051918;
  border-color: var(--teal);
  background-color: var(--teal);
  background-image: none;
  font-weight: 650;
}

.primary-button:not(:disabled):hover {
  color: #02100f;
  background-color: var(--teal-bright);
}

.portable-export-option {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.portable-export-option:has(input:disabled) {
  opacity: 0.55;
}

.export-note {
  width: min(100%, 620px);
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-teal);
  border-radius: 7px;
  color: var(--teal-bright);
  background: rgba(5, 92, 89, 0.16);
  font-size: 0.74rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.report-output {
  min-height: clamp(330px, 48vh, 620px);
  max-height: 66vh;
  margin: 0;
  overflow: auto;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #dce6e6;
  background:
    linear-gradient(90deg, rgba(31, 217, 212, 0.025), transparent 10rem),
    var(--surface-editor);
  box-shadow: inset 0 1px 12px rgba(0, 0, 0, 0.3);
  font-size: 0.82rem;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre-wrap;
  scrollbar-color: var(--teal-dark) var(--surface-editor);
}

.local-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.74rem;
}

.local-note span {
  display: inline-grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border: 1px solid var(--teal-dark);
  border-radius: 50%;
  color: var(--teal);
  font-family: Georgia, serif;
  font-weight: 700;
}

@keyframes status-spin {
  to {
    transform: rotate(360deg);
  }
}

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

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 28px, 1480px);
    padding-top: 24px;
  }

  .app-header {
    padding-inline: 24px;
  }

  .project-workspace {
    grid-template-columns: 1fr;
  }

  .summary-region {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .panel-header {
    flex-direction: column;
  }

  .panel-actions {
    width: 100%;
    align-items: stretch;
  }

  .action-row {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 18px, 1480px);
    padding-top: 14px;
  }

  .app-header {
    align-items: flex-start;
    gap: 18px;
    min-height: 0;
    padding: 12px 10px 24px;
  }

  .app-logo {
    width: 68px;
    height: 68px;
    border-radius: 16px;
  }

  h1 {
    margin-top: 4px;
    font-size: clamp(1.75rem, 9vw, 2.35rem);
  }

  .brand-copy p {
    font-size: 0.88rem;
  }

  .wide-copy-break {
    display: none;
  }

  .load-project-region,
  .summary-region,
  .report-panel {
    padding: 20px 18px;
  }

  .hero-actions,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-card:nth-last-child(2) {
    border-bottom: 1px solid rgba(66, 74, 75, 0.48);
  }

  .status-panel {
    padding-inline: 18px;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .secondary-button,
  .primary-button {
    width: 100%;
  }

  .report-output {
    min-height: 310px;
    max-height: 56vh;
    padding: 18px;
    font-size: 0.76rem;
  }
}
