:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #dfe3e8;
  --text: #1b1f24;
  --muted: #656d76;
  --accent: #2b6cb0;
  --accent-soft: #e8f0fa;
  --good: #2f7d54;
  --warn: #a86b1c;
  --bad: #b03a34;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 22, 26, .06), 0 4px 14px rgba(16, 22, 26, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1c2024;
    --surface-2: #23282d;
    --border: #333a41;
    --text: #e6e9ec;
    --muted: #949da6;
    --accent: #6fa8dc;
    --accent-soft: #22303d;
    --good: #6fbf8f;
    --warn: #d4a256;
    --bad: #e0827c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

/* display を指定した要素にも hidden 属性を効かせる */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.35; margin: 0; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── トップバー ─────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.brand { font-weight: 600; font-size: 15px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; margin-right: auto; }
.tab {
  background: none;
  border: none;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
}
.tab:hover { background: var(--surface-2); }
.tab.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.user { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }

.disclaimer {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
  padding: 9px 20px;
  text-align: center;
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

/* ── 共通パーツ ─────────────────────────────── */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--bad); border-color: var(--border); }
.btn-sm { padding: 4px 10px; font-size: 13px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.section-head h2 { font-size: 17px; }
.section-head .sub { font-size: 13px; color: var(--muted); margin-right: auto; }

.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; }
.field .help { font-size: 12px; color: var(--muted); font-weight: 400; }
.field input[type="text"],
.field textarea,
.field select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.field textarea { min-height: 72px; resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  font-size: 14px;
}

/* ── 銘柄一覧 ───────────────────────────────── */
.stock-grid { display: grid; gap: 12px; }
.stock-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 20px;
  align-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.stock-row:hover { border-color: var(--accent); }
.stock-main { min-width: 0; }
.stock-ticker { font-weight: 700; font-size: 16px; letter-spacing: .02em; }
.stock-name { color: var(--muted); font-size: 13px; margin-left: 8px; font-weight: 400; }
.stock-thesis {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stock-meta { display: flex; align-items: center; gap: 16px; }
.score-box { text-align: right; }
.score-num { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-den { font-size: 12px; color: var(--muted); }

.badge {
  display: inline-block;
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge-good { color: var(--good); border-color: currentColor; background: none; }
.badge-warn { color: var(--warn); border-color: currentColor; background: none; }
.badge-bad  { color: var(--bad);  border-color: currentColor; background: none; }

.bar { height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; width: 90px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

/* ── 評価軸 ─────────────────────────────────── */
.criterion-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--surface);
  display: grid;
  grid-template-columns: 1fr 110px auto;
  gap: 12px;
  align-items: start;
}
.criterion-item .c-name { font-weight: 600; margin-bottom: 3px; }
.criterion-item .c-hint { font-size: 12.5px; color: var(--muted); }
.weight-pick { display: grid; gap: 3px; }
.weight-pick label { font-size: 11px; color: var(--muted); }

/* ── 評価入力 ───────────────────────────────── */
.score-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--surface);
}
.score-item-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.score-item-head .c-name { font-weight: 600; }
.score-item .c-hint { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.scale { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.scale button {
  width: 38px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 7px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.scale button:hover { border-color: var(--accent); }
.scale button.is-on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.scale .scale-clear { width: auto; padding: 0 10px; font-size: 12px; color: var(--muted); }
.scale-legend { font-size: 11.5px; color: var(--muted); margin-left: 4px; }
.score-item textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  min-height: 58px;
  resize: vertical;
}

.summary-card {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.summary-card .score-num { font-size: 30px; }
.summary-note { font-size: 12.5px; color: var(--muted); flex: 1 1 240px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.actions .spacer { margin-left: auto; }

.data-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

@media (max-width: 620px) {
  .stock-row { grid-template-columns: 1fr; }
  .stock-meta { justify-content: space-between; }
  .criterion-item { grid-template-columns: 1fr; }
  .topbar-inner { gap: 10px; }
  .tabs { order: 3; width: 100%; }
}
