:root {
  color-scheme: light;
  --paper: #f3f4f7;
  --surface: #ffffff;
  --sunken: #f7f8fa;
  --ink: #161a2b;
  --ink-2: #555b6e;
  --ink-3: #8a8fa0;
  --line: #e2e4ea;
  --line-2: #eceef2;
  --brand: #d62416;
  --brand-ink: #ffffff;
  --brand-soft: #fdecea;
  --star: #e2a200;
  --star-soft: #fff6dc;
  --good: #11845b;
  --good-soft: #e3f4ec;
  --warn: #b25e00;
  --warn-soft: #fff1df;
  --bad: #c42b2b;
  --bad-soft: #fde9e9;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --ctl: #a2a7b4;
  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --shadow: 0 1px 2px rgba(22, 26, 43, .06), 0 1px 1px rgba(22, 26, 43, .03);
  --font: "IBM Plex Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
}
/* ── ダークモード（OSの設定に従う／手動で切り替え） ── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  color-scheme: dark;
  --paper: #13151c;
  --surface: #1b1e28;
  --sunken: #222632;
  --ink: #eceef4;
  --ink-2: #aab0bf;
  --ink-3: #7f8596;
  --line: #2f3342;
  --line-2: #272b38;
  --brand: #ef4a3c;
  --brand-ink: #ffffff;
  --brand-soft: #3b1e1c;
  --star: #f0b628;
  --star-soft: #352d17;
  --good: #3ccf91;
  --good-soft: #15342a;
  --warn: #f0a24a;
  --warn-soft: #382a17;
  --bad: #f07070;
  --bad-soft: #3a1d1e;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --ctl: #6d7282;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  }
  :root:not([data-theme="light"]) .logo .ll { display: none; }
  :root:not([data-theme="light"]) .logo .ld { display: block; }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #13151c;
  --surface: #1b1e28;
  --sunken: #222632;
  --ink: #eceef4;
  --ink-2: #aab0bf;
  --ink-3: #7f8596;
  --line: #2f3342;
  --line-2: #272b38;
  --brand: #ef4a3c;
  --brand-ink: #ffffff;
  --brand-soft: #3b1e1c;
  --star: #f0b628;
  --star-soft: #352d17;
  --good: #3ccf91;
  --good-soft: #15342a;
  --warn: #f0a24a;
  --warn-soft: #382a17;
  --bad: #f07070;
  --bad-soft: #3a1d1e;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --ctl: #6d7282;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
:root[data-theme="dark"] .logo .ll { display: none; }
:root[data-theme="dark"] .logo .ld { display: block; }
.logo .ld { display: none; }
.auth .logo .ll { display: block; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── 骨組み ── */
.shell { --side-w: 236px; min-height: 100vh; padding-left: 76px; }
.shell.pinned { padding-left: var(--side-w); }
.pinned .side, .pinned .side:hover, .resizing .side, .resizing .side:hover { box-shadow: none; transition: none; }
.logo-row { display: flex; align-items: center; justify-content: center; flex: none; }
.logo-row .logo { flex: 1; }
.pin { display: none; flex: none; width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-3); cursor: pointer; place-items: center; }
.pin:hover { background: var(--sunken); color: var(--ink); }
.pin.on { color: var(--brand); }
.side:hover .pin, .side:focus-within .pin, .pinned .pin { display: grid; }
/* サイドバー：普段はアイコンの列、マウスを乗せると広がる（中身の上に重なって出る） */
.side { position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: 76px; background: var(--surface); border-right: 1px solid var(--line); padding: 14px 8px 12px; display: flex; flex-direction: column; gap: 10px; overflow: hidden; transition: width .18s ease .15s, box-shadow .18s ease .15s; }
.side:hover, .side:focus-within, .pinned .side, .resizing .side { width: var(--side-w); box-shadow: 12px 0 32px -12px rgba(15, 18, 30, .28); transition-delay: .06s; }
.logo { display: flex; align-items: center; justify-content: center; height: 40px; padding: 0 6px; text-decoration: none; flex: none; }
.logo .mark { display: block; width: 30px; height: 30px; }
.logo .full { display: none; }
.logo .full img { height: 22px; width: auto; }
.side:hover .logo, .side:focus-within .logo, .pinned .side .logo, .resizing .side .logo { justify-content: flex-start; padding-left: 12px; }
.side:hover .logo .mark, .side:focus-within .logo .mark, .pinned .side .logo .mark, .resizing .side .logo .mark { display: none; }
.side:hover .logo .full, .side:focus-within .logo .full, .pinned .side .logo .full, .resizing .side .logo .full { display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0; scrollbar-width: none; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px 7px; border-radius: var(--r); text-decoration: none; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.nav a .tl { display: none; }
.nav a .ts { font-size: 10.5px; line-height: 1.2; }
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.nav a svg { flex: none; opacity: .9; width: 20px; height: 20px; }
.nav .grp { height: 1px; background: var(--line-2); margin: 6px 10px; font-size: 0; overflow: hidden; }
.side:hover .nav a, .side:focus-within .nav a, .pinned .side .nav a, .resizing .side .nav a { flex-direction: row; gap: 12px; padding: 10px 12px; }
.side:hover .nav a .tl, .side:focus-within .nav a .tl, .pinned .side .nav a .tl, .resizing .side .nav a .tl { display: inline; font-size: 14px; }
.side:hover .nav a .ts, .side:focus-within .nav a .ts, .pinned .side .nav a .ts, .resizing .side .nav a .ts { display: none; }
.side:hover .nav .grp, .side:focus-within .nav .grp, .pinned .side .nav .grp, .resizing .side .nav .grp { height: auto; background: none; margin: 10px 12px 2px; font-size: 12px; color: var(--ink-3); }
.side .me { flex: none; border-top: 1px solid var(--line-2); padding-top: 10px; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 12px; color: var(--ink-2); }
.side .me .av { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 14px; }
.side .me .mi, .side .me .out { display: none; }
.side:hover .me, .side:focus-within .me, .pinned .side .me, .resizing .side .me { justify-content: flex-start; padding-left: 6px; }
.side:hover .me .mi, .side:focus-within .me .mi, .pinned .side .me .mi, .resizing .side .me .mi { display: block; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.4; }
.side:hover .me .out, .side:focus-within .me .out, .pinned .side .me .out, .resizing .side .me .out { display: inline-flex; }
/* 上部のバー：表示するサイトの切り替え */
.topbar { position: sticky; top: 0; z-index: 40; height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 32px; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line-2); }
.topbar .lbl { margin: 0; }
.topbar select { min-width: 240px; }
.main { min-width: 0; padding: 26px 32px 60px; }
.page { max-width: 1240px; margin: 0 auto; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { font-size: 22px; font-weight: 700; }
.head p { margin: 4px 0 0; color: var(--ink-2); }
.head .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 13px; color: var(--ink-3); margin-bottom: 4px; }
.crumb a { text-decoration: none; color: var(--ink-2); }

