/* Lazuli ECM ─ デザイントークンと共通コンポーネント */
:root, :root[data-theme="dark"] {
  --page: #0b0c0e; --surface: #131518; --surface-2: #191c20; --surface-3: #20242a;
  --ink: #f3f2ee; --ink-2: #c9c8c1; --muted: #858b95; --line: #23272d; --line-2: #2f343b;
  --accent: #e3b45a; --accent-ink: #1a1405; --accent-soft: rgba(227,180,90,.14);
  --good: #3fcf8e; --good-bg: rgba(63,207,142,.14); --warn: #f0b429; --warn-bg: rgba(240,180,41,.14);
  --crit: #ef5b57; --crit-bg: rgba(239,91,87,.14); --crit-ink: #ffb3b0; --info: #6aa5f8; --info-bg: rgba(106,165,248,.14);
  --series-1: #e3b45a; --series-2: #6aa5f8; --series-3: #3fcf8e; --series-4: #c084fc; --series-5: #f28b6b;
  --glow-a: rgba(227,180,90,.10); --glow-b: rgba(106,165,248,.08);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35); --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --page: #f6f5f1; --surface: #ffffff; --surface-2: #faf9f6; --surface-3: #f0efe9;
  --ink: #141416; --ink-2: #44464c; --muted: #7b7f88; --line: #e6e4dc; --line-2: #d8d5cb;
  --accent: #b9872a; --accent-ink: #fff; --accent-soft: rgba(185,135,42,.12);
  --good: #1f9f68; --good-bg: rgba(31,159,104,.12); --warn: #b7821a; --warn-bg: rgba(183,130,26,.12);
  --crit: #cf3f3b; --crit-bg: rgba(207,63,59,.10); --crit-ink: #9b2420; --info: #2f6fd1; --info-bg: rgba(47,111,209,.12);
  --series-1: #b9872a; --series-2: #2f6fd1; --series-3: #1f9f68; --series-4: #8b5cf6; --series-5: #d9603e;
  --glow-a: rgba(185,135,42,.10); --glow-b: rgba(47,111,209,.08);
  --shadow: 0 1px 2px rgba(20,20,22,.06), 0 8px 24px rgba(20,20,22,.08); --shadow-lg: 0 24px 60px rgba(20,20,22,.14);
  color-scheme: light;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body { font-family: Inter, "Noto Sans JP", system-ui, -apple-system, sans-serif; background: var(--page); color: var(--ink);
  -webkit-font-smoothing: antialiased; line-height: 1.5; }
a { color: var(--info); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px;
  outline: none; transition: border-color .15s, box-shadow .15s; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
::placeholder { color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--ink); font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--surface-3); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--crit); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 11px; border-radius: 7px; }
.btn .spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* レイアウト */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.side .brand .mark { width: 32px; height: 32px; border-radius: 10px; background: var(--ink); color: var(--page); display: grid; place-items: center; font-weight: 700; }
.side .brand b { font-size: 15px; letter-spacing: -.01em; display: block; }
.side .brand small { color: var(--muted); font-size: 11px; }
.side .sec { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; font-weight: 600; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--ink-2); cursor: pointer; font-weight: 500; position: relative; }
.nav svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav:hover { background: var(--surface-2); color: var(--ink); }
.nav.active { background: var(--accent-soft); color: var(--ink); }
.nav.active::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--accent); }
.nav .cnt { margin-left: auto; font-size: 11px; background: var(--crit); color: #fff; border-radius: 999px; padding: 0 7px; min-width: 18px; text-align: center; font-weight: 600; }
.side .spacer { flex: 1; }
.side .me { border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--series-2), var(--series-4)); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.side .me b { display: block; font-size: 13px; }
.side .me small { color: var(--muted); font-size: 11px; }

