:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5b6472;
  --line: #d9e0e8;
  --soft: #f6f8fb;
  --paper: #ffffff;
  --teal: #087a7a;
  --teal-dark: #065f5f;
  --coral: #d95d39;
  --coral-dark: #b94729;
  --blue: #3159a8;
  --green: #287a45;
  --amber: #bd7a16;
  --shadow: 0 12px 32px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--teal);
  font-weight: 800;
}

.brand-title {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a,
.nav button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-decoration: none;
  font-size: 0.92rem;
}

.nav a:hover,
.nav button:hover,
.nav .active {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.82fr);
  gap: 22px;
  align-items: start;
  max-width: 100%;
}

.panel,
.finding-card,
.case-row,
.plan-block {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.panel + .panel {
  margin-top: 18px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--coral);
}

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

h1 {
  max-width: 720px;
  margin-bottom: 12px;
  font-size: clamp(2.2rem, 6vw, 4.6rem);
  line-height: 0.96;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1.06;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.lead {
  max-width: 680px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.segmented,
.doc-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.segment-btn,
.doc-btn,
.small-btn,
.primary-btn,
.secondary-btn,
.danger-btn {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.segment-btn,
.doc-btn {
  padding: 0 14px;
  white-space: normal;
}

.segment-btn.active,
.doc-btn.active {
  border-color: var(--teal);
  background: #e8f6f5;
  color: var(--teal-dark);
}

.field {
  margin-top: 18px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.input,
.select {
  min-height: 46px;
  padding: 0 12px;
}

.textarea {
  min-height: 260px;
  padding: 14px;
  resize: vertical;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
}

.textarea:focus,
.input:focus,
.select:focus {
  outline: 3px solid rgba(8, 122, 122, 0.16);
  border-color: var(--teal);
}

.primary-btn,
.secondary-btn,
.danger-btn,
.small-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.primary-btn {
  padding: 0 18px;
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

.primary-btn:hover {
  background: var(--teal-dark);
}

.secondary-btn {
  padding: 0 16px;
}

.secondary-btn:hover,
.small-btn:hover {
  border-color: var(--ink);
}

.danger-btn {
  padding: 0 14px;
  color: var(--coral-dark);
}

.small-btn {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.85rem;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.fineprint {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.metric {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.metric-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 8px;
  font-size: 1.65rem;
  font-weight: 850;
}

.findings-list {
  display: grid;
  gap: 12px;
}

.finding-card {
  padding: 16px;
  box-shadow: none;
}

.finding-card.high {
  border-left: 5px solid var(--coral);
}

.finding-card.medium {
  border-left: 5px solid var(--amber);
}

.finding-card.deadline {
  border-left: 5px solid var(--blue);
}

.finding-card.low {
  border-left: 5px solid var(--line);
}

.badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge.high {
  color: #fff;
  background: var(--coral);
}

.badge.medium {
  color: #fff;
  background: var(--amber);
}

.badge.deadline {
  color: #fff;
  background: var(--blue);
}

.badge.low,
.badge.neutral {
  color: var(--muted);
  background: #eef2f6;
}

.letter-box {
  width: 100%;
  min-height: 470px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--ink);
  background: #fff;
  resize: vertical;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
}

.rail {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 18px;
}

.visual-panel {
  padding: 0;
  overflow: hidden;
}

.visual-header {
  padding: 18px 18px 0;
}

.paperwork-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
}

.check-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.check-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
}

.case-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.case-row {
  width: 100%;
  padding: 13px;
  box-shadow: none;
  text-align: left;
}

.case-row:hover {
  border-color: var(--teal);
}

.case-title {
  display: block;
  margin-bottom: 4px;
  font-weight: 800;
}

.case-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
  background: #fff;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  border-radius: 8px;
  padding: 12px 14px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
}

.source-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.source-links a {
  color: var(--teal-dark);
  font-weight: 700;
}

.plan-page {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

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

.plan-block {
  padding: 20px;
  box-shadow: none;
}

.plan-block ul,
.plan-block ol {
  padding-left: 22px;
  line-height: 1.55;
}

.script-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  line-height: 1.55;
}

.script-card strong {
  display: block;
  margin-bottom: 6px;
}

.hidden {
  display: none !important;
}

@media (max-width: 920px) {
  .workspace-grid,
  .plan-grid {
    grid-template-columns: 1fr;
  }

  .workspace-grid > section,
  .rail {
    min-width: 0;
  }

  .rail {
    position: static;
  }

  h1 {
    font-size: clamp(2rem, 10vw, 2.65rem);
    line-height: 1.04;
  }

  .eyebrow {
    font-size: 0.7rem;
  }
}

@media (max-width: 640px) {
  .topbar-inner,
  .shell,
  .plan-page {
    width: calc(100% - 22px);
    max-width: 1180px;
  }

  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    justify-content: flex-start;
  }

  .panel {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding: 18px;
  }

  .split {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  h1,
  .lead,
  .eyebrow {
    max-width: 100%;
  }

  .lead {
    font-size: 0.98rem;
  }

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

  .textarea {
    min-height: 230px;
  }

  .segmented,
  .doc-buttons {
    display: grid;
    width: 100%;
  }

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

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

  .segment-btn {
    min-width: 0;
  }

  .doc-btn {
    min-width: 0;
  }
}

@media print {
  .topbar,
  .rail,
  .actions,
  .no-print {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .shell {
    width: 100%;
    padding: 0;
  }

  .panel {
    box-shadow: none;
    border: 0;
  }
}
