* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f0f3f5;
  color: #172026;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: #0b5e6f; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── トップバー ──────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: #fff;
  border-bottom: 1px solid #d9e1e5;
  flex-wrap: wrap;
}

.brand { color: #172026; font-weight: 700; font-size: 16px; margin-right: 8px; }

.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
}
.nav-links a {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #43525a;
  border: 1px solid #c8d2d8;
  background: #fff;
  white-space: nowrap;
}
.nav-links a:hover {
  background: #eef3f5;
  border-color: #a0b0b8;
  text-decoration: none;
}
.nav-links a.active {
  background: #0b7b8f;
  color: #fff;
  border-color: #0b7b8f;
}

main {
  width: min(1200px, calc(100% - 32px));
  margin: 24px auto 48px;
}

/* ── ボタン / フォーム要素 ──────────────────────────────────────── */
button, input, select {
  height: 36px;
  border: 1px solid #c8d2d8;
  border-radius: 6px;
  background: #fff;
  color: #172026;
  font: inherit;
}

button {
  padding: 0 12px;
  background: #164e63;
  color: #fff;
  border-color: #164e63;
  cursor: pointer;
  font-size: 13px;
}
button:hover { background: #1e6f8a; }

.btn-secondary { background: #4a5568; border-color: #4a5568; }
.btn-secondary:hover { background: #2d3748; }

.btn-accent { background: #7c3aed; border-color: #7c3aed; }
.btn-accent:hover { background: #6d28d9; }

.btn-embed { background: #0e7490; border-color: #0e7490; }
.btn-embed:hover { background: #0891b2; }

.btn-web-search {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 20px;
  background: #065f46;
  color: #fff;
  border: 1px solid #065f46;
  border-radius: 6px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
.btn-web-search:hover { background: #047857; color: #fff; }
.btn-web-search--secondary {
  background: transparent;
  color: #065f46;
  border-color: #065f46;
  font-size: 13px;
  padding: 6px 14px;
}
.btn-web-search--secondary:hover { background: #ecfdf5; color: #065f46; }

input, select { padding: 0 10px; font-size: 14px; }

/* ── ページタイトル ──────────────────────────────────────────────── */
.page-title { margin: 0 0 20px; font-size: 22px; }
.section-title { margin: 24px 0 12px; font-size: 17px; }

/* ── 通知バー ────────────────────────────────────────────────────── */
.notice {
  padding: 10px 16px;
  margin-bottom: 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
}

/* ── ツールバー（トップページ） ──────────────────────────────────── */
.toolbar {
  display: grid;
  grid-template-columns: 140px 140px 1fr;
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.label { color: #5f6f78; font-size: 12px; }
.metric { margin-top: 2px; font-size: 28px; font-weight: 700; }

.search {
  display: grid;
  grid-template-columns: 1fr 140px 100px 80px;
  gap: 8px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 160px 130px 80px;
  gap: 8px;
  margin-bottom: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.card {
  padding: 16px;
  background: #fff;
  border: 1px solid #d9e1e5;
  border-radius: 8px;
}

/* ── 記事リスト ──────────────────────────────────────────────────── */
.list { display: grid; gap: 8px; }

.row, .detail, .empty {
  padding: 16px 18px;
  background: #fff;
  border: 1px solid #d9e1e5;
  border-radius: 8px;
}

.row h2, .row h3 { margin: 6px 0 8px; font-size: 17px; line-height: 1.45; }
.row p { margin: 0; color: #43525a; line-height: 1.7; font-size: 14px; }

/* ── メタ情報 ────────────────────────────────────────────────────── */
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: #667780;
  font-size: 12px;
}

.meta span {
  padding: 2px 7px;
  background: #eef3f5;
  border-radius: 999px;
}

.tag-overseas {
  padding: 2px 7px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 999px;
  font-size: 12px;
}

.score {
  padding: 2px 7px;
  background: #eef3f5;
  border-radius: 999px;
  font-size: 12px;
}
.score-high { background: #fee2e2; color: #991b1b; }
.score-mid  { background: #fef3c7; color: #92400e; }

/* ── キーワードチップ ────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

.chip, .chips span {
  padding: 3px 8px;
  color: #31505b;
  background: #e6f2ef;
  border-radius: 999px;
  font-size: 12px;
}

.cat-tag {
  padding: 2px 7px;
  background: #ede9fe;
  color: #5b21b6;
  border-radius: 999px;
  font-size: 11px;
}

.signal-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 2px 7px;
  background: #eef3f5;
  color: #43525a;
  border-radius: 999px;
  font-size: 11px;
}
.signal-positive, .signal-tailwind { background: #dcfce7; color: #166534; }
.signal-negative, .signal-headwind { background: #fee2e2; color: #991b1b; }
.signal-mixed, .signal-uncertain { background: #fef3c7; color: #92400e; }
.signal-high { background: #e0f2fe; color: #075985; }
.signal-medium { background: #e6f2ef; color: #164e63; }
.signal-low, .signal-neutral { background: #eef3f5; color: #43525a; }

/* ── 2カラムレイアウト ────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* ── パネル ──────────────────────────────────────────────────────── */
.panel {
  padding: 16px;
  background: #fff;
  border: 1px solid #d9e1e5;
  border-radius: 8px;
}

.panel h2 { margin: 0 0 12px; font-size: 15px; color: #2d3748; }

/* ── 統計リスト（棒グラフ風） ────────────────────────────────────── */
.stat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.stat-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.stat-list li a { min-width: 100px; }

.bar-wrap {
  flex: 1;
  background: #eef3f5;
  border-radius: 3px;
  height: 10px;
  overflow: hidden;
}

.bar { height: 10px; background: #0b7b8f; border-radius: 3px; }

.stat-list b { min-width: 32px; text-align: right; font-size: 13px; }

.compact-articles {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
.compact-articles li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.compact-articles span {
  color: #667780;
  font-size: 12px;
}

/* ── キーワードリスト ────────────────────────────────────────────── */
.kw-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
}
.kw-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.kw-list b { margin-left: auto; }

/* ── カテゴリ選択リスト ──────────────────────────────────────────── */
.cat-select-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cat-select-list a {
  padding: 4px 10px;
  border: 1px solid #c8d2d8;
  border-radius: 6px;
  font-size: 13px;
}
.cat-select-list a.active {
  background: #164e63;
  color: #fff;
  border-color: #164e63;
}

/* ── 急増テーブル ────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th, .data-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #e8edf0;
  text-align: left;
}
.data-table th { background: #f5f8fa; font-weight: 600; }
.surge-high { color: #dc2626; font-weight: 700; }
.surge-mid  { color: #d97706; font-weight: 600; }

/* ── 日本波及パネル ──────────────────────────────────────────────── */
.ripple-panel { border-left: 4px solid #f59e0b; }

.ripple-row { padding: 10px 0; border-bottom: 1px solid #eef3f5; }
.ripple-row:last-child { border-bottom: none; }

.ripple-note {
  font-size: 13px;
  color: #92400e;
  background: #fffbeb;
  padding: 4px 8px;
  border-radius: 4px;
  margin-top: 6px;
}

/* ── システム状態 ────────────────────────────────────────────────── */
.status-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 16px;
  background: #fff;
  border: 1px solid #d9e1e5;
  border-radius: 8px;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.gauge-wrap {
  margin: 6px 0;
  height: 12px;
  background: #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}

.gauge { height: 12px; background: #10b981; border-radius: 6px; transition: width .3s; }
.gauge-mid  { background: #f59e0b; }
.gauge-warn { background: #ef4444; }

/* ── 記事詳細 ────────────────────────────────────────────────────── */
.detail h1 { font-size: 24px; line-height: 1.4; }

.analysis {
  margin: 18px 0;
  padding: 14px;
  background: #f7faf9;
  border: 1px solid #d9e1e5;
  border-radius: 8px;
}

.analysis h2 { margin: 0 0 12px; font-size: 15px; }

.analysis dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 14px;
  margin: 0;
}

.analysis dt { color: #667780; }
.analysis dd { margin: 0; }

.body-text { white-space: pre-wrap; line-height: 1.9; font-size: 14px; margin-top: 16px; }

/* ── レポート ────────────────────────────────────────────────────── */
.report-body { white-space: pre-wrap; line-height: 1.9; font-size: 14px; }

.country-tag {
  padding: 2px 7px;
  background: #dbeafe;
  color: #1e40af;
  border-radius: 999px;
  font-size: 12px;
}

/* ── 類似記事パネル ──────────────────────────────────────────────── */
.similar-panel { margin-top: 24px; }
.similar-panel h2 { font-size: 15px; margin: 0 0 12px; }

.similar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.similar-list li {
  padding: 10px 12px;
  background: #f7faf9;
  border: 1px solid #d9e1e5;
  border-radius: 6px;
}

.similar-list li a { font-size: 14px; font-weight: 500; }

.sim-score {
  padding: 2px 7px;
  background: #d1fae5;
  color: #065f46;
  border-radius: 999px;
  font-size: 12px;
}

/* ── チャット ────────────────────────────────────────────────────── */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
  height: calc(100vh - 100px);
  min-height: 480px;
}

.chat-main {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #d9e1e5;
  border-radius: 8px;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-welcome {
  text-align: center;
  color: #667780;
  margin: auto;
  max-width: 480px;
}
.chat-welcome p { margin-bottom: 16px; font-size: 14px; }
.chat-welcome .chips { justify-content: center; }

.chip-btn {
  background: #e6f2ef;
  color: #164e63;
  border: 1px solid #c3dcd6;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  height: auto;
}
.chip-btn:hover { background: #cce8e1; }

.chat-msg { display: flex; }
.chat-msg-user     { justify-content: flex-end; }
.chat-msg-assistant { justify-content: flex-start; }

.chat-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg-user .chat-bubble {
  background: #164e63;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg-assistant .chat-bubble {
  background: #f0f6f5;
  border: 1px solid #d9e1e5;
  border-bottom-left-radius: 4px;
  color: #172026;
}

.typing { color: #aaa; animation: blink 1s step-end infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }

.chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #d9e1e5;
  background: #fafbfc;
}
.chat-input-row {
  display: flex;
  gap: 8px;
}
.chat-input-area input  { flex: 1; height: 40px; font-size: 14px; min-width: 0; }
.chat-input-area button { height: 40px; padding: 0 20px; flex-shrink: 0; }

.chat-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chat-mode-tabs label { cursor: pointer; }
.chat-mode-tabs input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.chat-mode-tabs span {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid #c8d2d8;
  border-radius: 6px;
  background: #fff;
  color: #43525a;
  font-size: 12px;
}
.chat-mode-tabs input:checked + span {
  background: #164e63;
  border-color: #164e63;
  color: #fff;
}

.chat-sources {
  background: #fff;
  border: 1px solid #d9e1e5;
  border-radius: 8px;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.chat-sources h3 { margin: 0 0 12px; font-size: 14px; color: #2d3748; }

.sources-empty { color: #999; font-size: 13px; }

.sources-count {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: -4px 0 6px;
  padding: 6px 0;
  background: #fff;
  color: #667780;
  font-size: 12px;
  border-bottom: 1px solid #eef3f5;
}

.source-item {
  padding: 10px 0;
  border-bottom: 1px solid #eef3f5;
  font-size: 13px;
}
.source-item:last-child { border-bottom: none; }

.source-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.source-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  background: #164e63;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  margin-top: 1px;
}

.source-header a { font-size: 13px; line-height: 1.4; }

.source-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
  padding-left: 26px;
}
.source-meta span {
  padding: 1px 6px;
  background: #eef3f5;
  border-radius: 999px;
  font-size: 11px;
  color: #667780;
}

/* ── レスポンシブ ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .two-col, .status-grid, .resource-grid, .metrics, .filters { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { grid-template-columns: 1fr; }
  .search { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-messages { min-height: 360px; max-height: 60vh; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .actions { flex-wrap: wrap; }
}

/* ── チャート ────────────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  width: 100%;
}

.original-title { font-size: 12px; color: #8899a6; margin: -8px 0 8px; }

/* ── ログアウトボタン ────────────────────────────────────────────── */
.nav-logout {
  color: #8899a6 !important;
  border-color: #d9e1e5 !important;
}
.nav-logout:hover {
  color: #e65c5c !important;
  border-color: #e65c5c !important;
  background: #fff8f8 !important;
}

/* ── ログインページ ──────────────────────────────────────────────── */
.login-wrap {
  max-width: 360px;
  margin: 80px auto;
}
.login-form {
  background: #fff;
  border: 1px solid #d9e1e5;
  border-radius: 10px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #43525a;
}
.login-form input[type="password"] {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #c8d2d8;
  border-radius: 6px;
  font-size: 14px;
}
.login-form button {
  height: 40px;
  background: #0b7b8f;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.login-form button:hover { background: #09697a; }
.login-error {
  color: #e65c5c;
  font-size: 13px;
  margin: 0;
}

.region-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.region-tabs a {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 14px;
  border: 1px solid #c8d2d8;
  border-radius: 6px;
  background: #fff;
  color: #43525a;
  font-size: 13px;
  text-decoration: none;
}
.region-tabs a.active {
  background: #164e63;
  border-color: #164e63;
  color: #fff;
  font-weight: 600;
}
