:root {
  --blue-900: #0b2a5b;
  --blue-800: #123a7d;
  --blue-700: #1d4ea0;
  --blue-600: #2563c4;
  --blue-500: #3b82f6;
  --blue-400: #60a5fa;
  --blue-100: #dbeafe;
  --blue-50: #eff6ff;
  --grad-main: linear-gradient(135deg, #0b2a5b 0%, #1d4ea0 55%, #2f6fd8 100%);
  --grad-accent: linear-gradient(135deg, #1d4ea0 0%, #3b82f6 100%);
  --grad-soft: linear-gradient(135deg, #eff6ff 0%, #e0ecfd 100%);
  --ink: #1e293b;
  --ink-soft: #64748b;
  --line: #dbe4f0;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(11, 42, 91, .07);
  --shadow-hover: 0 6px 20px rgba(11, 42, 91, .14);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  background: linear-gradient(180deg, #f3f7fd 0%, #eef3fa 100%);
  min-height: 100vh;
  color: var(--ink);
  line-height: 1.7;
}
a { color: var(--blue-600); }

/* ---------- ヘッダー ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--grad-main); color: #fff; padding: 12px 28px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 14px rgba(11, 42, 91, .35);
}
.topbar-left { display: flex; align-items: center; gap: 18px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.06rem; letter-spacing: .04em;
}
.brand span {
  background: linear-gradient(90deg, #ffffff, #bfdbfe);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-logo {
  width: 30px; height: 30px; display: block;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.3)) brightness(1.35) saturate(.85);
}
.auth-logo { width: 72px; height: 72px; display: block; margin: 0 auto 14px; }
.site-switcher select {
  background: rgba(255,255,255,.12); color: #fff;
  border: 1px solid rgba(255,255,255,.3); border-radius: 8px;
  padding: 5px 10px; font-size: .88rem; cursor: pointer;
}
.site-switcher select option { color: var(--ink); }
.topbar nav { display: flex; align-items: center; gap: 4px; }
.topbar nav a {
  color: #c9dcf7; text-decoration: none; font-size: .92rem;
  padding: 6px 12px; border-radius: 8px; transition: .15s;
}
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
.topbar nav a.active { color: #fff; background: rgba(255,255,255,.16); font-weight: 600; }
.logout-form { margin-left: 10px; }
.logout-btn {
  background: rgba(255,255,255,.1); color: #c9dcf7;
  border: 1px solid rgba(255,255,255,.25); border-radius: 8px;
  padding: 5px 14px; font-size: .85rem; cursor: pointer; transition: .15s;
}
.logout-btn:hover { background: rgba(255,255,255,.2); color: #fff; }

main { max-width: 1100px; margin: 28px auto 90px; padding: 0 20px; }

/* ---------- ログイン/セットアップ ---------- */
.auth-main {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; margin: 0; max-width: none;
  background: var(--grad-main);
}
.auth-card {
  width: 400px; max-width: 92vw;
  background: #fff; border-radius: 16px; padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(3, 15, 39, .45);
}
.auth-brand {
  font-size: 1.5rem; font-weight: 700; text-align: center;
  background: var(--grad-accent);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-sub { text-align: center; color: var(--ink-soft); font-size: .9rem; margin: 6px 0 22px; }
.auth-error {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  border-radius: 8px; padding: 10px 14px; font-size: .88rem; margin-bottom: 14px;
}
.auth-btn {
  width: 100%; margin-top: 22px; padding: 12px;
  font-size: 1rem; font-weight: 600;
}

.banner { padding: 10px 24px; font-size: .92rem; }
.banner.warn { background: #fff8e6; color: #8a6100; border-bottom: 1px solid #f3e3b3; }
.banner.info { background: var(--blue-100); color: var(--blue-800); border-bottom: 1px solid #c4dbfa; }

h1 { font-size: 1.45rem; margin: 0 0 20px; font-weight: 700; }
h2 { font-size: 1.12rem; margin: 30px 0 12px; font-weight: 700; }

/* ---------- カード・テーブル ---------- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 26px; margin-bottom: 20px; box-shadow: var(--shadow);
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 14px; text-align: center; box-shadow: var(--shadow);
  border-top: 3px solid transparent;
  border-image: var(--grad-accent) 1;
  border-image-slice: 1 0 0 0;
}
.stat .num {
  font-size: 1.9rem; font-weight: 700;
  background: var(--grad-accent);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat .label { font-size: .84rem; color: var(--ink-soft); }

table.list {
  border-collapse: separate; border-spacing: 0; width: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
table.list th, table.list td {
  border-bottom: 1px solid var(--line); padding: 10px 14px;
  font-size: .91rem; text-align: left;
}
table.list th {
  background: var(--grad-soft); color: var(--blue-800);
  font-weight: 600; font-size: .86rem;
}
table.list tr:last-child td { border-bottom: none; }
table.list tr:hover td { background: var(--blue-50); }

/* ---------- ボタン・フォーム ---------- */
button, .btn {
  display: inline-block; background: var(--grad-accent); color: #fff;
  border: none; border-radius: 8px; padding: 9px 20px; font-size: .93rem;
  font-family: inherit; cursor: pointer; text-decoration: none;
  box-shadow: 0 2px 8px rgba(29, 78, 160, .3); transition: .15s;
}
button:hover, .btn:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
button.secondary, .btn.secondary {
  background: #fff; color: var(--blue-700);
  border: 1px solid var(--blue-400); box-shadow: none;
}
button.secondary:hover { background: var(--blue-50); }
button.danger, .btn.danger { background: linear-gradient(135deg, #b91c1c, #ef4444); }
button.small, .btn.small { padding: 5px 12px; font-size: .84rem; }
button:disabled { background: #a5b3c4; cursor: not-allowed; transform: none; box-shadow: none; }

input[type=text], input[type=password], input[type=url], input[type=number],
input[type=date], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #c3d2e5; border-radius: 8px;
  font-size: .93rem; font-family: inherit; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}
textarea { min-height: 90px; }
label { display: block; font-size: .86rem; color: #3b4a61; margin: 12px 0 5px; font-weight: 600; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 20px; }

.badge {
  display: inline-block; padding: 2px 11px; border-radius: 999px;
  font-size: .76rem; font-weight: 600;
}
.badge.pending { background: #e8eef6; color: #51617a; }
.badge.generating { background: #fef3c7; color: #92400e; }
.badge.generated { background: var(--blue-100); color: var(--blue-800); }
.badge.posted_draft { background: #e0e7ff; color: #3730a3; }
.badge.published { background: #dcfce7; color: #166534; }
.badge.error { background: #fee2e2; color: #991b1b; }
.badge.cv { background: var(--grad-main); color: #fff; }
.badge.pillar { background: var(--grad-accent); color: #fff; }
.badge.child { background: #e8eef6; color: #51617a; }
.badge.high { background: #fee2e2; color: #991b1b; }
.badge.medium { background: #fef3c7; color: #92400e; }
.badge.low { background: #e8eef6; color: #51617a; }

.job-toast {
  position: fixed; right: 24px; bottom: 24px;
  background: var(--grad-main); color: #fff;
  border-radius: 12px; padding: 15px 22px;
  box-shadow: 0 8px 28px rgba(3, 15, 39, .4); z-index: 200;
  width: 420px; max-width: calc(100vw - 48px);
}
.job-toast-row { display: flex; align-items: center; gap: 12px; }
.job-progress { margin-top: 10px; }
.job-progress-track {
  height: 8px; border-radius: 999px; background: rgba(255,255,255,.2);
  overflow: hidden;
}
.job-progress-bar {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, #60a5fa, #93c5fd);
  transition: width .6s ease;
}
.job-progress-meta { font-size: .78rem; margin-top: 5px; color: #c9dcf7; }
.merged-row td { background: #f1f4f9; color: #8492a6; }
.merged-row td .muted { font-size: .78rem; }

/* 案内ポップアップ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11, 42, 91, .45);
  display: flex; align-items: center; justify-content: center; z-index: 300;
}
.modal-box {
  background: #fff; border-radius: 14px; padding: 28px 32px;
  width: 460px; max-width: 90vw; text-align: center;
  box-shadow: 0 20px 60px rgba(3, 15, 39, .4);
  border-top: 4px solid; border-image: var(--grad-accent) 1;
  border-image-slice: 4 0 0 0;
}
.modal-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 10px; }
.modal-body { color: #3b4a61; font-size: .93rem; text-align: left; line-height: 1.8; }

.row-progress { min-width: 220px; }
.row-progress .job-progress-track { background: #dbe4f0; }
.row-progress .muted { font-size: .78rem; }
.spinner {
  width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 1s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 記事プレビュー ---------- */
.article-preview {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px 38px; max-width: 800px; box-shadow: var(--shadow);
}
.article-preview h2 {
  border-left: 5px solid; border-image: var(--grad-accent) 1;
  background: var(--grad-soft);
  padding: 10px 16px; margin: 34px 0 14px; font-size: 1.18rem;
}
.article-preview h3 {
  border-bottom: 2px solid var(--blue-500); padding: 6px 2px; margin: 26px 0 10px;
}
.article-preview img { max-width: 100%; height: auto; }
.balloon { display: flex; margin: 18px 0; }
.balloon.balloon-right { flex-direction: row-reverse; }
.balloon-name {
  flex-shrink: 0; width: 64px; text-align: center; font-size: .74rem; color: var(--ink-soft);
  padding-top: 42px;
  background: no-repeat center 4px / 36px 36px radial-gradient(circle, #c3d2e5 0 18px, transparent 18px);
}
.balloon-body {
  margin: 0 12px; padding: 12px 16px; background: var(--blue-50);
  border: 1px solid #c4dbfa; border-radius: 12px; max-width: 70%;
}
.balloon-right .balloon-body { background: #fffbeb; border-color: #f0e0b0; }

.thumb { max-width: 320px; border-radius: 10px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.img-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.img-grid figure { margin: 0; width: 200px; }
.img-grid img { width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.img-grid figcaption { font-size: .76rem; color: var(--ink-soft); }

details.article-edit summary { cursor: pointer; font-weight: 600; color: var(--blue-600); }
.mono { font-family: Menlo, Consolas, monospace; font-size: .84rem; }
.muted { color: var(--ink-soft); font-size: .87rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
