:root {
  --bg: #e9ebee; --ink: #111; --mute: #6b7584; --line: #d0d4da;
  --up: #1f9d2e; --dn: #d4231c; --frame: #4d4d4d;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Hiragino Sans", "Helvetica Neue", Arial, sans-serif; font-feature-settings: "tnum"; }

header { position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: 1px solid var(--line); }
.bar { display: flex; gap: 10px; align-items: center; padding: 8px 12px; flex-wrap: wrap; }
.title { font-size: 15px; margin-right: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button, .plain { border: 0; background: #fff; padding: 5px 11px; font-size: 13px; cursor: pointer; color: var(--ink); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: #1d2a6b; color: #fff; }
.plain { border: 1px solid var(--line); border-radius: 6px; }
.plain.on { background: #fff4d6; border-color: #e0b84a; }
.meta { margin-left: auto; color: var(--mute); font-size: 12px; display: flex; gap: 8px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #bbb; display: inline-block; }
.dot.on { background: #20c040; box-shadow: 0 0 0 3px rgba(32,192,64,.2); }
.tag { font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 3px; color: #fff; background: #555; }

main { padding: 8px 10px 4px; }
.group h2 { font-size: 13px; color: #333; margin: 10px 2px 5px; font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); gap: 4px; }

/* ---- タイル ---- */
.tile { container-type: inline-size; border: 3px solid var(--frame); border-radius: 3px; position: relative; background: #fff; cursor: pointer; overflow: hidden; display: flex; flex-direction: column; }
.tile.stale { filter: grayscale(.95); opacity: .6; }
.head { display: flex; align-items: center; gap: 5px; padding: 3px 6px; height: 24px;
  background: linear-gradient(#fdfdfd, #e4e4e4); border-bottom: 1px solid #c9c9c9; }
.head .ic { width: 17px; height: 17px; border-radius: 3px; object-fit: contain; flex: none; background: #fff; }
.head .fl { font-size: 15px; line-height: 1; flex: none; }
.head .nm { font-size: clamp(11px, 7.5cqw, 16px); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.02em; }
.head .src { font-size: 9px; font-weight: 700; color: #333; margin-left: 1px; flex: none; }
.head .src.y { color: #6001d2; }
.band { text-align: center; font-weight: 900; font-size: clamp(16px, 15cqw, 34px); line-height: 1.25; letter-spacing: -.01em; }
.band small { font-size: .6em; margin-left: 1px; }
svg.ch { width: 100%; height: auto; display: block; }
.foot { display: flex; align-items: baseline; justify-content: center; gap: 5px; padding: 0 4px 3px; white-space: nowrap; }
.foot .px { font-size: clamp(12px, 11.5cqw, 24px); font-weight: 900; letter-spacing: -.02em; border-radius: 3px; padding: 0 2px; transition: background .6s; }
.foot .px small, .foot .cg small { font-size: .7em; }
.foot .cg { font-size: clamp(10px, 8.5cqw, 18px); font-weight: 800; }
.foot .yen { font-size: 9px; color: var(--mute); }
.up-t { color: var(--up); } .dn-t { color: var(--dn); }
.px.flash-up { background: #b9f5b0; } .px.flash-dn { background: #ffc4c0; }
.err { color: var(--dn); font-size: 11px; padding: 10px; }

#modal { position: fixed; inset: 0; background: rgba(20,24,32,.5); display: flex; align-items: center; justify-content: center; z-index: 10; }
#modal[hidden] { display: none; }
#modal .box { background: #fff; border-radius: 8px; width: min(980px, 94vw); padding: 0 0 12px; position: relative; overflow: hidden; }
#modal .x { position: absolute; right: 10px; top: 4px; border: 0; background: none; font-size: 22px; cursor: pointer; z-index: 2; }
#modal .head { height: 34px; } #modal .head .nm { font-size: 18px; } #modal .head .ic { width: 22px; height: 22px; }
#modal .band { font-size: 40px; line-height: 50px; }
#modal .foot .px { font-size: 28px; } #modal .foot .cg { font-size: 20px; }
#big .note { color: var(--mute); font-size: 12px; margin: 4px 16px 0; }
footer { color: var(--mute); font-size: 11px; padding: 6px 14px 16px; line-height: 1.7; }

/* ---- 銘柄編集 ---- */
#editor { position: fixed; inset: 0; background: rgba(20,24,32,.55); display: flex; align-items: center; justify-content: center; z-index: 20; }
#editor[hidden] { display: none; }
.ebox { background: #fff; border-radius: 10px; width: min(1100px, 96vw); height: min(860px, 94vh); display: flex; flex-direction: column; overflow: hidden; }
.ehead { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 16px; }
.ehead .x { margin-left: auto; border: 0; background: none; font-size: 22px; cursor: pointer; }
.emeta { color: var(--mute); font-size: 12px; }
.ebody { flex: 1; display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }
.eleft, .eright { display: flex; flex-direction: column; min-height: 0; padding: 10px 14px; }
.eright { border-left: 1px solid var(--line); background: #fafbfc; }
.ebody h3 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.cats { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.cats button { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.cats button small { margin-left: 4px; color: var(--mute); }
.cats button.on { background: #1d2a6b; color: #fff; border-color: #1d2a6b; }
.cats button.on small { color: #c9d0ff; }
#eq { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.into { font-size: 12px; color: var(--mute); margin: 6px 0; }
.elist, .olist { flex: 1; overflow: auto; }
.erow, .orow { display: flex; align-items: center; gap: 7px; padding: 5px 6px; border-bottom: 1px solid #f0f1f3; font-size: 13px; cursor: pointer; }
.erow:hover { background: #f3f5f8; }
.erow .ic, .orow .ic { width: 18px; height: 18px; border-radius: 3px; object-fit: contain; }
.erow .lb, .orow .lb { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.erow .tk { color: var(--mute); font-size: 11px; }
.vol { margin-left: auto; color: var(--mute); font-size: 10px; flex: none; }
.vol + .stag { margin-left: 4px; }
.stag { margin-left: auto; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; color: #fff; background: #555; flex: none; }
.stag.s-hl { background: #1a8f78; } .stag.s-binance { background: #c99400; } .stag.s-bybit { background: #222; } .stag.s-bitget { background: #0e7fbf; } .stag.s-mexc { background: #2b5fd9; } .stag.s-yahoo { background: #6001d2; }
.empty { color: var(--mute); padding: 12px; font-size: 13px; }
.orow { background: #fff; cursor: grab; }
.orow .grip { color: #bbb; font-size: 11px; }
.orow button, .ogrp button { border: 1px solid var(--line); background: #fff; border-radius: 4px; font-size: 11px; padding: 1px 6px; cursor: pointer; }
.ogrp { display: flex; align-items: center; gap: 6px; padding: 8px 4px 4px; font-weight: 800; font-size: 13px; border-bottom: 2px solid #1d2a6b; margin-top: 6px; }
.ogrp small { color: var(--mute); font-weight: 400; margin-right: auto; }
.ogrp button:disabled { opacity: .3; cursor: default; }
.orow.dragging { opacity: .4; }
.orow.over { box-shadow: inset 0 2px 0 #1d2a6b; } .ogrp.over { background: #e8ecff; }
.efoot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.efoot .emeta { margin-left: auto; }
.plain.primary { background: #1d2a6b; color: #fff; border-color: #1d2a6b; }
.plain.sm { font-size: 11px; padding: 2px 8px; font-weight: 400; }
