:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2330;
  --muted: #677185;
  --line: #e3e7ee;
  --accent: #1f8fd6;
  --accent-soft: #e3f2fc;
  --ok: #1a9a5b;
  --ok-soft: #e4f6ec;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --err: #d23b3b;
  --err-soft: #fdeaea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .04);
  --yt: #FF0033;
  --ig: #E1306C;
  --th: #101010;
  --tt: #FE2C55;
  --nt: #41C9B4;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* ===== レイアウト ===== */
.topbar { display: none; }
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: #16202e; color: #cfd6e2;
  display: flex; flex-direction: column; padding: 20px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { font-size: 20px; font-weight: 800; color: #fff; padding: 0 10px 14px; letter-spacing: .02em; }
.brand span { color: #5fc0f5; }
.tenant-name { padding: 6px 10px 14px; font-size: 12px; color: #9aa6b8; }
.tenant-switch { padding: 0 8px 14px; }
.tenant-switch label { display: block; font-size: 11px; color: #9aa6b8; margin-bottom: 4px; }
.tenant-switch select { width: 100%; background: #223047; color: #fff; border: 1px solid #33455f; border-radius: 8px; padding: 6px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; color: #cfd6e2; padding: 9px 10px;
  border-radius: 8px; font-weight: 600; text-decoration: none;
}
.sidebar nav a svg { width: 18px; height: 18px; fill: currentColor; opacity: .85; }
.sidebar nav a:hover { background: #1f2c3e; }
.sidebar nav a.active { background: #1f8fd6; color: #fff; }
.sidebar nav a.nav-out { margin-top: 10px; border-top: 1px solid #263349; border-radius: 0 0 8px 8px; padding-top: 12px; }
.sidebar-foot { border-top: 1px solid #263349; padding: 12px 10px 0; font-size: 12px; }
.sidebar-foot .me { color: #fff; margin-bottom: 2px; }
.sidebar-foot a { color: #9aa6b8; }
.nav-backdrop { display: none; }
.main { flex: 1; min-width: 0; padding: 24px 28px 60px; max-width: 1280px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; }

/* ===== 部品 ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card, .section + .section { margin-top: 16px; }
.section { margin-top: 20px; }
.grid { display: grid; gap: 14px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid-accounts { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 800; line-height: 1.25; margin-top: 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.up { color: var(--ok); }
.down { color: var(--err); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap;
  font-family: inherit;
}
.btn:hover { background: #f1f4f8; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #197cbb; }
.btn-danger { color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline { display: inline; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.flash-ok { background: var(--ok-soft); color: #11663c; }
.flash-warn { background: var(--warn-soft); color: #7a5213; }
.flash-err { background: var(--err-soft); color: #9b2020; }

.pf {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  color: #fff; line-height: 1.7; white-space: nowrap;
}
.pf-youtube { background: var(--yt); }
.pf-instagram { background: linear-gradient(45deg, #F58529, #DD2A7B 55%, #8134AF); }
.pf-threads { background: var(--th); }
.pf-tiktok { background: #111; box-shadow: inset 3px 0 0 #25F4EE, inset -3px 0 0 var(--tt); }
.pf-note { background: var(--nt); }

.tag { display: inline-block; font-size: 11px; padding: 0 8px; border-radius: 999px; background: var(--accent-soft); color: #1567a0; font-weight: 600; }
.status { font-size: 12px; font-weight: 700; }
.status-active { color: var(--ok); }
.status-error, .status-failed { color: var(--err); }
.publish-log { margin-top: 4px; }
.publish-log summary { cursor: pointer; color: var(--muted); }
.publish-log-run { margin: 6px 0 8px; padding: 6px 8px; border-left: 3px solid var(--err); background: var(--bg); }
.publish-log ol { margin: 4px 0 0; padding-left: 18px; }
.publish-log li { margin: 2px 0; overflow-wrap: anywhere; }
.publish-log code { display: block; margin-top: 2px; font-size: 11px; white-space: pre-wrap; }
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item { padding: 10px 0 10px 12px; border-bottom: 1px solid var(--line); border-left: 3px solid var(--line); }
.activity-item.activity-failed { border-left-color: var(--err); }
.activity-item.activity-warn { border-left-color: #e6a700; }
.activity-item.activity-ok { border-left-color: #2e9e5b; }
.activity-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.activity-kind { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--bg); }
.activity-failed .activity-result { color: var(--err); font-weight: 600; }
.activity-warn .activity-result { color: #b07f00; font-weight: 600; }
.activity-ok .activity-result { color: #2e9e5b; }
.activity-message { margin: 4px 0; overflow-wrap: anywhere; }
.status-reauth { color: var(--warn); }
.status-disconnected, .status-canceled { color: var(--muted); }
.status-scheduled { color: var(--accent); }
.status-published { color: var(--ok); }

/* フォーム */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg a { padding: 6px 12px; color: var(--text); font-weight: 600; font-size: 13px; text-decoration: none; }
.seg a + a { border-left: 1px solid var(--line); }
.seg a.on { background: var(--accent); color: #fff; }
.seg-wrap { flex-wrap: wrap; }
.seg-wrap a + a { border-left: 0; box-shadow: -1px 0 0 var(--line); }
.period-custom { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.period-custom input[type=date] { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
select, input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=password], input[type=url], input[type=month], textarea {
  font: inherit; padding: 7px 10px; border: 1px solid #cfd6e1; border-radius: 8px; background: #fff; color: var(--text); max-width: 100%;
}
textarea { width: 100%; min-height: 140px; resize: vertical; }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.form-grid input, .form-grid select { width: 100%; }

/* テーブル */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.data th { font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; background: #fafbfd; }
table.data td.r, table.data th.r { text-align: right; }
table.data tr:hover td { background: #fafcff; }

/* アカウントカード */
.acc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #e6eaf0; flex-shrink: 0; }
.avatar-ph { display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; }
.acc-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.acc-stats .v { font-weight: 800; font-size: 17px; }
.acc-stats .l { font-size: 11px; color: var(--muted); }
.spark { height: 48px; margin-top: 8px; }

.chart-box { position: relative; height: 280px; }

/* 投稿 */
.post-cell { display: flex; gap: 10px; align-items: center; min-width: 260px; }
.thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #e6eaf0; flex-shrink: 0; }
.post-title { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 380px; }
.top-post { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.top-post:last-child { border-bottom: 0; }
.top-post .rank { font-weight: 800; color: var(--muted); width: 18px; text-align: center; }
.top-post .meta { font-size: 12px; color: var(--muted); }
.top-post .body { flex: 1; min-width: 0; }
.top-post .big { font-weight: 800; text-align: right; white-space: nowrap; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h2 { color: var(--text); }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

/* スケジュール */
.sched-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.sched-item:last-child { border-bottom: 0; }
.sched-time { width: 110px; flex-shrink: 0; font-weight: 700; }
.sched-body { flex: 1; min-width: 0; word-break: break-word; }
.sched-text { white-space: pre-wrap; margin-top: 4px; }
.sched-actions { display: flex; gap: 6px; flex-shrink: 0; }
.counter { font-size: 12px; color: var(--muted); text-align: right; }
.counter.over { color: var(--err); font-weight: 700; }

.tag-ok { background: var(--ok-soft); color: #11663c; }
.linked-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.linked-list li { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; min-width: 0; }
.linked-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-account { font-weight: 600; color: var(--text); }

.policy { max-width: 760px; margin: 0 auto; }
.policy ul { padding-left: 1.4em; margin: 0 0 8px; }

/* 概要欄の一括編集 */
.bulk-rule { display: grid; grid-template-columns: 200px 1fr 1fr; gap: 8px; margin-bottom: 8px; align-items: start; }
.bulk-rule textarea { min-height: 54px; }
.bulk-rules { margin: 0; padding-left: 1.4em; }
.bulk-rules li { margin-bottom: 8px; }
.bulk-rules pre { display: inline-block; vertical-align: top; margin: 2px 4px; padding: 4px 8px; background: var(--bg); border-radius: 6px; white-space: pre-wrap; font: inherit; font-size: 13px; max-width: 100%; }
.bulk-item { border-bottom: 1px solid var(--line); padding: 8px 0; }
.bulk-item summary { cursor: pointer; font-weight: 600; }
.bulk-diff { white-space: pre-wrap; word-break: break-word; font: inherit; font-size: 13px; line-height: 1.7; background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 6px 0 0; }
.bulk-diff span { display: block; }
.bulk-diff .add, .add-l { background: var(--ok-soft); color: #11663c; }
.bulk-diff .del, .del-l { background: var(--err-soft); color: #9b2020; text-decoration: line-through; }
.add-l, .del-l { padding: 0 4px; border-radius: 4px; text-decoration: none; }
@media (max-width: 860px) { .bulk-rule { grid-template-columns: 1fr; } }

/* 投稿帳 */
.book-progress { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.book-progress .bar { width: 140px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.book-progress .bar i { display: block; height: 100%; background: var(--ok); }
.book-tabs { display: flex; border-bottom: 2px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.book-tabs a { padding: 10px 16px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; text-decoration: none; }
.book-tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.book-filters { margin-bottom: 6px; }
.book-day h2 { margin: 22px 0 10px; }
.book-post { position: relative; display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.book-post + .book-post { margin-top: 12px; }
.book-post.done { opacity: .62; }
.book-post.done:hover { opacity: 1; }
.book-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-right: 90px; }
.tag-line { background: transparent; border: 1px solid var(--accent); }
.book-why { margin: 0; font-size: 12px; color: var(--muted); }
.book-text { white-space: pre-wrap; word-break: break-word; margin: 0; padding: 14px 16px; background: var(--bg); border-radius: 8px; font: inherit; font-size: 15px; line-height: 1.85; }
.book-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-posted { background: var(--err-soft); color: var(--err); border-color: var(--err); }
.book-stamp { position: absolute; top: 14px; right: 16px; border: 2px solid var(--err); color: var(--err); border-radius: 4px; padding: 1px 9px; font-weight: 700; font-size: 12px; transform: rotate(-6deg); background: var(--card); }
.book-reply { border-left: 3px solid var(--accent); padding-left: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.book-reply h3 { margin: 0; font-size: 12px; color: var(--accent); }
.book-reply .book-text { font-size: 14px; align-self: stretch; }
.book-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; }
.book-stats b { color: var(--text); }
.book-day-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; max-width: 760px; }
.book-day-head h2 { margin-right: auto; }
.book-story { display: flex; gap: 14px; align-items: flex-start; }
.book-story img, .book-story video { width: 160px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; background: #000; }
.book-story-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.book-sched-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.book-sched-form input[type=datetime-local] { padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.book-sched-state { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 560px) {
  .book-story { flex-direction: column; }
  .book-story img, .book-story video { width: 100%; max-width: 260px; }
}
.book-setting { padding: 10px 0; border-bottom: 1px solid var(--line); }
details.card summary { cursor: pointer; }
.flash { overflow-wrap: anywhere; }

/* ログイン */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card .brand { color: var(--text); text-align: center; padding: 0 0 18px; font-size: 24px; }
.auth-card .brand span { color: var(--accent); }
.auth-card input { width: 100%; }
.auth-card .btn { width: 100%; padding: 10px; }

/* 印刷(月次レポート) */
@media print {
  .sidebar, .topbar, .no-print, .flash { display: none !important; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ===== スマホ ===== */
@media (max-width: 860px) {
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    background: #16202e; color: #fff; padding: 8px 12px;
  }
  .menu-btn { background: none; border: 0; padding: 4px; cursor: pointer; }
  .menu-btn svg { width: 24px; height: 24px; fill: #fff; display: block; }
  .brand-sm { font-weight: 800; }
  .topbar-tenant { font-size: 12px; color: #9aa6b8; margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%);
    transition: transform .2s ease; height: 100%;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .main { padding: 16px 16px 60px; }
  h1 { font-size: 19px; }
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 20px; }
  .grid-2 { grid-template-columns: 1fr; }
  .chart-box { height: 230px; }
  .sched-item { flex-wrap: wrap; }
  .sched-time { width: auto; }
  .sched-actions { width: 100%; }
  /* 投稿テーブルをカード表示に */
  table.data.stack thead { display: none; }
  table.data.stack, table.data.stack tbody, table.data.stack tr, table.data.stack td { display: block; width: 100%; }
  table.data.stack tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.data.stack td { border: 0; padding: 3px 4px; text-align: left !important; }
  table.data.stack td[data-l]::before { content: attr(data-l) "："; color: var(--muted); font-size: 12px; }
  table.data.stack td.metrics-inline { display: inline-block; width: auto; margin-right: 10px; }
  .post-cell { min-width: 0; }
}

/* 予約投稿の投稿先カード */
.acc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.acc-card { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--card); min-width: 0; }
.acc-card:hover { border-color: var(--accent); }
.acc-card:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.acc-card input { position: absolute; opacity: 0; pointer-events: none; }
.acc-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.acc-card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 12px; }
.acc-card-text b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-card-open { position: absolute; top: 6px; right: 8px; font-size: 11px; color: var(--muted); text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.acc-card-open:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* 予約投稿の本文まわり(テンプレート・ハッシュタグ) */
.compose-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.compose-head select { max-width: 60%; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; }
.compose-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.tag-bar { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.tag-hash { font-size: 16px; font-weight: 700; min-width: 40px; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.tag-chip { border: 1px solid var(--line); background: var(--bg); color: var(--accent); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.tag-chip:hover { border-color: var(--accent); }
.tpl-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.tpl-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.tpl-list li > span { display: flex; flex-direction: column; min-width: 0; }

/* よく見られる曜日・時間帯 */
.best-pill { display: inline-block; margin: 0 12px 6px 0; }
.best-grid { border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.best-grid th, .best-grid td { padding: 6px 8px; text-align: center; border: 1px solid var(--line); white-space: nowrap; }
.best-grid tbody th { text-align: left; font-weight: normal; }
.best-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.tag-best { background: color-mix(in srgb, var(--accent) 16%, var(--card)); color: var(--accent); font-weight: bold; }
.best-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 12px; padding: 12px 16px; }
.tag-sticker { background: #fff3d6; color: #8a5a00; font-weight: bold; }
.book-sticker-note { font-size: 13px; background: #fff8e6; border: 1px solid #f0d79a; border-radius: 8px; padding: 8px 10px; margin: 8px 0 0; }
.th-part { border-left: 3px solid var(--line); padding-left: 10px; margin-bottom: 8px; }
.th-part textarea { width: 100%; }
.thumb-pick { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.thumb-now { width: 120px; min-height: 160px; border: 1px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; text-align: center; overflow: hidden; background: var(--bg); }
.thumb-now img { width: 100%; display: block; }
.thumb-tools { flex: 1; min-width: 200px; }
.thumb-tools video { width: 100%; max-height: 240px; background: #000; border-radius: 8px; display: block; }
.thumb-tools input[type=range] { width: 100%; margin: 6px 0 0; }
.sched-part { border-left: 3px solid var(--line); padding-left: 8px; }
.tag-chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.acc-cards.sorting .acc-card { flex-wrap: wrap; border-style: dashed; }
.acc-cards.sorting .acc-card-open { display: none; }
.acc-move { display: flex; gap: 6px; width: 100%; justify-content: space-between; }
.book-edit { margin-top: 10px; }
.book-edit summary { list-style: none; display: inline-block; }
.book-edit summary::-webkit-details-marker { display: none; }
.book-edit form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.book-edit textarea, .book-edit input[type=text] { width: 100%; }
.book-sched-topic { font-size: 13px; }
details.book-edit:not([open]) { display: inline-block; margin-right: 6px; }
.book-redo-day { width: 100%; }
.book-redo-day form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-width: 560px; }
.book-redo-day summary { list-style: none; display: inline-block; }
.book-redo-day summary::-webkit-details-marker { display: none; }
.book-redo-state { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 0; }
.tag-sched { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.book-prev { margin-top: 8px; }
.book-prev summary { cursor: pointer; color: var(--muted); }
.book-prev .book-text { opacity: .75; }
.book-prev-img { max-width: 160px; border-radius: 8px; display: block; margin: 6px 0; }
.todo-card { margin-bottom: 16px; }
.todo-card h2 { margin: 0 0 8px; font-size: 16px; }
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.todo-list a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.todo-list .todo-num { min-width: 2.2em; text-align: center; font-weight: 700; border-radius: 999px; padding: 1px 8px; background: var(--accent); color: #fff; }
.todo-list .todo-warn .todo-num { background: var(--err); }
.todo-list .todo-go { margin-left: auto; color: var(--muted); font-size: 13px; }
.todo-done { color: var(--muted); margin: 0; }
.tag-best.past { opacity: .45; text-decoration: line-through; }
.book-sched-state { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 0; }
.book-resched { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.sched-clamp:not(.open) > .sched-text:first-child { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.sched-clamp:not(.open) > .sched-part { display: none; }
.sched-more { border: 0; background: none; padding: 2px 0; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }
.sync-now { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin: 0; }
.best-pill.weak { opacity: .55; }
.tag-eff { font-size: .8em; color: var(--muted); margin-left: 2px; }
.video-card h2 { margin-bottom: 4px; }
.video-rank li { margin-bottom: 4px; }
.video-hints td { color: var(--muted); padding-top: 0; }
.video-link { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.video-link select { flex: 1; min-width: 0; max-width: 100%; }
.video-edit { margin-top: 10px; }
.video-edit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 12px; margin: 8px 0; }
.video-edit-grid label, .video-edit label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.video-edit textarea { width: 100%; }
.ret-curve { display: block; width: 90px; height: 32px; margin-top: 2px; }
.ret-curve polyline { fill: none; stroke: var(--accent); stroke-width: 2; }
.verdict { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.verdict-good { background: color-mix(in srgb, #1a9e5c 18%, transparent); color: #127a46; }
.verdict-mid { background: color-mix(in srgb, var(--muted) 15%, transparent); color: var(--muted); }
.verdict-bad { background: color-mix(in srgb, #d14343 15%, transparent); color: #b23030; }
.verdict-wait { background: color-mix(in srgb, #c98a00 15%, transparent); color: #946500; }

/* 投稿帳: ストーリーの修正(写真＋文字をその場で作る) */
.story-edit .se-wrap { display: flex; gap: 16px; align-items: flex-start; }
.story-edit .se-preview { flex: 0 0 220px; }
.story-edit .se-preview canvas { width: 220px; height: auto; aspect-ratio: 9 / 16; border-radius: 10px; border: 1px solid var(--line); display: block; background: #222; }
.story-edit .se-controls { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.story-edit .se-controls textarea { min-height: 0; }
.story-edit .se-style { display: flex; flex-direction: column; gap: 6px; }
.se-seg { flex-wrap: wrap; align-self: flex-start; }
.se-seg label { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; font-weight: 600; font-size: 13px; cursor: pointer; margin: 0; }
.se-seg label + label { border-left: 1px solid var(--line); }
.se-seg input { margin: 0; }
.se-seg label:has(input:checked) { background: var(--accent-soft); color: var(--accent); }
.story-edit .se-msg { color: var(--err); }
@media (max-width: 720px) {
  .story-edit .se-wrap { flex-direction: column; }
  .story-edit .se-preview { flex: none; align-self: center; }
}


/* コメントの受信箱 */
.nav-badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--err); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.cm-thread { display: flex; flex-direction: column; gap: 10px; }
.cm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cm-head .cm-post { font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.cm-head .cm-when { margin-left: auto; }
.cm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cm-item { padding: 8px 12px; border-radius: 10px; background: var(--bg); max-width: 640px; }
.cm-item.cm-reply { margin-left: 24px; }
.cm-item.cm-own { background: var(--accent-soft); margin-left: auto; margin-right: 0; }
.cm-item .cm-who { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.cm-item .cm-who b { color: var(--text); }
.cm-item .cm-who .cm-open { margin-left: auto; }
.cm-item .cm-body { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.cm-form { display: flex; flex-direction: column; gap: 6px; }
.cm-form textarea { min-height: 80px; }
.cm-draft-note { font-size: 12px; color: var(--warn); }
.cm-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cm-state { font-size: 12px; color: var(--ok); font-weight: 600; }
.cm-watch-off { color: var(--warn); font-weight: 600; }
@media (max-width: 720px) {
  .cm-item.cm-reply { margin-left: 12px; }
  .cm-head .cm-when { margin-left: 0; width: 100%; }
}

/* 予約につながった */
.tag-warn { background: #fff3d6; color: #8a5a00; }
details.card > summary { cursor: pointer; list-style: revert; }

/* 視聴者 */
.au-bars { display: grid; gap: 6px; }
.au-row { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto 34px; gap: 8px; align-items: center; font-size: 13px; }
.au-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-track { height: 10px; background: var(--accent-soft); border-radius: 5px; overflow: hidden; }
.au-track span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.au-val { text-align: right; white-space: nowrap; }
.au-diff { font-size: 11px; text-align: right; }
.au-diff.up { color: #11663c; } .au-diff.down { color: #b42318; }
.au-hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; align-items: end; height: 90px; }
.au-hour { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; text-align: center; }
.au-hour span { display: block; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }
.au-hour small { font-size: 10px; color: var(--muted, #888); height: 14px; }

/* 予約投稿のカレンダー */
.grid[hidden] { display: none; }
.sched-acc { margin: 0 0 10px; }
.sched-acc .pf { font-size: 10px; padding: 1px 5px; }
.cal-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-head { padding: 4px; font-size: 12px; font-weight: 600; text-align: center; background: var(--bg); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-sun { color: var(--err); }
.cal-sat { color: var(--accent); }
.cal-day { min-height: 96px; padding: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; }
.cal-out { background: #fafbfc; }
.cal-out .cal-date { color: var(--muted); }
.cal-past { background: #f6f7f9; }
.cal-today .cal-date { color: #fff; background: var(--accent); border-radius: 10px; padding: 0 7px; align-self: flex-start; }
.cal-drop { outline: 2px dashed var(--accent); outline-offset: -3px; background: #eef6fc; }
.cal-date { font-size: 12px; font-weight: 600; }
.cal-wd { display: none; }
.cal-chip { display: block; padding: 2px 5px; border-radius: 4px; font-size: 11px; line-height: 1.35; color: var(--text); text-decoration: none; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--line); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-chip[draggable] { cursor: grab; }
.cal-chip:hover { background: var(--bg); }
.cal-chip.dragging, .cal-chip.moving { opacity: .45; }
.cal-youtube { border-left-color: var(--yt); }
.cal-instagram { border-left-color: #DD2A7B; }
.cal-threads { border-left-color: var(--th); }
.cal-tiktok { border-left-color: #25F4EE; }
.cal-st-published { opacity: .55; }
.cal-st-failed { border-color: var(--err); background: var(--err-soft); }
.cal-flag { font-size: 10px; font-weight: 600; margin-left: 2px; }
.cal-st-failed .cal-flag { color: var(--err); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; }
.cal-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; border-left-width: 10px; border-left-style: solid; }
@media (max-width: 720px) {
  .cal { display: block; border: 0; }
  .cal-head, .cal-out, .cal-empty { display: none; }
  .cal-day { min-height: 0; border: 0; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .cal-wd { display: inline; }
  .cal-chip { white-space: normal; font-size: 13px; padding: 5px 8px; }
}

/* 投稿の自動作成(質問に答えてプロンプトを作る) */
.ag-form { display: grid; gap: 14px; }
.ag-form .card + .card { margin-top: 0; }
.ag-q h2 { display: flex; align-items: center; gap: 10px; font-size: 17px; margin: 0 0 12px; }
.ag-no { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 14px; }
.ag-q label { display: block; font-weight: 600; font-size: 13px; margin-top: 10px; }
.ag-q label input[type=text], .ag-q label textarea, .ag-q label select { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
.ag-q textarea { min-height: 0; }
.ag-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.ag-choices label { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.ag-choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ag-choices span { grid-column: 2; font-weight: 400; font-size: 12px; color: var(--muted); }
.ag-nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.ag-nums label { margin: 0; }
.ag-nums input { display: block; width: 100%; margin-top: 4px; }
.ag-days { display: flex; flex-wrap: wrap; gap: 8px; }
.ag-days label { margin: 0; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.ag-days label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ag-grid { align-items: start; }
.ag-grid label { margin-top: 0; }
.ag-acc { max-width: 360px; }
.ag-save { position: sticky; bottom: 0; padding: 10px 0; background: var(--bg); }
.ag-steps { padding-left: 20px; line-height: 1.8; }
.ag-copy { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; }
.ag-prompt { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 13px; line-height: 1.7; max-height: 480px; overflow: auto; }
.book-paste textarea { min-height: 120px; font-size: 13px; }
.book-story-nophoto { flex: none; width: 160px; aspect-ratio: 9 / 16; display: grid; place-content: center; gap: 6px; padding: 12px; text-align: center; font-size: 13px; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; background: var(--bg); }
.book-paste summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
@media (max-width: 640px) { .book-story-nophoto { width: 100%; max-width: 260px; } }

/* 運営管理の見守り */
.ops-alerts { margin: 8px 0 0; padding-left: 18px; font-weight: 400; }
.ops-alerts li { margin-bottom: 6px; }

/* デモサイト */
.demo-banner { background: var(--warn-soft); color: #7a5213; border-radius: 10px; padding: 8px 14px; margin-bottom: 14px; font-size: 13px; }
.demo-lead { margin: 0 0 16px; line-height: 1.7; font-size: 14px; }
.demo-enter { width: 100%; padding: 12px; font-size: 16px; }
