:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface2: #eef1f5; --line: #d9dee6;
  --text: #1b1f26; --text2: #4b5563; --muted: #7b8494;
  --accent: #1e3a5f; --accent-ink: #ffffff; --accent-soft: #e3ebf6;
  --up: #c93b3b; --up-soft: #fbe9e9; --down: #2a6fcf; --down-soft: #e6eefb; --flat: #6b7280;
  --warn-bg: #fff7e0; --warn-line: #e5c66a;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 8px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b22; --surface2: #1f242d; --line: #2c333f;
    --text: #e6e8eb; --text2: #b4bac4; --muted: #8a93a1;
    --accent: #8fb4e8; --accent-ink: #0f1216; --accent-soft: #1d2a3d;
    --up: #ff7b7b; --up-soft: #3a1f22; --down: #6fb0ff; --down-soft: #1c2a40; --flat: #9aa3b2;
    --warn-bg: #2b2611; --warn-line: #7a6a2e;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
  font-size: 15px; line-height: 1.65; font-feature-settings: "palt";
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; letter-spacing: .01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; display: flex; align-items: baseline; gap: .6em; flex-wrap: wrap; }
h2 small { font-size: .8rem; font-weight: normal; color: var(--muted); }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .8em; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--flat); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* 上部 */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top .in { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 12px; min-height: 52px; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); white-space: nowrap; }
.brand b { color: var(--accent); }
.top nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.top nav::-webkit-scrollbar { display: none; }
.top nav a { padding: 6px 10px; border-radius: 8px; color: var(--text2); white-space: nowrap; font-size: .92rem; }
.top nav a:hover { background: var(--surface2); text-decoration: none; }
.top nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.updbar { max-width: 1120px; margin: 0 auto; padding: 6px 16px 0; font-size: .82rem; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }

main { max-width: 1120px; margin: 0 auto; padding: 12px 16px 48px; }
section { margin: 22px 0 0; }
.hero { padding: 6px 0 2px; }
.hero p { color: var(--text2); max-width: 760px; }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 10px 14px; font-size: .88rem; margin: 14px 0 0; }
.notice.soft { background: var(--surface2); border-color: var(--line); }

/* カード */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.cards.wide { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; gap: 2px; cursor: pointer; transition: border-color .15s; }
.card:hover { border-color: var(--accent); }
.card .name { font-size: .86rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .price { font-size: 1.25rem; font-weight: 700; }
.card .chg { font-size: .9rem; font-weight: 600; }
.card .sub { font-size: .78rem; color: var(--muted); display: grid; grid-template-columns: 1fr 1fr; gap: 6px; white-space: nowrap; }
.card .sub span:last-child { text-align: right; }
.card svg.spark { width: 100%; height: 34px; margin-top: 4px; display: block; }
.card.static { cursor: default; }

/* 2列ブロック */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.cols.rank4 { grid-template-columns: 1fr; }
@media (min-width: 700px) { .cols.rank4 { grid-template-columns: 1fr 1fr; } }
.cols.partners { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.box h3 { margin-bottom: 6px; }
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: grid; grid-template-columns: 1.4em minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); cursor: pointer; }
.rank li:first-child { border-top: 0; }
.rank .n { color: var(--muted); font-size: .85rem; text-align: right; }
.rank .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .nm small { color: var(--muted); margin-left: 4px; }
.rank .v { font-weight: 600; min-width: 4.5em; text-align: right; }
.rank .p { text-align: right; min-width: 5em; }
.rank li:hover .nm { color: var(--accent); }

