/* かぶナビ — 値動きの「天気予報」。主役は来週の予報レンジ、他は静かに */
:root {
  color-scheme: light;
  --bg: #edf1f4;
  --surface: #ffffff;
  --surface-2: #f4f7f9;
  --line: #dce3e8;
  --ink: #15232e;
  --ink-2: #4c5d6b;
  --ink-3: #7d8b96;
  --primary: #0e6a85;
  --primary-ink: #ffffff;
  --primary-soft: #e1f0f5;
  --sky: rgba(64, 152, 214, .26);
  --sky-2: rgba(64, 152, 214, .12);
  --sky-line: #2f86c6;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --up: #0b7a4b;
  --up-soft: #e2f3ea;
  --down: #c13b2a;
  --down-soft: #fbe8e5;
  --warn: #9a6400;
  --warn-soft: #fbf0d9;
  --grid: #e8edf1;
  --shadow: 0 1px 2px rgba(21, 35, 46, .06), 0 2px 10px rgba(21, 35, 46, .05);
  --radius-l: 18px;
  --radius-m: 12px;
  --radius-s: 8px;
  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  --num: "Barlow Semi Condensed", "Zen Kaku Gothic New", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f171d; --surface: #17222a; --surface-2: #1d2a33; --line: #2a3a45;
    --ink: #e8eef2; --ink-2: #b3c1cb; --ink-3: #82939f;
    --primary: #4fb3d4; --primary-ink: #08212b; --primary-soft: #183846;
    --sky: rgba(90, 170, 230, .30); --sky-2: rgba(90, 170, 230, .14); --sky-line: #6db8ea;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --up: #46c987; --up-soft: #173527; --down: #f07a69; --down-soft: #3d201c; --warn: #e4ac3c; --warn-soft: #3a2f17;
    --grid: #22313b; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f171d; --surface: #17222a; --surface-2: #1d2a33; --line: #2a3a45;
  --ink: #e8eef2; --ink-2: #b3c1cb; --ink-3: #82939f;
  --primary: #4fb3d4; --primary-ink: #08212b; --primary-soft: #183846;
  --sky: rgba(90, 170, 230, .30); --sky-2: rgba(90, 170, 230, .14); --sky-line: #6db8ea;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --up: #46c987; --up-soft: #173527; --down: #f07a69; --down-soft: #3d201c; --warn: #e4ac3c; --warn-soft: #3a2f17;
  --grid: #22313b; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.7;
  font-feature-settings: "palt"; letter-spacing: .01em;
}
button, input { font: inherit; color: inherit; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--sky-line); outline-offset: 2px; border-radius: 6px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--ink-3); }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- アプリの枠 ---------- */
.app { max-width: 760px; margin: 0 auto; padding: 0 16px calc(88px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 12px; padding: 12px 0 10px; margin: 0 -16px; padding-inline: 16px;
}
.brand { font-weight: 700; font-size: 19px; letter-spacing: .04em; display: flex; align-items: center; gap: 8px; }
.brand svg { flex: none; }
.topbar .spacer { flex: 1; }
.topbar .updated { font-size: 12.5px; color: var(--ink-3); text-align: right; line-height: 1.35; }
.back {
  border: 0; background: var(--surface); border-radius: 999px; width: 40px; height: 40px;
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow);
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabbar nav { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  text-decoration: none; color: var(--ink-3); font-size: 11.5px; border-radius: 10px;
}
.tabbar a[aria-current="page"] { color: var(--primary); font-weight: 700; }
.tabbar svg { width: 24px; height: 24px; }

h1.page-title { font-size: 26px; line-height: 1.35; margin: 14px 0 4px; letter-spacing: .02em; }
.lead { color: var(--ink-2); margin: 0 0 18px; font-size: 15px; }
h2.sec { font-size: 18px; margin: 30px 0 12px; display: flex; align-items: baseline; gap: 10px; }
h2.sec small { font-size: 13px; color: var(--ink-3); font-weight: 400; }

/* ---------- 今日のまとめ ---------- */
.brief {
  background: var(--primary); color: var(--primary-ink); border-radius: var(--radius-l);
  padding: 18px 20px 16px; position: relative; overflow: hidden;
}
.brief h2 { margin: 0 0 8px; font-size: 15px; font-weight: 500; opacity: .85; }
.brief ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.brief li { font-size: 15.5px; line-height: 1.65; padding-left: 18px; position: relative; }
.brief li::before { content: ""; position: absolute; left: 2px; top: .7em; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .6; }

/* ---------- 銘柄カード ---------- */
.cards { display: grid; gap: 12px; }
.card {
  background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
a.stock {
  display: block; text-decoration: none; color: inherit; padding: 16px 18px 14px;
  transition: transform .15s ease;
}
a.stock:active { transform: scale(.99); }
.stock-head { display: flex; align-items: flex-start; gap: 10px; }
.stock-name { font-weight: 700; font-size: 17px; line-height: 1.35; }
.stock-code { font-size: 12px; color: var(--ink-3); font-weight: 400; display: block; }
.stock-price { margin-left: auto; text-align: right; line-height: 1.2; }
.stock-price .px { font-family: var(--num); font-size: 26px; font-weight: 600; }
.pill {
  display: inline-flex; align-items: center; gap: 2px; font-family: var(--num); font-weight: 600; font-size: 14.5px;
  padding: 1px 8px; border-radius: 999px; margin-top: 3px;
}
.pill.up { background: var(--up-soft); }
.pill.down { background: var(--down-soft); }
.pill.flat { background: var(--surface-2); }
.stock-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; align-items: end; margin-top: 10px; }
.spark { height: 54px; }
.spark svg { width: 100%; height: 54px; display: block; overflow: visible; }
.stock-note { margin-top: 10px; font-size: 14px; color: var(--ink-2); display: flex; gap: 8px; align-items: baseline; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 0 9px; border-radius: 999px;
  font-size: 12.5px; line-height: 22px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.chip.up { background: var(--up-soft); color: var(--up); }
.chip.down { background: var(--down-soft); color: var(--down); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

/* 来週の予報（このアプリの主役） */
.fc { font-size: 12.5px; }
.fc-label { color: var(--ink-3); display: flex; justify-content: space-between; }
.fc-label b { color: var(--sky-line); font-weight: 700; }
.fc-track { position: relative; height: 26px; margin: 3px 0 2px; }
.fc-axis { position: absolute; left: 0; right: 0; top: 12px; height: 2px; background: var(--grid); border-radius: 2px; }
.fc-band { position: absolute; top: 4px; height: 18px; border-radius: 9px; background: var(--sky); border: 1.5px solid var(--sky-line); }
.fc-now { position: absolute; top: 0; width: 4px; height: 26px; margin-left: -2px; border-radius: 2px; background: var(--ink); }
.fc-ends { display: flex; justify-content: space-between; font-family: var(--num); font-size: 14px; font-weight: 600; }
.fc-ends span small { font-weight: 400; color: var(--ink-3); font-size: 12px; margin-left: 2px; }

/* ---------- 詳細 ---------- */
.detail-head { display: flex; align-items: flex-end; gap: 12px; margin: 10px 0 14px; flex-wrap: wrap; }
.detail-head h1 { font-size: 24px; margin: 0; line-height: 1.3; }
.detail-head .px { font-family: var(--num); font-size: 38px; font-weight: 600; line-height: 1; }
.seg { display: inline-grid; grid-auto-flow: column; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 14px; color: var(--ink-2);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }
.chart-card { padding: 14px 14px 10px; }
.readout { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-height: 30px; font-size: 14px; color: var(--ink-2); }
.readout .v { font-family: var(--num); font-size: 22px; font-weight: 600; color: var(--ink); }
.chart { position: relative; margin-top: 6px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 18px; height: 3px; border-radius: 2px; display: inline-block; }
.key i.dot { width: 10px; height: 10px; border-radius: 50%; }
.key i.band { height: 10px; border-radius: 3px; background: var(--sky); border: 1px solid var(--sky-line); }
.event-box {
  margin-top: 12px; background: var(--surface-2); border-radius: var(--radius-m); padding: 12px 14px; font-size: 14.5px; color: var(--ink-2);
  border-left: 4px solid var(--ink-3);
}
.event-box.jump { border-left-color: var(--up); }
.event-box.drop { border-left-color: var(--down); }
.event-box.golden, .event-box.dead { border-left-color: var(--s2); }
.panel { padding: 18px 18px 16px; }
.panel h3 { margin: 0 0 8px; font-size: 16.5px; display: flex; align-items: center; gap: 6px; }
.panel p { margin: 0 0 8px; color: var(--ink-2); font-size: 15px; }
.story { display: grid; gap: 0; }
.story section { padding: 14px 0; border-top: 1px solid var(--grid); }
.story section:first-child { border-top: 0; padding-top: 2px; }
.story h3 { font-size: 15.5px; margin: 0 0 4px; }
.story p { margin: 0; color: var(--ink-2); font-size: 15px; }
.stack { display: grid; gap: 12px; }
.fc-big .fc-track { height: 34px; }
.fc-big .fc-band { top: 6px; height: 22px; border-radius: 11px; }
.fc-big .fc-now { height: 34px; }
.fc-big .fc-ends { font-size: 17px; }
.fc-row + .fc-row { margin-top: 14px; }

.meter { display: grid; grid-template-columns: 9.5em 1fr 3.2em; align-items: center; gap: 10px; font-size: 14px; margin: 8px 0; }
.meter .track { position: relative; height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.meter .fill { position: absolute; top: 0; bottom: 0; border-radius: 6px; }
.meter .mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--ink-3); }
.meter .val { text-align: right; font-family: var(--num); font-weight: 600; }

.q {
  border: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  font-size: 13px; font-weight: 700; cursor: pointer; display: inline-grid; place-items: center; padding: 0; line-height: 1; flex: none;
}

/* ---------- 下から出る説明シート ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(8, 18, 25, .45); z-index: 40; opacity: 0; transition: opacity .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--surface);
  border-radius: 20px 20px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  max-width: 760px; margin: 0 auto; max-height: 82vh; overflow: auto;
  transform: translateY(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet.open { transform: none; }
.sheet-bg.open { opacity: 1; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet h3 { margin: 0 0 8px; font-size: 19px; }
.sheet p { color: var(--ink-2); margin: 0 0 10px; }
.sheet .fig { background: var(--surface-2); border-radius: var(--radius-m); padding: 10px; margin: 6px 0 12px; }
.sheet .fig svg { width: 100%; height: auto; display: block; }
.sheet .close { width: 100%; margin-top: 6px; }

/* ---------- ボタン・フォーム ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; cursor: pointer; font-size: 16px;
  background: var(--primary); color: var(--primary-ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: var(--down-soft); color: var(--down); }
.btn:disabled { opacity: .55; cursor: default; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; font-weight: 700; }
.field input {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); font-size: 17px; width: 100%;
}
.field input:focus { border-color: var(--primary); outline: none; }
.hint { font-size: 13px; color: var(--ink-3); }
.error { background: var(--down-soft); color: var(--down); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.ok { background: var(--up-soft); color: var(--up); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }

/* ---------- ガイド ---------- */
.guide-list { display: grid; gap: 12px; }
.guide-item { padding: 18px; }
.guide-item h3 { margin: 0 0 6px; font-size: 18px; }
.guide-item p { margin: 0 0 8px; color: var(--ink-2); font-size: 15px; }
.guide-item .fig { background: var(--surface-2); border-radius: var(--radius-m); padding: 10px; margin: 10px 0; }
.guide-item .fig svg { width: 100%; height: auto; display: block; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--grid); }
.list-row:first-child { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.code-show { font-family: var(--num); font-size: 34px; letter-spacing: .14em; font-weight: 600; text-align: center; padding: 10px; background: var(--surface-2); border-radius: 12px; margin: 10px 0; }

.loading { padding: 60px 0; text-align: center; color: var(--ink-3); }
.empty-note { font-size: 14px; color: var(--ink-3); }

@media (min-width: 720px) {
  .cards.two { grid-template-columns: 1fr 1fr; }
  h1.page-title { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- 保有・配当・会社情報 ---------- */
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--grid); font-size: 13.5px; color: var(--ink-2); }
.card-foot .badges { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.portfolio { margin-bottom: 14px; }
.pf-label { font-size: 14px; color: var(--ink-2); }
.pf-value { font-size: 40px; font-weight: 600; line-height: 1.15; margin: 2px 0 10px; }
.pf-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pf-row div { background: var(--surface-2); border-radius: var(--radius-m); padding: 8px 12px; display: grid; }
.pf-row span { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 4px; }
.pf-row b { font-size: 20px; font-weight: 600; }
.pf-row small { font-size: 13px; }
.pf-edit { display: inline-block; margin-top: 10px; font-size: 14px; }
a.setup-cta { display: block; text-decoration: none; color: inherit; margin-bottom: 14px; border: 1.5px dashed var(--primary); }
.events { padding: 6px 18px; }
.ev-row { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid var(--grid); text-decoration: none; color: inherit; }
.ev-row:first-child { border-top: 0; }
.ev-date { flex: none; width: 64px; display: grid; text-align: center; background: var(--surface-2); border-radius: 10px; padding: 6px 0; line-height: 1.3; }
.ev-date b { font-size: 14.5px; }
.ev-date span { font-size: 12px; color: var(--primary); font-weight: 700; }
.ev-body p { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-2); }
.jump { display: flex; gap: 8px; overflow-x: auto; margin: 18px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; }
.jump a { flex: none; text-decoration: none; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); padding: 5px 12px; border-radius: 999px; font-size: 13.5px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 6px; }
.kpis > div { background: var(--surface-2); border-radius: var(--radius-m); padding: 10px 12px; display: grid; gap: 1px; align-content: start; }
.kpis span { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 4px; }
.kpis b { font-size: 19px; font-weight: 600; line-height: 1.35; }
.kpis small { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.callout { margin-top: 12px; background: var(--primary-soft); border-radius: var(--radius-m); padding: 10px 14px; font-size: 14.5px; }
.bars svg { width: 100%; height: auto; display: block; max-width: 520px; }
.yuutai-sum { font-size: 16px; }
ul.plain { margin: 6px 0 10px; padding-left: 1.2em; color: var(--ink-2); font-size: 14.5px; }
ul.plain li { margin: 3px 0; }
.news-row { display: grid; grid-template-columns: 5.8em 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--grid); font-size: 14.5px; }
.news-row:first-child { border-top: 0; }
.news-date { color: var(--ink-3); font-size: 13.5px; padding-top: 1px; }
fieldset.hold { margin: 0; min-width: 0; }
fieldset.hold legend { float: left; width: 100%; padding: 0; margin-bottom: 10px; font-size: 16px; }
.hold-grid { clear: both; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hold-grid label { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 6px; font-size: 13px; color: var(--ink-2); }
.hold-grid label input { grid-column: 1; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 17px; background: var(--surface); width: 100%; min-width: 0; font-family: var(--num); }
.hold-grid label input:focus { border-color: var(--primary); outline: none; }
.hold-grid label span { grid-column: 2; grid-row: 2; }
.hold-grid label.wide { grid-column: 1 / -1; }
