:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --ink: #1b2230;
  --ink-2: #3a4252;
  --muted: #747b88;
  --line: #e7e6e1;
  --line-2: #f0efea;
  --accent: #0f766e;
  --accent-ink: #0b5c56;
  --accent-soft: #e5f1ee;
  --sun: #f2b84b;
  --sun-soft: #fdf3df;
  --rose: #c2412d;
  --rose-soft: #fbe9e5;
  --sky: #3b6fd8;
  --sky-soft: #e8effc;
  --radius: 12px;
  --radius-sm: 8px;
  font-family: "Inter", "Noto Sans JP", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ---------- レイアウト ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--accent);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .02em;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.brand-sub { font-size: 11px; color: var(--muted); }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; color: var(--muted); padding: 0 10px 4px; letter-spacing: .06em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--line-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.nav a.active .dot { background: var(--accent); }
.side-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 8px; display: flex; flex-direction: column; gap: 6px; }

.main { padding: 28px 36px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: .01em; }
.page-desc { color: var(--muted); margin: 4px 0 0; font-size: 13px; }

/* ---------- 部品 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 18px 20px; }
.card-title { font-weight: 700; font-size: 14px; margin: 0 0 12px; }
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.stat { padding: 18px 20px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-family: "Inter", sans-serif; font-size: 28px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; }
.stat-sub { font-size: 12px; color: var(--muted); }
.bar { height: 6px; border-radius: 99px; background: var(--line-2); overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--line-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--rose); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=url], input[type=number], input[type=email], input[type=datetime-local], select, textarea {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: var(--radius-sm); padding: 9px 11px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 96px; resize: vertical; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; font-size: 12px;
  background: var(--line-2); color: var(--ink-2); border: 1px solid transparent; cursor: default; white-space: nowrap;
}
.chip.tag { background: var(--accent-soft); color: var(--accent-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.pick .chip { cursor: pointer; background: #fff; border-color: var(--line); color: var(--ink-2); }
.chips.pick .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips.pick.ex .chip.on { background: var(--rose); border-color: var(--rose); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge.draft { background: var(--line-2); color: var(--muted); }
.badge.scheduled { background: var(--sky-soft); color: var(--sky); }
.badge.sending { background: var(--sun-soft); color: #9a6a10; }
.badge.sent, .badge.on { background: var(--accent-soft); color: var(--accent-ink); }
.badge.failed, .badge.off { background: var(--rose-soft); color: var(--rose); }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fbfbf9; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--line-2); object-fit: cover; flex: none; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.list-item { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }

/* ---------- モーダル ---------- */
.overlay { position: fixed; inset: 0; background: rgba(27, 34, 48, .32); display: grid; place-items: center; z-index: 50; padding: 24px; }
.modal { background: var(--surface); border-radius: 16px; width: min(760px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; }
.modal.wide { width: min(1040px, 100%); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.split { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }

/* ---------- メッセージ編集・プレビュー ---------- */
.msg-block { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; background: #fcfcfa; }
.phone { background: #8cabd9; border-radius: 22px; padding: 16px 12px; min-height: 420px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; }
.phone-head { color: #fff; font-size: 12px; font-weight: 600; text-align: center; margin-bottom: 4px; opacity: .9; }
.bubble { background: #fff; border-radius: 16px; border-top-left-radius: 4px; padding: 9px 12px; max-width: 88%; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.bubble.img { padding: 0; overflow: hidden; }
.bubble.img img { display: block; max-width: 100%; }
.bubble .qr { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bubble .qr span { border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; font-size: 12px; }
.flex-card { background: #fff; border-radius: 14px; overflow: hidden; max-width: 88%; font-size: 13px; }
.flex-card .fc-body { padding: 12px; }
.flex-card .fc-btn { margin: 0 12px 12px; background: var(--accent); color: #fff; text-align: center; border-radius: 8px; padding: 8px; font-weight: 600; }
.btns-card { background: #fff; border-radius: 14px; max-width: 88%; font-size: 13px; overflow: hidden; }
.btns-card .t { padding: 12px; white-space: pre-wrap; }
.btns-card .a { border-top: 1px solid var(--line-2); padding: 9px; text-align: center; color: var(--sky); }

/* ---------- リッチメニュー ---------- */
.rm-canvas { position: relative; width: 100%; aspect-ratio: 2500 / 1686; background: var(--line-2) center / cover no-repeat; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); }
.rm-canvas.half { aspect-ratio: 2500 / 843; }
.rm-cell { position: absolute; border: 1.5px dashed rgba(255, 255, 255, .95); outline: 1px solid rgba(27, 34, 48, .25); display: grid; place-items: center; color: #fff; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.5); cursor: pointer; }
.rm-cell.sel { background: rgba(15, 118, 110, .35); }
.rm-thumb { width: 120px; aspect-ratio: 2500 / 1686; border-radius: 8px; background: var(--line-2) center / cover; border: 1px solid var(--line); flex: none; }
.layouts { display: flex; gap: 8px; flex-wrap: wrap; }
.layout-opt { width: 74px; border: 1px solid var(--line); border-radius: 8px; padding: 5px; cursor: pointer; background: #fff; }
.layout-opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.layout-opt .mini { position: relative; width: 100%; aspect-ratio: 2500/1686; background: var(--line-2); border-radius: 4px; }
.layout-opt .mini.half { aspect-ratio: 2500/843; }
.layout-opt .mini i { position: absolute; border: 1px solid #fff; background: #d8dcd6; }

/* ---------- ログイン ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); padding: 36px 32px; text-align: center; }
.login-card h1 { font-size: 20px; margin: 18px 0 6px; }
.login-card .brand-mark { margin: 0 auto; width: 44px; height: 44px; font-size: 16px; border-radius: 12px; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; }
#toast div { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; animation: up .2s ease; }
#toast div.err { background: var(--rose); }
@keyframes up { from { opacity: 0; transform: translateY(6px); } }

.confirm-inline { display: inline-flex; gap: 6px; align-items: center; }
.section-gap { margin-top: 22px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---------- スマホ：ヘッダーのハンバーガーでサイドメニューを開閉 ---------- */
.topbar { display: none; }
.side-backdrop { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 14px;
  }
  .burger { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 9px; background: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }
  .burger span, .burger span::before, .burger span::after { display: block; width: 16px; height: 2px; background: var(--ink); border-radius: 2px; position: relative; content: ''; }
  .burger span::before { position: absolute; top: -5px; }
  .burger span::after { position: absolute; top: 5px; }
  .topbar .brand { padding: 0; }
  .side {
    position: fixed; top: 0; left: 0; bottom: 0; width: 260px; height: 100vh; z-index: 60;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: none;
  }
  .side.open { transform: translateX(0); }
  .side-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(27, 34, 48, .32); z-index: 55; }
  .main { padding: 18px 16px 48px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .split { grid-template-columns: 1fr; }
  .card { overflow-x: auto; }
  .modal-body .split { grid-template-columns: 1fr; }
}
