:root {
  color-scheme: dark;
  --bg: #09090b;
  --panel: #18181b;
  --line: #27272a;
  --text: #e4e4e7;
  --muted: #a1a1aa;
  --dim: #52525b;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}
body { display: flex; flex-direction: column; }
header {
  padding: 9px 13px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #111113, #0b0b0d);
  flex-shrink: 0;
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
h1 { font-size: 14px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h1 small { color: var(--dim); font-weight: 500; font-size: 11px; margin-left: 4px; }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 헤더 우측 액션 영역 — 옵션 아이콘(+ 향후 일정 추가/삭제 등) */
.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; color: var(--muted); }
.icon-btn:hover { color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; display: block; }
.icon-btn[aria-expanded="true"] { background: #27272a; color: #fafafa; border-color: #3f3f46; }
/* 옵션 — 하단 바텀시트 모달 */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 30; background: #0007;
  opacity: 0; visibility: hidden; transition: opacity 0.22s ease, visibility 0.22s;
}
.sheet-backdrop.open { opacity: 1; visibility: visible; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  display: flex; flex-direction: column; max-height: 82vh;
  padding: 0 14px calc(12px + env(safe-area-inset-bottom)) 14px;
  background: linear-gradient(180deg, #161618, #0d0d0f);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 16px 16px 0 0; box-shadow: 0 -14px 44px #000b;
  transform: translateY(101%); transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 38px; height: 4px; flex: none; margin: 9px auto 5px; border-radius: 3px; background: #3f3f46; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; flex: none; padding: 1px 2px 10px; }
.sheet-title { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.sheet-close { padding: 4px 9px; font-size: 13px; line-height: 1; color: var(--muted); }
.sheet-body { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.sheet-body .controls { gap: 10px 8px; max-width: 100%; }
@media (prefers-reduced-motion: reduce) {
  .sheet { transition: none; }
}
@media (max-width: 560px) {
  .sheet-body .controls { gap: 11px 8px; }
  /* 세그 그룹: 라벨 위 / 컨트롤 아래 풀폭(버튼 균등 분할) — 좁은 폭에서 잘림 방지.
     min-width:0 = flex 자식이 컨테이너 아래로 줄어들 수 있게(기본 min-width:auto 오버플로 방지) */
  .sheet-body .seg-group { flex: 1 1 100%; min-width: 0; flex-direction: column; align-items: stretch; gap: 5px; }
  .sheet-body .seg { display: flex; min-width: 0; }
  .sheet-body .seg button { flex: 1; min-width: 0; }
  /* 슬라이더(길이·두께·최대줄·높이·핀치)도 각자 한 줄 풀폭 */
  .sheet-body .sl { flex: 1 1 100%; min-width: 0; }
  .sheet-body .sl input[type="range"] { flex: 1; width: auto; min-width: 0; }
  .sheet-body .vsep { display: none; }
}
button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
button:hover { border-color: #3f3f46; background: #1f1f23; }
button:active { background: #27272a; }

/* MODE 그룹 라벨 (MODE 1 / MODE 2) */
.seg-group { display: inline-flex; align-items: center; gap: 7px; }
.seg-label { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; color: var(--dim); text-transform: uppercase; white-space: nowrap; }

/* 세그먼트(모드 선택) */
.seg { display: inline-flex; background: #0d0d0f; border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; color: var(--muted); }
.seg button.on { background: #27272a; color: #fafafa; }
.seg button:hover { background: #1f1f23; }

/* 슬라이더 */
.sl { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); transition: opacity 0.2s; }
.sl b { color: var(--text); font-family: ui-monospace, monospace; min-width: 26px; text-align: right; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 92px; height: 4px; border-radius: 3px; background: #3f3f46; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%; background: #e4e4e7; border: 1px solid #52525b; cursor: pointer;
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #e4e4e7; border: 1px solid #52525b; cursor: pointer; }
.sl select {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 7px; font-size: 11px; font-weight: 600;
  font-family: ui-monospace, monospace; cursor: pointer; outline: none;
  transition: border-color 0.15s;
}
.sl select:hover { border-color: #3f3f46; }
.vsep { width: 1px; height: 20px; background: var(--line); }

.hint { margin: 7px 2px 0; font-size: 11px; color: var(--dim); line-height: 1.7; }
.hint b { color: var(--muted); font-weight: 600; }

#stage { position: relative; flex: 1; min-height: 0; touch-action: none; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#stage:focus { outline: none; }
/* 포커스 링(파란 보더)은 키보드 모달리티(html.kbd)에서만 — 마우스 클릭 시엔 숨김 */
html.kbd #stage:focus { outline: 2px solid #60a5fa; outline-offset: -2px; }

/* 접근성: 스크린리더 전용 라이브 영역 */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 막대 누름 정보 툴팁(상세 + 가려진 항목) */
.popover {
  position: fixed; z-index: 20; top: 0; left: 0; pointer-events: none;
  padding: 9px 11px; max-width: 250px;
  background: var(--panel); border: 1px solid #3f3f46; border-radius: 9px;
  font-size: 12px; color: var(--text); box-shadow: 0 10px 30px #000a;
}
.popover[hidden] { display: none; }
.popover .pop-h { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.popover .pop-h b { font-size: 13px; line-height: 1.2; }
.popover .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.popover .pop-r { color: var(--muted); margin-top: 2px; }
.popover .pop-r b { color: var(--text); font-family: ui-monospace, monospace; }
.popover .ms {
  display: inline-block; margin-top: 7px; font-size: 10px; color: #fbbf24;
  border: 1px solid #fbbf2455; border-radius: 5px; padding: 1px 6px;
}
.popover .pop-hh {
  margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 11px;
}
.popover .pop-hh b { color: var(--text); }
.popover .pop-hlist { margin-top: 3px; max-height: 38vh; overflow: hidden; }
.popover .pop-hi { color: var(--muted); font-size: 11px; line-height: 1.55; }
.popover .pop-hi::before { content: "· "; color: var(--dim); }

@media (prefers-contrast: more) {
  .popover { border-color: #fff; }
}
