/* マーケットサイズ AI の見た目 — 台本 AI (reel-ai) の app.css を写したもの (青の差し色・白いパネル・左のメニュー)。下に地図の画面の分を足した
   スマホ (幅 360px) でも横にはみ出さない。左のメニューは、幅の狭い画面では上の横並びになる */
:root {
  --bg: #f3f5f9; --panel: #ffffff; --panel-2: #f8fafc; --text: #172033; --muted: #5f6b7d; --line: #e4e9f0; --line-strong: #cbd4df;
  --accent: #2457c5; --accent-hover: #1c48a6; --accent-weak: #e8effc; --ring: rgba(36, 87, 197, .22);
  --ok: #15803d; --ok-weak: #e6f6ec; --warn: #b45309; --warn-weak: #fff4e3; --ng: #b91c1c; --ng-weak: #fdecec;
  --telop: #c2410c;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --head-h: 56px; --side-w: 220px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.7 "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif; font-feature-settings: "palt"; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── 上の帯 ── */
header.top { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .94); border-bottom: 1px solid var(--line); }
header.top .inner { height: var(--head-h); padding: 0 20px; display: flex; align-items: center; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.brand .mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #2f6fe4 0%, #1b3f8f 100%); display: grid; place-items: center; color: #fff; font-size: 14px; }
.brand:hover { color: var(--text); }
header.top .who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .88rem; min-width: 0; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 3px 12px 3px 4px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--text); text-decoration: none; min-width: 0; }
.user-chip .avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .78rem; font-weight: 700; display: grid; place-items: center; flex: none; }
.user-chip .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 12em; }
.user-chip .role { color: var(--muted); font-size: .78rem; white-space: nowrap; }

/* ── 画面の枠：左メニュー＋本文 ── */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: calc(100vh - var(--head-h)); }
.shell.bare { grid-template-columns: minmax(0, 1fr); }
.shell.bare aside.side { display: none; }
main { padding: 28px 36px 64px; width: 100%; max-width: 1120px; }
aside.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 12px; position: sticky; top: var(--head-h); align-self: start; height: calc(100vh - var(--head-h)); overflow-y: auto; }
aside.side .group-title { font-size: .72rem; font-weight: 700; color: var(--muted); margin: 14px 12px 6px; letter-spacing: .08em; }
aside.side a, aside.side button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font: inherit; font-size: .94rem; position: relative; background: none; border: 0; cursor: pointer; text-align: left; }
aside.side a:hover, aside.side button:hover { background: var(--panel-2); }
aside.side a.active { background: var(--accent-weak); color: var(--accent); font-weight: 700; }
aside.side a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
aside.side .ic { width: 20px; text-align: center; color: var(--muted); flex: none; }
aside.side a.active .ic { color: var(--accent); }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  aside.side { position: static; height: auto; display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  aside.side .group-title { display: none; }
  aside.side a, aside.side button { width: auto; white-space: nowrap; padding: 6px 10px; }
  aside.side a.active::before { display: none; }
  main { padding: 18px 16px 64px; }
  header.top .inner { padding: 0 16px; }
  .user-chip .role { display: none; }
}

