:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --line: #d6dde6;
  --line-strong: #aeb9c7;
  --ink: #15202b;
  --muted: #5f6d7c;
  --accent: #1f5fa8;
  --accent-strong: #16497f;
  --accent-soft: #e7f0fb;
  --success: #1f7a46;
  --success-soft: #e8f6ee;
  --danger: #b5493c;
  --danger-soft: #fceceb;
  --warning: #7b5a1d;
  --warning-soft: #f8f1df;
  --shadow: 0 14px 34px rgba(21, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

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

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0.78rem 1rem;
  border-radius: 4px;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
  text-decoration: none;
}

button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button.secondary {
  background: #fff;
  color: var(--accent);
}

button.secondary:hover {
  background: var(--accent-soft);
}

button.active-control {
  border-color: var(--accent-strong);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px var(--accent);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

button.ghost:hover {
  background: #fff;
  border-color: var(--line-strong);
}

a {
  color: var(--accent);
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  padding: 0.7rem 1rem;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 2rem;
}

.app-header,
.workspace,
.footer {
  width: min(1280px, calc(100vw - 2rem));
  margin-left: auto;
  margin-right: auto;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.25rem 0 0.9rem;
}

.header-kicker {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.32rem;
}

.header-kicker-link {
  display: inline-flex;
  text-decoration: none;
}

.header-kicker-link:hover {
  color: var(--accent-strong);
}

.app-header h1,
.about-head h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
}

.project-meta {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.45rem;
}

.status-badge,
.version-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 0.2rem 0.55rem;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
}

.version-badge {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-weight: 600;
}

.status-prototype {
  border-color: #dcc58f;
  background: var(--warning-soft);
  color: var(--warning);
}

.header-copy,
.muted {
  color: var(--muted);
}

.header-copy {
  margin: 0.45rem 0 0;
  max-width: 48rem;
  line-height: 1.5;
}

.header-actions,
.button-row,
.section-head,
.footer {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.section-head {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(390px, 0.9fr);
  gap: 1rem;
  align-items: start;
}

.input-pane,
.output-pane {
  display: grid;
  gap: 1rem;
}

.output-pane {
  align-self: start;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.sticky-card {
  position: static;
  z-index: 5;
}

.footer {
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem 0 2rem;
}

.support-card {
  margin-top: 1rem;
}

.mode-card .section-head {
  margin-bottom: 0;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.segmented-control button {
  min-height: 2.5rem;
  padding: 0.62rem 0.85rem;
}

.active-mode-banner {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 1.75rem;
  margin-top: 0.55rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 0.26rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.active-mode-banner::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--accent);
}

.session-grid {
  display: grid;
  grid-template-columns: minmax(90px, 0.45fr) minmax(0, 0.9fr) minmax(180px, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.session-actions {
  align-items: center;
}

.session-status {
  margin-top: 0.55rem;
  font-size: 0.86rem;
}

.transfer-card summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  cursor: pointer;
}

.transfer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 0.85rem;
}

.transfer-code {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  word-break: break-all;
}

.panel-title {
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

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

.timeline-entry-grid {
  display: grid;
  grid-template-columns: minmax(190px, 0.7fr) minmax(0, 1.3fr) auto;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.85rem;
}

.timeline-list {
  display: grid;
  gap: 0.55rem;
  margin: 0.2rem 0 0.85rem;
}

.timeline-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 0.7rem;
}

.timeline-item div {
  display: grid;
  gap: 0.15rem;
}

.timeline-item span {
  color: var(--muted);
}

.field,
.format-select {
  display: grid;
  gap: 0.35rem;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding-top: 1.35rem;
}

.checkbox-field input {
  width: auto;
}

.calculation-card {
  display: grid;
  gap: 0.2rem;
  margin-top: 0.85rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
}

.calculation-card strong {
  color: var(--ink);
}

.field span,
.format-select span {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  padding: 0.68rem 0.75rem;
}

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

.exam-list {
  display: grid;
  gap: 0.75rem;
}

.exam-item {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.85rem;
}

.exam-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
}

.exam-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  justify-content: space-between;
}

.exam-title {
  font-weight: 700;
}