/* ── 部品 ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card > .ch { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card > .ch h2 { font-size: 15px; font-weight: 700; }
.card > .ch .sub { color: var(--ink-3); font-size: 12px; }
.card > .cb { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 1fr) 340px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: 12px; }
.small { font-size: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--sunken); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunken); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.iconbtn { width: 28px; height: 28px; padding: 0; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=datetime-local], select, textarea {
  height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); min-width: 0; }
textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=color] { width: 34px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; }
input[type=range] { accent-color: var(--brand); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label, .lbl { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 12px; color: var(--ink-3); }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; margin: 4px 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; background: var(--sunken); gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 12px; border-radius: 4px; cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.live, .pill.running { background: var(--good-soft); color: var(--good); }
.pill.paused { background: var(--warn-soft); color: var(--warn); }
.pill.draft { background: var(--sunken); color: var(--ink-2); }
.pill.ended { background: var(--sunken); color: var(--ink-3); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--sunken); border: 1px solid var(--line-2); font-size: 11px; color: var(--ink-2); }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; white-space: nowrap; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--sunken); }
.tw { overflow-x: auto; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.kpi { padding: 14px 18px; border-right: 1px solid var(--line-2); }
.kpi:last-child { border-right: 0; }
.kpi .k { font-size: 12px; color: var(--ink-2); }
.kpi .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; margin-top: 2px; }
.kpi .d { font-size: 12px; color: var(--ink-3); }
.kpi.key { background: linear-gradient(var(--brand-soft), var(--brand-soft)) top / 100% 3px no-repeat; }
.kpi.key .v { color: var(--brand); }

/* 配分バー（POP STAR の顔） */
.alloc { display: flex; height: 30px; border-radius: 8px; overflow: hidden; gap: 2px; background: var(--surface); }
.alloc > div { position: relative; min-width: 3px; display: flex; align-items: center; padding: 0 8px; color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; transition: flex-basis .6s cubic-bezier(.2,.8,.2,1); }
.alloc > div.ctl { background: repeating-linear-gradient(135deg, #b9bdc8 0 6px, #aeb2be 6px 12px); color: #2a2e3c; }
.alloc.thin { height: 10px; border-radius: 5px; }
.alloc.thin > div { padding: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.star { color: var(--star); }
.best-row td { background: var(--star-soft); }

.explain { display: flex; gap: 14px; padding: 14px 16px; border-radius: var(--r); background: var(--sunken); border: 1px solid var(--line-2); line-height: 1.75; }
.explain .ico { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); }
.phase { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 99px; }
.phase.warmup { background: var(--warn-soft); color: var(--warn); }
.phase.optimizing { background: var(--brand-soft); color: var(--brand); }
.phase.fixed { background: var(--sunken); color: var(--ink-2); }

.empty { text-align: center; padding: 44px 20px; color: var(--ink-2); }
.empty h3 { font-size: 16px; margin-bottom: 6px; color: var(--ink); }
.empty .btn { margin-top: 14px; }

.code { position: relative; background: #1b1f30; color: #e7e9f2; border-radius: var(--r); padding: 14px 16px; font: 12.5px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; }
.code .cp { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,.1); color: #fff; border: 0; }
.code .cp:hover { background: rgba(255,255,255,.2); }
code.k { background: var(--sunken); border: 1px solid var(--line-2); padding: 0 5px; border-radius: 4px; font-size: 12px; }

/* 編集画面 */
.editor { display: grid; grid-template-columns: 420px minmax(0, 1fr); grid-template-rows: 100%; gap: 0; height: calc(100vh - 53px); margin: -26px -32px -60px; }
.editor > section { min-height: 0; }
.editor .panel { background: var(--surface); border-right: 1px solid var(--line); overflow: auto; display: flex; flex-direction: column; }
.editor .ptop { padding: 14px 18px 0; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.editor .ptop input.name { width: 100%; border: 0; padding: 0; height: 30px; font-size: 17px; font-weight: 700; background: transparent; }
.editor .ptop input.name:focus { box-shadow: none; }
.tabs { display: flex; gap: 2px; margin-top: 8px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 10px; border-bottom: 2px solid transparent; font-weight: 600; color: var(--ink-3); cursor: pointer; white-space: nowrap; font-size: 13px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--brand); }
.editor .pbody { padding: 18px; flex: 1; }
.editor .pfoot { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 18px; display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.stage { display: flex; flex-direction: column; min-width: 0; background: var(--paper); overflow: hidden; }
.stage .bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.stage .canvas { flex: 1; display: grid; place-items: center; padding: 24px; overflow: auto; }
.device { position: relative; overflow: hidden; background: #fff; border: 1px solid var(--line); box-shadow: 0 20px 50px -20px rgba(22,26,43,.35); transition: width .3s ease, height .3s ease; }
.device.pc { width: 860px; height: 540px; border-radius: 10px; }
.device.sp { width: 375px; height: 700px; border-radius: 34px; border: 9px solid #20243a; }
.device .chrome { height: 28px; background: #eef0f4; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 6px; padding: 0 10px; }
.device .chrome i { width: 9px; height: 9px; border-radius: 50%; background: #d3d6de; }
.device.sp .chrome { display: none; }
.device .lp { position: absolute; inset: 28px 0 0; overflow: hidden; }
.device.sp .lp { inset: 0; }
.mock { padding: 22px; }
.mock .mh { height: 150px; border-radius: 10px; background: linear-gradient(135deg, #e9ecf3, #dfe3ec); margin-bottom: 16px; display: grid; place-items: center; color: #9aa0b0; font-weight: 700; }
.mock .ml { height: 10px; border-radius: 5px; background: #eceef3; margin: 9px 0; }
.blocks { display: flex; flex-direction: column; gap: 8px; }
.blk { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.blk .bh { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 12px; cursor: pointer; }
.blk .bh .bt { font-weight: 600; font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk .bh .bt span { color: var(--ink-3); font-weight: 400; margin-left: 6px; }
.blk .bb { padding: 4px 12px 12px; border-top: 1px solid var(--line-2); }
.blk.open { border-color: #d3d6de; box-shadow: var(--shadow); }
.adders { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.trig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; cursor: pointer; background: var(--surface); text-align: left; }
.opt:hover { border-color: #cfd2da; }
.opt.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.opt b { display: block; font-size: 13px; }
.opt span { font-size: 12px; color: var(--ink-3); }
.rule { display: grid; grid-template-columns: 120px 1fr 28px; gap: 6px; margin-bottom: 6px; }
.swatches { display: flex; gap: 8px; align-items: center; }

/* テンプレート選択 */
.tpls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tpl { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; cursor: pointer; background: var(--surface); text-align: left; padding: 0; }
.tpl:hover, .tpl.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tpl .tv { position: relative; height: 170px; background: #eef0f4; overflow: hidden; }
.tpl .tv .scale { position: absolute; left: 0; top: 0; width: 200%; height: 200%; transform: scale(.5); transform-origin: 0 0; }
.tpl .ti { padding: 10px 12px; }
.tpl .ti b { display: block; font-size: 13px; }
.tpl .ti span { font-size: 12px; color: var(--ink-3); }

/* ダイアログ・トースト */
.dlg-bg { position: fixed; inset: 0; background: rgba(22,26,43,.42); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .15s ease; }
.dlg { background: var(--surface); border-radius: var(--r-lg); width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 30px 80px -20px rgba(22,26,43,.5); }
.dlg.wide { width: min(900px, 100%); }
.dlg .dh { padding: 18px 20px 6px; }
.dlg .dh h3 { font-size: 17px; }
.dlg .db { padding: 12px 20px; }
.dlg .df { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: var(--r); box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); font-weight: 500; animation: fade .2s ease; }
.toast.err { background: var(--bad); color: #fff; }

/* ログイン */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .box { width: min(400px, 100%); }
.auth .logo { justify-content: center; margin-bottom: 22px; }
.auth .logo img { height: 34px; }
.auth .card { padding: 26px; }
.auth .btn { width: 100%; height: 40px; }

/* グラフ */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 24px -8px rgba(22,26,43,.25); border-radius: 8px; padding: 8px 10px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -100%); margin-top: -10px; z-index: 3; }
.chart .tip .tt { font-weight: 700; margin-bottom: 3px; }
.chart .tip .tr { display: flex; justify-content: space-between; gap: 14px; }
.chart .tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.ci { position: relative; height: 22px; }
.ci .ln { position: absolute; top: 10px; height: 2px; border-radius: 1px; }
.ci .dt { position: absolute; top: 5px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; border: 2px solid var(--surface); }
.bar-inline { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; min-width: 60px; }
.bar-inline > div { height: 100%; border-radius: 3px; }

.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps div { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps div.on { background: var(--brand); }
.arms-ed .arm { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-bottom: 10px; background: var(--surface); }
.arms-ed .arm .ah { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.arms-ed .arm .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-right: 0; }
  .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--line-2); }
  .g-side, .g3 { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 360px minmax(0, 1fr); }
  .device.pc { width: 640px; }
}
@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .topbar select { min-width: 0; flex: 1; }
  .main { padding: 18px 16px 40px; }
  .g2 { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; height: auto; margin: -18px -16px -40px; }
  .tpls { grid-template-columns: 1fr 1fr; }
  .device.pc { width: 100%; }
}

input:disabled, select:disabled, textarea:disabled { background: var(--sunken); color: var(--ink-3); cursor: not-allowed; }

/* サイドバーの幅をドラッグで変える */
.side-resize { position: absolute; top: 0; right: -3px; width: 8px; height: 100%; cursor: col-resize; z-index: 2; display: none; }
.side-resize::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background .15s; }
.side-resize:hover::after, .resizing .side-resize::after { background: var(--brand); }
.side:hover .side-resize, .pinned .side-resize, .resizing .side-resize { display: block; }
.resizing, .resizing * { cursor: col-resize !important; user-select: none !important; }
.resizing .side, .resizing.shell { transition: none !important; }

/* 画像のアップロード */
.img-drop { min-height: 120px; border: 1.5px dashed var(--line); border-radius: var(--r); background: var(--sunken); display: grid; place-items: center; overflow: hidden; transition: border-color .15s, background .15s; }
.img-drop.over { border-color: var(--brand); background: var(--brand-soft); }
.img-drop img { display: block; max-width: 100%; max-height: 240px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-height: 60vh; overflow: auto; }
.media-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.media-pick { padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--sunken); aspect-ratio: 3 / 4; overflow: hidden; cursor: pointer; }
.media-pick:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.media-pick img { width: 100%; height: 100%; object-fit: contain; }
.media-meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-width: 0; }
.media-meta .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 2つつまみのスライダー（範囲） */
.dual { position: relative; height: 28px; margin: 4px 8px 0; }
.dual-track { position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 2px; background: var(--line); }
.dual-fill { position: absolute; top: 0; bottom: 0; border-radius: 2px; background: var(--brand); }
.dual input[type=range] { position: absolute; left: -8px; right: -8px; width: calc(100% + 16px); top: 4px; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; height: 20px; }
.dual input[type=range]::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); box-shadow: var(--shadow); cursor: grab; }
.dual input[type=range]::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); cursor: grab; }
.dual input[type=range]::-webkit-slider-runnable-track { background: none; }
.ticks { display: flex; justify-content: space-between; gap: 4px; margin-top: 8px; }
.tick { flex: 1; min-width: 0; height: 30px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink-3); font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; text-decoration: line-through; }
.tick.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); text-decoration: none; }
.tick.out { opacity: .35; cursor: default; text-decoration: none; }

/* ？ボタンと解説 */
.lbl-row { display: inline-flex; align-items: center; gap: 6px; }
.help-wrap { position: relative; display: inline-flex; }
.help-btn { width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink-3); font: 700 11px/16px var(--font); cursor: pointer; flex: none; }
.help-btn:hover, .help-wrap.open .help-btn { border-color: var(--brand); color: var(--brand); }
.help-pop { display: none; position: absolute; z-index: 30; top: calc(100% + 8px); left: -12px; width: min(300px, 80vw); padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 32px -10px rgba(15, 18, 30, .3); font-size: 12.5px; font-weight: 400; color: var(--ink-2); line-height: 1.7; text-align: left; white-space: normal; }
.help-pop b { display: block; color: var(--ink); font-size: 13px; margin-bottom: 4px; }
.help-pop p { margin: 0 0 6px; }
.help-pop p:last-child { margin-bottom: 0; }
.help-wrap.open .help-pop { display: block; }
.grid.g2 > .field:nth-child(2n) .help-pop { left: auto; right: -12px; }

