:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --border: #e7e9ee;
  --border-strong: #d6dae1;
  --text: #0f1729;
  --muted: #5b6577;
  --faint: #94a0b3;
  --accent: #2563eb;
  --accent-h: #1d4ed8;
  --accent-soft: #eef4ff;
  --up: #0a9d57;
  --up-soft: #e7f6ee;
  --down: #e0344a;
  --down-soft: #fdeced;
  --gold: #b8860b;
  --gold-strong: #9a6f08;
  --gold-soft: #fff5d6;
  --gold-line: #f1d58a;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow: 0 8px 24px -10px rgba(16, 24, 40, 0.16);
  --shadow-lg: 0 24px 48px -18px rgba(16, 24, 40, 0.22);
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.1px;
}

.hidden { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* フォーカス可視（アクセシビリティ） */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:focus-visible, .tab:focus-visible, .quicknav button:focus-visible,
.qa-q:focus-visible, .ticker-btn:focus-visible, .modal-x:focus-visible,
.rank-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ブランドマーク（インラインSVG・認証/topbar共用） */
.brand-mark { width: 26px; height: 26px; flex-shrink: 0; }
.brand-mark .bm-bg { fill: var(--accent); }
.brand-mark .bm-line { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark .bm-dot { fill: #fff; }
.brand .brand-mark { vertical-align: -6px; margin-right: 9px; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== ボタン ===== */
.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s, box-shadow 0.16s, transform 0.16s, border-color 0.16s, color 0.16s;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn.primary:hover { background: var(--accent-h); transform: translateY(-1px); box-shadow: 0 6px 16px -6px rgba(37, 99, 235, 0.5); }
.btn.primary:active { transform: translateY(0); }
.btn.ghost {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border-strong);
}
.btn.ghost:hover { color: var(--text); border-color: var(--faint); background: var(--surface-2); }
.btn.link { background: none; color: var(--accent); padding: 6px; font-weight: 600; font-size: 13px; }
.btn.link:hover { color: var(--accent-h); text-decoration: underline; }
.btn.buy {
  background: var(--up-soft); color: var(--up); border: 1px solid rgba(10, 157, 87, 0.25);
  padding: 8px 14px; border-radius: 9px;
}
.btn.buy:hover { background: var(--up); color: #fff; }
.btn.sell {
  background: var(--down-soft); color: var(--down); border: 1px solid rgba(224, 52, 74, 0.25);
  padding: 8px 14px; border-radius: 9px;
}
.btn.sell:hover { background: var(--down); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none; }

/* ===== 認証画面 ===== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(700px 400px at 50% -5%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 38px 34px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.45s ease both;
}
.brand {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}
.brand span {
  display: block;
  margin-top: 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
}
.tagline { margin: 0 0 26px; color: var(--muted); font-size: 14px; }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 22px;
  background: #eef1f5;
  padding: 4px;
  border-radius: 11px;
}
.tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.18s;
}
.tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.auth-form { display: flex; flex-direction: column; gap: 13px; animation: fadeUp 0.3s ease both; }
.auth-form input {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 13px 15px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.auth-form input::placeholder { color: var(--faint); }
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.hint { color: var(--muted); font-size: 13px; margin: 0; line-height: 1.6; }
.auth-msg { margin: 14px 0 0; font-size: 13px; min-height: 18px; font-weight: 600; }
.auth-msg.error { color: var(--down); }
.auth-msg.ok { color: var(--up); }

/* パスワード要件チェックリスト */
.pw-rules { list-style: none; margin: -2px 0 2px; padding: 0; display: grid; gap: 7px; }
.pw-rules li {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.5px; color: var(--faint);
  transition: color 0.18s;
}
.pw-rules li .mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: #eef1f5; border: 1px solid var(--border);
  font-size: 11px; line-height: 1; transition: all 0.2s; color: var(--faint);
}
.pw-rules li.ok { color: var(--up); }
.pw-rules li.ok .mark { background: var(--up); border-color: var(--up); color: #fff; font-weight: 800; }

/* ===== トップバー ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(12px) saturate(150%);
}
.topbar-brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; letter-spacing: -0.3px; color: var(--text); }

/* クイックナビ（セクションジャンプ）— PC:上部 / スマホ:下部固定 */
.stickytop { position: sticky; top: 0; z-index: 10; }
.stickytop .topbar { position: static; }
.quicknav {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 26px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px) saturate(160%);
  overflow-x: auto;
}
.quicknav button {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--muted); padding: 8px 14px; border-radius: 999px;
  font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer;
  white-space: nowrap; transition: all 0.15s;
}
.quicknav button:hover { color: var(--accent); border-color: var(--accent); }
.quicknav button.active { color: #fff; background: var(--accent); border-color: var(--accent); box-shadow: 0 4px 12px -6px rgba(37, 99, 235, 0.5); }
.qn-ico { font-size: 15px; }
#sec-assets, #sec-market, #sec-history { scroll-margin-top: 116px; }

@media (max-width: 600px) {
  /* スマホは画面下部に固定タブバー */
  .quicknav {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    justify-content: space-around;
    gap: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border); border-bottom: none;
    box-shadow: 0 -6px 18px -10px rgba(16, 24, 40, 0.25);
    background: rgba(255, 255, 255, 0.96);
    z-index: 30; overflow: visible;
  }
  .quicknav button {
    flex: 1; flex-direction: column; gap: 2px;
    border: none; background: none; border-radius: 12px;
    padding: 5px 4px; font-size: 11px; color: var(--muted);
  }
  .quicknav button:hover { border: none; }
  .quicknav button:active { background: var(--accent-soft); color: var(--accent); }
  .quicknav button.active { background: none; color: var(--accent); box-shadow: none; position: relative; }
  .quicknav button.active::before {
    content: ""; position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
    width: 26px; height: 3px; border-radius: 3px; background: var(--accent);
  }
  .qn-ico { font-size: 20px; }
  /* 下部バーに隠れないよう余白 */
  .container { padding-bottom: 84px; }
  /* 上部の固定はトップバーのみになるのでオフセットを縮小 */
  #sec-assets, #sec-market, #sec-history { scroll-margin-top: 64px; }
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-email {
  color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 7px 14px; background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 999px; cursor: pointer; font-family: inherit;
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: all 0.15s;
}
.user-email:hover { color: var(--text); border-color: var(--faint); background: var(--surface); }

/* マイページ */
.mp-section { padding: 16px 0; border-top: 1px solid var(--border); }
.mp-section:first-of-type { border-top: none; padding-top: 4px; }
.mp-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.mp-k { color: var(--muted); }
.mp-v { font-weight: 700; font-family: var(--mono); }
.mp-label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 8px; letter-spacing: 0.3px; }
.mp-inline { display: flex; gap: 8px; }
.mp-inline input { flex: 1; }
.mp-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.mp-section input {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 11px 13px; color: var(--text);
  font-family: inherit; font-size: 14px;
}
.mp-section input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mp-current { font-size: 14px; font-weight: 600; margin-bottom: 10px; word-break: break-all; }
.mp-hint { color: var(--faint); font-size: 12px; margin: 8px 0 0; line-height: 1.6; }
.mp-danger { border-top: 1px solid #f4d2d2; }
.mp-msg { margin: 12px 0 0; font-size: 13px; min-height: 18px; font-weight: 600; }
.mp-msg.ok { color: var(--up); }
.mp-msg.error { color: var(--down); }
.btn.danger { background: var(--down); color: #fff; }
.btn.danger:hover { background: #c42a3e; transform: translateY(-1px); }

/* ===== Q&A アコーディオン ===== */
.qa-list { display: flex; flex-direction: column; }
.qa-item { border-bottom: 1px solid var(--border); }
.qa-q {
  width: 100%; background: none; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 2px; font-family: inherit; font-size: 14px; font-weight: 700;
  color: var(--text); text-align: left;
}
.qa-q:hover { color: var(--accent); }
.qa-arrow { color: var(--faint); transition: transform 0.2s; flex-shrink: 0; }
.qa-item.open .qa-arrow { transform: rotate(180deg); }
.qa-a {
  display: none;
  padding: 0 2px 16px;
  color: var(--muted); font-size: 13.5px; line-height: 1.7;
}
.qa-item.open .qa-a { display: block; }
.qa-a p { margin: 0 0 8px; }

/* ===== 市場：検索・銘柄ボタン ===== */
.market-tools { margin-bottom: 12px; }
#market-search {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 11px 14px; color: var(--text);
  font-family: inherit; font-size: 14px;
}
#market-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ticker-btn {
  background: none; border: none; cursor: pointer; padding: 0; text-align: left;
  font-family: inherit; color: var(--text); display: flex; flex-direction: column; gap: 2px;
}
.ticker-btn strong { font-size: 14.5px; }
.ticker-sub { color: var(--muted); font-size: 12px; }
.ticker-btn:hover strong { color: var(--accent); }
.ticker-btn:hover .ticker-sub { color: var(--accent); }

/* ===== 会社情報モーダル ===== */
.co-chart { margin: 0 0 16px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; min-height: 320px; background: var(--surface-2); }
.co-chart iframe { display: block; border: 0; width: 100% !important; }

/* ===== アフィリエイト導線（控えめ・既存カードと統一） ===== */
.aff-footer { margin-top: 18px; }
.aff-card {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 14px;
}
.aff-pr {
  display: inline-block; font-size: 10px; font-weight: 700; color: var(--faint);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px;
  letter-spacing: 0.3px; background: var(--surface);
}
.aff-body { margin: 10px 0 12px; }
.aff-headline { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.aff-name { font-size: 16px; font-weight: 800; margin: 0 0 2px; }
.aff-desc { font-size: 12.5px; color: var(--muted); margin: 0; }
.aff-cta {
  display: inline-block; text-decoration: none; font-weight: 700; font-size: 13.5px;
  color: #fff; background: var(--accent); border-radius: 10px; padding: 9px 18px;
}
.aff-cta:hover { background: var(--accent-h); }
.aff-risk { font-size: 11px; color: var(--faint); margin: 10px 0 0; }
/* 週間バナーの控えめテキストリンク */
.aff-week {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
  font-size: 12px; color: var(--muted); text-decoration: none;
}
.aff-week:hover { color: var(--accent); }
.aff-week .aff-pr { font-size: 9px; }
/* サイトフッター（運営者情報・ポリシー導線） */
.site-footer { margin-top: 26px; padding: 18px 4px 8px; border-top: 1px solid var(--border); }
.foot-links { display: flex; flex-wrap: wrap; gap: 14px; }
.foot-links a { font-size: 12px; color: var(--muted); text-decoration: none; }
.foot-links a:hover { color: var(--accent); text-decoration: underline; }
.foot-note { font-size: 11px; color: var(--faint); margin: 10px 0 0; line-height: 1.6; }

/* ===== 投資シミュレーション バッジ＆初回案内 ===== */
.sim-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border: 1px solid #cfe0ff;
  border-radius: 999px; padding: 3px 10px; margin: 8px 0 0;
  white-space: nowrap;
}
.sim-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.tb-name { display: inline-flex; align-items: center; gap: 9px; }
.sim-badge-top { margin: 0; font-size: 10.5px; padding: 2px 8px; }
.sim-badge-lg { font-size: 13px; padding: 5px 14px; margin: 0; }
@media (max-width: 600px) {
  /* iPhone等では「カブテラ」を上段・「投資シミュレーション」を下段に分ける */
  .topbar-brand { flex-direction: column; align-items: flex-start; gap: 3px; }
  .sim-badge-top { font-size: 10px; padding: 2px 7px; }
}

.intro-hero { text-align: center; margin-bottom: 14px; }
.intro-hero .sim-badge { margin: 0 auto; }
.intro-title { font-size: 19px; margin: 12px 0 0; }
.intro-lead { font-size: 14px; color: var(--text); line-height: 1.7; margin: 0 0 16px; }
.intro-points { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.intro-points li { display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; line-height: 1.65; }
.intro-points .ip-ico { font-size: 20px; flex-shrink: 0; line-height: 1.3; }
.intro-points strong { color: var(--text); }
.intro-note { font-size: 11.5px; color: var(--faint); margin: 0 0 16px; line-height: 1.6; }

/* ===== Googleログイン ===== */
.google-btn {
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #3c4043; border: 1px solid var(--border);
  font-weight: 700; font-size: 14.5px; padding: 11px 16px; border-radius: 10px; margin-top: 6px;
  cursor: pointer; transition: background 0.15s, box-shadow 0.15s;
}
.google-btn:hover { background: #f7f9fc; box-shadow: var(--shadow-sm); }
.g-icon { width: 18px; height: 18px; flex-shrink: 0; }
.social-divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 11.5px; margin: 16px 0 6px; }
.social-divider::before, .social-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ===== PWA インストールバナー / 手順 ===== */
.install-banner {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px;
  width: min(440px, calc(100% - 24px)); z-index: 60;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.28);
  padding: 10px 12px;
}
.ib-icon { width: 40px; height: 40px; border-radius: 9px; flex-shrink: 0; }
.ib-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; flex: 1; }
.ib-text strong { font-size: 13.5px; }
.ib-text span { font-size: 11.5px; color: var(--muted); }
.ib-add { padding: 8px 16px; flex-shrink: 0; }
.ib-x { background: none; border: none; color: var(--faint); font-size: 15px; cursor: pointer; padding: 4px 6px; flex-shrink: 0; }
@media (max-width: 600px) { .install-banner { bottom: 78px; } } /* 下部タブを避ける */
.ios-steps { padding-left: 20px; margin: 8px 0 14px; }
.ios-steps li { font-size: 13.5px; line-height: 1.95; }

.co-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.co-logo { width: 52px; height: 52px; object-fit: contain; border-radius: 10px; border: 1px solid var(--border); background: #fff; padding: 4px; }
.co-name { font-size: 18px; font-weight: 800; }
.co-en { color: var(--muted); font-size: 13px; }
.co-dl { margin: 0; display: grid; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.co-dl > div { display: flex; justify-content: space-between; gap: 12px; background: var(--surface); padding: 11px 14px; }
.co-dl dt { color: var(--muted); font-size: 13px; margin: 0; }
.co-dl dd { margin: 0; font-weight: 700; font-size: 14px; text-align: right; }
.co-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.co-buy { display: flex; gap: 8px; }
.co-buy .qty-input { width: 80px; }
.co-web { color: var(--accent); font-weight: 700; font-size: 13px; text-decoration: none; }
.co-web:hover { text-decoration: underline; }

/* ===== 取引履歴：期間・サマリ・ページャ ===== */
.hist-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.hist-tools select, .hist-tools input[type="date"] {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 9px; padding: 9px 12px; color: var(--text);
  font-family: inherit; font-size: 14px;
}
.hist-tools select:focus, .hist-tools input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hist-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.hs-item {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-sm);
}
.hs-item span:first-child { color: var(--muted); font-size: 12px; }
.hs-item strong { font-size: 16px; font-family: var(--mono); }
.hs-item span:last-child { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.hs-net { background: var(--accent-soft); border-color: #d7e3fb; }
.hist-pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 14px; }
.hist-page { color: var(--muted); font-size: 13px; font-weight: 600; }

/* 取引履歴：銘柄別グループ見出し */
.grp-cell { background: var(--surface-2); border-top: 2px solid var(--border); }
.grp-head-inner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.grp-ticker { font-weight: 800; font-size: 15px; }
.grp-meta { color: var(--muted); font-size: 12px; }
.grp-pl { margin-left: auto; font-family: var(--mono); font-weight: 800; font-size: 14px; }
@media (max-width: 600px) {
  #history-table td.grp-cell { display: block; }
  #history-table td.grp-cell::before { content: ""; }
  .grp-pl { margin-left: 0; width: 100%; }
}

/* モーダルが画面端に触れないよう余白（全サイズ共通） */
.modal { padding: 16px; }
.btn-label { } /* 通常時はラベル表示。モバイルで非表示にする */

/* ===== モバイル（iPhone 13 = 390px 等） ===== */
@media (max-width: 600px) {
  .topbar { padding: 11px 14px; }
  .topbar-brand { font-size: 16px; }
  .topbar-right { gap: 6px; }
  /* トップバーのボタンはアイコンのみに縮約（横はみ出し防止） */
  .btn-label { display: none; }
  .user-email { padding: 9px 11px; max-width: none; }
  .topbar-right .btn.ghost { padding: 9px 11px; }
  #ranking-btn .rank-dot { top: 3px; right: 4px; }

  .container { padding: 20px 14px 50px; }
  .summary { gap: 12px; }
  .card { padding: 16px; }
  .card-value { font-size: 20px; }
  .card.hero .card-value { font-size: 28px; }

  .auth-card { padding: 30px 22px; }
  .modal-card { padding: 20px; }
  .section-title { margin: 22px 0 12px; }

  /* テーブルを「1行＝カード」に（横スクロール解消＋カードUI） */
  .table-wrap { overflow-x: visible; background: transparent; border: none; box-shadow: none; }
  #holdings-table, #market-table, #history-table,
  #holdings-table tbody, #market-table tbody, #history-table tbody { display: block; }
  #holdings-table thead, #market-table thead, #history-table thead { display: none; }
  #holdings-table tbody tr,
  #market-table tbody tr,
  #history-table tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 12px 14px;
    margin-bottom: 10px;
  }
  #holdings-table tbody tr:nth-child(even),
  #market-table tbody tr:nth-child(even),
  #history-table tbody tr:nth-child(even),
  #holdings-table tbody tr:hover,
  #market-table tbody tr:hover,
  #history-table tbody tr:hover { background: var(--surface); }
  #holdings-table td,
  #market-table td,
  #history-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    text-align: right;
    white-space: normal;
    border: none;
  }
  #holdings-table td::before,
  #market-table td::before,
  #history-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    font-family: "Plus Jakarta Sans", sans-serif;
    text-align: left;
    flex-shrink: 0;
  }
  /* 先頭セル＝カード見出し（銘柄/日時）を強調、区切り線を引く */
  #holdings-table td:first-child,
  #market-table td:first-child,
  #history-table td:first-child {
    border-bottom: 1px solid var(--border);
    padding-bottom: 9px; margin-bottom: 5px;
  }
  #holdings-table td:first-child::before,
  #market-table td:first-child::before,
  #history-table td:first-child::before { content: ""; }
  #holdings-table td:first-child strong,
  #history-table td:first-child strong,
  .ticker-btn strong { font-size: 16px; }
  /* 操作セル（買う/売る）は全幅ボタンで押しやすく */
  td.act-cell { display: block; padding-top: 10px; }
  td.act-cell::before { content: ""; }
  td.act-cell .btn { width: 100%; padding: 12px; font-size: 15px; }
  /* 空状態は1枚のカードとして中央表示 */
  td.empty { display: block; text-align: center; }
  td.empty::before { content: ""; }
  #market-table td .qty-input { width: 100px; }
}

