:root {
  --bg:       #efe6d2;
  --bg2:      #e4d7bd;
  --surface:  rgba(255, 251, 242, 0.82);
  --surface-strong: #fbf6ea;
  --border:   #c7b998;
  --line:     rgba(91, 74, 38, 0.14);
  --accent:   #b85a2e;
  --accent2:  #1d6b67;
  --accent3:  #3d4f7c;
  --text:     #231b13;
  --muted:    #6a5b46;
  --red:      #b43f36;
  --green:    #2f7a4c;
  --shadow:   0 18px 40px rgba(63, 42, 17, 0.10);
  --mono:     "Consolas", "Lucida Console", "Courier New", monospace;
  --ui:       "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
  --serif:    "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 8% -5%, rgba(29,107,103,0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(184,90,46,0.10), transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg2));
  color: var(--text);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.6;
  position: relative;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(circle at 50% 20%, black 35%, transparent 95%);
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.65), rgba(255,255,255,0.35)),
    var(--surface);
  border-bottom: 1px solid rgba(91, 74, 38, 0.16);
  padding: 1.35rem 2rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}
header .logo {
  font-size: 1rem;
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(184,90,46,0.18), rgba(29,107,103,0.16));
  border: 1px solid rgba(184,90,46,0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}
header h1 {
  font-family: var(--ui);
  letter-spacing: 0.02em;
  font-size: 1.45rem;
  font-weight: 800;
  margin-bottom: 0.05rem;
}
header p  {
  color: var(--muted);
  font-family: var(--ui);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

nav {
  background: transparent;
  border-bottom: 1px solid rgba(91, 74, 38, 0.10);
  padding: 0.75rem 2rem 0.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
nav button {
  background: rgba(255,255,255,0.42);
  border: 1px solid rgba(91, 74, 38, 0.12);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.55rem 0.95rem;
  transition: transform 0.16s ease, color 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.75);
}
nav button:hover  {
  color: var(--text);
  transform: translateY(-1px);
  border-color: rgba(29,107,103,0.24);
}
nav button.active {
  color: #fff;
  border-color: rgba(29,107,103,0.42);
  background: linear-gradient(180deg, #2b867f, #1f6f69);
  box-shadow: 0 8px 18px rgba(29,107,103,0.20);
}

main { max-width: 1080px; margin: 0 auto; padding: 1.8rem 2rem 2.5rem; }
section { display: none; }
section.active {
  display: block;
  animation: fadeLift 220ms ease-out;
}

h2 {
  font-family: var(--ui);
  font-size: 1.28rem;
  margin-bottom: 0.25rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.section-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.1rem;
  max-width: 72ch;
}
h3 {
  font-family: var(--ui);
  font-size: 0.98rem;
  margin: 1.35rem 0 0.55rem;
  color: var(--accent2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.70), rgba(255,255,255,0.45)),
    var(--surface);
  border: 1px solid rgba(91, 74, 38, 0.14);
  border-radius: 16px;
  padding: 1.2rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, rgba(184,90,46,0.75), rgba(29,107,103,0.75), rgba(61,79,124,0.55));
  opacity: 0.35;
}

label {
  display: block;
  font-family: var(--ui);
  font-size: 0.77rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
}