/* クリエイティブの見本 */
.crthumb { position: relative; overflow: hidden; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.crstage { position: absolute; left: 0; top: 0; width: 375px; height: 667px; transform-origin: 0 0; background: #fff; }
.crbtn { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 9px; }
.crbtn:hover .crthumb { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.crview { display: flex; flex-direction: column; align-items: center; }
.crview .crthumb { border-radius: 22px; border: 7px solid #20243a; box-sizing: content-box; }

.h1-sub { margin-left: 10px; font-size: 13px; font-weight: 600; color: var(--ink-3); vertical-align: middle; }

/* 変更履歴 */
.hist { display: flex; flex-direction: column; }
.hist-row { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.hist-row:last-child { border-bottom: 0; }
.hist-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--ink-3); }
.hist-dot.publish { background: var(--good); }
.hist-dot.pause { background: var(--warn); }
.hist-dot.restore, .hist-dot.adopt { background: var(--brand); }

/* 前期間比・期間指定 */
.kpi .dl { margin-top: 2px; }
.delta { font-size: 12px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.daterange { display: inline-flex; align-items: center; gap: 4px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--sunken); }
.daterange.on { border-color: var(--brand); background: var(--brand-soft); }
.daterange input[type=date] { height: 28px; border: 0; background: transparent; padding: 0 4px; }

/* はじめにやること */
.guide-bar { height: 4px; background: var(--line-2); }
.guide-bar > div { height: 100%; background: var(--brand); transition: width .4s ease; }
.guide-steps { list-style: none; margin: 0; padding: 6px 18px 12px; }
.guide-steps li { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.guide-steps li:last-child { border-bottom: 0; }
.guide-steps .gcheck { display: grid; place-items: center; width: 28px; height: 28px; cursor: pointer; }
.guide-steps .gcheck input { width: 20px; height: 20px; margin: 0; cursor: pointer; }
.guide-steps .gcheck input[aria-disabled=true] { cursor: default; }
.guide-steps li.ok b { text-decoration: line-through; text-decoration-color: var(--ink-3); }
.guide-steps .gnum { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--sunken); color: var(--ink-3); border: 1px solid var(--line); }
.guide-steps li.ok { opacity: .6; }
.guide-steps li.ok .gnum { background: var(--good-soft); color: var(--good); border-color: transparent; }
.guide-steps li.next .gnum { background: var(--brand); color: var(--brand-ink); border-color: transparent; }

.guide-btn { position: relative; width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: 700 13px/22px var(--font); cursor: pointer; }
.guide-btn:hover { border-color: var(--brand); color: var(--brand); }
.guide-btn.todo::after { content: ""; position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); border: 2px solid var(--paper); }

/* 公開中なのに受信がないときの帯 */
.warnbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; margin-bottom: 16px; border-radius: 12px; background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); color: var(--ink); }
.stack > .warnbar { margin-bottom: 0; }
.warnbar b { color: var(--bad); }
.warnbar > div > div { margin-top: 2px; color: var(--ink-2); font-size: 13px; }
.warnbar .btn { flex-shrink: 0; }
@media (max-width: 640px) { .warnbar { flex-direction: column; align-items: stretch; } }

