:root {
    --bg: #F2EDE3;
    --bg-warm: #EAE3D5;
    --surface: #FAF6EE;
    --surface-2: #F5EFE2;
    --ink: #2A2823;
    --ink-soft: #5C5750;
    --ink-muted: #8A8479;
    --line: #DDD3C0;
    --line-soft: #E8DFCC;
    --sage: #6B8E7F;
    --sage-deep: #4F6E62;
    --sage-soft: #C5D2C9;
    --terracotta: #B85540;
    --terracotta-soft: #E8C4B8;
    --amber: #C58A2E;
    --amber-soft: #ECD7A8;
    --skin: #E8D9C2;
    --skin-line: #B89E7A;
    --shadow-soft: 0 1px 2px rgba(60, 50, 30, 0.04), 0 8px 24px rgba(60, 50, 30, 0.06);
    --shadow-card: 0 1px 2px rgba(60, 50, 30, 0.05), 0 12px 32px rgba(60, 50, 30, 0.08);
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
  }
  * { box-sizing: border-box; }
  html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  body {
    background:
      radial-gradient(1200px 600px at 90% -10%, rgba(107, 142, 127, 0.08), transparent 60%),
      radial-gradient(900px 500px at -10% 100%, rgba(184, 85, 64, 0.05), transparent 60%),
      var(--bg);
    min-height: 100vh;
  }
  .frame { max-width: 1280px; margin: 0 auto; padding: 32px 36px 80px; }
  header.top {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 24px; padding-bottom: 22px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 28px;
  }
  .brand { display: flex; align-items: baseline; gap: 14px; }
  .brand-mark {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--sage); position: relative;
    transform: translateY(4px);
    box-shadow: inset 0 -6px 0 0 var(--sage-deep);
  }
  .brand-mark::after {
    content: ''; position: absolute; inset: 7px;
    border-radius: 50%; background: var(--surface);
  }
  .brand h1 {
    font-family: 'Fraunces', serif;
    font-weight: 500; font-size: 30px;
    letter-spacing: -0.015em; margin: 0;
    font-variation-settings: "opsz" 36, "SOFT" 50;
  }
  .brand .tag {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px; color: var(--ink-muted);
    letter-spacing: 0.08em; text-transform: uppercase;
    margin-left: 4px;
  }
  .meta { font-size: 13px; color: var(--ink-soft); text-align: right; }
  .meta strong { font-weight: 500; color: var(--ink); }
  .meta .count {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px; color: var(--sage-deep);
    margin-top: 2px; display: block;
  }
  .disclaimer {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--sage);
    border-radius: var(--r-md);
    padding: 14px 18px;
    font-size: 13.5px; color: var(--ink-soft);
    margin-bottom: 28px;
    display: flex; gap: 12px; align-items: flex-start;
  }
  .disclaimer .ico {
    font-family: 'Fraunces', serif; font-style: italic;
    font-size: 18px; color: var(--sage-deep); margin-top: -2px;
  }
  .grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 32px; align-items: start; }
  @media (max-width: 960px) { .grid { grid-template-columns: 1fr; } .frame { padding: 24px 20px 64px; } }
  .panel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); padding: 26px;
    box-shadow: var(--shadow-soft);
  }
  .panel h2 {
    font-family: 'Fraunces', serif; font-weight: 500;
    font-size: 20px; margin: 0 0 4px;
    letter-spacing: -0.005em;
    font-variation-settings: "opsz" 24;
  }
  .panel .sub { font-size: 13px; color: var(--ink-muted); margin-bottom: 18px; }
  textarea.input {
    width: 100%; min-height: 280px; resize: vertical;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-md);
    padding: 14px 16px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13.5px; line-height: 1.7;
    color: var(--ink);
  }
  textarea.input:focus {
    outline: none; border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(107, 142, 127, 0.18);
  }
  .controls {
    display: flex; gap: 10px; margin-top: 16px;
    align-items: center; flex-wrap: wrap;
  }
  button.primary {
    background: var(--sage-deep); color: var(--surface);
    border: none; padding: 11px 22px;
    border-radius: var(--r-sm);
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 500; font-size: 14px;
    letter-spacing: 0.01em; cursor: pointer;
    transition: transform 0.08s ease, background 0.15s ease;
  }
  button.primary:hover { background: var(--sage); }
  button.primary:active { transform: translateY(1px); }
  button.ghost {
    background: transparent; color: var(--ink-soft);
    border: 1px solid var(--line); padding: 10px 16px;
    border-radius: var(--r-sm);
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 13.5px; cursor: pointer;
  }
  button.ghost:hover { background: var(--surface-2); }
  .examples { margin-top: 18px; font-size: 12.5px; color: var(--ink-muted); }
  .examples .label {
    text-transform: uppercase; letter-spacing: 0.1em;
    font-size: 11px; margin-right: 8px;
  }
  .examples a {
    color: var(--sage-deep); text-decoration: none;
    cursor: pointer; border-bottom: 1px dotted var(--sage);
    margin-right: 12px; padding-bottom: 1px;
  }
  .examples a:hover { color: var(--terracotta); border-color: var(--terracotta); }
  .output-stack { display: flex; flex-direction: column; gap: 22px; }
  .emergency-banner {
    background: #FBEBE6;
    border: 1px solid var(--terracotta-soft);
    border-left: 3px solid var(--terracotta);
    border-radius: var(--r-md);
    padding: 14px 18px; color: #6B2818; display: none;
  }
  .emergency-banner.show { display: block; }
  .emergency-banner strong {
    font-family: 'Fraunces', serif; font-weight: 500;
    display: block; font-size: 16px; margin-bottom: 4px;
  }
  .emergency-banner .terms {
    font-size: 13px; margin-top: 6px; color: #8A3A26;
  }
  .summary {
    font-family: 'Fraunces', serif; font-weight: 400;
    font-size: 17px; line-height: 1.7;
    color: var(--ink);
    font-variation-settings: "opsz" 14;
  }
  .summary .empty { color: var(--ink-muted); font-style: italic; }
  .annotated {
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-md);
    padding: 16px 18px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px; line-height: 1.85;
    color: var(--ink-soft);
    white-space: pre-wrap; word-wrap: break-word;
    max-height: 260px; overflow-y: auto;
  }
  .annotated mark {
    background: transparent; color: var(--ink);
    border-bottom: 2px solid var(--sage);
    padding-bottom: 1px; cursor: help;
    font-weight: 500;
  }
  .annotated mark.severity-moderate { border-color: var(--amber); }
  .annotated mark.severity-urgent { border-color: var(--terracotta); }
  .annotated mark.unmatched {
    background: rgba(184, 85, 64, 0.08);
    border-bottom: 2px dotted var(--terracotta);
    color: var(--ink-soft);
  }
  .term-list {
    list-style: none; padding: 0; margin: 8px 0 0;
    display: flex; flex-direction: column; gap: 10px;
  }
  .term-card {
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-md);
    padding: 12px 14px;
    display: grid;
    grid-template-columns: 10px 1fr auto;
    gap: 6px 14px;
    align-items: start;
    transition: border-color 0.15s ease;
  }
  .term-card:hover { border-color: var(--line); }
  .term-card .dot {
    width: 8px; height: 8px;
    border-radius: 50%; margin-top: 8px;
    background: var(--sage);
  }
  .term-card.severity-moderate .dot { background: var(--amber); }
  .term-card.severity-urgent .dot { background: var(--terracotta); }
  .term-card .original {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px; color: var(--ink); font-weight: 500;
  }
  .term-card .original .canon {
    color: var(--ink-muted); font-weight: 400; margin-left: 6px;
  }
  .term-card .badge {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--ink-muted);
    border: 1px solid var(--line);
    padding: 2px 7px; border-radius: 3px;
    background: var(--surface);
  }
  .term-card .badge.tier-derived { color: var(--sage-deep); border-color: var(--sage-soft); }
  .term-card .plain {
    grid-column: 2 / 4; font-size: 14.5px;
    line-height: 1.55; color: var(--ink-soft);
  }
  .term-card .source {
    grid-column: 2 / 4; font-size: 11.5px;
    font-family: 'IBM Plex Mono', monospace;
    color: var(--ink-muted); margin-top: 2px;
  }
  .anatomy-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 20px;
    box-shadow: var(--shadow-soft);
    display: flex; flex-direction: column; align-items: center;
  }
  .anatomy-controls {
    display: flex; gap: 8px; margin-bottom: 12px;
    align-items: center; width: 100%;
    justify-content: space-between;
  }
  .anatomy-controls .title {
    font-family: 'Fraunces', serif; font-weight: 500;
    font-size: 16px;
  }
  .toggle {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--ink-soft); cursor: pointer;
    user-select: none;
  }
  .toggle input { accent-color: var(--sage-deep); }
  .body-svg {
    width: 100%; max-width: 340px; height: auto;
  }
  .body-svg .skin-fill { fill: var(--skin); }
  .body-svg .skin-stroke { stroke: var(--skin-line); stroke-width: 1.4; fill: none; }
  .body-svg .organ {
    fill: #EFE0CC; stroke: var(--skin-line);
    stroke-width: 1; opacity: 0;
    transition: opacity 0.3s ease;
  }
  .body-svg.organs-on .organ { opacity: 0.92; }
  .body-svg .region {
    fill: var(--skin); stroke: var(--skin-line);
    stroke-width: 1.2; transition: fill 0.4s ease;
  }
  .body-svg .region.highlight-info { fill: var(--sage-soft); }
  .body-svg .region.highlight-moderate { fill: var(--amber-soft); }
  .body-svg .region.highlight-urgent { fill: var(--terracotta-soft); }
  .body-svg .region.highlight-info,
  .body-svg .region.highlight-moderate,
  .body-svg .region.highlight-urgent { stroke-width: 1.6; }
  .body-svg .organ.highlight-info { fill: var(--sage); opacity: 0.9; }
  .body-svg .organ.highlight-moderate { fill: var(--amber); opacity: 0.9; }
  .body-svg .organ.highlight-urgent { fill: var(--terracotta); opacity: 0.9; }
  .anatomy-legend {
    width: 100%; margin-top: 14px;
    font-size: 12px; color: var(--ink-soft);
    border-top: 1px solid var(--line-soft);
    padding-top: 12px;
  }
  .anatomy-legend .key {
    display: inline-flex; align-items: center; gap: 5px;
    margin-right: 14px;
  }
  .anatomy-legend .swatch {
    width: 10px; height: 10px; border-radius: 2px;
    display: inline-block;
  }
  .stats {
    display: flex; gap: 20px; margin-top: 8px;
    padding-top: 12px; border-top: 1px solid var(--line-soft);
    font-size: 12px; color: var(--ink-muted);
  }
  .stats .stat strong {
    color: var(--ink); font-weight: 500;
    display: block; font-family: 'Fraunces', serif;
    font-size: 18px; line-height: 1; margin-bottom: 2px;
  }
  footer.bottom {
    margin-top: 50px; padding-top: 24px;
    border-top: 1px solid var(--line);
    font-size: 12px; color: var(--ink-muted);
    line-height: 1.7;
  }
  footer.bottom strong {
    color: var(--ink-soft); font-weight: 500;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.08em; display: block;
    margin-bottom: 6px;
  }
  footer.bottom a {
    color: var(--sage-deep);
    text-decoration: none;
    border-bottom: 1px dotted var(--sage);
  }
  /* Tooltip */
  .tooltip {
    position: absolute;
    background: var(--ink); color: var(--surface);
    padding: 8px 11px; border-radius: 6px;
    font-size: 12px; line-height: 1.4;
    max-width: 240px; pointer-events: none;
    z-index: 1000; opacity: 0;
    transition: opacity 0.15s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  }
  .tooltip.show { opacity: 1; }
  .tooltip .ttl-canon {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10.5px; color: var(--sage-soft);
    letter-spacing: 0.04em; text-transform: uppercase;
    margin-bottom: 3px;
  }
  /* Empty state */
  .empty-state {
    text-align: center; padding: 30px 20px;
    color: var(--ink-muted);
  }
  .empty-state .ico {
    font-family: 'Fraunces', serif; font-style: italic;
    font-size: 38px; color: var(--sage-soft);
    margin-bottom: 6px; line-height: 1;
  }
  .empty-state p { margin: 4px 0; font-size: 13.5px; }
  .loading {
    color: var(--ink-muted); font-style: italic; font-size: 13px;
  }
  /* Section heading inside panel */
  .section-h {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px; color: var(--ink-muted);
    letter-spacing: 0.1em; text-transform: uppercase;
    margin: 20px 0 10px; font-weight: 500;
  }
  .section-h:first-child { margin-top: 0; }