/* ニュース */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs button, .chip { background: var(--surface); border: 1px solid var(--line); color: var(--text2); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .88rem; cursor: pointer; }
.tabs button[aria-selected="true"], .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.news { list-style: none; margin: 0; padding: 0; }
.news li { padding: 9px 0; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.news li:first-child { border-top: 0; }
.news a { color: var(--text); font-weight: 500; }
.news a:visited { color: var(--text2); }
.news .meta { font-size: .78rem; color: var(--muted); }

/* 一覧の操作 */
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0 12px; }
.controls input, .controls select { font: inherit; font-size: .92rem; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
.controls input { min-width: 180px; flex: 1 1 180px; }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 8px 10px; text-align: right; white-space: nowrap; border-top: 1px solid var(--line); }
th { font-weight: 600; color: var(--text2); font-size: .82rem; background: var(--surface2); border-top: 0; position: sticky; top: 0; cursor: pointer; user-select: none; }
th[aria-sort="descending"]::after { content: " ▼"; font-size: .7em; }
th[aria-sort="ascending"]::after { content: " ▲"; font-size: .7em; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
th:first-child { background: var(--surface2); z-index: 1; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface2); }
td .code { color: var(--muted); font-size: .8rem; margin-left: 6px; }
td svg.spark { width: 90px; height: 26px; display: block; }
.badge { display: inline-block; font-size: .72rem; padding: 1px 6px; border-radius: 6px; background: var(--surface2); color: var(--text2); margin-left: 4px; vertical-align: middle; }

/* 注目銘柄 */
.screen { margin-top: 18px; }
.screen .rule { font-size: .86rem; color: var(--text2); margin: 0 0 8px; }
.screen .empty { color: var(--muted); font-size: .9rem; padding: 6px 0; }

/* 詳細ダイアログ */
dialog.detail { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(680px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog.detail::backdrop { background: rgba(0,0,0,.45); }
.detail .hd { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px 16px 0; }
.detail .hd h2 { margin: 0; font-size: 1.15rem; display: block; }
.detail .hd .code { color: var(--muted); font-size: .85rem; }
.detail .close { background: var(--surface2); border: 0; color: var(--text); border-radius: 8px; width: 34px; height: 34px; font-size: 1.2rem; cursor: pointer; flex: none; }
.detail .bigprice { padding: 4px 16px 0; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.detail .bigprice .p { font-size: 1.7rem; font-weight: 700; }
.detail .bigprice .c { font-size: 1rem; font-weight: 600; }
.detail .chartwrap { padding: 8px 8px 0; position: relative; }
.detail svg.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.detail .tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); font-size: .78rem; padding: 4px 8px; border-radius: 6px; transform: translate(-50%, -100%); white-space: nowrap; display: none; }
.detail .stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px 12px; padding: 10px 16px; font-size: .88rem; }
.detail .stats div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 3px 0; }
.detail .stats span:first-child { color: var(--muted); }
.detail .acts { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 16px 16px; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); padding: 9px 16px; border-radius: 10px; font-weight: 600; border: 0; font: inherit; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn.ghost { background: var(--surface2); color: var(--text); }

/* 口座開設・静的ページ */
.steps { counter-reset: s; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 10px 0; }
.steps .box { position: relative; padding-top: 14px; }
.steps .box::before { counter-increment: s; content: counter(s); position: absolute; top: -12px; left: 12px; background: var(--accent); color: var(--accent-ink); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.partner { display: flex; flex-direction: column; gap: 8px; }
.partner .btn { align-self: flex-start; margin-top: auto; }
.partner .tag { font-size: .78rem; color: var(--accent); font-weight: 600; }
.partner ul { margin: 6px 0 0; padding-left: 1.2em; font-size: .9rem; color: var(--text2); }
.partner .pr { font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; margin-left: 6px; vertical-align: middle; }
.prose { max-width: 760px; }
.prose h2 { margin-top: 1.4em; }
.prose ul { padding-left: 1.3em; }
.cta { background: var(--accent-soft); border-radius: var(--radius); padding: 16px 18px; display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 22px; }
.cta p { margin: 0; }

footer { border-top: 1px solid var(--line); background: var(--surface); }
footer .in { max-width: 1120px; margin: 0 auto; padding: 18px 16px 28px; font-size: .8rem; color: var(--muted); }
footer .links { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
footer .links a { color: var(--text2); }

.skeleton { color: var(--muted); padding: 14px; text-align: center; font-size: .9rem; }
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .top .in { flex-wrap: wrap; padding-bottom: 6px; }
  .top nav { margin-left: -4px; width: 100%; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards.wide { grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)); }
  .card .price { font-size: 1.12rem; }
}