.arm-design { display: grid; grid-template-columns: 98px 1fr; gap: 14px; align-items: start; }
.arm-design .small { word-break: break-all; }

/* サイドバー：うすい青で中身と分ける（ダーク表示では濃い紺） */
:root { --side-bg: #eef3fa; --side-line: #dfe7f3; --side-ink: #45506a; --side-ink-hi: #141b2d; --side-ink-lo: #8a95ab; --side-hover: rgba(43, 86, 160, .07); --side-on-bg: #ffffff; --side-on-ink: var(--brand); --side-on-shadow: 0 1px 2px rgba(20, 40, 90, .08), 0 2px 8px -2px rgba(20, 40, 90, .10); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --side-bg: #11151f; --side-line: rgba(255,255,255,.06); --side-ink: #b9bfcd; --side-ink-hi: #ffffff; --side-ink-lo: #7c8396; --side-hover: rgba(255,255,255,.06); --side-on-bg: rgba(239,74,60,.14); --side-on-ink: #ff7a6e; --side-on-shadow: none; } }
:root[data-theme="dark"] { --side-bg: #11151f; --side-line: rgba(255,255,255,.06); --side-ink: #b9bfcd; --side-ink-hi: #ffffff; --side-ink-lo: #7c8396; --side-hover: rgba(255,255,255,.06); --side-on-bg: rgba(239,74,60,.14); --side-on-ink: #ff7a6e; --side-on-shadow: none; }
.side { background: var(--side-bg); border-right-color: var(--side-line); color: var(--side-ink); }
.side .nav a { color: var(--side-ink); font-weight: 500; }
.side .nav a:hover { background: var(--side-hover); color: var(--side-ink-hi); }
.side .nav a.on { background: var(--side-on-bg); color: var(--side-on-ink); box-shadow: var(--side-on-shadow); font-weight: 700; }
.side .nav .grp { background: var(--side-line); }
.side:hover .nav .grp, .side:focus-within .nav .grp, .pinned .side .nav .grp, .resizing .side .nav .grp { background: none; color: var(--side-ink-lo); }
.side .me { border-top-color: var(--side-line); color: var(--side-ink); }
.side .me b { color: var(--side-ink-hi); }
.side .me .faint { color: var(--side-ink-lo); }
.side .me .btn.ghost { color: var(--side-ink); }
.side .me .btn.ghost:hover { background: var(--side-hover); color: var(--side-ink-hi); }
.side .pin { color: var(--side-ink-lo); }
.side .pin:hover { background: var(--side-hover); color: var(--side-ink-hi); }
.side .pin.on { color: var(--side-on-ink); }
.side :focus-visible { outline-color: var(--side-on-ink); }
