:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #5f6f6b;
  --line: #d8e1dd;
  --panel: #ffffff;
  --canvas: #eef3ef;
  --field: #f8faf8;
  --accent: #0f6d5d;
  --accent-strong: #0a4d43;
  --gold: #c88016;
  --blue: #2e7da0;
  --danger: #a33a2d;
  --shadow: 0 16px 50px rgba(20, 38, 34, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(15, 109, 93, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 109, 93, 0.08) 1px, transparent 1px),
    var(--canvas);
  background-size: 32px 32px;
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
pre:focus-visible {
  outline: 3px solid rgba(46, 125, 160, 0.35);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 43vw);
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 35, 31, 0.18);
}

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

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

h1 {
  font-size: clamp(1.45rem, 2.6vw, 2.3rem);
  line-height: 1.05;
}

h2 {
  font-size: 1rem;
}

p {
  margin: 0;
  color: var(--muted);
}

.topbar-actions,
.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.input-grid {
  display: grid;
  gap: 16px;
}

.panel,
.packet-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(185, 201, 195, 0.82);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-heading p {
  margin-top: 3px;
  font-size: 0.9rem;
}

.step-marker {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  height: 28px;
  border-radius: 8px;
  background: #10231f;
  color: #fff;
  font-weight: 800;
}

.field-grid,
.evidence-composer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.fact-stack,
.questionnaire-editor {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #33423f;
  font-size: 0.82rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
}

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

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button:hover {
  border-color: #9cb3ab;
}

.evidence-composer .primary-button {
  align-self: end;
}

.file-picker {
  color: var(--muted);
}

.evidence-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
  margin-top: 14px;
}

.evidence-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  border: 1px solid #c8d6d1;
  border-radius: 8px;
  background: #f4f8f6;
  padding: 7px 8px 7px 10px;
  color: #263633;
  font-size: 0.84rem;
}

.evidence-chip span {
  overflow-wrap: anywhere;
}

.evidence-chip button,
.icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  min-height: 30px;
  border: 1px solid #d6c1bd;
  background: #fff8f6;
  color: var(--danger);
}

.answer-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(170px, 0.85fr) minmax(220px, 1.4fr) minmax(160px, 0.75fr) 34px;
  gap: 10px;
  align-items: end;
  margin: 0;
  border: 1px solid #dce5e1;
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}

.preview-rail {
  position: sticky;
  top: 20px;
  display: grid;
  align-self: start;
  gap: 16px;
  max-height: calc(100vh - 40px);
}

.packet-card {
  padding: 16px;
}

.readiness {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.readiness-score {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.readiness-score strong {
  font-size: 2.4rem;
  line-height: 0.95;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: #dce7e2;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--accent), var(--blue));
  transition: width 180ms ease-out;
}

.readiness-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.readiness-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #edf2ef;
  padding: 5px 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.readiness-list b {
  color: var(--ink);
}

.preview-card {
  min-height: 0;
}

.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.packet-preview {
  max-height: calc(100vh - 320px);
  min-height: 420px;
  margin: 0;
  overflow: auto;
  border: 1px solid #d7e1dd;
  border-radius: 8px;
  background: #101b19;
  color: #e6f3ee;
  padding: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.84rem;
}

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

  .preview-rail {
    position: static;
    max-height: none;
  }

  .packet-preview {
    max-height: 560px;
  }
}

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

  .topbar,
  .readiness-score {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .export-actions {
    width: 100%;
  }

  .topbar-actions button,
  .export-actions button {
    flex: 1;
  }

  .field-grid,
  .evidence-composer,
  .answer-row {
    grid-template-columns: 1fr;
  }

  .answer-row .icon-button {
    width: 100%;
  }
}
