/* デザイン標準はデジタル庁デザインシステム（DADS）。色・フォント・文字サイズ・フォーカスは
   先に読み込む dads-tokens.css の変数だけを使う（documents/design/design-standard.md）。
   ダークは dads-tokens.css が持つ（DADS の原色から派生させた配色）。
   意味づけ：選択・再生中=キーカラー、未書き出し・未録音=破線と補助文字、検査の FAIL=エラー色、警告の区分=警告色。
   黄色（yellow-300）はフォーカス専用なので、選択の印には使わない。 */
:root {
  --radius: var(--border-radius-12);
  --radius-control: var(--border-radius-8);
  --target: 2.75rem; /* 押せる領域の最小（44px） */
  --top: 60px; --tray: 64px;
}

* { box-sizing: border-box; scrollbar-color: var(--border) transparent; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-family-sans); font-size: var(--font-size-16);
       line-height: var(--line-height-170); display: flex; flex-direction: column; overflow: hidden; }
button, select, input { font: inherit; color: var(--text); }
button { cursor: pointer; min-height: 2.5rem; padding: 4px 14px; border: 1px solid var(--border); border-radius: var(--radius-control);
         background: var(--bg); text-underline-offset: calc(3 / 16 * 1rem); }
@media (hover: hover) { button:hover { border-color: var(--accent); background: var(--accent-tint); } }
button[aria-pressed="true"], button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
button.link { border: none; background: none; min-height: 2rem; padding: 2px 6px; color: var(--link); text-decoration: underline; }
input, select { min-height: 2.5rem; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--bg); }
input[type=checkbox] { min-height: 0; width: 1.25rem; height: 1.25rem; padding: 0; margin: 0 6px 0 0; vertical-align: -0.2em; accent-color: var(--accent); }
:focus-visible { outline: 4px solid var(--focus-outline); outline-offset: 2px; box-shadow: 0 0 0 2px var(--focus-ring); }
.muted { color: var(--subtext); font-size: var(--font-size-14); }
[hidden] { display: none !important; }

/* ---- 上段 */
.top { height: var(--top); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 16px;
       border-bottom: 1px solid var(--line); background: var(--surface); color: var(--text); }
.brand { flex: 1; display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.brand b { font-size: var(--font-size-18); color: var(--text-strong); }
.brand .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; min-width: 5rem; }
.seg button:first-child { border-radius: var(--radius-control) 0 0 var(--radius-control); }
.seg button:last-child { border-radius: 0 var(--radius-control) var(--radius-control) 0; border-left: none; }

.tools { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px 4px; background: var(--bg); }
.tools input[type=search] { width: 22rem; max-width: 100%; }
.chk { display: inline-flex; align-items: center; min-height: 2.5rem; white-space: nowrap; }
.keys { flex: 1; text-align: right; min-width: 12rem; }
body.k-video .aonly, body.k-audio .vonly { display: none; }

.chips { flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 16px 10px; border-bottom: 1px solid var(--line); background: var(--bg); }
.chips button { min-height: 2.25rem; padding: 2px 12px; border-radius: var(--border-radius-full); font-size: var(--font-size-16); }
.chips button .n { color: inherit; opacity: 0.85; margin-left: 4px; font-size: var(--font-size-14); }
.chips button.warn { border-color: var(--warning); color: var(--warning); }

/* ---- 一覧 */
.grid { flex: 1; overflow-y: auto; padding: 14px 16px 24px; display: grid; gap: 14px;
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); grid-auto-rows: max-content; align-content: start; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); display: flex;
        flex-direction: column; overflow: hidden; outline-offset: 2px; }
