:root {
  color-scheme: light;
  font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color: #2c4031;
  background: #f3f4eb;
  font-synthesis: none;
  --green: #345c42;
  --muted: #7b8575;
  --line: #dfe5d5;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 3px solid #8ba57c; outline-offset: 4px; }
[hidden] { display: none !important; }
.branch-study { width: min(1432px, 100%); margin: 0 auto; padding: 38px 44px 34px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 27px; }
.eyebrow { margin: 0; color: #6b8066; font-size: 10px; font-weight: 700; letter-spacing: .17em; }
h1 { margin: 11px 0 9px; font-size: clamp(26px, 2.8vw, 35px); font-weight: 680; line-height: 1.25; letter-spacing: -.055em; }
.intro { margin: 0; color: #7b8575; font-size: 13px; line-height: 1.75; letter-spacing: -.02em; }
.study-mark { padding-top: 5px; color: #9aa58f; font-size: 10px; letter-spacing: .12em; white-space: nowrap; }
.study-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 28px; align-items: start; }
.stage { position: relative; height: clamp(480px, 71vh, 800px); min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 21px; background: #f6f6ee; }
#branch-viewer { position: absolute; inset: 0; }
#branch-viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.stage-label { position: absolute; top: 23px; left: 25px; display: flex; align-items: center; gap: 9px; color: #6b7963; font-size: 11px; font-weight: 550; pointer-events: none; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: #6b8a62; }
.label-divider { margin: 0 4px; color: #c0cbb5; }
.stage-hint { position: absolute; bottom: 19px; left: 16px; right: 16px; margin: 0; color: #8f9984; font-size: 10px; text-align: center; pointer-events: none; }
.load-status { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 35px; color: #6a795f; background: #f6f6eeed; font-size: 13px; line-height: 1.8; text-align: center; pointer-events: none; }
.load-status.error { color: #87634e; }
.study-panel { padding-top: 3px; }
.reference-card { margin: 0 0 27px; }
.reference-card figcaption { display: flex; align-items: center; justify-content: space-between; margin: 0 1px 12px; color: #536a4d; font-size: 12px; font-weight: 650; }
.reference-open { color: #8d9c80; font-size: 14px; font-weight: 400; }
.reference-card a { display: grid; min-height: 160px; overflow: hidden; border: 1px solid #e0e5d6; border-radius: 14px; background: #fff; text-decoration: none; }
.reference-card img { display: block; width: 100%; height: 200px; object-fit: contain; padding: 10px; }
.reference-hint { margin: 9px 2px 0; color: #97a08d; font-size: 10px; line-height: 1.6; }
.reference-status { margin: 8px 1px; color: #8a6e59; font-size: 11px; line-height: 1.7; }
.control-section { margin: 0 0 24px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
h2 { margin: 0 1px 12px; font-size: 12px; font-weight: 650; letter-spacing: -.02em; }
.angle-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
button { min-height: 39px; padding: 8px 6px; border: 1px solid #dce3d1; border-radius: 9px; background: transparent; color: #7d8a72; font-size: 11px; line-height: 1.35; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
@media (hover: hover) and (pointer: fine) and (min-width: 721px) { button:hover { color: var(--green); background: #e6ecdd; border-color: #b9c8ac; } }
button[aria-pressed="true"] { color: var(--green); background: #e5ecdd; border-color: #8ca37e; font-weight: 650; }
button:disabled { cursor: wait; opacity: .45; }
.surface-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border-radius: 11px; background: #e8eddf; }
.surface-buttons button { border-color: transparent; min-height: 37px; }
.surface-buttons button[aria-pressed="true"] { background: #fff; border-color: #fff; box-shadow: 0 1px 4px #314a2410; }
.control-note { margin: 12px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.85; letter-spacing: -.015em; word-break: keep-all; }
.surface-section { margin-bottom: 0; border-bottom: 0; }

@media (max-width: 960px) {
  .branch-study { padding: 32px 27px; }
  .study-layout { grid-template-columns: minmax(0, 1fr) 236px; gap: 22px; }
  .reference-card img { height: 180px; }
  .stage { height: clamp(490px, 71vh, 760px); }
}

@media (max-width: 720px) {
  .branch-study { padding: 27px 19px 30px; }
  .page-header { margin-bottom: 22px; align-items: flex-start; gap: 16px; }
  .eyebrow { font-size: 9px; letter-spacing: .12em; }
  h1 { font-size: 29px; margin-top: 10px; }
  .intro { font-size: 11px; }
  .study-mark { font-size: 8px; padding-top: 3px; }
  .study-layout { grid-template-columns: 1fr; gap: 24px; }
  .stage { height: clamp(300px, 78vw, 500px); border-radius: 17px; }
  .stage-label { top: 20px; left: 20px; font-size: 10px; }
  .stage-hint { bottom: 17px; font-size: 9px; }
  .study-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; padding: 0; }
  .reference-card { grid-row: span 2; margin: 0; }
  .reference-card a { min-height: 150px; }
  .reference-card img { height: 170px; padding: 6px; }
  .reference-card figcaption { font-size: 11px; }
  .reference-hint { font-size: 9px; }
  .control-section { margin-bottom: 0; padding-bottom: 19px; }
  .surface-section { padding-bottom: 0; }
  h2 { font-size: 11px; }
  button { font-size: 10px; min-height: 36px; padding-inline: 3px; }
  .angle-buttons { gap: 4px; }
  .control-note { font-size: 10px; margin-top: 10px; }
  .desktop-break { display: none; }
}

@media (max-width: 420px) {
  .study-mark { display: none; }
  .study-panel { gap: 16px; }
  .angle-buttons { grid-template-columns: 1fr; }
  .angle-buttons button { min-height: 31px; }
  .reference-card img { height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