.collapse-toggle {
  min-height: 1.85rem;
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
  padding: 0.25rem 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.collapse-toggle:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.normal-text {
  color: var(--muted);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.exam-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.3rem;
}

.exam-meta span,
.position-divider {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.2rem 0.4rem;
}

.exam-meta.position-hidden:empty {
  display: none;
}

.position-divider {
  background: var(--accent-soft);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.55rem 0.7rem;
  margin-top: 0.35rem;
}

.abnormal-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  align-self: start;
  border: 1px solid rgba(181, 73, 60, 0.28);
  border-radius: 4px;
  background: #fff;
  color: var(--danger);
  font-weight: 700;
  padding: 0.35rem 0.55rem;
  white-space: nowrap;
}

.abnormal-toggle input {
  width: auto;
}

.abnormal-field {
  margin-top: 0.75rem;
}

.exam-item.is-abnormal {
  border-color: rgba(181, 73, 60, 0.45);
  background: var(--danger-soft);
}

.exam-content {
  display: block;
}

.exam-item.is-collapsed .normal-text,
.exam-item.is-collapsed .exam-content {
  display: none;
}

.problem-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.visually-hidden {
  display: none;
}

.problem-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 2.1rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  padding: 0.35rem 0.55rem;
  font-size: 0.9rem;
}

.problem-chip input {
  width: auto;
}

.problem-chip:has(input:checked),
.focus-chip:has(input:checked) {
  border-color: rgba(181, 73, 60, 0.45);
  color: var(--danger);
  font-weight: 700;
}

.focus-list,
.choice-list,
.marker-controls,
.conclusion-grid,
.detail-grid {
  display: grid;
  gap: 0.75rem;
}

.focus-list,
.choice-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.clinical-choice-block {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 0.85rem 0;
}

.clinical-choice-block .choice-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.focus-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  padding: 0.55rem 0.65rem;
}

.focus-chip input {
  width: auto;
}

.epj-plan-toggle {
  margin: 0.45rem 0 0.75rem;
  width: fit-content;
  max-width: 100%;
}

.marker-controls,
.conclusion-grid,
.detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-panel {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  margin-top: 0.75rem;
  padding: 0.75rem;
}

.compact-field {
  max-width: 220px;
}

.cranial-panel {
  display: grid;
  gap: 0.75rem;
}

.visual-field-preview {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  padding: 0.75rem;
}

.vf-title {
  font-weight: 700;
  margin-bottom: 0.55rem;
}

.vf-eyes {
  display: flex;
  gap: 0.8rem;
}

.vf-eye {
  position: relative;
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  cursor: crosshair;
  padding: 0;
}

.vf-zone {
  position: absolute;
  z-index: 1;
  border-radius: 0;
  background: rgba(31, 95, 168, 0.06);
  border: 1px solid rgba(31, 95, 168, 0.16);
  pointer-events: none;
}

.vf-zone.active {
  background: rgba(17, 17, 17, 0.82);
  border-color: rgba(17, 17, 17, 0.9);
}

.vf-upper-left {
  inset: 0 50% 50% 0;
}

.vf-upper-right {
  inset: 0 0 50% 50%;
}

.vf-lower-left {
  inset: 50% 50% 0 0;
}

.vf-lower-right {
  inset: 50% 0 0 50%;
}

.vf-center-dot {
  position: absolute;
  z-index: 2;
  width: 26%;
  height: 26%;
  inset: auto;
  border-radius: 999px;
  border: 2px solid rgba(31, 95, 168, 0.32);
  background: rgba(255, 255, 255, 0.78);
  pointer-events: none;
}

.vf-center-dot.active {
  background: rgba(17, 17, 17, 0.78);
  border-color: rgba(17, 17, 17, 0.9);
}

.vf-eye::before,
.vf-eye::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
}

.vf-eye-label {
  position: relative;
  z-index: 4;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  padding: 0.18rem 0.28rem;
}

.vf-guide-line {
  position: absolute;
  z-index: 3;
  background: rgba(31, 95, 168, 0.4);
  pointer-events: none;
}

.vf-guide-vertical {
  width: 2px;
  inset: 0 auto 0 50%;
  transform: translateX(-50%);
}

.vf-guide-horizontal {
  height: 2px;
  inset: 50% 0 auto 0;
  transform: translateY(-50%);
}

.vf-note {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
  margin-top: 0.55rem;
}