.card.cur { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.card.playing { box-shadow: 0 0 0 2px var(--accent), inset 0 4px 0 var(--accent); }
.media { position: relative; flex: none; aspect-ratio: 16 / 9; background: var(--surface-2); cursor: pointer; }
.media img, .media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.media .none { position: absolute; inset: 0; display: grid; place-items: center; color: var(--subtext); background: var(--surface-2);
               border-bottom: 1px dashed var(--border); font-size: var(--font-size-16); }
.cbody { flex: none; padding: 8px 10px 10px; display: grid; gap: 4px; }
.ctitle { display: flex; gap: 8px; align-items: baseline; }
.ctitle .id { font-family: var(--font-family-mono); font-weight: 700; color: var(--text-strong); }
.ctitle .name { font-weight: 700; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmeta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: var(--font-size-14); color: var(--subtext); }
.crow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crow button { min-height: 2.25rem; padding: 2px 10px; font-size: var(--font-size-14); }
.badge { font-size: var(--font-size-14); line-height: var(--line-height-150); padding: 0 8px; border-radius: var(--border-radius-full);
         border: 1px solid var(--line); color: var(--text); background: var(--bg); white-space: nowrap; }
.b-fail { border-color: var(--error); color: var(--error); font-weight: 700; }
.b-ok { border-color: var(--success); color: var(--success); }
.b-none { border-style: dashed; color: var(--subtext); }
.b-warn { border-color: var(--warning); color: var(--warning); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs button { min-height: 2.25rem; min-width: 3.25rem; padding: 0 8px; font-family: var(--font-family-mono); font-size: var(--font-size-14); }
.tabs button.missing { border-style: dashed; color: var(--subtext); }
.tabs button.missing[aria-pressed="true"] { color: var(--on-accent); }   /* 選んだ未録音の素材も読めるように */
.ab { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ab .side { font-size: var(--font-size-14); padding: 0 8px; border-radius: var(--border-radius-full); border: 1px solid var(--line); }
.ab .side.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.empty { grid-column: 1 / -1; color: var(--subtext); padding: 24px 0; }

/* ---- 比較の枠 */
.tray { height: var(--tray); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-top: 1px solid var(--line);
        background: var(--surface); color: var(--text); }
.slots { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.slots li { min-width: 5.5rem; min-height: 2.5rem; display: flex; align-items: center; gap: 4px; padding: 0 8px; border: 1px dashed var(--border);
            border-radius: var(--radius-control); background: var(--bg); color: var(--subtext); font-size: var(--font-size-14); }
.slots li.full { border-style: solid; color: var(--text-strong); font-family: var(--font-family-mono); }
.slots li.on { border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.now { flex: 1; text-align: right; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---- ダイアログ */
dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px 20px; width: min(960px, 94vw); max-height: 90vh;
         background: var(--bg); color: var(--text); }
dialog.wide { width: 96vw; }
dialog::backdrop { background: color-mix(in srgb, var(--text-strong) 45%, transparent); }
.dhead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.dhead h2 { flex: 1; margin: 0; font-size: var(--font-size-20); color: var(--text-strong); }
.dvideo { width: 100%; aspect-ratio: 16 / 9; background: var(--surface-2); display: block; border-radius: var(--radius-control); }
.dl { display: grid; grid-template-columns: 9rem 1fr; gap: 6px 14px; margin: 14px 0; }
.dl dt { color: var(--subtext); font-size: var(--font-size-16); }
.dl dd { margin: 0; }
.path { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.path code, code { font-family: var(--font-family-mono); font-size: var(--font-size-14); background: var(--surface); color: var(--text);
                   padding: 2px 6px; border-radius: var(--border-radius-4); word-break: break-all; }
table.kf { border-collapse: collapse; width: 100%; font-size: var(--font-size-14); }
table.kf th, table.kf td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }
table.kf th { color: var(--subtext); font-weight: 400; }
table.kf td code { white-space: pre-wrap; }
.related button { font-family: var(--font-family-mono); }
.cgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cgrid .cell { border: 1px solid var(--line); border-radius: var(--radius-control); padding: 8px; background: var(--bg); }
.cgrid .cell.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.cgrid video { width: 100%; aspect-ratio: 16 / 9; background: var(--surface-2); display: block; }
.cgrid img { width: 100%; display: block; }
.fails { margin: 4px 0 0; padding-left: 1.2em; color: var(--error); font-size: var(--font-size-14); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tray) + 12px); transform: translateX(-50%); padding: 8px 16px; border-radius: var(--radius-control);
         background: var(--text-strong); color: var(--bg); font-size: var(--font-size-16); z-index: 10; }
/* ---- 狭い画面（スマホ幅）：要約・キー一覧・枠の説明を隠し、比較の枠は横に送る */
@media (max-width: 700px) {
  .top { gap: 8px; padding: 0 12px; }
  .brand .muted, .keys, .tray > .muted:first-child, .now { display: none; }
  .brand b { white-space: nowrap; }
  .seg button { min-width: 3.5rem; }
  .tray { gap: 8px; padding: 0 12px; }
  .slots { flex: 1; min-width: 0; overflow-x: auto; }
  .slots li { min-width: 4.5rem; flex: none; }
  .tray button { flex: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
