:root {
  color-scheme: light;
  --ink: #10252a;
  --muted: #5a6b70;
  --accent: #0f6670;
  --accent-dark: #0f4c5c;
  --accent-soft: #e4f1ef;
  --orange: #ce6630;
  --paper: #fffefb;
  --warm: #f5f0e8;
  --line: #d9e0dd;
  --white: #ffffff;
  --danger: #a73b32;
  --shadow: 0 20px 55px rgba(15, 76, 92, 0.11);
  --radius: 22px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

:focus-visible {
  outline: 3px solid rgba(206, 102, 48, 0.6);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  padding: 0.65rem 1rem;
}

.skip-link:focus { top: 1rem; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 0.75rem clamp(1rem, 4vw, 4rem);
  border-bottom: 1px solid rgba(217, 224, 221, 0.9);
  background: rgba(255, 254, 251, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: var(--accent-dark);
  color: white;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 700;
}

.brand strong, .brand small { display: block; line-height: 1.05; }
.brand small { margin-top: 0.25rem; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.07em; text-transform: uppercase; }

.view-tabs { display: flex; gap: 0.35rem; }

.view-tab {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.view-tab:hover { background: var(--accent-soft); color: var(--accent-dark); }
.view-tab.is-active { background: var(--ink); color: white; }

.count-badge {
  display: inline-grid;
  min-width: 1.5rem;
  height: 1.5rem;
  margin-left: 0.25rem;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.75rem;
}

main { overflow: hidden; }

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: clamp(2rem, 6vw, 6rem);
  align-items: end;
  padding: clamp(3.8rem, 9vw, 8.5rem) max(1rem, calc((100vw - 1280px) / 2));
  background:
    radial-gradient(circle at 83% 18%, rgba(206, 102, 48, 0.18) 0 7%, transparent 7.2%),
    linear-gradient(135deg, #0b4653 0%, #0f6670 62%, #347c78 100%);
  color: white;
}

.hero::after {
  content: "";
  position: absolute;
  right: -7rem;
  bottom: -10rem;
  width: 31rem;
  height: 31rem;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 50%;
  box-shadow: 0 0 0 5rem rgba(255, 255, 255, 0.035), 0 0 0 10rem rgba(255, 255, 255, 0.02);
  pointer-events: none;
}

.hero-copy, .privacy-card { position: relative; z-index: 1; }

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--orange);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hero .eyebrow { color: #ffd1b5; }

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

h1, h2 {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.035em;
}

h1 {
  max-width: 850px;
  margin-bottom: 1.4rem;
  font-size: clamp(3rem, 7vw, 6.6rem);
  font-weight: 500;
  line-height: 0.94;
}

.hero-summary {
  max-width: 760px;
  margin-bottom: 2rem;
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(1rem, 1.6vw, 1.2rem);
}

.hero-meta { display: flex; flex-wrap: wrap; gap: 0.65rem 1.8rem; color: rgba(255, 255, 255, 0.75); }
.hero-meta strong { color: white; font-size: 1.2rem; }

.privacy-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.11);
  padding: 1.25rem;
  backdrop-filter: blur(12px);
}

.privacy-card p { margin: 0.25rem 0 0; color: rgba(255, 255, 255, 0.76); font-size: 0.9rem; }
.privacy-icon { display: grid; width: 2.15rem; height: 2.15rem; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #dff4e9; color: #176554; font-weight: 900; }

.app-view, .clinical-note {
  width: min(1280px, calc(100% - 2rem));
  margin-inline: auto;
}

.app-view { padding: clamp(3rem, 7vw, 6rem) 0; }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.section-heading h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.25rem); font-weight: 500; line-height: 1; }
.result-count { margin: 0; color: var(--muted); font-size: 0.9rem; }

.filter-panel {
  display: grid;
  grid-template-columns: minmax(280px, 1.7fr) minmax(190px, 1fr) minmax(130px, 0.5fr) auto;
  gap: 0.8rem;
  align-items: end;
  margin-bottom: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 1rem;
  box-shadow: 0 8px 28px rgba(15, 76, 92, 0.05);
}

.filter-panel label, .editor-field { display: grid; gap: 0.42rem; }
.filter-panel label > span, .editor-field > span { color: var(--muted); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  padding: 0.74rem 0.85rem;
}