/* ── 見出し・文章 ── */
h1 { font-size: 1.45rem; line-height: 1.35; margin: 0 0 6px; }
h2 { font-size: 1.08rem; margin: 22px 0 10px; }
h3 { font-size: .98rem; margin: 16px 0 6px; }
.page-head { margin-bottom: 18px; }
.lead { color: var(--muted); font-size: .92rem; margin: 2px 0 0; max-width: 76ch; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.tiny { font-size: .78rem; color: var(--muted); }
.panel, .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel > h2:first-child, .card > h2:first-child { margin-top: 0; }
@media (max-width: 640px) { .panel, .card { padding: 14px 16px; } }
.center { max-width: 420px; margin: 32px auto; }

/* ── 注意の箱 ── */
.error, .notice, .warnbox, .alert { padding: 10px 14px; border-radius: var(--radius-sm); border-left: 3px solid; margin: 8px 0; }
.error, .alert.err { color: var(--ng); background: var(--ng-weak); border-color: var(--ng); }
.notice, .alert.ok { color: var(--ok); background: var(--ok-weak); border-color: var(--ok); }
.warnbox { color: var(--warn); background: var(--warn-weak); border-color: var(--warn); }
.alert.info { color: var(--text); background: var(--accent-weak); border-color: var(--accent); }

/* ── バッジ ── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: #edf1f6; color: #3f4c5f; white-space: nowrap; line-height: 1.5; vertical-align: middle; }
.badge.ok { color: var(--ok); background: var(--ok-weak); }
.badge.warn { color: var(--warn); background: var(--warn-weak); }
.badge.ng { color: var(--ng); background: var(--ng-weak); }
.badge.info { color: var(--accent); background: var(--accent-weak); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700; border: 1px solid currentColor; white-space: nowrap; }
.pill.未定 { color: var(--muted); } .pill.採用 { color: var(--ok); background: var(--ok-weak); } .pill.不採用 { color: var(--ng); background: var(--ng-weak); }
.pill.作成中 { color: var(--warn); background: var(--warn-weak); } .pill.失敗 { color: var(--muted); }

/* ── 入力 ── */
label.field, .field { display: block; margin: 12px 0; }
label.field > span, .field > .label { display: block; font-size: .86rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 12px; min-height: 42px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
textarea { resize: vertical; line-height: 1.6; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 14px 10px; margin: 14px 0; min-width: 0; }
legend { font-weight: 700; font-size: .9rem; padding: 0 6px; }
.radio-row { display: flex; gap: 8px; align-items: baseline; padding: 5px 0; cursor: pointer; }
.radio-row input { flex: none; margin: 0; transform: translateY(2px); accent-color: var(--accent); }
.radio-row b { white-space: nowrap; }
.radio-row .note { color: var(--muted); font-size: .84rem; }
.radio-sub { font-size: .76rem; font-weight: 700; color: var(--muted); margin: 8px 0 2px; letter-spacing: .04em; }
.btn, button.primary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 700; min-height: 42px; padding: 8px 18px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); color: #fff; }
.btn.sm { min-height: 34px; padding: 4px 12px; font-size: .86rem; }
.btn.ok { border-color: var(--ok); color: var(--ok); }
.btn.danger { border-color: var(--ng); color: var(--ng); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.grid-perf { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.chip { font: inherit; font-size: .86rem; padding: 4px 12px; min-height: 32px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
details > summary { cursor: pointer; color: var(--accent); }
.hide { display: none !important; }

/* ── 表 ── */
.table-wrap, .tablewrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .88rem; }
th { background: var(--panel-2); font-weight: 600; font-size: .78rem; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td, table tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: #fbfcfe; }
tr.採用 td:first-child { box-shadow: inset 4px 0 0 var(--ok); }
tr.不採用 td { color: var(--muted); } tr.不採用 td:first-child { box-shadow: inset 4px 0 0 var(--ng); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── ネタの例 (ねらい・切り口で絞る。1 つのネタ = 1 枚のカード) ── */
.ideas ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.ideas li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.ideas li:hover { border-color: var(--line-strong); }
.ideas .idea-main { flex: 1; min-width: 0; }
.ideas .idea-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 2px; }
.ideas .idea-topic { margin: 2px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ideas li > .btn { flex: none; }
.ideas .ideas-more { display: flex; width: 100%; margin-top: 8px; color: var(--accent); }
.ideas-empty { margin-top: 10px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--panel-2); }
.ideas-empty p { margin: 0 0 8px; }
@media (max-width: 640px) {
  .ideas li { flex-direction: column; align-items: stretch; }
  .ideas .chips { gap: 4px; }
  .ideas .chip { font-size: .8rem; padding: 2px 9px; min-height: 28px; }
  .ideas .chips .chip-label { flex-basis: 100%; }
}
.chips .chip-label { font-size: .78rem; font-weight: 700; color: var(--muted); align-self: center; min-width: 3.5em; }
.chip-group { font-size: .72rem; font-weight: 800; align-self: center; margin-left: 6px; letter-spacing: .02em; }
.chip .n { margin-left: 6px; font-size: .74rem; font-variant-numeric: tabular-nums; opacity: .75; }
.chip.zero:not(.on) { border-style: dashed; color: var(--muted); background: var(--panel-2); }
.chips + .chips { margin-top: -4px; }
.chip-set { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; } /* 客数 UP・客単価 UP の 3 つずつは、なるべく同じ行に */
/* ねらいの色: 客数 UP = 青・客単価 UP = 紫。切り口 = 白に枠 */
.g-kyaku { color: var(--accent); } .badge.g-kyaku { background: var(--accent-weak); }
.g-tanka { color: #7c3aed; } .badge.g-tanka { background: #f1e9fe; }
.badge.angle { background: #fff; border: 1px solid var(--line-strong); color: var(--muted); font-weight: 600; }
.goal-month { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin: -4px 0 10px; }
.goal-month-group { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.goal-month-group .chip-group { margin-left: 0; }
.goal-month-item { font-size: .78rem; padding: 1px 8px; border-radius: 999px; background: #fff; border: 1px solid var(--line); }
.goal-month-item.zero { color: var(--muted); border-style: dashed; }

/* ── 台本 ── */
.reel-doc .reel-h { margin: 18px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 1.02rem; }
.reel-doc p { margin: 4px 0; }
.reel-list { margin: 4px 0 8px; padding-left: 1.3em; }
.reel-scene { display: grid; grid-template-columns: 7.5em 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.reel-time { display: flex; flex-direction: column; font-size: .86rem; color: var(--muted); }
.reel-time span { font-variant-numeric: tabular-nums; }
.reel-time b { color: var(--accent); font-weight: 700; }
.reel-lines p { margin: 2px 0; }
.reel-dir { color: var(--muted); font-size: .84rem; }
.reel-telop { color: var(--telop); font-weight: 800; }
.reel-speaker { display: inline-block; min-width: 1.7em; text-align: center; margin-right: 6px; padding: 0 6px; border-radius: 6px; font-size: .78rem; font-weight: 800; }
.reel-speaker-a { background: var(--warn-weak); color: var(--warn); } .reel-speaker-b { background: var(--accent-weak); color: var(--accent); }
.reel-legend { margin: 6px 0 0; }
.reel-story { margin: 6px 0 0; line-height: 1.9; }
.reel-input { margin-bottom: 8px; font-size: .9rem; }
@media (max-width: 640px) { .reel-scene { grid-template-columns: 1fr; gap: 2px; } .reel-time { flex-direction: row; gap: 8px; } }

/* ── 出した数字 ── */
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); color: var(--muted); font-size: .82rem; }
.kpi b { display: block; font-size: 1.5rem; color: var(--text); line-height: 1.2; margin-top: 2px; }
.meter { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin: 4px 0; border: 1px solid var(--line); }
.meter > i { display: block; height: 100%; background: var(--accent); }
.secret { font-family: ui-monospace, monospace; font-size: 13px; padding: 10px; background: var(--panel-2); border-radius: 8px; overflow-wrap: anywhere; user-select: all; margin: 6px 0; }

/* ── A4 1 枚の原稿 (印刷・PDF) ── */
.reel-sheet { background: #fff; max-width: 190mm; margin: 0 auto; padding: 10mm 12mm; border: 1px solid var(--line); font-size: 11.5pt; line-height: 1.6; color: #111; }
.reel-sheet-title { font-size: 17pt; font-weight: 800; line-height: 1.35; }
.reel-sheet-meta { font-size: 9pt; color: #555; margin: 4px 0 8px; }
.reel-sheet-legend { margin-left: 8px; }
.reel-sheet table { border: 1px solid #999; }
.reel-sheet th, .reel-sheet td { border: 1px solid #bbb; font-size: 10.5pt; padding: 5px 8px; }
.reel-sheet th { width: 17%; background: #f3f5f9; color: #111; white-space: normal; }
.reel-sheet th .t { display: block; font-variant-numeric: tabular-nums; color: #555; font-weight: 600; }
.reel-sheet td p { margin: 1px 0; }
.reel-sheet-sub { margin-top: 8px; font-size: 9.5pt; }
.reel-sheet-sub p { margin: 1px 0; }
.reel-sheet-foot { margin-top: 10px; font-size: 8pt; color: #777; border-top: 1px solid #ddd; padding-top: 4px; }
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  header.top, aside.side, .no-print, #toast { display: none !important; }
  .shell { display: block; } main { padding: 0; max-width: none; }
  .reel-sheet { border: 0; padding: 0; max-width: none; }
}

/* ── 知らせ・確かめ ── */
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 40; display: grid; gap: 6px; width: min(92vw, 420px); }
#toast .t { padding: 10px 14px; border-radius: 10px; background: #172033; color: #fff; box-shadow: var(--shadow); font-size: .9rem; }
#toast .t.err { background: var(--ng); }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--text); max-width: min(92vw, 440px); padding: 18px; }
dialog::backdrop { background: rgba(16, 24, 40, .35); }
/* ===== マーケットサイズ AI: 地図の画面 (台本 AI の見た目に足したもの) ===== */
main.wide { max-width: none; padding: 16px 20px 40px; }
.back-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--accent); color: var(--accent); background: var(--accent-weak); text-decoration: none; font-weight: 700; font-size: .84rem; white-space: nowrap; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.map-wrap { position: sticky; top: calc(var(--head-h) + 12px); }
.map-box { height: calc(100vh - var(--head-h) - 120px); min-height: 420px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: #e8edf3; }
.map-box.drawing { cursor: crosshair; touch-action: none; }
.map-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.map-tools .chip { min-height: 38px; }
.map-hint { font-size: .8rem; color: var(--muted); margin: 6px 2px 0; }
.map-credit { font-size: .74rem; color: var(--muted); margin: 6px 2px 0; }
.panel-col { display: grid; gap: 12px; }
.panel-col .card { margin-bottom: 0; }
.result-big { font-size: 2rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.result-grid div { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 8px; font-size: .76rem; color: var(--muted); }
.result-grid b { display: block; color: var(--text); font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.store-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0; background: #fff; }
.store-item.off { opacity: .6; }
.store-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.ring-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 6px 0; }
.ring-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: .84rem; background: #fff; }
.ring-chip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 2px 6px; min-height: 28px; }
.ring-chip.use { border-color: var(--accent); background: var(--accent-weak); color: var(--accent); font-weight: 700; }
.mini-table th, .mini-table td { padding: 5px 8px; font-size: .82rem; }
.notes { margin: 8px 0 0; padding-left: 1.2em; font-size: .8rem; color: var(--muted); }
.notes li { margin: 3px 0; }
.leaflet-container { font: inherit; }
.ring-handle { width: 18px !important; height: 18px !important; margin-left: -9px !important; margin-top: -9px !important; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: ew-resize; }
.vertex-handle { width: 14px !important; height: 14px !important; margin-left: -7px !important; margin-top: -7px !important; border-radius: 3px; background: #fff; border: 2px solid #b45309; cursor: move; }
.leaflet-tooltip.ring-label { background: rgba(255,255,255,.92); border: 1px solid var(--line-strong); box-shadow: none; padding: 1px 6px; font-weight: 700; font-size: .78rem; color: var(--accent); }
.leaflet-tooltip.ring-label::before { display: none; }
.leaflet-tooltip.store-label { font-weight: 700; }
.spend-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 10px 0; background: #fff; }
.spend-value { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cand { border-top: 1px dashed var(--line); padding: 8px 0; }
.cand:first-child { border-top: 0; }
.area-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.area-row:first-child { border-top: 0; }
@media (max-width: 960px) {
  main.wide { padding: 10px 10px 40px; }
  .map-layout { grid-template-columns: minmax(0, 1fr); }
  .map-wrap { position: static; }
  .map-box { height: 56vh; min-height: 320px; }
  .result-big { font-size: 1.7rem; }
}
/* つながるシステムから来た人: 狭い画面では「〇〇に戻る」を残し、名前の札は隠す (上の帯からはみ出さないように) */
@media (max-width: 640px) {
  header.top .who:has(.back-chip) .user-chip { display: none; }
  .brand { font-size: .95rem; }
}