input, select {
  background: rgba(255, 255, 255, 0.70);
  border: 1px solid rgba(91, 74, 38, 0.18);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.55rem 0.75rem;
  width: 100%;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85);
}
input:focus, select:focus {
  border-color: rgba(29,107,103,0.45);
  box-shadow: 0 0 0 3px rgba(29,107,103,0.12), inset 0 1px 0 rgba(255,255,255,0.85);
  outline: none;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

button.primary {
  background: linear-gradient(180deg, #cf6b3c, #b85a2e);
  border: 1px solid rgba(120, 48, 21, 0.28);
  border-radius: 999px;
  color: #fff8f0;
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.62rem 1.15rem;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
  box-shadow: 0 10px 18px rgba(184,90,46,0.22), inset 0 1px 0 rgba(255,255,255,0.3);
}
button.primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(184,90,46,0.28), inset 0 1px 0 rgba(255,255,255,0.3);
}

button.secondary, a.secondary {
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(91,74,38,0.14);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.5rem 0.9rem;
  transition: all 0.15s;
  margin-left: 0.5rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}
button.secondary:hover, a.secondary:hover {
  border-color: rgba(29,107,103,0.3);
  color: var(--accent2);
  background: rgba(255,255,255,0.65);
}
a.secondary {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Harp-type toggle ── */
.type-toggle { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.type-btn {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(91,74,38,0.14);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.84rem;
  font-weight: 700;
  padding: 0.45rem 0.9rem;
  transition: all 0.15s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}
.type-btn.active {
  border-color: rgba(184,90,46,0.25);
  color: #fff;
  background: linear-gradient(180deg, #c86a3c, #b85a2e);
  box-shadow: 0 8px 15px rgba(184,90,46,0.2);
}

/* ── Recommendation card ── */
.rec-card {
  background: linear-gradient(180deg, rgba(47,122,76,0.06), rgba(47,122,76,0.03));
  border: 1px solid rgba(47,122,76,0.20);
  border-radius: 14px;
  padding: 1.1rem 1.4rem;
  margin-bottom: 1rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.rec-card .rec-label { font-size: 0.75rem; color: var(--green); text-transform: uppercase;
                       letter-spacing: 0.06em; font-weight: 700; margin-bottom: 0.25rem; }
.rec-card .rec-name  { font-size: 1.15rem; font-weight: 700; color: var(--text); margin-bottom: 0.3rem; }
.rec-card .rec-gauge { font-family: var(--mono); color: var(--green); font-size: 1.6rem;
                       font-weight: 700; line-height: 1; margin-bottom: 0.3rem; }
.rec-card .rec-reason{ color: var(--muted); font-size: 0.88rem; }

.wound-card {
  background: linear-gradient(180deg, rgba(184,90,46,0.06), rgba(184,90,46,0.03));
  border: 1px solid rgba(184,90,46,0.18);
  border-radius: 14px;
  padding: 1.1rem 1.4rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Comparison table ── */
.chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.chart-table th {
  background: rgba(61,79,124,0.05);
  border-bottom: 1px solid rgba(91,74,38,0.16);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  text-align: left;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chart-table td {
  border-bottom: 1px solid rgba(91,74,38,0.10);
  padding: 0.5rem 0.75rem;
  vertical-align: middle;
}
.chart-table tr:last-child td { border-bottom: none; }
.chart-table tr.rec-row td { background: rgba(47,122,76,0.05); }
.chart-table tr:hover td { background: rgba(61,79,124,0.03); }

.note-c  { color: var(--red);   font-weight: 700; }
.note-f  { color: var(--muted); font-weight: 700; }
.note-other { color: var(--text); }

.gauge-pill {
  background: rgba(47,122,76,0.08);
  border: 1px solid rgba(47,122,76,0.18);
  border-radius: 999px;
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.14rem 0.55rem;
  white-space: nowrap;
}

.snapped-pill {
  background: rgba(29,107,103,0.08);
  border: 1px solid rgba(29,107,103,0.16);
  border-radius: 999px;
  color: var(--accent2);
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
}

.ok   { color: var(--green); }
.warn { color: var(--accent); }
.bad  { color: var(--red); }

.star { color: var(--green); font-size: 0.9rem; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-family: var(--ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid rgba(91,74,38,0.12);
  background: rgba(255,255,255,0.55);
  color: var(--text);
}
.badge-calc      { background: rgba(29,107,103,0.10); color: var(--accent2); }
.badge-verified  { background: rgba(47,122,76,0.10); color: var(--green); border-color: rgba(47,122,76,0.16); }
.badge-missing   { background: rgba(180,63,54,0.10); color: var(--red); }
.badge-official {
  background: rgba(29,107,103,0.10);
  color: var(--accent2);
  border-color: rgba(29,107,103,0.16);
}
.badge-recreated {
  background: rgba(184,90,46,0.08);
  color: var(--accent);
  border-color: rgba(184,90,46,0.14);
}
.badge-community {
  background: rgba(47,122,76,0.10);
  color: var(--green);
  border-color: rgba(47,122,76,0.16);
}
.badge-review {
  background: rgba(184,90,46,0.08);
  color: var(--accent);
  border-color: rgba(184,90,46,0.14);
}

.banner {
  border-radius: 12px;
  margin-bottom: 1.25rem;
  padding: 0.85rem 1.25rem;
  font-size: 0.9rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55);
}
.banner-warn    { background: rgba(184,90,46,0.08);  border: 1px solid rgba(184,90,46,0.18); }
.banner-info    { background: rgba(29,107,103,0.08); border: 1px solid rgba(29,107,103,0.16); }
.banner-success { background: rgba(47,122,76,0.08);  border: 1px solid rgba(47,122,76,0.16); }

.formula {
  background: rgba(255,255,255,0.52);
  border: 1px dashed rgba(91,74,38,0.18);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.9rem;
  margin: 1rem 0;
  padding: 0.75rem 1.25rem;
}

code {
  background: rgba(61,79,124,0.07);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 0.1em 0.35em;
}

footer {
  border-top: 1px solid rgba(91,74,38,0.10);
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 3rem;
  padding: 1.5rem 2rem 2rem;
  text-align: center;
}

#sf-result { margin-top: 1.5rem; }

.divider {
  border: none;
  border-top: 1px solid rgba(91,74,38,0.10);
  margin: 1.5rem 0;
}

.tension-hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }

/* ── Profiler ── */
.lock-banner {
  background: rgba(29,107,103,0.08);
  border: 1px solid rgba(29,107,103,0.16);
  border-radius: 12px;
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.profile-table input[type=number] {
  width: 90px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}
.profile-table input[type=text] {
  width: 58px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}
.t-ok   { color: var(--green); font-weight: 600; }
.t-lo   { color: var(--accent2); font-weight: 600; }
.t-hi   { color: var(--accent); font-weight: 600; }
.t-wound{ color: var(--red); font-weight: 600; }
.t-none { color: var(--muted); }
.mini-note { color: var(--muted); font-size: 0.83rem; }
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.step-card {
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(91,74,38,0.10);
  border-radius: 12px;
  padding: 0.85rem;
}
.step-num {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: rgba(29,107,103,0.10);
  color: var(--accent2);
  font-family: var(--ui);
  font-weight: 700;
  font-size: 0.75rem;
  margin-bottom: 0.35rem;
}
.step-card h4 {
  font-family: var(--ui);
  font-size: 0.9rem;
  margin: 0 0 0.25rem;
  color: var(--text);
}
.checkline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.checkline input[type=checkbox] {
  width: auto;
  margin: 0;
}
.confidence-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.16rem 0.5rem;
  font-family: var(--ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.conf-high { background: rgba(47,122,76,0.10); color: var(--green); border-color: rgba(47,122,76,0.18); }
.conf-med  { background: rgba(29,107,103,0.10); color: var(--accent2); border-color: rgba(29,107,103,0.18); }
.conf-low  { background: rgba(184,90,46,0.10); color: var(--accent); border-color: rgba(184,90,46,0.18); }
.warning-list {
  margin: 0.6rem 0 0 1.15rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.7;
}
.order-block {
  background: rgba(255,255,255,0.48);
  border: 1px dashed rgba(91,74,38,0.18);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin-top: 0.75rem;
}
.order-block pre {
  margin: 0.45rem 0 0;
  white-space: pre-wrap;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.45;
}
.copy-btn {
  margin-left: auto;
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(91,74,38,0.14);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.32rem 0.65rem;
}
.copy-btn:hover { color: var(--accent2); border-color: rgba(29,107,103,0.22); }
.supplier-links {
  margin-top: 0.75rem;
  background: rgba(255,255,255,0.46);
  border: 1px solid rgba(91,74,38,0.10);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
}
.supplier-links ul {
  margin: 0.45rem 0 0 1.15rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.8;
}
.supplier-links h4 {
  margin: 0.65rem 0 0.2rem;
  font-family: var(--ui);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
}
.supplier-links .warn-box {
  margin-top: 0.7rem;
  background: rgba(184,90,46,0.06);
  border: 1px solid rgba(184,90,46,0.16);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  margin-top: 0.8rem;
}
.info-tile {
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(91,74,38,0.10);
  border-radius: 12px;
  padding: 0.8rem;
}
.info-tile h4 {
  margin: 0 0 0.35rem;
  font-family: var(--ui);
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
}
.info-tile p, .info-tile li {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}
.info-tile ul {
  margin: 0.25rem 0 0 1rem;
}
.lib-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.8rem;
  margin-top: 0.8rem;
}
.lib-item {
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(91,74,38,0.10);
  border-radius: 12px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.lib-item h4 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}
.lib-meta {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}
.lib-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.lib-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.15rem;
}
.lib-actions a, .lib-actions button {
  font-size: 0.78rem;
}
.library-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-top: 0.8rem;
}
.library-summary .stat {
  background: rgba(255,255,255,0.43);
  border: 1px solid rgba(91,74,38,0.10);
  border-radius: 10px;
  padding: 0.65rem 0.7rem;
}
.library-summary .stat-label {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.library-summary .stat-value {
  margin-top: 0.25rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
}
.library-viewer-head {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:0.8rem;
  flex-wrap:wrap;
  margin-bottom:0.8rem;
}
.library-viewer-head h3 { margin: 0; }
.viewer-flash {
  animation: viewerPulse 0.9s ease;
}
@keyframes viewerPulse {
  0% { box-shadow: 0 0 0 0 rgba(29,107,103,0.00); }
  35% { box-shadow: 0 0 0 4px rgba(29,107,103,0.12); }
  100% { box-shadow: 0 0 0 0 rgba(29,107,103,0.00); }
}
.tiny-list {
  margin: 0.4rem 0 0 1rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

details {
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(91,74,38,0.10);
  border-radius: 12px;
  padding: 0.35rem 0.55rem;
}
details[open] { padding-bottom: 0.6rem; }
details summary {
  font-family: var(--ui);
  font-weight: 700;
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: "▸";
  color: var(--accent2);
  margin-right: 0.4rem;
}
details[open] summary::before { content: "▾"; }

@keyframes fadeLift {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 700px) {
  header {
    padding: 1rem 1rem 0.9rem;
    gap: 0.8rem;
  }
  nav {
    padding: 0.6rem 1rem 0.15rem;
  }
  nav button {
    font-size: 0.78rem;
    padding: 0.45rem 0.75rem;
  }
  main {
    padding: 1rem;
  }
  .card {
    border-radius: 14px;
    padding: 0.95rem;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
  button.secondary {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  section.active { animation: none; }
}
