/* Rewrite X UI — Rewrite Steps と同じデザイントークン */
:root {
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --hair: #e8e8ed;
  --bg: #f5f5f7;
  --card: #ffffff;
  --fill: #f5f5f7;
  --accent: #0071e3;
  --accent-ink: #0060c0;
  --accent-weak: #e8f1fd;
  --danger: #d70015;
  --danger-weak: #fdecee;
  --ok: #1d7a44;
  --ok-weak: #e9f6ee;
  --warn: #7a4d0b;
  --warn-weak: #fff8e6;
  --violet: #6b21c8;
  --violet-weak: #f3eafd;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 14px rgba(0, 0, 0, 0.05);
  --shadow-hi: 0 2px 6px rgba(0, 0, 0, 0.06), 0 12px 28px rgba(0, 0, 0, 0.09);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* スクロールバーの有無でページ幅が変わらないようにする */
html { scrollbar-gutter: stable; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro JP", "SF Pro Text",
    "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
h1, h2, h3 { letter-spacing: -0.012em; margin: 0; word-break: auto-phrase; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }

/* ---- シェル ---- */
.shell-wrap { display: flex; min-height: 100vh; }

/* ナビは白いパネルにして本文のグレー背景と区別する（視認性優先） */
.sidenav {
  width: 230px; flex: 0 0 230px; background: var(--card);
  display: flex; flex-direction: column; padding: 18px 12px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--hair);
}
.sidenav .brand {
  display: block; padding: 2px 12px 16px; font-size: 20px; font-weight: 700;
  letter-spacing: -0.02em; color: var(--ink);
}
.sidenav .brand em { font-style: normal; color: var(--accent); }
.sidenav-main { display: flex; flex-direction: column; flex: 1 1 auto; }
.nav-head {
  font-size: 11px; letter-spacing: 0.05em; color: #a1a1a6; font-weight: 700;
  margin: 16px 12px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  color: #3a3a3c; padding: 9px 12px; font-size: 14px; font-weight: 500;
  border: 0; background: none; border-radius: var(--r-sm); margin: 1px 0; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { color: var(--ink); background: rgba(0, 0, 0, 0.05); }
.nav-item.active { color: #fff; background: var(--accent); font-weight: 600; }
.nav-ico { width: 18px; height: 18px; flex: none; opacity: 0.75; }
.nav-item.active .nav-ico { opacity: 1; }
.nav-item > span:not(.cnt) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .cnt {
  flex: none; font-size: 11.5px; font-weight: 700; color: #fff; background: var(--danger);
  border-radius: 999px; padding: 0 7px; min-width: 19px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.nav-item .cnt:empty { display: none; }
.nav-item.active .cnt { background: rgba(255, 255, 255, 0.3); }
.nav-sep { border: 0; border-top: 1px solid var(--hair); margin: 10px 10px; width: auto; }
.nav-bottom { margin-top: auto; padding-top: 8px; }
.sidenav-foot {
  padding: 12px 12px 2px; border-top: 1px solid var(--hair); margin-top: 10px;
  font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px;
}
.sidenav-foot .nav-user { color: var(--ink); font-weight: 600; }
.sidenav-foot a:hover { color: var(--danger); }

.shell-main { flex: 1; min-width: 0; padding: 26px 32px 90px; max-width: 1240px; }

.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 25px; font-weight: 600; letter-spacing: -0.02em; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.page-head .spacer { flex: 1; }

/* ---- ボタン ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 15px; font-size: 13.5px; font-weight: 500; line-height: 1.5;
  border: 0; border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.05); color: var(--ink); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn:hover { background: rgba(0, 0, 0, 0.09); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--danger); background: var(--danger-weak); }
.btn.danger:hover { background: #fadadd; }
.btn.small { padding: 5px 11px; font-size: 12.5px; }
.btn.ghost { background: none; color: var(--muted); }
.btn.ghost:hover { background: rgba(0, 0, 0, 0.05); color: var(--ink); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:disabled:hover { background: rgba(0, 0, 0, 0.05); }

/* ---- 入力 ---- */
input, textarea, select {
  font-family: inherit; font-size: 14px; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 12px;
  background: var(--card); width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3.5px rgba(0, 113, 227, 0.18); outline: none;
}
textarea { resize: vertical; line-height: 1.8; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }

/* ---- カード ---- */
.card {
  background: var(--card); border-radius: var(--r-md); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 20px;
}
.card > h2 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.card-note { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.card > h2 + .card-note { margin-top: 2px; }

/* ---- コンポーザー（スタジオの主役） ---- */
.composer {
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow-hi);
  padding: 20px 22px 16px; margin-bottom: 24px;
}
.composer textarea {
  border: 0; padding: 4px 2px; font-size: 16px; line-height: 1.9; min-height: 96px;
  box-shadow: none !important; border-radius: 0; background: none;
}
.composer-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-top: 1px solid var(--hair); margin-top: 10px; padding-top: 12px;
}
.char-count { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.char-count.over { color: var(--danger); font-weight: 600; }
.composer-foot .spacer { flex: 1; }
.ai-panel {
  display: flex; gap: 9px; flex-wrap: wrap; align-items: center;
  background: var(--fill); border-radius: var(--r-sm); padding: 10px 12px; margin-top: 12px;
}
.ai-panel select { width: auto; max-width: 200px; flex: 0 1 auto; background: var(--card); }
.ai-panel input[type="text"] { flex: 1 1 200px; min-width: 0; background: var(--card); }

/* ---- パイプラインボード ---- */
.board {
  display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 16px;
  overflow-x: auto; padding-bottom: 8px;
}
.board-col { min-width: 0; }
.col-head {
  display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px;
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.col-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.col-head .col-cnt { color: var(--muted); font-weight: 500; font-size: 12px; font-variant-numeric: tabular-nums; }
.col-head .col-hint { margin-left: auto; font-size: 11.5px; color: #a1a1a6; font-weight: 400; }
.col-body { display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.col-empty {
  border: 1.5px dashed var(--line); border-radius: var(--r-md);
  color: #a1a1a6; font-size: 12.5px; text-align: center; padding: 22px 12px;
}
.post-card {
  background: var(--card); border-radius: var(--r-md); box-shadow: var(--shadow);
  padding: 13px 15px; transition: box-shadow 0.15s;
}
.post-card:hover { box-shadow: var(--shadow-hi); }
.post-card .pc-text { font-size: 13.5px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.post-card .pc-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 11.5px; color: #a1a1a6; margin-top: 9px; font-variant-numeric: tabular-nums;
}
.post-card .pc-actions {
  display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--hair);
  margin-top: 10px; padding-top: 10px;
}
.post-card .issue { margin-top: 8px; }

/* ---- KPI ---- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi { background: var(--card); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 15px 18px; }
.kpi .k-label { font-size: 12px; color: var(--muted); margin: 0 0 2px; }
.kpi .k-value { font-size: 25px; font-weight: 600; letter-spacing: -0.02em; margin: 0; line-height: 1.3; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.kpi .unit { font-size: 14px; font-weight: 400; margin-left: 2px; }
.deficit { color: var(--danger); }
.surplus { color: var(--ok); }

/* ---- 「いまやること」 ---- */
.now-band {
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 24px 26px; margin-bottom: 20px;
}
.now-band .label { font-size: 12px; color: var(--accent); font-weight: 700; margin: 0 0 6px; letter-spacing: 0.02em; }
.now-band .headline { font-size: 20px; font-weight: 600; line-height: 1.55; margin: 0; letter-spacing: -0.015em; }
.now-band .band-actions { margin: 16px 0 0; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- 表 ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--hair); padding: 8px 10px; white-space: nowrap;
}
tbody td { border-bottom: 1px solid var(--hair); padding: 11px 10px; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(0, 0, 0, 0.018); }
td.r, th.r { text-align: right; }
.post-text { max-width: 520px; line-height: 1.75; }

/* ---- チップ ---- */
.chip {
  display: inline-flex; align-items: center; border-radius: 6px;
  padding: 1px 8px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.chip.candidate { background: var(--violet-weak); color: var(--violet); }
.chip.draft { background: rgba(0, 0, 0, 0.06); color: var(--ink); }
.chip.pending { background: var(--warn-weak); color: var(--warn); }
.chip.approved { background: var(--accent-weak); color: var(--accent-ink); }
.chip.sent { background: var(--ok-weak); color: var(--ok); }
.chip.archived { background: rgba(0, 0, 0, 0.04); color: #a1a1a6; }

/* ---- 指摘 ---- */
.issue { font-size: 12.5px; margin: 6px 0 0; display: flex; gap: 6px; align-items: flex-start; }
.issue.error { color: var(--danger); }
.issue.warn { color: var(--warn); }
.issue::before { content: "!"; flex: none; font-weight: 700; }
.issue.warn::before { content: "?"; }

/* ---- 図表 ---- */
.chart-block { overflow-x: auto; }
.chart-caption { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
svg text { font-family: inherit; }

.heatmap { border-collapse: separate; border-spacing: 2px; }
.heatmap th { font-size: 11px; color: var(--muted); font-weight: 500; padding: 1px 4px; border: 0; }
.heatmap td { width: 21px; height: 19px; border-radius: 3px; padding: 0; border: 0; }
.heatmap td.best { box-shadow: 0 0 0 2px var(--accent); }
.heatmap tbody tr:hover { background: none; }

/* ---- モーダル ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .35); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal {
  background: var(--card); border-radius: var(--r-lg); max-width: 620px; width: 100%;
  padding: 26px 28px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-hi);
}
.modal h3 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.modal textarea { min-height: 130px; }
.check-list { background: var(--fill); border-radius: var(--r-sm); padding: 12px 14px; margin: 14px 0; font-size: 13px; }
.check-list label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check-list input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.quote {
  background: var(--fill); border-radius: var(--r-sm); padding: 14px 16px; margin: 12px 0;
  white-space: pre-wrap; line-height: 1.8; font-size: 14px;
}
.warn-note {
  display: flex; gap: 9px; align-items: flex-start; margin: 12px 0; padding: 12px 14px;
  background: var(--warn-weak); color: var(--warn); border-radius: var(--r-sm); font-size: 13px; line-height: 1.75;
}

/* ---- 定義リスト ---- */
.profile-grid { margin: 0; }
.profile-grid dt { font-size: 12px; color: var(--muted); margin-top: 12px; font-weight: 600; }
.profile-grid dt:first-child { margin-top: 0; }
.profile-grid dd { margin: 2px 0 0; font-size: 13.5px; }
.bullet { margin: 0; padding-left: 20px; font-size: 13.5px; }
.bullet li { margin: 5px 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 22px; }

/* ---- 認証画面 ---- */
.auth-page { background: var(--bg); }
.auth-card {
  max-width: 400px; margin: 92px auto; background: var(--card);
  border-radius: 20px; padding: 40px 36px; box-shadow: var(--shadow); text-align: center;
}
.auth-card h1 { font-size: 26px; font-weight: 600; margin-bottom: 6px; }
.auth-card h1 em { font-style: normal; color: var(--accent); }
.auth-card > p { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.auth-card form { text-align: left; }
.auth-card .btn { width: 100%; margin-top: 20px; padding: 11px; font-size: 15px; }
.error { color: var(--danger); font-size: 13.5px; margin: 10px 0 0; }

.empty-state {
  background: var(--card); border-radius: var(--r-lg); padding: 48px 40px;
  text-align: center; box-shadow: var(--shadow); color: var(--muted);
}
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--hair); }
.task-list li:last-child { border-bottom: 0; }
.toolbar {
  display: flex; gap: 9px; flex-wrap: wrap; align-items: center;
  background: var(--card); border-radius: var(--r-md); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 18px;
}
.toolbar .spacer { flex: 1; }


/* ---- 成績: わかったこと ---- */
.insight { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 20px 24px; margin-bottom: 20px; }
.insight h2 { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.insight ul { margin: 0; padding: 0; list-style: none; }
.insight li { padding: 7px 0; font-size: 14.5px; line-height: 1.75; border-bottom: 1px solid var(--hair); }
.insight li:last-child { border-bottom: 0; }
.insight li strong { font-weight: 600; }
.insight .up { color: var(--ok); font-weight: 600; }
.insight .down { color: var(--danger); font-weight: 600; }

/* ---- 成績: 横棒比較 ---- */
.hbar-group { margin: 14px 0 4px; }
.hbar-group .hg-title { font-size: 12px; color: var(--muted); font-weight: 600; margin: 0 0 6px; }
.hbar { display: flex; align-items: center; gap: 10px; margin: 5px 0; }
.hbar .hb-label { flex: 0 0 128px; font-size: 12.5px; color: var(--ink); text-align: right; }
.hbar .hb-label .n { color: #a1a1a6; font-size: 11px; }
.hbar .hb-track { flex: 1; background: var(--fill); border-radius: 5px; height: 20px; overflow: hidden; }
.hbar .hb-fill { height: 100%; background: var(--accent); border-radius: 5px; min-width: 2px; }
.hbar.dim .hb-fill { background: #b8d4f3; }
.hbar .hb-val { flex: 0 0 64px; font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ---- 折りたたみ ---- */
details.fold { background: var(--card); border-radius: var(--r-md); box-shadow: var(--shadow); margin-bottom: 20px; }
details.fold > summary {
  cursor: pointer; padding: 15px 22px; font-size: 14px; font-weight: 600; list-style: none;
  display: flex; align-items: center; gap: 8px; color: var(--ink);
}
details.fold > summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > .fold-body { padding: 0 22px 18px; }


/* ---- ネタ探しチップ ---- */
.kw-block { background: var(--card); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 14px 16px; margin: 12px 0; }
.kw-block .hg-title { font-size: 12px; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.chip-cloud { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin: 6px 0; }
.cloud-tag { flex: none; font-size: 11px; color: #a1a1a6; font-weight: 600; min-width: 52px; }
.kw-chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 4px 13px; font-size: 12.5px; color: var(--ink); cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.kw-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
.kw-chip .n { font-size: 11px; color: #a1a1a6; font-variant-numeric: tabular-nums; }


/* ---- Xアカウントリンク ---- */
a.xh { color: var(--ink); font-weight: 600; }
a.xh:hover { color: var(--accent); text-decoration: underline; }
.btn.follow { background: var(--ink); color: #fff; }
.btn.follow:hover { background: #000; color: #fff; }

/* ---- レスポンシブ ---- */
@media (max-width: 1080px) {
  .board { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
}
@media (max-width: 860px) {
  .shell-wrap { flex-direction: column; }
  .sidenav {
    width: 100%; flex: none; height: auto; position: static;
    border-right: 0; border-bottom: 1px solid var(--hair);
    flex-direction: row; align-items: center; gap: 2px; padding: 8px 10px; overflow-x: auto;
  }
  .sidenav .brand { padding: 0 10px 0 4px; font-size: 17px; white-space: nowrap; }
  .sidenav-main { flex-direction: row; align-items: center; gap: 2px; }
  .nav-item { width: auto; white-space: nowrap; margin: 0; flex: none; padding: 8px 11px; }
  .nav-item > span:not(.cnt) { overflow: visible; }
  .nav-head { display: none; }
  .nav-sep { display: none; }
  .nav-bottom { margin: 0; padding: 0; }
  .sidenav-foot { display: none; }
  .shell-main { padding: 18px 14px 70px; }
  .post-text { max-width: none; }
  .hide-sm { display: none; }
  .board { grid-template-columns: 1fr; }
  .now-band { padding: 18px 18px; }
  .now-band .headline { font-size: 17px; }
  .composer { padding: 14px 16px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