.vf-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
  margin-top: 0.55rem;
}

.vf-guide span {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  padding: 0.25rem 0.4rem;
}

.vf-left-mono .vf-eye:first-child::before,
.vf-right-mono .vf-eye:last-child::before {
  background: #111;
}

.vf-right-homonymous .vf-eye::before,
.vf-right-upper .vf-eye::before,
.vf-right-lower .vf-eye::before {
  clip-path: inset(0 0 0 50%);
  background: #111;
}

.vf-left-homonymous .vf-eye::before,
.vf-left-upper .vf-eye::before,
.vf-left-lower .vf-eye::before {
  clip-path: inset(0 50% 0 0);
  background: #111;
}

.vf-bitemporal .vf-eye:first-child::before,
.vf-binasal .vf-eye:last-child::before {
  clip-path: inset(0 50% 0 0);
  background: #111;
}

.vf-bitemporal .vf-eye:last-child::before,
.vf-binasal .vf-eye:first-child::before {
  clip-path: inset(0 0 0 50%);
  background: #111;
}

.vf-right-upper .vf-eye::before,
.vf-left-upper .vf-eye::before {
  clip-path: polygon(50% 0, 100% 0, 100% 50%, 50% 50%);
}

.vf-left-upper .vf-eye::before {
  clip-path: polygon(0 0, 50% 0, 50% 50%, 0 50%);
}

.vf-right-lower .vf-eye::before {
  clip-path: polygon(50% 50%, 100% 50%, 100% 100%, 50% 100%);
}

.vf-left-lower .vf-eye::before {
  clip-path: polygon(0 50%, 50% 50%, 50% 100%, 0 100%);
}

.vf-central .vf-eye::after {
  inset: 25%;
  border-radius: 999px;
  background: #111;
}

.vf-upper-altitudinal .vf-eye::before {
  clip-path: inset(0 0 50% 0);
  background: #111;
}

.vf-lower-altitudinal .vf-eye::before {
  clip-path: inset(50% 0 0 0);
  background: #111;
}

.mrc-table {
  display: grid;
  gap: 0.55rem;
}

.mrc-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 90px 90px;
  gap: 0.55rem;
  align-items: center;
}

