:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --paper: #fffdf8;
  --panel: #ffffff;
  --ink: #1f2528;
  --muted: #667075;
  --line: #d9d2c7;
  --green: #1d6b55;
  --green-dark: #124b3b;
  --blue: #245e8a;
  --amber: #a65f16;
  --red: #a43d33;
  --shadow: 0 16px 44px rgba(31, 37, 40, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #f0ece4;
}

.brand-block {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 14px;
}

.mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid #bfcfc9;
  border-radius: 8px;
  background: #dcebe5;
  color: var(--green-dark);
  font-weight: 800;
}

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

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.1rem;
  line-height: 1.2;
}

h2 {
  font-size: clamp(1.45rem, 2vw, 2.1rem);
  line-height: 1.1;
}

h3 {
  font-size: 0.98rem;
  line-height: 1.2;
}

.module-nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.ghost-button,
.secondary-button,
.primary-button,
.copy-button,
.file-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 12px;
  font-weight: 750;
  letter-spacing: 0;
}

.nav-item {
  width: 100%;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: #c9c2b8;
  background: var(--paper);
}

.project-tools {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.ghost-button,
.file-button {
  border-color: #c9c2b8;
  background: transparent;
  color: var(--ink);
  text-align: center;
}

.secondary-button {
  border-color: #b7c9cf;
  background: #e6f0f2;
  color: #173f4c;
}

.primary-button {
  border-color: var(--green-dark);
  background: var(--green);
  color: #ffffff;
}

.copy-button {
  min-height: 32px;
  padding: 6px 10px;
  border-color: #d2d5d2;
  background: #f4f6f3;
  color: var(--ink);
  font-size: 0.82rem;
}

.project-tools input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.main {
  min-width: 0;
  padding: 28px;
}

.site-landing {
  padding: 28px;
  border-bottom: 1px solid var(--line);
}

.landing-page {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 0.78fr);
  gap: 34px;
  align-items: center;
  min-height: calc(100vh - 180px);
  max-width: 1240px;
  margin: 0 auto 28px;
  padding: 18px 0 28px;
}

.landing-copy {
  display: grid;
  gap: 20px;
  align-content: center;
}

.landing-copy h1 {
  max-width: 820px;
  font-size: 3.15rem;
  line-height: 0.98;
  font-weight: 900;
}

.landing-lede {
  max-width: 740px;
  margin: 0;
  color: #3f4a4f;
  font-size: 1.08rem;
  line-height: 1.62;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.landing-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  text-decoration: none;
}

.landing-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 760px;
  margin: 4px 0 0;
}

.landing-facts div {
  border-top: 1px solid #c8d5d0;
  padding-top: 10px;
}

.landing-facts dt,
.landing-facts dd {
  margin: 0;
}

.landing-facts dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.landing-facts dd {
  margin-top: 4px;
  color: #243035;
  font-weight: 820;
}

.landing-facts a {
  color: var(--green-dark);
  overflow-wrap: anywhere;
}

.landing-preview {
  display: grid;
  gap: 10px;
  margin: 0;
}

.landing-preview img {
  width: 100%;
  max-height: 600px;
  object-fit: cover;
  object-position: top;
  border: 1px solid #cbd6d1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.landing-preview figcaption {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.45;
}