.main { min-width: 0; }
.topbar { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 28px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.topbar h2 { font-size: 16px; font-weight: 600; }
.topbar .grow { flex: 1; }
.topbar select { width: auto; min-width: 180px; height: 34px; padding: 0 32px 0 12px; }
.content { padding: 24px 28px 60px; max-width: 1480px; }

/* カード・グリッド */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.card h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card h3 .sub { font-weight: 400; color: var(--muted); font-size: 12px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g2 { grid-template-columns: repeat(2, 1fr); }
.g23 { grid-template-columns: 2fr 1fr; } .g32 { grid-template-columns: 3fr 2fr; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3, .g23, .g32 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .app { grid-template-columns: 1fr; } .side { display: none; } .g2, .g4 { grid-template-columns: 1fr; } .content { padding: 16px; } .topbar { padding: 0 16px; } }

/* KPI */
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .val { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .val small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.kpi .delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.delta.up { color: var(--good); } .delta.down { color: var(--crit); } .delta.flat { color: var(--muted); }
.kpi svg.spark { width: 100%; height: 36px; margin-top: 4px; }

/* テーブル */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; }
tr.clickable { cursor: pointer; }

/* バッジ・ステージ */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.draft { color: var(--muted); } .badge.copy { color: var(--series-4); background: rgba(192,132,252,.14); }
.badge.review { color: var(--warn); background: var(--warn-bg); } .badge.approved { color: var(--info); background: var(--info-bg); }
.badge.published { color: var(--good); background: var(--good-bg); } .badge.archived { color: var(--muted); }
.badge.error { color: var(--crit); background: var(--crit-bg); } .badge.synced { color: var(--info); background: var(--info-bg); }
.badge.pending, .badge.unverified { color: var(--warn); background: var(--warn-bg); } .badge.connected, .badge.done { color: var(--good); background: var(--good-bg); }
.badge.demo { color: var(--series-4); background: rgba(192,132,252,.14); } .badge.rejected, .badge.superseded { color: var(--muted); }
.badge.running, .badge.partial { color: var(--warn); background: var(--warn-bg); } .badge.unpublished { color: var(--muted); }
.badge.plain::before { display: none; }

/* パイプライン（Kanban） */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; min-height: 300px; }
.col h4 { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 4px 6px 12px; }
.col h4 .n { color: var(--muted); font-weight: 500; }
.pcard { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; cursor: pointer; transition: border-color .15s, transform .1s; }
.pcard:hover { border-color: var(--muted); transform: translateY(-1px); }
.pcard .t { font-weight: 600; font-size: 13px; line-height: 1.35; margin-bottom: 6px; }
.pcard .m { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); }
.pcard img { width: 100%; height: 90px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; background: var(--surface-3); }
.pcard .noimg { height: 60px; border-radius: 8px; background: var(--surface-3); margin-bottom: 8px; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.pipe-flow { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.pipe-flow .step { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; font-weight: 600; }
.pipe-flow .step .d { width: 8px; height: 8px; border-radius: 50%; }
.pipe-flow .arr { color: var(--muted); }

/* チャート */
.chart { width: 100%; height: 240px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { opacity: .12; }
.chart .bar { rx: 4; }
.tip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface-3); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); display: none; min-width: 120px; }
.tip b { display: block; margin-bottom: 4px; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.legend { display: flex; gap: 14px; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; font-size: 13px; }
.hbar .track { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; grid-column: 1 / -1; margin-bottom: 8px; }
.hbar .fill { height: 100%; border-radius: 4px; background: var(--series-1); }

/* モーダル・ドロワー */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); z-index: 50; display: none; }
.overlay.show { display: block; }
.modal { position: fixed; z-index: 70; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(560px, 94vw); max-height: 90vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px; padding: 24px; box-shadow: var(--shadow-lg); display: none; }
.modal.show { display: block; }
.modal h3 { font-size: 16px; margin-bottom: 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.drawer { position: fixed; z-index: 60; top: 0; right: 0; bottom: 0; width: min(760px, 96vw); background: var(--surface); border-left: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .22s ease; overflow: auto; }
.drawer.show { transform: translateX(0); }
.drawer .head { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line); padding: 16px 24px; display: flex; align-items: center; gap: 12px; z-index: 2; }
.drawer .head h3 { font-size: 16px; flex: 1; }
.drawer .body { padding: 20px 24px 40px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.form { display: grid; gap: 12px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.form .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { color: var(--ink); }

/* 文案カード */
.copy { border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 12px; background: var(--surface-2); }
.copy.approved { border-color: var(--good); }
.copy .ch { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.copy .ct { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.copy .cd { font-size: 13px; color: var(--ink-2); line-height: 1.7; }
.copy .cd h3 { font-size: 14px; margin: 8px 0 4px; color: var(--ink); }
.copy .cd p { margin-bottom: 6px; }
.copy ul { padding-left: 18px; margin: 8px 0; font-size: 13px; }
.copy .fb { background: var(--warn-bg); border-radius: 8px; padding: 8px 10px; font-size: 12px; margin-top: 8px; }
.copy .ca { display: flex; gap: 8px; margin-top: 12px; }
.copy .rationale { font-size: 12px; color: var(--muted); margin-top: 8px; border-top: 1px dashed var(--line-2); padding-top: 8px; }

/* タイムライン */
.tl { list-style: none; }
.tl li { display: grid; grid-template-columns: 10px 1fr; gap: 12px; padding: 6px 0; font-size: 13px; }
.tl li .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--series-2); margin-top: 7px; }
.tl li .w { color: var(--ink-2); }
.tl li .w b { color: var(--ink); font-weight: 600; }
.tl li .ts { font-size: 11px; color: var(--muted); }

/* その他 */
.toast { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast div { background: var(--surface-3); border: 1px solid var(--line-2); border-left: 3px solid var(--good); border-radius: 10px; padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow); animation: fadein .2s; }
.toast div.err { border-left-color: var(--crit); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }
.banner { background: var(--warn-bg); border: 1px solid var(--warn); border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.banner b { color: var(--warn); }
.banner .btn { margin-left: auto; }
.banner.demo { background: rgba(192,132,252,.12); border-color: var(--series-4); }
.banner.demo b { color: var(--series-4); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 13px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar .grow { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.chip.active { background: var(--ink); color: var(--page); border-color: var(--ink); }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface-3); flex: none; }
.pname { display: flex; align-items: center; gap: 10px; }
.pname b { display: block; font-weight: 600; } .pname small { color: var(--muted); font-size: 11px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.channel-card { display: flex; gap: 14px; align-items: flex-start; }
.channel-card .logo { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; font-size: 16px; }
.channel-card .meta { flex: 1; min-width: 0; }
.channel-card .meta b { display: block; font-size: 14px; }
.channel-card .meta small { color: var(--muted); display: block; margin-top: 2px; }
.channel-card.planned { opacity: .55; }
.sim-grid { display: grid; grid-template-columns: 340px 1fr; gap: 16px; }
@media (max-width: 1000px) { .sim-grid { grid-template-columns: 1fr; } }
.range { display: grid; grid-template-columns: 1fr 64px; gap: 8px; align-items: center; margin-bottom: 10px; }
.range label { font-size: 12px; color: var(--ink-2); display: flex; justify-content: space-between; }
.range input[type=range] { width: 100%; padding: 0; border: none; background: transparent; accent-color: var(--accent); }
.range input[type=number] { padding: 6px 8px; text-align: right; }
.preset { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); margin-bottom: 6px; cursor: pointer; }
.preset:hover { border-color: var(--accent); }
.preset b { display: block; font-size: 13px; } .preset small { color: var(--muted); font-size: 11px; }
.sel-count { font-size: 12px; color: var(--muted); }
.stage-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.imgs { display: flex; gap: 8px; flex-wrap: wrap; }
.imgs img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.imgs .add { width: 72px; height: 72px; border-radius: 10px; border: 1px dashed var(--line-2); display: grid; place-items: center; color: var(--muted); cursor: pointer; font-size: 20px; }
.help { font-size: 12px; color: var(--muted); line-height: 1.6; }
.help code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.pw-rule { font-size: 11px; color: var(--muted); }
.loading { display: grid; place-items: center; padding: 60px; color: var(--muted); }
