/* 相場ノート — スマホ優先。レイアウト: 上に固定ヘッダ、下にタブ、間はスクロール */
:root {
  --bg: #f6f7f9; --card: #ffffff; --fg: #1a1d23; --muted: #6b7280; --line: #e4e7ec;
  --accent: #2a5bd7; --accent-soft: #e8eefc; --up: #e5484d; --down: #1f8f5f; --warn: #b7791f;
  --chip: #eef0f4; --shadow: 0 1px 2px rgba(16,24,40,.06);
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --card: #171b21; --fg: #e8eaed; --muted: #9aa3ad; --line: #262c35;
    --accent: #6f9bff; --accent-soft: #1b2740; --up: #ff6b6b; --down: #3ccf8e; --warn: #e0b35a;
    --chip: #222831; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .muted { color: var(--muted); }

#app { height: 100%; display: flex; flex-direction: column; }
header.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line);
  padding: calc(8px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
  display: flex; align-items: center; justify-content: space-between; gap: 8px; }
header.top h1 { font-size: 17px; margin: 0; letter-spacing: .02em; }
header.top .sub { font-size: 12px; color: var(--muted); }
main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-block: 12px calc(16px + 64px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.view[hidden] { display: none; }
.view > * + * { margin-top: 12px; }

nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
nav.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 10px; color: var(--muted); font-size: 11px; }
nav.tabs button .ic { font-size: 20px; line-height: 1; }
nav.tabs button.on { color: var(--accent); background: var(--accent-soft); }

.card { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card h2 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; background: var(--chip); border-radius: 999px; padding: 6px 12px; font-size: 13px; white-space: nowrap; border: 1px solid transparent; }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.chip.add { color: var(--accent); }

/* ウォッチリスト */
.watch { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
.watch::-webkit-scrollbar { display: none; }
.wt { flex: none; width: 128px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; text-align: left; position: relative; }
.wt.on { border-color: var(--accent); background: var(--accent-soft); }
.wt .nm { font-size: 12px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wt .pr { font-weight: 700; font-size: 15px; display: block; }
.wt .ch { font-size: 12px; font-weight: 600; }
.wt canvas { position: absolute; right: 8px; bottom: 8px; width: 40px; height: 18px; opacity: .8; }

.ticker-head .name { font-size: 18px; font-weight: 700; }
.ticker-head .price { font-size: 28px; font-weight: 800; letter-spacing: -.01em; }
.ticker-head .chg { font-size: 14px; font-weight: 600; }
.seg { display: flex; background: var(--chip); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; padding: 6px 0; border-radius: 8px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--fg); font-weight: 600; box-shadow: var(--shadow); }
#chart-main { height: 300px; width: 100%; }
#chart-sub { height: 120px; width: 100%; border-top: 1px dashed var(--line); margin-top: 6px; }
#chart-sub[hidden] { display: none; }
.chart-wrap { position: relative; }
.chart-wrap .loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; background: color-mix(in srgb, var(--card) 70%, transparent); border-radius: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }

/* 分析 */
.verdict { display: flex; align-items: center; gap: 12px; }
.verdict .big { font-size: 20px; font-weight: 800; }
.gauge { height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--down), #cfd3da 50%, var(--up)); position: relative; margin: 10px 0 4px; }
.gauge .pin { position: absolute; top: -5px; width: 20px; height: 20px; border-radius: 50%; background: var(--card); border: 3px solid var(--fg); transform: translateX(-50%); }
.gauge-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.points { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.points li { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.points .tag { flex: none; font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--chip); color: var(--muted); margin-top: 2px; min-width: 52px; text-align: center; }
.points .tag.bull { background: color-mix(in srgb, var(--up) 15%, transparent); color: var(--up); }
.points .tag.bear { background: color-mix(in srgb, var(--down) 15%, transparent); color: var(--down); }
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.levels div { background: var(--chip); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.levels b { display: block; font-size: 16px; }
.note { font-size: 11px; color: var(--muted); margin-top: 10px; }

/* ニュース */
.pick { display: grid; gap: 10px; }
.news-item { display: block; padding: 10px 0; border-top: 1px solid var(--line); }
.news-item:first-child { border-top: 0; padding-top: 0; }
.news-item .t { font-size: 15px; font-weight: 600; line-height: 1.4; }
.news-item .m { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.news-item .cat { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--chip); }
.news-item .sym { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.news-item.hot .t::before { content: "注目 "; color: var(--warn); font-size: 12px; }
.why { font-size: 12px; color: var(--warn); margin-top: 2px; }

/* コピトレ */
.trader { display: grid; gap: 10px; }
.trader .head { display: flex; gap: 10px; align-items: center; }
.trader .av { width: 44px; height: 44px; border-radius: 12px; background: var(--chip); display: grid; place-items: center; font-size: 24px; flex: none; }
.trader .nm { font-weight: 700; font-size: 16px; }
.trader .st { font-size: 12px; color: var(--muted); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.badge.r低 { background: color-mix(in srgb, var(--down) 15%, transparent); color: var(--down); }
.badge.r中 { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.r高 { background: color-mix(in srgb, var(--up) 15%, transparent); color: var(--up); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stats div { background: var(--chip); border-radius: 10px; padding: 6px 8px; }
.stats small { display: block; font-size: 11px; color: var(--muted); }
.stats b { font-size: 15px; }
.spark { width: 100%; height: 56px; display: block; }
.pos { font-size: 12px; color: var(--muted); }
.pos b { color: var(--fg); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 12px; font-weight: 700; background: var(--accent); color: #fff; width: 100%; }
.btn.ghost { background: var(--chip); color: var(--fg); }
.btn.danger { background: color-mix(in srgb, var(--up) 12%, transparent); color: var(--up); }
.btn.sm { width: auto; padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; }

/* 資産 */
.total .big { font-size: 32px; font-weight: 800; letter-spacing: -.01em; }
.bar { height: 10px; border-radius: 999px; background: var(--chip); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.list > div { padding: 10px 0; border-top: 1px solid var(--line); }
.list > div:first-child { border-top: 0; padding-top: 0; }
.kv { display: flex; justify-content: space-between; font-size: 13px; }
.kv + .kv { margin-top: 4px; }
#eq-canvas { width: 100%; height: 140px; display: block; }

/* シート（下から出る） */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex; align-items: flex-end; }
.sheet-bg[hidden] { display: none; }
.sheet { background: var(--card); width: 100%; border-radius: 18px 18px 0 0; padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); max-height: 85vh; overflow-y: auto; }
.sheet h3 { margin: 0 0 10px; font-size: 16px; }
.sheet input[type=text], .sheet input[type=number], .sheet textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.sheet textarea { font-family: var(--mono); font-size: 11px; min-height: 100px; }
.sr { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); gap: 8px; }
.sr:first-of-type { border-top: 0; }
.sr .s { font-weight: 700; } .sr .n { font-size: 12px; color: var(--muted); }
.presets { display: flex; gap: 6px; margin: 8px 0; }
.presets button { flex: 1; padding: 8px 0; border-radius: 9px; background: var(--chip); font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 13px; z-index: 30; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; font-size: 13px; }
.msg { font-size: 13px; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (min-width: 720px) { main { max-width: 720px; margin: 0 auto; width: 100%; } nav.tabs { max-width: 720px; margin: 0 auto; border-radius: 14px 14px 0 0; } }