.landing-band {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  max-width: 1240px;
  margin: 0 auto 34px;
  padding: 24px 0 30px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.workflow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.workflow-grid article {
  display: grid;
  gap: 8px;
  border-left: 3px solid #b7c9cf;
  padding-left: 12px;
}

.workflow-grid p {
  margin: 0;
  color: #4f5b60;
  font-size: 0.9rem;
  line-height: 1.52;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 28px;
  max-width: 1240px;
}

.workspace-header > div:first-child {
  min-width: 0;
  flex: 1;
}

.project-name {
  width: 100%;
  max-width: 820px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: clamp(1.25rem, 2vw, 1.95rem);
  font-weight: 850;
  line-height: 1.1;
}

.project-name:focus {
  border-bottom-color: var(--green);
  outline: 0;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-strip span {
  border: 1px solid #cbd5d0;
  border-radius: 999px;
  padding: 7px 10px;
  background: #eef6f2;
  color: #24443b;
  font-size: 0.82rem;
  font-weight: 750;
}

.view {
  display: none;
  max-width: 1240px;
  margin: 0 auto;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(360px, 1.18fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.inline-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.72fr);
  gap: 12px;
}

label,
legend {
  display: grid;
  gap: 7px;
  color: #394044;
  font-size: 0.84rem;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfc8be;
  border-radius: 7px;
  background: #fffefb;
  color: var(--ink);
  padding: 10px 11px;
  font-weight: 520;
}

textarea {
  resize: vertical;
}

.source-capture {
  display: grid;
  gap: 12px;
  border: 1px solid #d6e2dd;
  border-radius: 8px;
  padding: 14px;
  background: #f8fcfa;
}

.source-capture-head,
.source-item-head,
.source-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.source-capture-head {
  align-items: start;
}

.source-list {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.source-item {
  display: grid;
  gap: 8px;
  border: 1px solid #dce4df;
  border-radius: 7px;
  padding: 10px;
  background: #ffffff;
  color: #293034;
}

.source-item strong,
.source-item span,
.source-item a {
  overflow-wrap: anywhere;
}

.source-item-head > div {
  display: grid;
  gap: 2px;
}

.source-item-head span,
.source-meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.source-item p {
  margin: 0;
}

.source-meta {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.source-meta span,
.source-meta a {
  border-radius: 999px;
  padding: 4px 7px;
  background: #edf4f2;
  color: var(--green-dark);
  text-decoration: none;
}

.mini-button {
  min-height: 32px;
  border: 1px solid #d2d5d2;
  border-radius: 7px;
  background: #f4f6f3;
  color: var(--ink);
  padding: 6px 9px;
  font-size: 0.78rem;
  font-weight: 800;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29, 107, 85, 0.14);
  outline: 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.output-panel {
  min-height: 560px;
  overflow: hidden;
}

.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf6;
}

.structured-output {
  display: grid;
  gap: 14px;
  padding: 18px;
  color: #293034;
  line-height: 1.52;
  white-space: pre-wrap;
}

.structured-output.empty {
  min-height: 260px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.structured-output table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  white-space: normal;
}

.structured-output th,
.structured-output td {
  vertical-align: top;
  border-bottom: 1px solid #e4ded5;
  padding: 10px;
  text-align: left;
  min-width: 120px;
  overflow-wrap: break-word;
}

.structured-output td:nth-child(5),
.structured-output td:nth-child(6) {
  overflow-wrap: anywhere;
}

.structured-output th {
  background: #f4f0e9;
  color: #2b3235;
  font-size: 0.82rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  border-radius: 999px;
  padding: 5px 8px;
  background: #edf4f2;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.callout {
  border-left: 4px solid var(--amber);
  padding: 12px 14px;
  background: #fff5e7;
}

.artifact-card {
  display: grid;
  gap: 8px;
  border: 1px solid #d6e2dd;
  border-radius: 8px;
  padding: 14px;
  background: #f8fcfa;
  white-space: normal;
}

.artifact-card p {
  margin: 0;
}

.risk {
  color: var(--red);
  font-weight: 800;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border: 0;
  padding: 0;
  margin: 0;
}

.segmented legend {
  width: 100%;
}

.segmented label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid #cfc8be;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fffefb;
}

.segmented input {
  width: auto;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  transform: translateY(18px);
  opacity: 0;
  border: 1px solid #b8ccc5;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f7fffb;
  color: #183b31;
  box-shadow: var(--shadow);
  font-weight: 760;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: relative;
    height: auto;
    padding: 16px;
  }

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

  .nav-item {
    text-align: center;
  }

  .project-tools {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 0;
  }

  .main {
    padding: 18px;
  }

  .site-landing {
    padding: 18px;
  }

  .landing-page {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 8px;
  }

  .landing-copy h1 {
    font-size: 2.35rem;
    line-height: 1.03;
  }

  .landing-preview img {
    max-height: 420px;
  }

  .landing-band {
    grid-template-columns: 1fr;
  }

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

  .workspace-header,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .output-panel {
    min-height: 420px;
  }
}

@media (max-width: 600px) {
  .inline-grid {
    grid-template-columns: 1fr;
  }

  .landing-copy h1 {
    font-size: 2rem;
  }

  .landing-facts,
  .workflow-grid {
    grid-template-columns: 1fr;
  }

  .landing-actions {
    display: grid;
  }

  .landing-link {
    width: 100%;
  }

  .module-nav,
  .project-tools {
    grid-template-columns: 1fr 1fr;
  }

  .nav-item,
  .ghost-button,
  .secondary-button,
  .primary-button,
  .file-button {
    min-height: 44px;
    padding: 9px 10px;
  }

  .section-heading .primary-button {
    width: 100%;
  }
}

.field-error {
  margin: 6px 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--red);
}

input.invalid,
textarea.invalid,
select.invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(164, 61, 51, 0.12);
}

.structured-output.output-error {
  border: 1px solid var(--red);
  background: #fdf6f4;
}

.error-page h3 {
  margin-top: 0;
  color: var(--red);
}

.error-page ul {
  margin: 10px 0;
  padding-left: 20px;
}

.error-page li {
  margin-bottom: 6px;
}
