/* =========================================================================
   우리반 피아노 — 스타일
   태블릿 가로 화면 기준. 터치 영역은 최소 46px 이상으로 잡았다.
   ========================================================================= */

:root {
  --bg: #14112b;
  --bg-2: #1d1840;
  --panel: rgba(255, 255, 255, 0.07);
  --panel-line: rgba(255, 255, 255, 0.14);
  --text: #efeaff;
  --text-dim: #a59dc8;
  --accent: #ffc93c;
  --accent-2: #8b7cf6;
  --white-key: linear-gradient(180deg, #ffffff 0%, #fbfaff 62%, #ece8f6 100%);
  --white-key-on: linear-gradient(180deg, #fff8e2 0%, #ffeebc 100%);
  --black-key: linear-gradient(180deg, #3b3552 0%, #171326 72%, #0c0a16 100%);
  --black-key-on: linear-gradient(180deg, #6b5fa0 0%, #2c2447 100%);
  --radius: 16px;
  --font: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo',
          'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* hidden 속성이 항상 이기도록 — 아래 패널들은 display 값을 직접 갖고 있다 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* 무대 조명 같은 배경 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, #3b2f77 0%, rgba(59, 47, 119, 0) 60%),
    radial-gradient(80% 60% at 12% 110%, #2a1f5c 0%, rgba(42, 31, 92, 0) 65%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  z-index: -1;
}

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ------------------------------------------------------------ 윗줄(제목) */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px clamp(12px, 2vw, 22px) 6px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 38px; height: 38px; flex: none; filter: drop-shadow(0 4px 10px rgba(0,0,0,.45)); }
.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0;
  font-size: clamp(17px, 2.1vw, 22px);
  font-weight: 800;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.brand-text p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.topbar-actions { display: flex; gap: 8px; flex: none; }

.icon-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.icon-btn span { font-size: 16px; line-height: 1; }
.icon-btn em { font-style: normal; }
.icon-btn:active { transform: scale(.96); background: rgba(255,255,255,.14); }

/* ---------------------------------------------------------------- 조작줄 */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: clamp(8px, 1.4vw, 18px);
  padding: 6px clamp(12px, 2vw, 22px) 10px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: .02em;
  padding-left: 2px;
}

.key-picker { display: flex; align-items: center; gap: 8px; }

#keySelect {
  appearance: none;
  -webkit-appearance: none;
  min-height: 46px;
  padding: 0 38px 0 14px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%23bdb4e6' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center / 12px 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
#keySelect option { background: #241e4a; color: #fff; }
#keySelect optgroup { background: #1b1638; color: var(--text-dim); }

.key-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 201, 60, .14);
  border: 1px solid rgba(255, 201, 60, .35);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

/* 분절 버튼 (이동도 / 고정도 / 음이름 / 끄기) */
.seg {
  display: inline-flex;
  padding: 4px;
  gap: 3px;
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  background: var(--panel);
}
.seg button {
  min-height: 38px;
  padding: 0 clamp(10px, 1.3vw, 16px);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.seg button[aria-pressed="true"] {
  background: linear-gradient(180deg, #fff 0%, #ece7ff 100%);
  color: #241c4d;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.seg button:active { transform: scale(.97); }
.seg.wide { display: flex; width: 100%; }
.seg.wide button { flex: 1; min-height: 46px; font-size: 15px; }

/* 옥타브 이동 */
.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  background: var(--panel);
}
.stepper button {
  width: 44px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}
.stepper button:active { background: rgba(255,255,255,.2); }
.stepper-value {
  min-width: 78px;
  text-align: center;
  font-size: 14.5px;
  font-weight: 800;
  white-space: nowrap;
}

/* 페달 토글 */
.toggle-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  background: var(--panel);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.toggle-btn .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  transition: background .15s, box-shadow .15s;
}
.toggle-btn[aria-pressed="true"] {
  background: rgba(255, 201, 60, .16);
  border-color: rgba(255, 201, 60, .5);
  color: var(--accent);
}
.toggle-btn[aria-pressed="true"] .dot {
  background: var(--accent);
  box-shadow: 0 0 12px rgba(255, 201, 60, .9);
}

/* ---------------------------------------------------------------- 건반 */

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  /* 건반이 너무 길어지면 위쪽에 여백을 두고 아래로 붙인다 */
  max-height: calc(var(--kb-max, 9999px) + 30px);
  margin: auto clamp(10px, 1.8vw, 22px) clamp(6px, 1.2vw, 14px);
  padding: 16px 12px 12px;
  border-radius: 20px;
  background: linear-gradient(180deg, #2e2553 0%, #1a1438 100%);
  border: 1px solid rgba(255,255,255,.09);
  box-shadow:
    0 -1px 0 rgba(255,255,255,.09) inset,
    0 26px 60px rgba(0,0,0,.55);
}

.kb {
  position: relative;
  height: 100%;
  touch-action: none;
}

/* 건반 위 빨간 펠트 띠 — 진짜 피아노 느낌 */
.kb::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: -9px;
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(180deg, #d31b46 0%, #8d0f2c 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,.45);
}

.kb-whites {
  display: flex;
  gap: 3px;
  height: 100%;
}

.kb-blacks {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 61%;
  pointer-events: none;
}

.key {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: clamp(8px, 1.4vh, 18px);
  overflow: hidden;
  cursor: pointer;
  transition: transform .04s ease-out, filter .12s;
}

.key.white {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 5px 5px 11px 11px;
  background: var(--white-key);
  box-shadow:
    0 -2px 0 rgba(0,0,0,.07) inset,
    0 -9px 12px -9px rgba(90, 70, 140, .5) inset,
    0 5px 0 #b9b1d2,
    0 8px 14px rgba(0,0,0,.4);
  color: #35305a;
}

.key.black {
  position: absolute;
  top: 0;
  height: 100%;
  pointer-events: auto;
  border-radius: 3px 3px 8px 8px;
  background: var(--black-key);
  box-shadow:
    0 -1px 0 rgba(255,255,255,.16) inset,
    0 5px 0 #05040c,
    0 9px 16px rgba(0,0,0,.6);
  color: #efeaff;
  padding-bottom: clamp(6px, 1vh, 12px);
  z-index: 2;
}

/* 누른 상태 */
.key.white.on {
  background: var(--white-key-on);
  transform: translateY(3px);
  box-shadow:
    0 -10px 16px -10px rgba(255, 160, 40, .55) inset,
    0 2px 0 #b9b1d2,
    0 4px 10px rgba(0,0,0,.4);
}
.key.black.on {
  background: var(--black-key-on);
  transform: translateY(3px);
  box-shadow:
    0 -1px 0 rgba(255,255,255,.3) inset,
    0 2px 0 #05040c,
    0 4px 12px rgba(0,0,0,.6);
}
/* 계이름 색이 켜져 있으면 누른 건반이 그 계이름 색으로 물든다 */
.key.white.on.colored {
  /* 색 층을 불투명한 흰건반 위에 덧씌운다 (아래 판이 비치지 않도록) */
  background:
    linear-gradient(180deg, rgba(var(--solfa-rgb), 0) 38%, rgba(var(--solfa-rgb), .18) 62%, rgba(var(--solfa-rgb), .62) 100%),
    var(--white-key);
  box-shadow:
    0 0 0 2px rgba(var(--solfa-rgb), .75) inset,
    0 0 26px -4px rgba(var(--solfa-rgb), .8),
    0 2px 0 #b9b1d2,
    0 4px 10px rgba(0,0,0,.4);
}
.key.black.on.colored {
  background:
    linear-gradient(180deg, rgba(var(--solfa-rgb), .95) 0%, rgba(var(--solfa-rgb), .55) 100%),
    var(--black-key-on);
  box-shadow:
    0 0 0 1.5px rgba(var(--solfa-rgb), .9) inset,
    0 0 26px -4px rgba(var(--solfa-rgb), .85),
    0 2px 0 #05040c,
    0 4px 12px rgba(0,0,0,.6);
}
.key.black.on.colored .key-label { color: #1a1330; }

.key-label {
  font-size: clamp(14px, 2.3vw, 30px);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.1;
  pointer-events: none;
  transition: color .15s, opacity .15s;
}
.key.white .key-label { color: #3b3566; }
.key.black .key-label { font-size: clamp(11px, 1.6vw, 21px); color: #f2eeff; }
.key.colored .key-label { color: var(--solfa); }

/* 계이름 색을 켜면 흰건반 아래에 색 띠가 생겨 멀리서도 구분된다 */
.key.white.colored::after {
  content: '';
  position: absolute;
  left: 12%; right: 12%;
  bottom: 5px;
  height: 4px;
  border-radius: 3px;
  background: var(--solfa);
  opacity: .85;
}

.key-sub {
  margin-top: 3px;
  font-size: clamp(9px, 1vw, 12px);
  font-weight: 700;
  opacity: .5;
  pointer-events: none;
}
.key.white .key-sub { color: #5b5486; }
.key.black .key-sub { color: #cfc7ee; }

/* 조성에 없는 음(임시표가 붙는 음)은 흐리게 */
.key.out-of-key .key-label { opacity: .34; }
.key.out-of-key.white { filter: saturate(.5) brightness(.965); }
.key.out-of-key.white.colored::after { opacity: .2; }
.key.out-of-key.black { filter: brightness(.82); }

/* 누를 때 퍼지는 빛 */
.key-spark {
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 8px; height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--solfa, #ffd66b) 0%, rgba(255,214,107,0) 70%);
  pointer-events: none;
  animation: spark .5s ease-out forwards;
}
@keyframes spark {
  from { transform: scale(1); opacity: .85; }
  to   { transform: scale(14); opacity: 0; }
}

/* 누른 음 이름이 위로 떠오르는 표시 */
.float-layer {
  position: absolute;
  left: 12px; right: 12px;
  top: 0;
  height: 0;
  pointer-events: none;
  z-index: 5;
}
.float-pill {
  position: absolute;
  transform: translate(-50%, 0);
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(20, 16, 45, .92);
  border: 1.5px solid var(--solfa, #ffc93c);
  color: var(--solfa, #ffc93c);
  font-size: clamp(14px, 1.8vw, 20px);
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
  animation: floatUp .85s cubic-bezier(.2,.7,.3,1) forwards;
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, 8px) scale(.8); }
  22%  { opacity: 1; transform: translate(-50%, -12px) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -48px) scale(1); }
}

.hint-bar {
  margin: 0;
  padding: 0 clamp(12px, 2vw, 22px) 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  text-align: center;
}

/* ------------------------------------------------------- 설정 / 도움말 */

.sheet-backdrop, .modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 20, .62);
  backdrop-filter: blur(3px);
  z-index: 40;
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #241d4c 0%, #191338 100%);
  border-left: 1px solid var(--panel-line);
  box-shadow: -20px 0 60px rgba(0,0,0,.55);
  animation: slideIn .22s cubic-bezier(.2,.8,.3,1);
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.modal {
  position: fixed;
  z-index: 50;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 92vw);
  max-height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(180deg, #241d4c 0%, #191338 100%);
  border: 1px solid var(--panel-line);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
  animation: popIn .2s cubic-bezier(.2,.8,.3,1);
}
@keyframes popIn { from { opacity: 0; transform: translate(-50%,-50%) scale(.94); } to { opacity: 1; transform: translate(-50%,-50%) scale(1); } }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--panel-line);
  flex: none;
}
.sheet-head h2 { margin: 0; font-size: 19px; font-weight: 800; }
.close-btn {
  width: 42px; height: 42px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}
.close-btn:active { background: rgba(255,255,255,.16); }

.sheet-body {
  padding: 6px 20px 26px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.opt { padding: 16px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.opt:last-child { border-bottom: 0; }
.opt h3 { margin: 0 0 10px; font-size: 14px; font-weight: 800; color: var(--text); }
.opt-help { margin: 8px 0 0; font-size: 13.5px; line-height: 1.65; color: var(--text-dim); }
.opt-help b { color: var(--text); }

.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row span { font-size: 13px; font-weight: 700; color: var(--text-dim); flex: none; }
input[type="range"] {
  flex: 1;
  height: 34px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px;
  background: rgba(255,255,255,.16);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  margin-top: -9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
input[type="range"]::-moz-range-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,.16); }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--accent); }

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  position: relative;
  width: 52px; height: 30px;
  flex: none;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  transition: background .18s;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(22px); }
.switch-text { font-size: 15px; font-weight: 600; }

.ghost-btn {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.ghost-btn:active { background: rgba(255,255,255,.16); }

/* ---------------------------------------------------------------- 시작화면 */

.splash {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 20px 18px;
  text-align: center;
  background:
    radial-gradient(90% 60% at 50% -8%, #4b3aa8 0%, rgba(75,58,168,0) 62%),
    radial-gradient(70% 50% at 88% 108%, #6b2f8f 0%, rgba(107,47,143,0) 62%),
    linear-gradient(180deg, #1b1540 0%, #100d26 100%);
}
.splash.hide { opacity: 0; pointer-events: none; transition: opacity .35s; }

.splash-main {
  margin: auto;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 16px;
}

.splash-logo { width: 76px; height: 76px; filter: drop-shadow(0 10px 26px rgba(0,0,0,.6)); }
.splash h2 {
  margin: 14px 0 0;
  font-size: clamp(26px, 6vw, 36px);
  font-weight: 800;
  letter-spacing: -.03em;
}
.splash-tag { margin: 6px 0 0; color: var(--text-dim); font-size: 15px; }

/* 앱을 한눈에 보여 주는 작은 건반 그림 */
.splash-keys {
  position: relative;
  width: min(420px, 84vw);
  height: clamp(86px, 24vw, 110px);
  margin: 26px 0 24px;
  filter: drop-shadow(0 18px 34px rgba(0,0,0,.55));
}
.sk-whites { display: flex; gap: 3px; height: 100%; }
.sk-whites span {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 9px;
  border-radius: 4px 4px 9px 9px;
  background: linear-gradient(180deg, #ffffff 0%, #efecf9 100%);
  color: var(--k);
  font-size: clamp(13px, 3.4vw, 16px);
  font-weight: 800;
  box-shadow: 0 4px 0 #b9b1d2;
}
.sk-blacks { position: absolute; left: 0; right: 0; top: 0; height: 62%; }
.sk-blacks i {
  position: absolute;
  top: 0;
  width: 9.4%;
  height: 100%;
  border-radius: 3px 3px 6px 6px;
  background: linear-gradient(180deg, #3b3552 0%, #100d1c 100%);
  box-shadow: 0 4px 0 #05040c;
}
.sk-note {
  position: absolute;
  font-style: normal;
  color: var(--accent);
  opacity: .85;
  text-shadow: 0 4px 14px rgba(255,201,60,.55);
  animation: floatNote 4.5s ease-in-out infinite;
}
.sk-note.n1 { left: -6%;  top: -28%; font-size: 26px; animation-delay: 0s; }
.sk-note.n2 { right: -4%; top: -38%; font-size: 32px; animation-delay: 1.3s; color: #ff8fb0; text-shadow: 0 4px 14px rgba(255,143,176,.5); }
.sk-note.n3 { right: 16%; top: -20%; font-size: 20px; animation-delay: 2.6s; color: #7fd4ff; text-shadow: 0 4px 14px rgba(127,212,255,.5); }
@keyframes floatNote {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-12px) rotate(5deg); }
}

.splash-feats {
  list-style: none;
  margin: 0 0 26px;
  padding: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  text-align: left;
}
.splash-feats li {
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 13px;
  background: rgba(255,255,255,.06);
}
.splash-feats b { display: block; font-size: 14.5px; font-weight: 800; margin-bottom: 3px; }
.splash-feats span { font-size: 12px; line-height: 1.5; color: var(--text-dim); }

.start-btn {
  min-height: 62px;
  padding: 0 46px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffd463 0%, #ffa93c 100%);
  color: #2a1c04;
  font-family: inherit;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(255, 169, 60, .36);
}
.start-btn:active { transform: scale(.97); }
.splash-hint { margin: 14px 0 0; font-size: 12.5px; color: var(--text-dim); }

.splash-foot {
  width: 100%;
  max-width: 620px;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-dim);
}
.splash-foot p { margin: 0; }
.splash-foot b { color: var(--text); }
.splash-foot a { color: var(--text-dim); }
.foot-copy { margin-top: 2px !important; opacity: .8; }
.foot-links { margin-top: 8px !important; display: flex; justify-content: center; gap: 10px; align-items: center; }
.link-btn {
  border: 0;
  background: none;
  padding: 6px 2px;
  color: var(--accent);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

@media (max-width: 520px) {
  .splash-feats { grid-template-columns: 1fr; }
  .splash-keys { margin: 20px 0 18px; }
}
@media (max-height: 620px) {
  .splash-logo { width: 54px; height: 54px; }
  .splash-keys { height: 72px; margin: 16px 0 16px; }
  .splash-feats { margin-bottom: 18px; }
  .splash-feats li { padding: 9px 12px; }
  .start-btn { min-height: 54px; font-size: 18px; }
  .splash-hint { display: none; }
}

.rotate-hint {
  position: fixed;
  left: 50%; top: 30%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(255, 201, 60, .94);
  color: #2c1f02;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}


/* ------------------------------------------------------------- 화음 막대 */

.chordbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 0 clamp(12px, 2vw, 22px) 8px;
}

.chord-pads {
  display: flex;
  gap: 6px;
  flex: 1 1 420px;
  min-width: 0;
}

.chord-pad {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 58px;
  padding: 4px 2px;
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, transform .06s;
}
.chord-pad .pad-solfa { font-size: clamp(15px, 1.8vw, 19px); font-weight: 800; line-height: 1.1; }
.chord-pad .pad-role  { font-size: 10px; font-weight: 800; color: var(--accent); line-height: 1.2; }
.chord-pad .pad-name  { font-size: 11.5px; font-weight: 700; color: var(--text-dim); line-height: 1.2; }
.chord-pad.primary {
  background: rgba(255, 201, 60, .13);
  border-color: rgba(255, 201, 60, .42);
}
.chord-pad.on {
  background: linear-gradient(180deg, #fff 0%, #ece7ff 100%);
  color: #241c4d;
  transform: translateY(2px);
  box-shadow: 0 0 18px -2px rgba(255, 201, 60, .7);
}
.chord-pad.on .pad-name { color: #5a5280; }
.chord-pad.on .pad-role { color: #9a6b00; }

.chord-side { display: flex; align-items: center; gap: 8px; flex: none; }
.toggle-btn.accomp { min-height: 44px; }

#patternSelect {
  appearance: none;
  -webkit-appearance: none;
  min-height: 44px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%23bdb4e6' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center / 11px 7px;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
}
#patternSelect option { background: #241e4a; color: #fff; }

.stepper.tempo .stepper-value { min-width: 62px; }

.stop-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.stop-btn span { font-size: 10px; }
.stop-btn:active { background: rgba(255,255,255,.18); }

/* 지금 울리는 화음에 속한 음을 건반 위쪽에 금색 띠로 표시 */
.key.chord-hint::before {
  content: '';
  position: absolute;
  left: 20%; right: 20%;
  top: 9px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(255, 201, 60, .95);
  pointer-events: none;
}
.key.black.chord-hint::before { left: 16%; right: 16%; top: 7px; height: 6px; }

/* ---------------------------------------------------------- 함께치기 */

.room {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 clamp(10px, 1.8vw, 22px) 6px;
  padding: 8px 12px;
  border: 1px solid rgba(139, 124, 246, .45);
  border-radius: 14px;
  background: rgba(139, 124, 246, .12);
}
.room-code {
  flex: none;
  padding: 5px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .14);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .14em;
  font-variant-numeric: tabular-nums;
}
.room-label { flex: none; font-size: 13px; font-weight: 700; color: var(--text-dim); }
.room-players { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; min-width: 0; }
.room-player {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.room-player i {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--who);
  box-shadow: 0 0 8px var(--who);
}
.room-player.me { background: rgba(255, 255, 255, .18); }
.room-state { flex: none; font-size: 12px; font-weight: 700; color: var(--text-dim); }
.room-state.bad { color: #ff9098; }
.room .toggle-btn, .room .stop-btn { min-height: 38px; }

.room-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid rgba(139, 124, 246, .5);
  border-radius: 13px;
  background: rgba(139, 124, 246, .15);
  color: #c3b8ff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  flex: none;
}
.room-btn:active { background: rgba(139, 124, 246, .3); }
.room-btn[aria-pressed="true"] { background: #7c6ae8; border-color: #7c6ae8; color: #120b33; }

.room-input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  margin-bottom: 8px;
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
}
.room-input.code {
  font-size: 24px;
  letter-spacing: .22em;
  text-align: center;
  text-transform: uppercase;
}
.round-btn.wide { width: 100%; }

/* 다른 사람이 누른 건반 */
.key.remote {
  box-shadow: 0 0 0 3px var(--who) inset, 0 0 24px -2px var(--who) !important;
}
.key.white.remote { background: linear-gradient(180deg, #ffffff 0%, #f2f0fb 55%, var(--who) 100%) !important; }
.key.black.remote { background: linear-gradient(180deg, var(--who) 0%, #1a1430 100%) !important; }

@media (max-height: 520px) {
  .room { margin: 0 8px 4px; padding: 5px 10px; gap: 7px; }
  .room-code { font-size: 14px; padding: 3px 9px; }
  .room-label { display: none; }
}

/* ------------------------------------------------------------ 따라치기 */

.along {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 clamp(10px, 1.8vw, 22px) 6px;
  padding: 8px 12px;
  border: 1px solid rgba(63, 191, 111, .4);
  border-radius: 14px;
  background: rgba(63, 191, 111, .1);
}
.along-tag { font-size: 15px; color: #3fbf6f; flex: none; }
.along-name {
  flex: none;
  max-width: 22vw;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.along-play {
  width: 44px; height: 40px;
  flex: none;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, #6fe6a0 0%, #2fae66 100%);
  color: #06301a;
  font-size: 15px;
  cursor: pointer;
}
.along-play:active { transform: scale(.95); }
.along .progress { height: 8px; }
.along .progress-fill { background: #3fbf6f; }
.along-time { font-size: 13px; font-weight: 800; color: var(--text-dim); font-variant-numeric: tabular-nums; flex: none; }
.along .stepper { flex: none; padding: 3px; }
.along .stepper button { width: 36px; height: 32px; }
.along .stepper-value { min-width: 52px; font-size: 13px; }
.along .stop-btn { min-height: 38px; }

.along-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid rgba(63, 191, 111, .42);
  border-radius: 13px;
  background: rgba(63, 191, 111, .12);
  color: #8fe6b4;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  flex: none;
}
.along-btn:active { background: rgba(63, 191, 111, .26); }
.along-btn[aria-pressed="true"] { background: #2fae66; border-color: #2fae66; color: #062e18; }

/* 지금 쳐야 할 건반 — 계이름 색 띠에 가리지 않도록 건반 전체를 물들인다 */
.key.white.guide {
  background: linear-gradient(180deg, #ffffff 0%, #d6f7e5 58%, #6fe0a0 100%) !important;
}
.key.black.guide {
  background: linear-gradient(180deg, #7bebac 0%, #219b56 100%) !important;
}
.key.guide {
  box-shadow: 0 0 0 2px rgba(47, 174, 102, .9) inset, 0 0 26px -2px rgba(63, 191, 111, .95) !important;
}
.key.black.guide .key-label { color: #06301a; }

.along-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  margin-bottom: 8px;
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  background: var(--panel);
  width: 100%;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.along-item b { flex: 1; font-size: 14.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.along-item span { font-size: 12px; color: var(--text-dim); flex: none; }

@media (max-height: 520px) {
  .along { margin: 0 8px 4px; padding: 5px 10px; gap: 7px; }
  .along-play { height: 34px; width: 38px; }
  .along-name { max-width: 16vw; font-size: 12.5px; }
}

/* -------------------------------------------------------- 코드 진행 */

.prog {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 clamp(10px, 1.8vw, 22px) 6px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 201, 60, .4);
  border-radius: 14px;
  background: rgba(255, 201, 60, .1);
}
.prog-tag { font-size: 14px; color: var(--accent); flex: none; }
.prog-bars { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.prog-bars::-webkit-scrollbar { display: none; }
.prog-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  flex: none;
  min-width: 56px;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .07);
  transition: background .12s, transform .12s;
}
.prog-step b { font-size: 14.5px; font-weight: 800; }
.prog-step span { font-size: 9.5px; color: var(--text-dim); }
.prog-step.now {
  background: linear-gradient(180deg, #ffd463 0%, #ffa93c 100%);
  color: #2a1c04;
  transform: scale(1.06);
  box-shadow: 0 0 18px -2px rgba(255, 169, 60, .85);
}
.prog-step.now span { color: #7a5200; }

.prog-presets { display: flex; flex-wrap: wrap; gap: 7px; }
.prog-presets button {
  flex: 1 1 130px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 52px;
  padding: 8px 12px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.prog-presets button b { font-size: 14px; font-weight: 800; }
.prog-presets button span { font-size: 11px; color: var(--text-dim); }
.prog-presets button:active { background: rgba(255,255,255,.16); }

/* 건반 화면에서 화음 단추를 바꿀 때 */
.pad-picker { margin: 0 clamp(10px, 1.8vw, 22px) 8px; }
.chord-pad.editing { border-color: rgba(255,201,60,.7); border-style: dashed; }

@media (max-height: 520px) {
  .prog { margin: 0 8px 4px; padding: 4px 10px; }
  .prog-step { min-width: 46px; padding: 3px 7px; }
  .prog-step b { font-size: 13px; }
  .prog-step span { display: none; }
}

/* -------------------------------------------------------------- 아래 줄 */

.bottombar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 clamp(12px, 2vw, 22px) 8px;
}
.bottombar .hint-bar { flex: 1; padding: 0; }

.rec-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid rgba(255, 90, 100, .45);
  border-radius: 13px;
  background: rgba(255, 90, 100, .14);
  color: #ff9098;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  flex: none;
}
.rec-btn .rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #ff4d5a; }
.rec-btn[aria-pressed="true"] {
  background: #ff4d5a;
  border-color: #ff4d5a;
  color: #fff;
  box-shadow: 0 0 20px -2px rgba(255, 77, 90, .8);
}
.rec-btn[aria-pressed="true"] .rec-dot { background: #fff; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: .25; } }

.rec-time {
  font-size: 15px;
  font-weight: 800;
  color: #ff9098;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.lib-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  flex: none;
}
.lib-btn b {
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #2a1c04;
  font-size: 12.5px;
}
.lib-btn:active { background: rgba(255,255,255,.16); }

/* --------------------------------------------------------- 내 연주 화면 */

.panel-backdrop { position: fixed; inset: 0; background: rgba(8,6,20,.6); z-index: 55; }

.panel {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #241d4c 0%, #16112f 100%);
  animation: popIn .18s cubic-bezier(.2,.8,.3,1);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.panel .sheet-head {
  padding-block: 16px 12px;
  padding-inline: max(clamp(16px, 3vw, 32px), calc((100% - 760px) / 2));
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* 가운데 760px 기둥에 맞춰 글도 단추도 같은 선에서 시작하게 한다 */
  padding-top: 8px;
  padding-bottom: 48px;
  padding-inline: max(clamp(16px, 3vw, 32px), calc((100% - 760px) / 2));
}

#libTools { flex: none; padding-bottom: 0; overflow: visible; }
.lib-tools {
  padding: 14px;
  margin-bottom: 12px;
  border: 1px dashed rgba(255, 201, 60, .35);
  border-radius: 14px;
  background: rgba(255, 201, 60, .06);
}
.lib-tools .opt-help { margin-top: 8px; }

.empty-note { padding: 48px 20px; text-align: center; color: var(--text-dim); font-size: 15px; line-height: 1.7; }

.rec-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  background: var(--panel);
}
.rec-item-main { flex: 1; min-width: 0; }
.rec-item-name { font-size: 15.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-item-meta { margin-top: 2px; font-size: 12px; color: var(--text-dim); }
.rec-item .round-btn { flex: none; }

.back-btn {
  min-height: 40px;
  padding: 0 14px;
  margin-bottom: 12px;
  border: 1px solid var(--panel-line);
  border-radius: 11px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.edit-name input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  background: rgba(255,255,255,.06);
  color: var(--text);
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
}

.player { display: flex; align-items: center; gap: 14px; padding: 16px 0 8px; }
.play-btn {
  width: 58px; height: 58px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd463 0%, #ffa93c 100%);
  color: #2a1c04;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(255,169,60,.3);
}
.play-btn:active { transform: scale(.95); }
.progress { flex: 1; height: 10px; border-radius: 999px; background: rgba(255,255,255,.14); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .1s linear; }
.player-time { font-size: 14px; font-weight: 800; color: var(--text-dim); font-variant-numeric: tabular-nums; flex: none; }

.note-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
  padding: 4px 2px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 0 0 10px;
  border: 1px solid var(--panel-line);
  border-radius: 11px;
  background: rgba(255,255,255,.07);
  font-size: 14px;
  font-weight: 800;
  color: var(--solfa, var(--text));
  overflow: hidden;
}
.chip.accomp { opacity: .58; }
.chip .chip-label { padding: 7px 2px 7px 0; cursor: pointer; }
.chip .chip-x {
  width: 26px;
  align-self: stretch;
  border: 0;
  border-left: 1px solid var(--panel-line);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}
.chip .chip-x:active { background: rgba(255,90,100,.35); color: #fff; }
.chips-more { padding: 8px 2px 0; font-size: 12.5px; color: var(--text-dim); }

/* ---------------------------------------------------------- 피아노롤 */

.roll-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}
.roll-zoom { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--panel-line); border-radius: 12px; background: var(--panel); }
.roll-zoom button {
  min-height: 38px;
  padding: 0 13px;
  border: 0;
  border-radius: 9px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
}
.roll-zoom button:active { background: rgba(255,255,255,.22); }

.roll-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 370px;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  background: #1a1538;
  overscroll-behavior: contain;
}
.roll-inner { display: flex; width: max-content; min-width: 100%; }

/* 왼쪽 계이름 칸은 옆으로 밀어도 따라온다 */
.roll-labels {
  position: sticky;
  left: 0;
  z-index: 5;
  flex: none;
  width: 54px;
  background: #221b47;
  border-right: 1px solid rgba(255,255,255,.12);
}
.roll-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--solfa, var(--text-dim));
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.roll-label.tonic { background: rgba(255,255,255,.07); }
.roll-label.spacer { border-bottom: 1px solid rgba(255,255,255,.14); }
.roll-label.accomp { font-size: 10.5px; color: var(--accent); opacity: .8; }

.roll-canvas { position: relative; flex: none; }

/* 시간 눈금 */
.roll-ruler {
  position: absolute;
  top: 0; left: 0;
  height: 26px;
  border-bottom: 1px solid rgba(255,255,255,.14);
}
.roll-tick {
  position: absolute;
  top: 0; bottom: 0;
  border-left: 1px solid rgba(255,255,255,.16);
  padding-left: 4px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-dim);
  line-height: 26px;
  pointer-events: none;
}

.roll-body { position: absolute; left: 0; }
.roll-row { position: absolute; left: 0; right: 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.roll-row.tonic { background: rgba(255,255,255,.055); }
.roll-row.black { background: rgba(0,0,0,.18); }

.roll-note {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding-right: 6px;
  font-size: 10.5px;
  font-weight: 800;
  color: rgba(0, 0, 0, .6);
  border-radius: 5px;
  background: var(--solfa, #8b7cf6);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.28), 0 1px 3px rgba(0,0,0,.4);
  cursor: grab;
  touch-action: none;
}
/* 오른쪽 끝을 잡으면 길이가 바뀐다는 표시 (좁은 막대에는 넣지 않는다) */
.roll-note::after {
  content: '';
  position: absolute;
  right: 2px; top: 26%; bottom: 26%;
  width: 2px;
  border-radius: 2px;
  background: rgba(0,0,0,.32);
}
.roll-note.narrow::after { display: none; }
.roll-note.narrow { font-size: 9.5px; }
.roll-note.sel {
  outline: 2.5px solid #fff;
  outline-offset: 1px;
  z-index: 4;
  box-shadow: 0 0 16px -2px var(--solfa, #fff);
}
.roll-note.dragging { cursor: grabbing; opacity: .9; }

/* 반주 칸 */
.roll-accomp { position: absolute; left: 0; border-top: 1px solid rgba(255,255,255,.14); background: rgba(255,201,60,.05); }
.roll-accomp-note { position: absolute; height: 5px; border-radius: 3px; background: rgba(255,201,60,.6); }

/* 잘려 나가는 구간 */
.roll-cut {
  position: absolute;
  top: 0; bottom: 0;
  z-index: 3;
  background: repeating-linear-gradient(135deg, rgba(10,7,24,.82) 0 7px, rgba(10,7,24,.66) 7px 14px);
  pointer-events: none;
}
.roll-cut.before { left: 0; }
.roll-cut.after { right: 0; }

.roll-handle {
  position: absolute;
  top: 0;
  width: 22px;
  height: 26px;
  z-index: 6;
  background: var(--accent);
  cursor: ew-resize;
  touch-action: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.roll-handle::after {
  content: '';
  position: absolute;
  top: 8px; bottom: 8px;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: rgba(0,0,0,.45);
}
.roll-handle.start { border-radius: 6px 0 8px 0; transform: translateX(-22px); }
.roll-handle.end { border-radius: 0 6px 0 8px; }

.roll-head {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 10px rgba(255,255,255,.9);
  z-index: 5;
  pointer-events: none;
}

.roll-empty { padding: 40px 16px; text-align: center; color: var(--text-dim); font-size: 14px; }

.roll-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(255,201,60,.35);
  border-radius: 13px;
  background: rgba(255,201,60,.08);
}
.roll-actions .round-btn { min-height: 42px; padding: 0 13px; font-size: 14px; }
.roll-actions .round-btn.danger { color: #ff9098; border-color: rgba(255,90,100,.45); }
.roll-sel {
  min-width: 58px;
  padding: 0 10px;
  font-size: 16px;
  font-weight: 800;
  color: var(--solfa, var(--accent));
}

@media (max-width: 620px) {
  .roll-wrap { max-height: 300px; }
  .roll-actions .round-btn { flex: 1 1 auto; }
}

/* ------------------------------------------------- 녹음에 반주 넣기 */

.acc-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.acc-field { display: flex; flex-direction: column; gap: 5px; }
#accPattern {
  appearance: none;
  -webkit-appearance: none;
  min-height: 46px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%23bdb4e6' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center / 11px 7px;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
}
#accPattern option { background: #241e4a; color: #fff; }

.bar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.bar-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 62px;
  min-height: 52px;
  padding: 6px 8px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}
.bar-chip .bar-no { font-size: 10px; font-weight: 700; color: var(--text-dim); }
.bar-chip .bar-name { font-size: 15px; font-weight: 800; }
.bar-chip .bar-solfa { font-size: 10px; font-weight: 700; color: var(--text-dim); }
.bar-chip.primary { border-color: rgba(255, 201, 60, .42); background: rgba(255, 201, 60, .1); }
.bar-chip.sel {
  background: linear-gradient(180deg, #fff 0%, #ece7ff 100%);
  color: #241c4d;
  box-shadow: 0 0 16px -3px rgba(255, 201, 60, .8);
}
.bar-chip.sel .bar-no, .bar-chip.sel .bar-solfa { color: #5a5280; }

.chord-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 201, 60, .35);
  border-radius: 13px;
  background: rgba(255, 201, 60, .08);
}
.chord-picker { flex-direction: column; align-items: stretch; }
.chord-picker .pick-label { font-size: 12.5px; font-weight: 700; color: var(--text-dim); margin: 2px 0; }
.pick-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-row.tight { gap: 5px; }
.chord-picker button {
  flex: 1 1 0;
  min-width: 58px;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid var(--panel-line);
  border-radius: 11px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}
.chord-picker button b { font-size: 14px; font-weight: 800; }
.chord-picker button span { font-size: 10px; color: var(--text-dim); }
.chord-picker button.primary { border-color: rgba(255, 201, 60, .45); background: rgba(255, 201, 60, .12); }
.chord-picker button.on { background: linear-gradient(180deg, #fff 0%, #ece7ff 100%); color: #241c4d; }
.chord-picker button.on span { color: #5a5280; }

/* 자세히 고르기: 밑음과 종류 */
.chord-picker button.small { min-width: 52px; min-height: 44px; flex: 1 1 52px; }
.chord-picker button.small b { font-size: 13px; }
.chord-picker button.small span { font-size: 9.5px; }
.chord-picker button.small.inkey { border-color: rgba(255,255,255,.26); }
.chord-picker button.small:not(.inkey):not(.on) b { opacity: .55; }

.pick-more {
  width: 100%;
  min-height: 40px;
  margin-top: 4px;
  border: 1px solid var(--panel-line);
  border-radius: 11px;
  background: rgba(255,255,255,.06);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.pick-more:active { background: rgba(255,255,255,.16); }

.round-btn.go {
  background: linear-gradient(135deg, #ffd463 0%, #ffa93c 100%);
  border-color: transparent;
  color: #2a1c04;
  font-weight: 800;
}

/* 피아노롤 위의 마디 구분선 */
.roll-bar {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: rgba(255, 201, 60, .3);
  pointer-events: none;
}
.roll-bar span {
  position: absolute;
  top: 1px; left: 3px;
  font-size: 9.5px;
  font-weight: 800;
  color: rgba(255, 201, 60, .8);
}

.edit-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.edit-value { min-width: 92px; text-align: center; font-size: 15px; font-weight: 800; }

.round-btn {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
}
.round-btn:active { background: rgba(255,255,255,.18); }
.round-btn.ghost { color: var(--text-dim); }

.switch.small .switch-text { font-size: 13.5px; }

.export-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.export-btn {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px;
  border-radius: 14px;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}
.export-btn b { font-size: 15.5px; }
.export-btn em { font-style: normal; font-size: 11.5px; color: var(--text-dim); line-height: 1.4; }
.export-btn.midi { background: rgba(139,124,246,.16); border: 1px solid rgba(139,124,246,.45); }
.export-btn.mp3  { background: rgba(63,191,111,.16); border: 1px solid rgba(63,191,111,.45); }
.export-btn:active { transform: scale(.98); }
.export-btn[disabled] { opacity: .45; }

.work { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.work span { font-size: 13px; color: var(--text-dim); flex: none; }

.ghost-btn.danger { margin-top: 8px; color: #ff9098; border-color: rgba(255,90,100,.4); }

.inst-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.inst-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 54px;
  padding: 6px 4px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text-dim);
  font-family: inherit;
  cursor: pointer;
}
.inst-btn b { font-size: 15px; font-weight: 700; }
.inst-state { font-size: 9.5px; font-weight: 700; letter-spacing: -.01em; }
.inst-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, #fff 0%, #ece7ff 100%);
  color: #241c4d;
}
/* 진짜 녹음 소리가 준비되면 초록, 받는 중이면 노랑 */
.inst-btn.real .inst-state { color: #3fbf6f; }
.inst-btn[aria-pressed="true"].real .inst-state { color: #1f8f4a; }
.inst-btn.loading .inst-state { color: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.inst-btn[aria-pressed="true"].loading .inst-state { color: #a06a00; }
@keyframes pulse { 50% { opacity: .35; } }

/* 방침·출처 창은 시작 화면 위에서도 열려야 한다 */
#infoBackdrop { z-index: 99; }
#infoModal { z-index: 100; }

.countin {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 7, 24, .42);
  color: #fff;
  font-size: clamp(80px, 20vw, 210px);
  font-weight: 800;
  letter-spacing: -.04em;
  text-shadow: 0 10px 44px rgba(0, 0, 0, .75);
  pointer-events: none;
}
.countin.pop { animation: countPop .45s cubic-bezier(.2,.8,.3,1); }
@keyframes countPop {
  from { transform: scale(1.6); opacity: 0; }
  60%  { transform: scale(.96); opacity: 1; }
  to   { transform: scale(1); opacity: 1; }
}

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 120;
  max-width: min(560px, 90vw);
  padding: 13px 22px;
  border-radius: 999px;
  background: rgba(20, 16, 45, .96);
  border: 1px solid var(--panel-line);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: popIn .16s ease-out;
}

/* ---------------------------------------------------------------- 반응형 */

/* 화면이 좁을 때: 글자와 여백을 줄이고 조작줄을 두 줄로 */
@media (max-width: 860px) {
  .brand-text p { display: none; }
  .icon-btn em { display: none; }
  .icon-btn { padding: 0 12px; }
  .field-label { font-size: 11px; }
  .seg button { padding: 0 10px; font-size: 13.5px; }
  .stepper-value { min-width: 66px; font-size: 13.5px; }
  .hint-bar { display: none; }
  .chord-pad .pad-role { display: none; }
  .chord-pad { min-height: 50px; }
  .export-row { grid-template-columns: 1fr; }
}

/* 세로로 짧은 화면(태블릿 가로, 노트북): 위쪽 여백을 더 줄여 건반을 키운다 */
@media (max-height: 560px) {
  .topbar { padding: 6px 14px 2px; }
  .brand-logo { width: 30px; height: 30px; }
  .brand-text h1 { font-size: 16px; }
  .brand-text p { display: none; }
  .toolbar { padding: 2px 14px 6px; gap: 10px; }
  .stage { margin: auto 10px 6px; padding: 12px 10px 10px; }
  .hint-bar { display: none; }
  .chordbar { padding: 0 14px 5px; gap: 7px; }
  .chord-pad { min-height: 44px; }
  .chord-pad .pad-role { display: none; }
  .chord-pad .pad-name { font-size: 10.5px; }
  .bottombar { padding: 0 14px 5px; }
}

@media (max-width: 560px) {
  .toolbar { gap: 8px; }
  .key-badge { display: none; }
}

/* 세로가 아주 짧은 화면(핸드폰 가로 등):
   조작줄이 두 줄로 접히면 건반이 사라진다. 접지 말고 옆으로 밀어 보게 한다. */
@media (max-height: 520px) {
  .topbar { padding: 4px 12px 2px; }
  .brand-logo { width: 26px; height: 26px; }
  .brand-text h1 { font-size: 15px; }
  .icon-btn { min-height: 38px; padding: 0 10px; }

  .toolbar, .chordbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .toolbar::-webkit-scrollbar, .chordbar::-webkit-scrollbar { display: none; }
  .toolbar > .field, .chord-side { flex: none; }

  #keySelect, .seg button, .stepper button, .toggle-btn, #patternSelect { min-height: 36px; }
  .seg { border-radius: 11px; padding: 3px; }
  .stop-btn { min-height: 36px; padding: 0 10px; font-size: 13px; }

  .chord-pads { flex: 1 0 auto; }
  .chord-pad { min-height: 38px; min-width: 54px; padding: 2px; }
  .chord-pad .pad-solfa { font-size: 14px; }

  .stage { margin: auto 8px 4px; padding: 10px 8px 8px; min-height: 132px; }
  .kb::before { top: -7px; height: 5px; }
  .bottombar { padding: 0 12px 4px; }
  .rec-btn, .lib-btn { min-height: 38px; padding: 0 12px; font-size: 13.5px; }
  .key-badge { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
