/* 键盘钢琴 · 深色主题（沿用本仓设计 tokens，与扫雷/棋类站同族） */
:root { --kbd-h: clamp(150px, 26vh, 215px); }
  body {
    --bgA: #1e3a5f;      --bgB: #0f172a;
    --card: #1e293b;     --panel: #0f172a;
    --glass: rgba(30, 41, 59, .85);
    --border: rgba(148,163,184,.15);
    --border2: rgba(148,163,184,.3);
    --accent: #10b981;   --accentH: #34d399;
    --btnText: #062a1e;
    --btn2: #334155;     --btn2h: #475569;
    --bad: #f87171;
    --text: #e2e8f0;     --muted: #94a3b8;
    --shadowBar: 0 8px 24px rgba(0,0,0,.35);
    --shadowPanel: 0 12px 40px rgba(0,0,0,.5);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  /* 触屏：消除双击缩放判定带来的点击延迟 */
  button, select, input { touch-action: manipulation; }
  body {
    font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
    background: radial-gradient(1200px 800px at 50% -10%, var(--bgA) 0%, var(--bgB) 55%) fixed;
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: safe center;
    padding: 4px 12px;
    color: var(--text);
    user-select: none; -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  h1 {
    font-size: 19px; letter-spacing: 1px; margin-right: 6px; white-space: nowrap;
    background: linear-gradient(90deg, #34d399, #60a5fa);
    -webkit-background-clip: text; background-clip: text; color: transparent;
  }
  .zl-home {
    font-style: italic; font-weight: 900; font-size: 18px; line-height: 1;
    white-space: nowrap; text-decoration: none; padding: 0 1px;
    background: linear-gradient(90deg, #34d399, #60a5fa);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    transition: filter .15s;
  }
  .zl-home:hover { filter: brightness(1.3) drop-shadow(0 0 6px var(--accent)); }

  /* ---------- 工具栏 ---------- */
  .toolbar {
    background: var(--glass); backdrop-filter: blur(6px);
    border: 1px solid var(--border); border-radius: 12px;
    padding: 12px 16px; margin-bottom: 8px;
    display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center;
    max-width: 1100px; width: 100%;
    box-shadow: var(--shadowBar);
    font-size: 13px;
  }
  button.ui {
    font-size: 13px; padding: 7px 11px;
    background: var(--accent); color: var(--btnText); font-weight: 700;
    border: none; border-radius: 7px; cursor: pointer;
    transition: background .15s, transform .1s;
  }
  button.ui:hover { background: var(--accentH); }
  button.ui:active { transform: scale(.96); }
  button.ui.secondary { background: var(--btn2); color: var(--text); font-weight: 600; }
  button.ui.secondary:hover { background: var(--btn2h); }
  button.ui.on { background: var(--accent); color: var(--btnText); }
  button.ui:disabled { opacity: .45; cursor: not-allowed; transform: none; }
  button.ui.danger { background: #b91c1c; color: #fff; }
  button.ui.danger:hover { background: #dc2626; }
  button:focus-visible, input:focus-visible { outline: 2px solid var(--accentH); outline-offset: 2px; }

  /* 标注切换（分段按钮） */
  .seg { display: inline-flex; border: 1px solid var(--border2); border-radius: 7px; overflow: hidden; }
  .seg button { border-radius: 0 !important; }
  .seg button + button { border-left: 1px solid var(--border2); }
  /* 布局选择 + 键位编辑入口 */
  .layout-ctl { display: inline-flex; align-items: center; gap: 8px; }
  select.ui {
    font-size: 13px; padding: 7px 8px; font-weight: 600;
    background: var(--btn2); color: var(--text);
    border: none; border-radius: 7px; cursor: pointer;
    font-family: inherit;
  }
  select.ui:hover { background: var(--btn2h); }

  .oct { display: inline-flex; align-items: center; gap: 6px; }
  .oct button { padding: 7px 10px; }
  #octShow {
    min-width: 30px; text-align: center; font-weight: 700;
    font-family: Consolas, monospace; color: var(--text);
  }
  .vol { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
  .vol input[type=range] { width: 92px; accent-color: var(--accent); cursor: pointer; }

  /* ---------- 舞台 ---------- */
  main { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 10px; }
  .stage { display: flex; flex-direction: column; gap: 10px; }
  .kb-frame {
    background: linear-gradient(#26344a, #1a2536);
    border: 1px solid var(--border2); border-radius: 14px;
    padding: 10px 10px 13px;
    box-shadow: var(--shadowPanel);
  }
  .felt {
    height: 5px; border-radius: 4px 4px 0 0;
    background: linear-gradient(#c53030, #7f1d1d);
    margin-bottom: 2px;
  }
  #kb {
    position: relative; display: flex;
    height: var(--kbd-h);
    touch-action: none;          /* 弹奏手势归页面，浏览器不抢 */
    user-select: none; -webkit-user-select: none;
  }
  .k { position: relative; cursor: pointer; }
  .k.w {
    background: linear-gradient(#fdfefe 0%, #eef2f7 82%, #dbe3ec 100%);
    border: 1px solid #8fa0b3; border-left: none;
    border-radius: 0 0 7px 7px;
    box-shadow: inset 0 -7px 9px -6px rgba(15,23,42,.5);
    transition: background .05s;
  }
  .k.w:first-child { border-left: 1px solid #8fa0b3; border-radius: 0 0 8px 8px; }
  .k.w.on {
    background: linear-gradient(#d9f5ea 0%, #b9e8d5 90%, #a3ddc6 100%);
    box-shadow: inset 0 3px 7px rgba(15,23,42,.28), inset 0 -6px 10px -6px rgba(16,185,129,.55);
  }
  .k.b {
    position: absolute; top: 0;
    z-index: 2; height: 62%;
    background: linear-gradient(#435062 0%, #2a3547 8%, #101623 78%, #05080e 100%);
    border: 1px solid #000; border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 5px 7px rgba(0,0,0,.55), inset 0 -9px 12px -8px rgba(255,255,255,.28);
    transition: background .05s;
  }
  .k.b.on {
    background: linear-gradient(#1d2736 0%, #0d1320 80%);
    box-shadow: inset 0 2px 5px rgba(0,0,0,.6), inset 0 -6px 10px -6px rgba(16,185,129,.6);
  }
  .lbl {
    position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
    font-size: 11px; line-height: 1; color: #5b6b80;
    pointer-events: none; white-space: nowrap;
  }
  .k.w.on .lbl { color: #2f6f57; }
  .k.b .lbl { color: #a9bad0; bottom: 7px; font-size: 10px; }
  .lbl.jp { font-size: 15px; font-weight: 700; color: #46566c; }
  .k.b .lbl.jp { color: #a9bad0; }
  .lbl i { position: absolute; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
  .lbl i.hi { top: -7px; }
  .lbl i.lo { bottom: -7px; }
  /* 组合键（⇧T）与音名（C#4）标注：字符多，缩小防溢出 */
  .lbl.combo { font-size: 9px; }
  .k.b .lbl.combo { font-size: 8.5px; }
  .lbl.nn { font-family: Consolas, monospace; font-size: 9.5px; }
  .k.b .lbl.nn { font-size: 8.5px; }

  /* 键位编辑态：琴键进入可点选状态，选中的琴键蓝色描边 */
  body.editing .k.w:hover { background: linear-gradient(#e8f1fd 0%, #d7e6f9 90%); }
  body.editing .k.b:hover { background: linear-gradient(#2c3a52 0%, #131c2e 80%); }
  .k.sel { box-shadow: 0 0 0 3px #60a5fa, 0 0 14px rgba(96, 165, 250, .75) !important; z-index: 3; }
  body.editing .key-hint { color: var(--text); }
  .key-hint .ui { margin-left: 10px; padding: 4px 10px; font-size: 12px; }

  .key-hint { text-align: center; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
  .key-hint b { color: var(--text); font-family: Consolas, monospace; }

  /* ---------- 电脑键盘图（跟弹指示灯，108 键全尺寸分区） ---------- */
  .kbdk-wrap {
    background: var(--glass); backdrop-filter: blur(6px);
    border: 1px solid var(--border); border-radius: 12px;
    padding: 10px 12px; box-shadow: var(--shadowBar);
  }
  .kbdk { display: flex; flex-direction: column; gap: 6px; }
  .pc-row { display: flex; gap: 5px; }
  .pc-top .pc-k { height: 30px; }
  .pc-top .grp { margin-left: 10px; }
  .pc-body { display: flex; gap: 10px; align-items: stretch; }
  .pc-main { flex: 14.6 1 0; display: flex; flex-direction: column; gap: 5px; }
  .pc-mid { flex: 3.3 1 0; display: flex; flex-direction: column; gap: 12px; }
  .pc-edit { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
  .pc-arrows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: auto; }
  .pc-pad { flex: 4.4 1 0; display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 40px; gap: 5px; align-content: start; }
  .pc-pad .pc-k { height: auto; }   /* 高度交给 grid 行高，+ / Enter 才能跨两行 */
  .pc-k {
    flex: 1 1 0; min-width: 0; height: 40px; border-radius: 6px;
    background: linear-gradient(#2c394d, #212c3d);
    border: 1px solid rgba(148,163,184,.18); border-bottom-width: 2px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    line-height: 1; transition: background .05s;
  }
  .pc-k .ch { font-size: 9px; color: var(--muted); font-family: Consolas, monospace; }
  .pc-k .nt { font-size: 10.5px; font-weight: 700; color: var(--text); font-family: Consolas, monospace; }
  .pc-k .sh { font-size: 8px; color: var(--muted); font-family: Consolas, monospace; }
  .pc-k.dim { opacity: .45; }
  .pc-k.on {
    background: linear-gradient(#0f9d6f, #0b7d59);
    border-color: #34d399;
  }
  .pc-k.on .ch, .pc-k.on .sh { color: #d3fae8; }
  .pc-k.on .nt { color: #fff; }
  .pc-k.sel { border-color: #60a5fa; box-shadow: 0 0 0 2px rgba(96,165,250,.7); }

  /* ---------- 录音 / 曲目 ---------- */
  .panel {
    background: var(--glass);
    border: 1px solid var(--border); border-radius: 12px;
    padding: 10px 16px;
    display: flex; flex-wrap: wrap; gap: 8px 26px; align-items: center;
    box-shadow: var(--shadowBar); font-size: 13px;
  }
  .pgroup { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .pgroup h2 { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: 1px; }
  .rec-time { font-family: Consolas, monospace; color: var(--accentH); min-width: 44px; font-size: 12.5px; }
  .chip { min-width: 64px; }

  /* ---------- 响应式 ---------- */
  @media (max-width: 640px) {
    :root { --kbd-h: clamp(132px, 21vh, 170px); }
    body { padding: 4px 8px; }
    .toolbar { padding: 8px 10px; gap: 8px 10px; }
    h1 { font-size: 17px; }
    select.ui { padding: 7px 6px; }
    .vol input[type=range] { width: 74px; }
    .kb-frame { padding: 7px 7px 10px; border-radius: 11px; }
    .panel { padding: 8px 10px; gap: 8px 16px; }
    .key-hint { font-size: 12px; }
    .lbl { font-size: 10px; bottom: 5px; }
    .lbl.jp { font-size: 13px; }
    .k.b .lbl { font-size: 9px; }
    .kbdk-wrap { padding: 7px 8px; }
    .kbdk { gap: 4px; }
    .pc-row, .pc-main, .pc-edit, .pc-arrows, .pc-pad { gap: 3px; }
    .pc-body { gap: 5px; }
    .pc-k { height: 32px; border-radius: 5px; }
    .pc-pad { grid-auto-rows: 32px; }
    .pc-top .pc-k { height: 24px; }
    .pc-top .grp { margin-left: 5px; }
    .pc-k .ch { font-size: 7.5px; }
    .pc-k .nt { font-size: 9px; }
    .pc-k .sh { display: none; }   /* 窄屏键帽放不下 Shift 音小字 */
    .pc-mid { gap: 8px; }
  }
  /* 触屏为主、且没有鼠标的设备：电脑键盘相关控件与提示无意义，收起 */
  @media (hover: none) and (pointer: coarse) {
    .oct, .key-hint, .layout-ctl, .kbdk-wrap { display: none; }
  }