.mrc-row.header {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.output-text {
  min-height: 470px;
  background: #fbfdff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92rem;
}

.output-section {
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
}

.output-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.output-section + .output-section {
  margin-top: 1rem;
}

.output-section > summary {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  gap: 0.7rem;
  justify-content: space-between;
  list-style: none;
  margin: -0.25rem -0.35rem 0.6rem;
  padding: 0.35rem;
}

.output-section > summary::-webkit-details-marker {
  display: none;
}

.output-section > summary::after {
  color: var(--muted);
  content: "▾";
  font-size: 0.9rem;
  font-weight: 900;
}

.output-section:not([open]) > summary {
  margin-bottom: 0;
}

.output-section:not([open]) > summary::after {
  content: "▸";
}

.output-section > summary:hover {
  background: #f3f6f9;
}

.summary-hint {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.output-format-select {
  margin-bottom: 0.7rem;
}

.separate-output {
  border-top: 1px solid var(--line);
  margin-top: 1rem;
  padding-top: 1rem;
}

.reason-output {
  min-height: 110px;
}

.conclusion-output {
  min-height: 190px;
}

.copy-status {
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.body-map {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) auto;
  grid-template-areas: "rightLeft front leftMiddle back rightRight";
  align-items: center;
  gap: 0.55rem;
  width: min(760px, 100%);
  margin: 0.75rem auto 1rem;
}

.body-map-direction {
  align-self: center;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  writing-mode: vertical-rl;
}

.body-map-direction-right-left {
  grid-area: rightLeft;
}

.body-map-direction-left-middle {
  grid-area: leftMiddle;
}

.body-map-direction-right-right {
  grid-area: rightRight;
}

.body-view {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdfe;
  padding: 0.55rem;
}

.body-view-front {
  grid-area: front;
}

.body-view-back {
  grid-area: back;
}

.body-view-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.25rem;
}

.body-map-canvas {
  position: relative;
  display: block;
  width: 100%;
  cursor: crosshair;
  outline: none;
}

.body-map-canvas:focus-visible {
  box-shadow: 0 0 0 3px rgba(31, 95, 168, 0.2);
}

.body-map-image {
  display: block;
  width: 100%;
  border-radius: 6px;
  user-select: none;
}

.body-marker {
  position: absolute;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  padding: 0;
  border: 3px solid var(--marker-color, #d52929);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--marker-color, #a51010);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 2px rgba(21, 32, 43, 0.35));
}

.body-zone {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(31, 95, 168, 0.82);
  border-radius: 4px;
  background: rgba(31, 95, 168, 0.12);
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  padding: 0.12rem;
  cursor: crosshair;
  pointer-events: auto;
}

.body-zone span {
  max-width: 7.8rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.88);
  padding: 0.1rem 0.22rem;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.body-zone:hover span {
  opacity: 1;
  transform: translateY(0);
}

.body-marker:hover {
  background: #fff;
}

.body-line-marker {
  position: absolute;
  z-index: 3;
  height: 0;
  padding: 0;
  border: 0;
  border-top: 5px solid var(--marker-color, #d52929);
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 0 2px rgba(21, 32, 43, 0.35));
  pointer-events: auto;
  transform-origin: left center;
}

.body-line-marker::before,
.body-line-marker::after {
  content: "";
  position: absolute;
  top: -9px;
  width: 13px;
  height: 13px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--marker-color, #d52929);
}

.body-line-marker::before {
  left: -6px;
}

.body-line-marker::after {
  right: -6px;
}

.body-line-label {
  position: absolute;
  z-index: 4;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--marker-color, #d52929);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 2px rgba(21, 32, 43, 0.35));
}

.body-line-marker.selected {
  border-top-width: 7px;
}

.body-line-label.selected {
  box-shadow: 0 0 0 3px rgba(31, 95, 168, 0.25);
}

.body-hover-label {
  position: absolute;
  z-index: 4;
  max-width: 15rem;
  border: 1px solid rgba(21, 32, 43, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 18px rgba(21, 32, 43, 0.14);
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.15;
  opacity: 0;
  padding: 0.3rem 0.42rem;
  pointer-events: none;
  transform: translate(0.5rem, -120%);
  transition: opacity 0.08s ease;
  white-space: nowrap;
}

.body-hover-label.visible {
  opacity: 1;
}

.body-marker.selected {
  background: var(--marker-color, #d52929);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(21, 32, 43, 0.16);
}

.marker-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 0.55rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  border: 2px solid var(--line);
  border-left-width: 6px;
  border-left-color: var(--legend-color, var(--line));
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.3rem 0.45rem;
}

.legend-item.active {
  border-color: var(--legend-color, var(--accent));
  background: #f8fbff;
  color: var(--ink);
  box-shadow: 0 0 0 3px rgba(21, 32, 43, 0.09), inset 0 0 0 1px var(--legend-color, var(--accent));
  transform: translateY(-1px);
}

.active-marker-type {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 2px solid var(--active-marker-color, var(--accent));
  border-left-width: 8px;
  border-radius: 4px;
  background: #fbfdff;
  color: var(--ink);
  font-weight: 700;
  margin: 0.75rem 0 0.55rem;
  padding: 0.65rem 0.75rem;
}

.active-marker-type span:not(.active-marker-dot) {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.active-marker-dot {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  box-shadow: 0 0 0 3px rgba(21, 32, 43, 0.08);
}

.legend-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
}

.legend-active-label {
  border-radius: 999px;
  background: var(--legend-color, var(--accent));
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  padding: 0.12rem 0.32rem;
  text-transform: uppercase;
}

.detail-title {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.cranial-reference {
  display: grid;
  gap: 0.32rem;
}

.cranial-reference-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 0.32rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  padding: 0.42rem 0.5rem;
}

.cranial-reference-row.not-examined {
  background: #f7f8fa;
  color: var(--muted);
}

.cranial-reference-text {
  line-height: 1.32;
}

.cranial-reference-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.25rem;
}

.cranial-chip {
  min-height: 1.65rem;
  padding: 0.18rem 0.38rem;
  font-size: 0.82rem;
}

.not-examined-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 1.65rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.18rem 0.38rem;
  white-space: nowrap;
}

.not-examined-toggle input {
  width: auto;
}

.support-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.support-grid h2 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.support-grid ul {
  margin: 0;
  padding-left: 1.2rem;
  line-height: 1.45;
}

.ddx-item {
  margin-bottom: 0.7rem;
}

.ddx-label {
  font-weight: 800;
}

.icd-code-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.28rem;
}