input:hover, select:hover, textarea:hover { border-color: #9db6b4; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid rgba(15, 102, 112, 0.12); }
textarea { line-height: 1.45; resize: vertical; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(310px, 0.72fr) minmax(0, 1.28fr);
  gap: 1.25rem;
  align-items: start;
}

.protocol-list {
  display: grid;
  gap: 0.65rem;
  max-height: 74vh;
  overflow: auto;
  padding-right: 0.25rem;
  scrollbar-color: #a9bfbd transparent;
}

.protocol-card {
  display: grid;
  gap: 0.32rem;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 254, 251, 0.78);
  color: var(--ink);
  padding: 1rem;
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.protocol-card:hover { transform: translateY(-1px); border-color: #94b8b5; background: white; }
.protocol-card.is-selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.protocol-card strong { margin-top: 0.25rem; font-size: 1rem; }
.protocol-card > span:not(.protocol-card-topline) { color: var(--accent-dark); font-size: 0.8rem; font-weight: 700; }
.protocol-card small { display: -webkit-box; overflow: hidden; color: var(--muted); line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.protocol-card-topline { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }

.level-chip, .detail-kicker span {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: #e7f2f5;
  color: var(--accent-dark);
  padding: 0.24rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.measurement { color: var(--muted); font-size: 0.7rem; }

.detail-panel {
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 110px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: clamp(1.25rem, 3vw, 2.25rem);
  box-shadow: var(--shadow);
  scrollbar-color: #a9bfbd transparent;
}

.detail-kicker { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.detail-kicker span:last-child { background: #f5eee1; color: #7a4d25; }
.detail-panel h2 { margin-bottom: 0.45rem; font-size: clamp(2rem, 4vw, 3.3rem); font-weight: 500; line-height: 1; }
.detail-meta { color: var(--muted); font-size: 0.85rem; }
.goal-statement { margin: 1.4rem 0; border-left: 4px solid var(--orange); padding-left: 1rem; font-family: Georgia, "Times New Roman", serif; font-size: 1.2rem; line-height: 1.45; }

.detail-actions { display: flex; flex-wrap: wrap; gap: 0.65rem; margin: 1.5rem 0 1.8rem; }

.button {
  border: 1px solid var(--accent-dark);
  border-radius: 999px;
  background: var(--accent-dark);
  color: white;
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  font-weight: 800;
}

.button:hover { background: var(--ink); border-color: var(--ink); }
.button-secondary { background: white; color: var(--accent-dark); }
.button-secondary:hover { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent); }

.text-button { border: 0; background: transparent; color: var(--accent-dark); padding: 0.6rem; font-size: 0.84rem; font-weight: 800; text-decoration: underline; text-underline-offset: 0.2em; }
.text-button:hover { color: var(--orange); }

.detail-section { padding: 1.25rem 0; border-top: 1px solid var(--line); }
.detail-section h3 { margin-bottom: 0.45rem; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }
.detail-section p { margin: 0; color: #344d52; }
.detail-callout { margin: 0.5rem 0; border: 0; border-radius: 16px; background: var(--accent-soft); padding: 1rem; }
.section-label-row { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.section-label-row span { color: var(--muted); font-size: 0.75rem; }

.target-list { display: grid; gap: 0.75rem; margin: 0; padding-left: 1.45rem; }
.target-list li { padding-left: 0.25rem; }
.target-list details { margin-top: 0.35rem; color: var(--muted); font-size: 0.82rem; }
.target-list summary { color: var(--accent-dark); cursor: pointer; font-weight: 700; }
.target-list details p { margin: 0.45rem 0; }

.detail-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; margin: 1.25rem 0; }
.detail-facts > div { display: grid; gap: 0.2rem; border-radius: 14px; background: #f5f4ef; padding: 0.9rem; }
.detail-facts span { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; }
.detail-facts strong { font-size: 0.88rem; }
.detail-notice { margin: 1.4rem 0 0; border-top: 1px solid var(--line); padding-top: 1rem; color: var(--muted); font-size: 0.78rem; }

.empty-state, .copies-empty, .detail-empty {
  display: grid;
  place-items: center;
  min-height: 300px;
  border: 1px dashed #aebfbc;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
  padding: 2rem;
  text-align: center;
}

.empty-state > span { color: var(--accent); font-size: 3rem; }
.empty-state h3, .copies-empty h3 { margin: 0.5rem 0; }
.empty-state p, .copies-empty p { max-width: 520px; color: var(--muted); }

.copies-grid { display: grid; grid-template-columns: minmax(250px, 0.45fr) minmax(0, 1.55fr); gap: 1.25rem; align-items: start; }
.copy-list { display: grid; gap: 0.65rem; position: sticky; top: 90px; max-height: calc(100vh - 110px); overflow: auto; }
.copy-list-item { display: grid; gap: 0.3rem; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,0.7); color: var(--ink); padding: 0.9rem; text-align: left; }
.copy-list-item.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.copy-list-item span, .copy-list-item small { color: var(--muted); font-size: 0.76rem; }
.copy-editor { position: relative; top: auto; max-height: none; }
.copy-editor .detail-kicker { align-items: center; }
.save-state { color: #176554 !important; background: #e4f4eb !important; }
.editor-title-field textarea { border: 0; border-radius: 0; padding: 0; color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1; resize: none; }
.editor-title-field textarea:focus { outline: 0; box-shadow: inset 0 -2px 0 var(--accent); }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.editor-field { align-content: start; }
.editor-field.is-wide { grid-column: 1 / -1; }
.editor-field small { margin-top: -0.25rem; color: var(--muted); font-size: 0.75rem; }
.danger-link { margin-left: auto; color: var(--danger); }

.empty-illustration { display: grid; width: 5rem; height: 6.2rem; place-items: center; border: 2px solid var(--accent); border-radius: 10px; background: var(--paper); color: var(--accent); font-size: 2rem; box-shadow: 10px 10px 0 var(--accent-soft); }

.clinical-note {
  margin-bottom: clamp(3rem, 7vw, 6rem);
  border-radius: var(--radius);
  background: var(--ink);
  color: white;
  padding: clamp(1.5rem, 5vw, 4rem);
}

.clinical-note h2 { max-width: 850px; font-size: clamp(2rem, 4vw, 3.8rem); font-weight: 500; line-height: 1.03; }
.clinical-note p:not(.eyebrow) { max-width: 900px; color: rgba(255, 255, 255, 0.75); }

footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 1.5rem max(1rem, calc((100vw - 1280px) / 2));
  color: var(--muted);
  font-size: 0.82rem;
}

footer p { margin: 0; }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  max-width: min(390px, calc(100vw - 2rem));
  border-radius: 14px;
  background: var(--ink);
  color: white;
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  font-size: 0.86rem;
}

.toast[data-tone="error"] { background: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .privacy-card { max-width: 520px; }
  .filter-panel { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .content-grid, .copies-grid { grid-template-columns: 1fr; }
  .protocol-list, .copy-list { position: static; max-height: 50vh; }
  .detail-panel { position: static; max-height: none; }
}

@media (max-width: 620px) {
  .site-header { align-items: flex-start; gap: 0.65rem; }
  .brand small { display: none; }
  .view-tabs { justify-content: flex-end; }
  .view-tab { padding: 0.55rem 0.65rem; font-size: 0.76rem; }
  .hero { padding-inline: 1rem; }
  .hero-meta { display: grid; grid-template-columns: 1fr 1fr; }
  .section-heading { display: grid; gap: 0.8rem; }
  .filter-panel { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .detail-facts, .editor-grid { grid-template-columns: 1fr; }
  .editor-field.is-wide { grid-column: auto; }
  footer { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@media print {
  @page { size: letter; margin: 0.6in; }
  body { background: white; color: black; font-size: 10.5pt; }
  .site-header, .hero, .section-heading, .filter-panel, .protocol-list, .copy-list, .clinical-note, footer, .screen-only, .toast { display: none !important; }
  .app-view { width: 100%; padding: 0; }
  .content-grid, .copies-grid { display: block; }
  .detail-panel { position: static; max-height: none; overflow: visible; border: 0; border-radius: 0; padding: 0; box-shadow: none; }
  .detail-panel h2, .editor-title-field textarea { font-size: 24pt; }
  .detail-section { break-inside: avoid; }
  .target-list li { break-inside: avoid; }
  .target-list details > summary { display: none; }
  .target-list details:not([open]) > :not(summary) { display: block !important; }
  .editor-grid { display: block; }
  .editor-field { margin-bottom: 0.22in; break-inside: avoid; }
  .editor-field textarea, .editor-title-field textarea { overflow: visible; border: 0; padding: 0; resize: none; }
  .editor-field > span { color: black; }
  .detail-notice { font-size: 8pt; }
}
