/* hidden 属性はUA既定の [hidden]{display:none} で効くが、
   クラス側で display を指定すると後勝ちで打ち消される。
   .suggest や .formgrid label がこれに当たり、hidden を付けても消えなかった。 */
[hidden] { display: none !important; }

:root {
    --bg:#16181d; --panel:#1e2128; --card:#232730; --line:#2f333d;
    --fg:#e6e8ec; --muted:#9aa1ad; --accent:#5b8def; --ok:#4caf7d; --danger:#e05561;
  }
  * { box-sizing:border-box; }
  body { margin:0; background:var(--bg); color:var(--fg);
         font:14px/1.6 system-ui,"Noto Sans JP",sans-serif; }
  header { padding:10px 18px; border-bottom:1px solid var(--line);
           display:flex; align-items:center; gap:14px; flex-wrap:wrap;
           position:sticky; top:0; background:var(--bg); z-index:10; }
  h1 { font-size:16px; margin:0; }
  .tabs { display:flex; gap:4px; }
  .tabs button { background:transparent; border:1px solid transparent; color:var(--muted);
                 padding:5px 14px; border-radius:6px; }
  .tabs button.on { background:var(--panel); border-color:var(--line); color:var(--fg); }
  main { padding:14px 18px; }
  .panel { background:var(--panel); border:1px solid var(--line);
           border-radius:8px; padding:13px; margin-bottom:14px; }
  .panel h2 { font-size:12px; margin:0 0 10px; color:var(--muted);
              text-transform:uppercase; letter-spacing:.06em; }
  input,select,button { font:inherit; color:var(--fg); background:#262a33;
                        border:1px solid var(--line); border-radius:6px; padding:6px 9px; }
  button { cursor:pointer; }
  button:hover { border-color:var(--accent); }
  button.primary { background:var(--accent); border-color:var(--accent); color:#fff; }
  button.danger { color:var(--danger); }
  .row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
  .play-layout { display:grid; grid-template-columns:1fr 290px; gap:14px; align-items:start; }
  @media (max-width:880px){ .play-layout{ grid-template-columns:1fr; } }
  .side { position:sticky; top:60px; }
  .grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:7px; }
  .snd { background:var(--card); border:1px solid var(--line); border-radius:7px;
         padding:9px; cursor:pointer; }
  .snd:hover { border-color:var(--accent); }
  .snd.sel { border-color:var(--accent); background:#28303f; }
  .snd .nm { font-weight:600; word-break:break-all; }
  .snd input[type=checkbox] { width:16px; height:16px; margin:0; accent-color:var(--accent); cursor:pointer; }
  .snd .bottom { display:flex; align-items:center; gap:8px; margin-top:8px; }
  .snd .dur { color:var(--muted); font-size:11px; font-variant-numeric:tabular-nums; flex:1; }
  .ordno { background:var(--accent); color:#fff; border-radius:9px; font-size:11px;
           padding:0 6px; margin-left:4px; }
  .tag { display:inline-block; background:#303643; border-radius:10px;
         padding:0 6px; font-size:10px; margin:2px 3px 0 0; }
  .tagbtn { background:#262a33; border:1px solid var(--line); border-radius:12px;
            padding:3px 10px; font-size:12px; }
  .tagbtn.on { background:var(--accent); border-color:var(--accent); color:#fff; }
  table { width:100%; border-collapse:collapse; font-size:13px; }
  th,td { text-align:left; padding:5px 6px; border-bottom:1px solid var(--line); vertical-align:top; }
  th { color:var(--muted); font-weight:500; }
  td.n,th.n { text-align:right; font-variant-numeric:tabular-nums; }
  .qitem { display:flex; align-items:center; gap:5px; padding:4px 0; border-bottom:1px solid var(--line); }
  .qitem .nm { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .qitem button { padding:2px 7px; font-size:12px; }
  .note { color:var(--muted); font-size:12px; }
  .err { color:var(--danger); }
  .dot { display:inline-block; width:8px; height:8px; border-radius:50%; background:#555; margin-right:5px; }
  .dot.on { background:var(--ok); }
  #toast { position:fixed; right:16px; bottom:16px; background:var(--panel);
           border:1px solid var(--line); border-radius:6px; padding:9px 13px;
           display:none; max-width:380px; z-index:20; }

.tb { color: var(--danger); white-space: pre-wrap; margin: 4px 0 0; font-size: 11px; }
.snd .bottom button { padding: 3px 10px; font-size: 12px; }
.qitem button { padding: 2px 7px; font-size: 12px; }

/* 利用できない機能は、隠さず理由が分かる形で無効化する */
.disabled { opacity: .65; }
.disabled button:not(:disabled) { pointer-events: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:disabled:hover { border-color: var(--line); }
.badge-off { background: #4a3038; color: #f0a0a8; border-radius: 10px;
             padding: 1px 9px; font-size: 11px; }
.notice { background: #262a33; border: 1px solid var(--line);
          border-radius: 6px; padding: 10px 12px; font-size: 13px; }
.notice a { color: var(--accent); }
.tabs button .badge-off { margin-left: 6px; }

/* 再生回数のヒートマップ。
   色は magnitude を表す逐次スケールなので単一色相の明度段階で作る。
   文字の背後に濃い色を敷くと補助テキストがコントラスト基準を割るため、
   背景は可読域に収まる淡いティントに留め、強度は下端の帯で表す。 */
.snd { position: relative; overflow: hidden; }
.snd::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: transparent;
}
.snd.heat-1 { background: #242c39; } .snd.heat-1::after { background: #39528a; }
.snd.heat-2 { background: #262f42; } .snd.heat-2::after { background: #4870bd; }
.snd.heat-3 { background: #27334b; } .snd.heat-3::after { background: #5b8def; }
.snd.heat-4 { background: #283654; } .snd.heat-4::after { background: #85adf5; }
.snd.heat-5 { background: #283654; } .snd.heat-5::after { background: #b3cdfb; }
/* 選択中は枠で示すため、ヒートの背景より選択状態を優先する */
.snd.sel { background: #28303f; }

.heatlegend { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; }
.heatlegend i { width: 16px; height: 8px; border-radius: 2px; display: inline-block; }

/* 入力項目は何を入れる欄か分かるようにラベルを添える */
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.formgrid label { display: flex; flex-direction: column; gap: 4px;
                  font-size: 12px; color: var(--muted); }
.formgrid input { width: 100%; }

dialog { background: var(--panel); color: var(--fg); border: 1px solid var(--line);
         border-radius: 10px; padding: 18px 20px; min-width: min(560px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h3 { margin: 0 0 14px; font-size: 15px; }

/* パネル見出しの右に置く操作。アイコンだけなので title と aria-label を必ず添える */
.panel h2 { display: flex; align-items: center; gap: 6px; }
.h2actions { margin-left: auto; display: flex; gap: 4px; }
.iconbtn { padding: 2px 9px; font-size: 12px; line-height: 1.4; }

/* 表示名は1行で切る。全文はカードの title で読める */
.snd .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* タグ補完の候補 */
.suggest { position: absolute; z-index: 30; background: var(--panel);
           border: 1px solid var(--line); border-radius: 6px; padding: 4px;
           display: flex; flex-wrap: wrap; gap: 3px; max-width: 320px;
           box-shadow: 0 6px 18px rgba(0, 0, 0, .5); }
.suggest button { padding: 2px 8px; font-size: 12px; background: #2b303b; }

/* 編集モードの表 */
#mtable input, #mtable select { padding: 3px 6px; font-size: 12px; width: 100%; }
#mtable td { position: relative; }
tr.dirty td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
