/* Aup2GapFiller Web - 画面 */

:root {
  --bg: #f4f4f8;
  --panel: #fbfbfe;
  --panel2: #ffffff;
  --line: #c8ccda;
  --line2: #e2e5ee;
  --fg: #1d2230;
  --fg-dim: #6a7183;
  --accent: #34558b;
  --accent-fg: #fff;
  --alt-row: #eef0f6;
  --sel-row: #cfe0f8;
  --warn: #a06000;
  --err: #c02020;
  --ok: #1d7a45;
  --mark: #fff2c8;
  --head: #e7eaf2;
  --shadow: 0 2px 10px rgba(20, 28, 50, .12);
  --tip-bg: #2a3142;
  --tip-fg: #f3f5fa;
  --row-h: 26px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181f;
    --panel: #1d2028;
    --panel2: #22252e;
    --line: #3a3f4d;
    --line2: #2c303a;
    --fg: #e6e8ef;
    --fg-dim: #949bad;
    --accent: #7aa7e8;
    --accent-fg: #10131a;
    --alt-row: #1f222b;
    --sel-row: #2e4568;
    --warn: #e0a850;
    --err: #ff7b7b;
    --ok: #63d295;
    --mark: #4a3f1e;
    --head: #262a35;
    --shadow: 0 2px 10px rgba(0, 0, 0, .4);
    --tip-bg: #39414f;
    --tip-fg: #eef1f7;
  }
}

:root[data-theme="dark"] {
  --bg: #16181f;
  --panel: #1d2028;
  --panel2: #22252e;
  --line: #3a3f4d;
  --line2: #2c303a;
  --fg: #e6e8ef;
  --fg-dim: #949bad;
  --accent: #7aa7e8;
  --accent-fg: #10131a;
  --alt-row: #1f222b;
  --sel-row: #2e4568;
  --warn: #e0a850;
  --err: #ff7b7b;
  --ok: #63d295;
  --mark: #4a3f1e;
  --head: #262a35;
  --shadow: 0 2px 10px rgba(0, 0, 0, .4);
  --tip-bg: #39414f;
  --tip-fg: #eef1f7;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.5 "Segoe UI", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 全体の骨格 ---------- */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 8px 14px 6px;
  gap: 5px;
  min-height: 0;
  /* 画面が低いときは一覧を潰さず、上を含めて縦スクロールさせる */
  overflow: auto;
}

.bar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.bar.tight { gap: 6px; }
.grow { flex: 1 1 auto; min-width: 0; }
.sep { width: 1px; align-self: stretch; background: var(--line2); margin: 0 4px; }
.dim { color: var(--fg-dim); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
/* 余白を埋めつつ、狭くなったら自分が縮んで隣のボタンを折り返させない補足文 */
.squeeze { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- ヘッダ ---------- */
header.top {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  flex: 0 0 auto;
}
header.top h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .01em; }
header.top .sub { color: var(--fg-dim); font-size: 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent);
  border-radius: 999px; padding: 2px 10px; font-size: 11.5px; font-weight: 600;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
header.top a { color: var(--accent); }

/* ---------- パネル ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
  flex: 0 0 auto;
}
.panel.pad0 { padding: 0; }

/* ---------- ファイル受け ---------- */
#drop {
  border: 1.5px dashed var(--line);
  border-radius: 6px;
  background: var(--panel2);
  padding: 6px 10px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  transition: border-color .12s, background .12s;
  flex: 0 0 auto;
}
#drop.hot { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel2)); }
#drop .fname { font-weight: 600; word-break: break-all; }

/* ---------- 部品 ---------- */
button {
  font: inherit; color: var(--fg);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 11px; cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary {
  background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600;
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.sm { padding: 2px 7px; font-size: 12px; }

input[type=text], input[type=number], textarea, select {
  font: inherit; color: var(--fg);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 5px; padding: 3px 6px;
}
input[type=text]:focus, input[type=number]:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: -1px;
}
input.mark { background: var(--mark); }
input.bad { border-color: var(--err); }
input.w40 { width: 46px; } input.w56 { width: 56px; } input.w80 { width: 82px; }
input.w200 { width: 210px; }

label.chk { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; }
label.chk input { margin: 0; }
label.chk.off { opacity: .45; }

/* ヘルプの ⓘ */
.hint {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--fg-dim);
  font-size: 10.5px; font-weight: 700; cursor: help; flex: 0 0 auto;
}
.hint:hover { border-color: var(--accent); color: var(--accent); }
.hint:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* 説明が出ている間は ⓘ を隠す。display:none にすると
   マウスが外れた扱いになって説明が点滅するので、場所は残したまま透明にする。 */
.hint.tip-open { opacity: 0; }

#tip {
  position: fixed; z-index: 200; left: 0; top: 0;
  max-width: min(440px, calc(100vw - 24px));
  background: var(--tip-bg); color: var(--tip-fg);
  border-radius: 6px; padding: 8px 11px;
  font-size: 12.5px; line-height: 1.65;
  box-shadow: var(--shadow);
  white-space: pre-line;   /* title の改行をそのまま活かす */
  pointer-events: none;
  visibility: hidden; opacity: 0; transform: translateY(-3px);
  transition: opacity .12s ease, transform .12s ease, visibility 0s linear .12s;
}
#tip.on { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }

@media (prefers-reduced-motion: reduce) {
  #tip, .hint { transition: none; }
}

/* 手順の番号。この3つは実際に順番に操作するものなので番号が意味を持つ */
.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; border-radius: 50%; flex: 0 0 auto;
  background: var(--accent); color: var(--accent-fg);
  font-size: 11px; font-weight: 700; line-height: 1;
}
.arrow { color: var(--fg-dim); font-weight: 600; }