.icd-code-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28rem;
  max-width: 100%;
  border: 1px solid rgba(31, 95, 168, 0.22);
  border-radius: 4px;
  background: #f8fbff;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.2;
  padding: 0.16rem 0.36rem;
  text-decoration: none;
}

.icd-code-chip:hover {
  border-color: rgba(31, 95, 168, 0.45);
  background: #eef6ff;
}

.icd-code-chip small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.about-dialog {
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  max-width: min(720px, calc(100vw - 2rem));
  padding: 0;
}

.about-dialog::backdrop {
  background: rgba(16, 25, 34, 0.45);
}

.about-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem 1rem 0.5rem;
}

.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1.25rem;
}

.about-content {
  padding: 0 1rem 1rem;
  line-height: 1.55;
}

.about-meta {
  display: grid;
  gap: 0.45rem;
  margin: 1rem 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.about-meta div {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.about-meta dt {
  font-weight: 700;
  color: var(--ink);
}

.about-meta dd {
  margin: 0;
}

.about-content h3 {
  margin-bottom: 0.25rem;
}

.presentation-dialog {
  width: min(1120px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.5rem);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 0;
}

.presentation-dialog::backdrop {
  background: rgba(16, 25, 34, 0.45);
}

.presentation-shell {
  background: var(--bg);
  color: var(--ink);
}

.presentation-topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 1rem;
}

.presentation-topbar h2 {
  margin: 0;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
}

.presentation-content {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  max-height: calc(100vh - 7rem);
  overflow: auto;
}

.presentation-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
  gap: 1rem;
}

.presentation-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 1rem;
}

.presentation-card h3 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

.presentation-list {
  margin: 0;
  padding-left: 1.2rem;
  line-height: 1.5;
}

.presentation-text {
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  padding: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  line-height: 1.45;
}

.presentation-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.presentation-meta div {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  padding: 0.65rem;
}

.presentation-meta dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.presentation-meta dd {
  margin: 0.18rem 0 0;
}

.presentation-visual-field {
  display: grid;
  gap: 0.75rem;
}

.presentation-visual-field .vf-eye {
  cursor: default;
}

.presentation-body-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.presentation-body-view {
  display: grid;
  gap: 0.45rem;
}

.presentation-body-canvas {
  position: relative;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  overflow: hidden;
}

.presentation-body-canvas .body-map-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.presentation-body-marker {
  position: absolute;
  display: grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--marker-color);
  color: #fff;
  box-shadow: 0 6px 16px rgba(21, 32, 43, 0.18);
  font-size: 0.78rem;
  font-weight: 800;
}

.presentation-body-line {
  position: absolute;
  z-index: 3;
  height: 0;
  border-top: 5px solid var(--marker-color, #d52929);
  filter: drop-shadow(0 0 2px rgba(21, 32, 43, 0.28));
  transform-origin: left center;
}

.presentation-body-line::before,
.presentation-body-line::after {
  content: "";
  position: absolute;
  top: -9px;
  width: 13px;
  height: 13px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--marker-color, #d52929);
}

.presentation-body-line::before {
  left: -6px;
}

.presentation-body-line::after {
  right: -6px;
}

@media (max-width: 980px) {
  .workspace,
  .field-grid,
  .session-grid,
  .timeline-entry-grid,
  .presentation-grid,
  .presentation-meta,
  .presentation-body-map,
  .transfer-grid,
  .support-grid,
  .focus-list,
  .choice-list,
  .clinical-choice-block,
  .cranial-reference-row,
  .marker-controls,
  .conclusion-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .sticky-card {
    position: static;
  }

  .output-pane {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .body-map {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "rightLeft front leftMiddle"
      "rightRight back leftMiddle";
  }
}

@media (max-width: 680px) {
  .app-header {
    display: grid;
  }

  .header-actions,
  .button-row {
    width: 100%;
  }

  .header-actions > button,
  .button-row > button:not(.icon-btn) {
    width: 100%;
  }

  .mrc-row {
    grid-template-columns: 1fr;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--line);
  }

  .mrc-row.header {
    display: none;
  }

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