/* ===== コンテナ ===== */
.container { max-width: 1080px; margin: 0 auto; padding: 30px 26px 60px; animation: fadeUp 0.35s ease both; }

/* サマリ：3層の階層（hero / 損益・収益率 / 現金・為替） */
.summary {
  display: grid;
  gap: 14px;
  margin-bottom: 34px;
  grid-template-columns: 1.5fr 0.5fr 1fr 1fr;
  grid-template-areas:
    "hero hero pl  ret"
    "hero hero cash fx";
}
.summary .hero { grid-area: hero; }
.summary .accent-pl { grid-area: pl; }
.summary .accent-return { grid-area: ret; }
.summary .accent-cash { grid-area: cash; }
.summary .accent-fx { grid-area: fx; }
@media (max-width: 880px) {
  .summary {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "hero hero"
      "pl   ret"
      "cash fx";
  }
}
/* ②パフォーマンス（損益・収益率）は主役級：大きく・符号で背景tint（:has） */
.card.accent-pl .card-value, .card.accent-return .card-value { font-size: 24px; }
.card.accent-pl:has(.pos), .card.accent-return:has(.pos) {
  background: var(--up-soft); border-color: rgba(10, 157, 87, 0.28);
}
.card.accent-pl:has(.neg), .card.accent-return:has(.neg) {
  background: var(--down-soft); border-color: rgba(224, 52, 74, 0.28);
}
/* ③現金・為替は参照値：視覚ウェイトを一段下げる */
.card.accent-cash, .card.accent-fx { background: var(--surface-2); }
.card.accent-cash .card-value, .card.accent-fx .card-value { font-size: 18px; color: var(--text); }
.card.accent-cash .card-label, .card.accent-fx .card-label { font-size: 11px; }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card::before {
  content: ""; position: absolute; top: 0; left: 0; bottom: 0; width: 3px;
  background: var(--accent);
}
.card.accent-cash::before { background: #2563eb; }
.card.accent-pl::before { background: linear-gradient(180deg, var(--up), var(--down)); }
.card.accent-return::before { background: #0ea5e9; }
.card.accent-fx::before { background: #f59e0b; }
.card-label { color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.card-value { font-size: 22px; font-weight: 800; font-family: var(--mono); letter-spacing: -0.5px; color: var(--text); }

.card.hero {
  background: linear-gradient(180deg, #ffffff, var(--accent-soft));
  border-color: #d7e3fb;
}
.card.hero::before { width: 0; }
.card.hero .card-label { color: var(--accent); font-weight: 700; }
.card.hero .card-value { font-size: 33px; }
.card-foot { margin-top: 12px; }
.badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700; font-family: var(--mono);
  background: #eef1f5; color: var(--muted); border: 1px solid var(--border);
}
.badge.pos { color: var(--up); border-color: rgba(10, 157, 87, 0.3); background: var(--up-soft); }
.badge.neg { color: var(--down); border-color: rgba(224, 52, 74, 0.3); background: var(--down-soft); }

.section-title {
  font-size: 13px; font-weight: 700; margin: 28px 0 14px;
  color: var(--muted); letter-spacing: 0.4px; text-transform: uppercase;
  display: flex; align-items: center; gap: 12px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 14px 16px; text-align: left; white-space: nowrap; }
th {
  color: var(--faint); font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.14s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:nth-child(even) { background: #fcfdff; }
tbody tr:hover { background: var(--surface-2); }
td strong { font-weight: 700; font-size: 14.5px; }
td.empty { text-align: center; color: var(--faint); padding: 40px 20px; font-size: 13.5px; }
.pos { color: var(--up); }
.neg { color: var(--down); }
td.est { color: var(--muted); font-weight: 600; }

/* スケルトン（読み込み中のシマー） */
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skeleton {
  border-radius: 8px; color: transparent !important;
  background: linear-gradient(90deg, #eef1f6 25%, #f6f8fb 37%, #eef1f6 63%);
  background-size: 800px 100%; animation: shimmer 1.3s linear infinite;
}

/* ===== ランキング ===== */
.rank-mine {
  margin-left: 10px; color: var(--accent); font-weight: 700;
  font-size: 12px; letter-spacing: 0; text-transform: none;
  background: var(--accent-soft); border: 1px solid #d7e3fb;
  padding: 2px 10px; border-radius: 999px;
}
.rank-num { font-family: var(--mono); font-weight: 700; font-size: 15px; }
tbody tr.me-row { background: var(--accent-soft); }
tbody tr.me-row:hover { background: #e3edff; }
.you-tag {
  display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 700;
  color: var(--accent); background: var(--surface); border: 1px solid #d7e3fb;
  border-radius: 999px; padding: 1px 8px;
}
tr.rank-sep td { text-align: center; color: var(--faint); padding: 4px; letter-spacing: 4px; }

/* ランキング タブ */
.rank-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.rank-tab {
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--muted); padding: 8px 16px; border-radius: 999px;
  font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer;
  transition: all 0.16s;
}
.rank-tab:hover { color: var(--text); }
.rank-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.rank-note { color: var(--muted); font-size: 12px; margin: 10px 2px 0; line-height: 1.6; }

/* 取引履歴のタグ */
.tag-buy, .tag-sell, .tag-bonus {
  display: inline-block; font-size: 12px; font-weight: 700;
  padding: 2px 10px; border-radius: 6px;
}
.tag-buy { color: var(--up); background: var(--up-soft); border: 1px solid rgba(10, 157, 87, 0.25); }
.tag-sell { color: var(--down); background: var(--down-soft); border: 1px solid rgba(224, 52, 74, 0.25); }
.tag-bonus { color: var(--accent); background: var(--accent-soft); border: 1px solid #d7e3fb; }
.qty-input {
  width: 74px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--mono);
  text-align: right;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.qty-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.updated { color: var(--faint); font-size: 12px; text-align: right; margin-top: 12px; }

/* ===== SBI風 カードリスト（保有株 / 市場 / 取引履歴） ===== */
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px 8px; color: var(--faint); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.cardlist {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px;
}
.cardlist .empty {
  grid-column: 1 / -1; text-align: center; color: var(--faint);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px 20px; box-shadow: var(--shadow-sm); font-size: 13.5px;
}
.qcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 14px 16px; transition: box-shadow 0.18s, transform 0.18s;
}
.qcard:hover { box-shadow: var(--shadow); }
.qcard-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.qcard-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; align-items: flex-start; }
.qcard-id strong { font-size: 17px; font-weight: 800; letter-spacing: -0.2px; }
.qcard-top .ticker-btn strong { font-size: 17px; }
.qcard-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px; }
.qcard-kpi { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.qcard-kpi-label { color: var(--faint); font-size: 11px; font-weight: 600; }
.qcard-kpi-val { font-family: var(--mono); font-size: 20px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); }
.qcard-kpi-sub { font-family: var(--mono); font-size: 13px; font-weight: 700; }
.qcard-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 14px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.qcard-grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.qcard-grid span { color: var(--faint); font-size: 11px; font-weight: 600; }
.qcard-grid b { font-family: var(--mono); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.qcard-foot { margin-top: 12px; display: flex; }
.qcard-foot .btn { padding: 9px 16px; }
.qcard-foot.qcard-buyrow { align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.qcard-est { color: var(--muted); font-size: 12.5px; }
.qcard-est b { font-family: var(--mono); color: var(--text); font-weight: 700; margin-left: 4px; }
.qcard-buyctl { display: flex; gap: 8px; align-items: center; }
.qcard-buyctl .qty-input { width: 84px; }
.qcard-date { color: var(--faint); font-size: 12px; font-family: var(--mono); flex-shrink: 0; white-space: nowrap; }

/* 銘柄別グループ見出し（カードリスト内・全幅） */
.grp-head {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; margin-top: 6px;
}
.grp-ticker { font-weight: 800; font-size: 15px; }
.grp-meta { color: var(--muted); font-size: 12px; }
.grp-pl { margin-left: auto; font-family: var(--mono); font-weight: 800; font-size: 14px; }

@media (max-width: 600px) {
  .cardlist { grid-template-columns: 1fr; gap: 10px; }
  .qcard { padding: 13px 14px; }
  .qcard-foot.qcard-buyrow .btn.buy { padding: 10px 18px; }
  .grp-pl { margin-left: 0; width: 100%; }
}

/* ===== トースト ===== */
.toast {
  position: fixed; top: 22px; left: 50%;
  transform: translateX(-50%) translateY(-90px);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 22px; border-radius: 12px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.25), opacity 0.3s;
  z-index: 100; font-size: 14px; font-weight: 600;
  border-left: 4px solid var(--accent);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { border-left-color: var(--down); }
.toast.ok { border-left-color: var(--up); }

/* ===== モーダル ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 41, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; backdrop-filter: blur(3px);
  animation: fadeUp 0.18s ease both;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-card h3 { margin: 0 0 14px; font-size: 18px; font-weight: 800; }
.modal-card p { color: var(--muted); font-size: 14px; line-height: 1.7; }
.modal-card p strong { color: var(--text); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* 今週の結果バナー（常設・ゴールド祝祭トーン） */
.week-result {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--gold-soft), #fffdf6);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  padding: 13px 18px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.wr-label { font-weight: 800; color: var(--gold-strong); font-size: 13px; }
.wr-rank { font-weight: 800; font-size: 18px; color: var(--text); font-family: var(--mono); }
.wr-bonus { color: var(--gold-strong); font-weight: 800; font-size: 14px; font-family: var(--mono); }
.week-result .btn.link { margin-left: auto; color: var(--gold-strong); }
.week-result .btn.link:hover { color: var(--gold); }

/* ===== ランキングモーダル ===== */
.modal-wide { max-width: 560px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 3;
  background: var(--surface);
  padding-bottom: 12px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-x { flex-shrink: 0; }
.modal-x {
  background: none; border: none; color: var(--faint); font-size: 18px;
  cursor: pointer; line-height: 1; padding: 4px 8px; border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.modal-x:hover { background: #eef1f5; color: var(--text); }

/* 🏆ボタンの未読ドット */
#ranking-btn { position: relative; }
.rank-dot {
  position: absolute; top: 6px; right: 8px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--down); border: 2px solid var(--surface);
  animation: dotPulse 1.6s ease-in-out infinite;
}
@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

/* 発表バナー（ゴールド祝祭＋控えめなきらめき） */
@keyframes goldSheen {
  0% { background-position: -250px 0; }
  100% { background-position: 350px 0; }
}
.rank-announce {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--gold-soft), #fffdf6);
  border: 1px solid var(--gold-line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
  text-align: center;
  animation: fadeUp 0.4s ease both;
}
.rank-announce::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.55) 50%, transparent 60%);
  background-size: 250px 100%; background-repeat: no-repeat;
  animation: goldSheen 2.4s ease-in-out 0.3s 2;
}
.announce-title { font-size: 18px; font-weight: 800; color: var(--gold-strong); }
.announce-me { margin-top: 8px; font-size: 14px; color: var(--muted); }
.announce-me strong { color: var(--text); font-size: 16px; font-family: var(--mono); }

/* ボーナスのタグもゴールド */
.tag-bonus { color: var(--gold-strong) !important; background: var(--gold-soft) !important; border-color: var(--gold-line) !important; }