/* 押す前に「何件がどう変わるか」を出す行 */
.guide {
  font-size: 12px; color: var(--fg-dim); line-height: 1.55;
  padding: 4px 2px 0; min-height: 21px;
}
.guide b { color: var(--fg); font-weight: 600; }
.guide .hit { color: var(--accent); font-weight: 700; }
.guide.ready .hit { color: var(--ok); }
.guide.warn { color: var(--warn); }
.guide.warn b { color: var(--warn); }

/* キャラ/音量のチップ置き場 */
.chips { display: flex; flex-wrap: wrap; gap: 3px 12px; max-height: 44px; overflow: auto; }
.chip { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.chip .n { color: var(--fg-dim); font-size: 11.5px; }

/* ---------- タブ ---------- */
.tabs { display: flex; gap: 2px; align-items: flex-end; flex: 0 0 auto; }
.tabs button {
  border-bottom-left-radius: 0; border-bottom-right-radius: 0;
  border-bottom-color: transparent; background: var(--bg); color: var(--fg-dim);
}
.tabs button.on {
  background: var(--panel2); color: var(--fg); font-weight: 600;
  border-color: var(--line); border-bottom-color: var(--panel2);
  margin-bottom: -1px; padding-bottom: 5px;
}
.tabwrap {
  flex: 1 1 auto; min-height: 210px;
  border: 1px solid var(--line); border-radius: 0 6px 6px 6px;
  background: var(--panel2); display: flex; flex-direction: column;
}
.tabpage { display: none; flex: 1 1 auto; min-height: 0; flex-direction: column; }
.tabpage.on { display: flex; }
.tabtools { padding: 6px 8px; border-bottom: 1px solid var(--line2); }

/* ---------- 仮想テーブル ---------- */
.vt { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.vt-headwrap { overflow: hidden; background: var(--head); border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.vt-head { display: flex; height: var(--row-h); align-items: stretch; }
.vt-th {
  display: flex; align-items: center; padding: 0 6px; font-weight: 600; font-size: 12px;
  border-right: 1px solid var(--line2); cursor: pointer; user-select: none;
  overflow: hidden; white-space: nowrap;
}
.vt-th:hover { color: var(--accent); }
.vt-th .ar { margin-left: 3px; font-size: 9px; color: var(--accent); }
.vt-body { overflow: auto; flex: 1 1 auto; min-height: 0; }
.vt-canvas { position: relative; }
.vt-rows { position: absolute; left: 0; top: 0; }
.vt-row { display: flex; height: var(--row-h); align-items: stretch; cursor: default; }
.vt-row:nth-child(even) { background: var(--alt-row); }
.vt-row.sel { background: var(--sel-row) !important; }
.vt-row.clickable { cursor: pointer; }
.vt-td {
  padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; border-right: 1px solid transparent;
}
.vt-td.num { justify-content: flex-end; font-variant-numeric: tabular-nums; }
.vt-td.mono { font-variant-numeric: tabular-nums; }
.vt-empty { padding: 18px 12px; color: var(--fg-dim); }
.cell-add { color: var(--ok); }
.cell-cut { color: var(--warn); }
.cell-err { color: var(--err); font-weight: 600; }
.cell-edit { color: var(--accent); font-weight: 600; }

/* ---------- 状態行 ---------- */
#status {
  flex: 0 0 auto; padding: 5px 2px 0; font-size: 12px; color: var(--fg-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#status b { color: var(--fg); font-weight: 600; }
#status .e { color: var(--err); font-weight: 600; }
#status .w { color: var(--warn); font-weight: 600; }

#notice {
  flex: 0 0 auto;
  border-radius: 6px; padding: 6px 11px; display: none; align-items: flex-start; gap: 8px;
  border: 1px solid; line-height: 1.55;
}
#notice.on { display: flex; }
#notice.err { background: color-mix(in srgb, var(--err) 12%, transparent); border-color: color-mix(in srgb, var(--err) 45%, transparent); }
#notice.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
#notice.info { background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
#notice .x { margin-left: auto; cursor: pointer; color: var(--fg-dim); font-weight: 700; padding: 0 4px; }

/* ---------- ダイアログ ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 8px; padding: 0;
  background: var(--panel); color: var(--fg); box-shadow: var(--shadow);
  max-width: min(720px, 94vw); width: 660px;
}
dialog::backdrop { background: rgba(10, 14, 24, .45); }
dialog .dlg-head { padding: 12px 16px 0; font-weight: 700; font-size: 14px; }
dialog .dlg-body { padding: 10px 16px; display: flex; flex-direction: column; gap: 8px; }
dialog .dlg-foot { padding: 10px 16px 14px; display: flex; gap: 8px; justify-content: flex-end; }
dialog textarea { width: 100%; min-height: 150px; resize: vertical; font-size: 14px; line-height: 1.6; }
dialog .meta { color: var(--accent); font-size: 12px; }
dialog .orig { color: var(--fg-dim); font-size: 12px; word-break: break-all; }
dialog .help { color: var(--fg-dim); font-size: 12px; }
dialog h4 { margin: 10px 0 2px; font-size: 13px; }
dialog p { margin: 0 0 6px; }
dialog code { background: var(--panel2); border: 1px solid var(--line2); border-radius: 3px; padding: 0 4px; }
dialog ul { margin: 4px 0; padding-left: 1.3em; }
#helpDlg { width: 720px; }
#helpDlg .dlg-body { max-height: 70vh; overflow: auto; }

/* ---------- 画面が狭いとき ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100%; padding: 10px 12px; }
  .tabwrap { min-height: 60vh; }
  .chips { max-height: none; }
}
