:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --up: #0a7d33;
  --down: #c0392b;
  --accent: #2563eb;
  --bull: #0a7d33;
  --bear: #c0392b;
  --watch: #b8860b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Segoe UI", sans-serif;
  background: #f1f5f9;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg); color: #fff;
  padding: env(safe-area-inset-top) 0 0;
}
.topbar-inner {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; gap: 12px;
}
.brand { font-weight: 700; font-size: 16px; }
.controls { display: flex; gap: 8px; align-items: center; }
.date-select {
  background: #1e293b; color: #fff; border: 1px solid #334155;
  border-radius: 8px; padding: 6px 8px; font-size: 13px;
}
.ghost-btn {
  background: transparent; color: #fff; border: 1px solid #475569;
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.ghost-btn:hover { background: #1e293b; }

.main { max-width: 760px; margin: 0 auto; padding: 16px; }
.status { color: var(--muted); padding: 24px 4px; font-size: 14px; }
.hidden { display: none !important; }

.overall {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; margin-bottom: 14px;
}
.overall-head { font-weight: 700; margin-bottom: 8px; font-size: 14px; color: var(--muted); }
.overall-text { font-size: 15px; line-height: 1.75; }
.generated-at { margin-top: 10px; font-size: 11px; color: var(--muted); }

.stocks { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px;
}
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.name { font-weight: 700; font-size: 16px; }
.ticker { color: var(--muted); font-weight: 400; font-size: 12px; }
.held { background: #dcfce7; color: #166534; font-size: 11px; padding: 2px 6px; border-radius: 6px; font-weight: 700; }
.watch { background: #f1f5f9; color: #64748b; font-size: 11px; padding: 2px 6px; border-radius: 6px; }
.price { font-size: 15px; font-weight: 600; white-space: nowrap; }
.chg { margin-left: 6px; font-weight: 700; }
.chg.up { color: var(--up); }
.chg.down { color: var(--down); }
.chg.flat { color: var(--muted); }

.analysis { margin-top: 10px; font-size: 14px; line-height: 1.7; }
.bbw { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.bb { font-size: 13px; line-height: 1.65; padding-left: 4px; }
.bb span { display: inline-block; min-width: 34px; font-weight: 700; margin-right: 6px; }
.bb.bull span { color: var(--bull); }
.bb.bear span { color: var(--bear); }
.bb.watch span { color: var(--watch); }

.heads { margin-top: 10px; }
.heads summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.heads ul { margin: 8px 0 0; padding-left: 18px; }
.heads li { font-size: 13px; margin: 4px 0; line-height: 1.5; }
.heads a { color: var(--ink); text-decoration: none; }
.heads a:hover { text-decoration: underline; }
.heads .src { color: var(--muted); font-size: 11px; margin-left: 6px; }

/* マクロ帯 */
.macro { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; -webkit-overflow-scrolling: touch; }
.mchip { flex: 0 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 96px; }
.mchip .ml { font-size: 10px; color: var(--muted); }
.mchip .mv { font-size: 14px; font-weight: 700; margin-top: 2px; white-space: nowrap; }

/* 注目Top3 */
.focus { background: #fffbeb; border: 1px solid #fde68a; border-radius: 14px; padding: 14px 18px; margin-bottom: 14px; }
.focus-head { font-weight: 700; font-size: 14px; color: #92400e; margin-bottom: 8px; }
.focus-list { margin: 0; padding-left: 20px; }
.focus-list li { font-size: 14px; line-height: 1.7; margin: 6px 0; }

/* 2カラム(保有損益 / 値動き) */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.pcard-head { font-weight: 700; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.pf-row { display: flex; flex-direction: column; gap: 2px; font-size: 13px; margin-bottom: 8px; }
.pf-cur { font-weight: 700; }
.mv-group { margin-bottom: 8px; }
.mv-label { font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.mv-label.up { color: var(--up); }
.mv-label.down { color: var(--down); }
.mover { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }

.snip { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 3px; }

@media (max-width: 560px) {
  .two-col { grid-template-columns: 1fr; }
}

.disclaimer { color: var(--muted); font-size: 11px; line-height: 1.6; margin-top: 20px; }

/* モーダル */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; z-index: 20; }
.modal-card { background: #fff; border-radius: 14px; padding: 18px; max-width: 720px; width: 100%; }
.modal-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.modal-head .ghost-btn { color: var(--ink); border-color: var(--line); }
.modal-hint { color: var(--muted); font-size: 12px; margin: 8px 0 12px; }
.holdings-list { display: flex; flex-direction: column; gap: 8px; }
.hrow { display: grid; grid-template-columns: 1.6fr .8fr .8fr 1.4fr auto auto; gap: 6px; align-items: center; }
.hrow .hname { font-size: 13px; font-weight: 600; }
.hrow input { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; width: 100%; }
.primary-btn { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.add-row { display: grid; grid-template-columns: 1.4fr 1.2fr .7fr auto; gap: 6px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.add-row input, .add-row select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; }

@media (max-width: 560px) {
  .hrow { grid-template-columns: 1fr 1fr; }
  .hrow .hname { grid-column: 1 / -1; }
  .add-row { grid-template-columns: 1fr 1fr; }
}
