/* Layout: a fixed left rail of destinations beside one work area; on phones the rail becomes a bottom tab bar.
   The composer splits the work area into an editing column and a dark "stage" that holds the phone + desktop previews. */
:root {
  --paper: #eef2f6;      /* app background: cool, slightly blue white */
  --panel: #ffffff;      /* surfaces */
  --ink: #0d1b2c;        /* text: PardBet navy */
  --ink-2: #4f5d6f;      /* secondary text */
  --ink-3: #7b8796;      /* hints */
  --line: #d8dfe8;       /* borders */
  --hover: #e6ecf3;
  --accent: #1468e0;     /* actions: same blue as the email buttons */
  --accent-ink: #ffffff;
  --accent-soft: #e2edfd;
  --gold: #f5b301;       /* bonus gold: progress + current step */
  --gold-soft: #fff4d1;
  --stage: #0f212e;      /* preview stage: email header navy */
  --stage-2: #16303f;
  --ok: #138a4a; --ok-soft: #dcf3e6;
  --warn: #a86400; --warn-soft: #fdf0d7;
  --bad: #c62f36; --bad-soft: #fbe3e4;
  --shadow: 0 1px 2px rgba(13, 27, 44, .06), 0 8px 24px rgba(13, 27, 44, .08);
  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --r: 10px;
  --rail: 236px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0a131c; --panel: #111d29; --ink: #e5ecf4; --ink-2: #9fb0c2; --ink-3: #74869a; --line: #223345; --hover: #172738;
    --accent: #4d8dff; --accent-ink: #ffffff; --accent-soft: #15294a; --gold: #ffc633; --gold-soft: #3a2f0c;
    --stage: #060d14; --stage-2: #0d1b27;
    --ok: #3ccf7f; --ok-soft: #0e2d1d; --warn: #f0b23e; --warn-soft: #33260b; --bad: #ff6b72; --bad-soft: #3a1418;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0a131c; --panel: #111d29; --ink: #e5ecf4; --ink-2: #9fb0c2; --ink-3: #74869a; --line: #223345; --hover: #172738;
  --accent: #4d8dff; --accent-ink: #ffffff; --accent-soft: #15294a; --gold: #ffc633; --gold-soft: #3a2f0c;
  --stage: #060d14; --stage-2: #0d1b27;
  --ok: #3ccf7f; --ok-soft: #0e2d1d; --warn: #f0b23e; --warn-soft: #33260b; --bad: #ff6b72; --bad-soft: #3a1418;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.hint { color: var(--ink-3); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- shell */
#app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100%; }
#app.booting { visibility: hidden; }
#app.auth .rail, #app.auth .tabbar { display: none; }
#app.auth { grid-template-columns: minmax(0, 1fr); }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px;
  padding: max(22px, env(safe-area-inset-top, 0px)) 14px 18px max(14px, env(safe-area-inset-left, 0px));
  background: var(--stage); color: #dfe8f1;
}
.wordmark { display: flex; align-items: baseline; gap: 8px; padding: 0 10px; }
.wm-pard { font-family: var(--font-display); font-weight: 800; font-style: italic; font-size: 24px; color: #fff; letter-spacing: -0.02em; }
.wm-sub { font-size: 13px; color: #8fa6bb; font-weight: 600; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-nav a, .tabbar a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
  color: #b9c9d8; text-decoration: none; font-weight: 500; cursor: pointer;
}
.rail-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.rail-nav a.on { background: rgba(255, 255, 255, .1); color: #fff; }
.rail-nav a.on svg { color: var(--gold); }
.rail-nav a.new { background: var(--accent); color: #fff; margin-bottom: 10px; justify-content: center; font-weight: 600; }
.rail-nav a.new:hover { filter: brightness(1.08); }
.rail-nav svg, .tabbar svg { width: 19px; height: 19px; flex: none; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 6px; font-size: 13px; }
.meter-label { display: flex; justify-content: space-between; color: #8fa6bb; }
.meter-label b { color: #fff; font-weight: 600; }
.meter { height: 6px; background: rgba(255, 255, 255, .1); border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.rail-foot .linkish { color: #8fa6bb; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.rail-foot .linkish:hover { color: #fff; }
.demo-flag { background: rgba(245, 179, 1, .14); color: #ffd56a; border-radius: 8px; padding: 10px 12px; line-height: 1.4; }

#view { min-width: 0; outline: none; padding: max(28px, env(safe-area-inset-top, 0px)) max(32px, env(safe-area-inset-right, 0px)) 48px 32px; }
#view.full { padding: 0; }
.wrap { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 6px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tabbar { display: none; }

@media (max-width: 860px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  #view { padding: max(18px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(88px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-around;
    background: var(--stage); padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }
  .tabbar a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; min-width: 56px; }
  .tabbar a.on { color: #fff; }
  .tabbar a.on svg { color: var(--gold); }
  .tabbar a.new svg { color: #fff; background: var(--accent); border-radius: 10px; padding: 5px; width: 30px; height: 30px; margin: -3px 0 -2px; }
  h1 { font-size: 25px; }
}

/* ---------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--hover); }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1b1300; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.lg { height: 48px; padding: 0 22px; font-size: 16px; }
.btn.icon { width: 34px; height: 34px; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.busy { pointer-events: none; opacity: .7; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { margin-top: -2px; }
.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); min-width: 0;
}
textarea.input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row .input { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } }
.count { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.count.over { color: var(--warn); font-weight: 600; }

.seg { align-self: flex-start; display: inline-flex; background: var(--hover); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 11px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.seg button svg { width: 16px; height: 16px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--hover); color: var(--ink-2); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.draft { }
.pill.scheduled { background: var(--accent-soft); color: var(--accent); }
.pill.sending { background: var(--gold-soft); color: var(--warn); }
.pill.sending::before { animation: pulse 1.4s infinite; }
.pill.paused { background: var(--warn-soft); color: var(--warn); }
.pill.done, .pill.subscribed { background: var(--ok-soft); color: var(--ok); }
.pill.cancelled, .pill.unsubscribed { background: var(--hover); color: var(--ink-3); }
.pill.bounced, .pill.failed { background: var(--bad-soft); color: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }

.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); height: 32px; padding: 0 12px; border-radius: 99px; font-size: 13px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.chip-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-btn.on.ex { background: var(--bad); border-color: var(--bad); }
.chip-btn small { font-weight: 500; opacity: .75; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.panel-pad { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.empty { text-align: center; padding: 48px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--ink-2); }
.empty svg { width: 40px; height: 40px; color: var(--ink-3); }
.empty h3 { color: var(--ink); }

.progress { height: 8px; border-radius: 99px; background: var(--hover); overflow: hidden; display: flex; }
.progress i { display: block; height: 100%; background: var(--gold); }
.progress i.f { background: var(--bad); }

/* ---------- toasts + modal */
#toasts { position: fixed; z-index: 100; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
@media (max-width: 860px) { #toasts { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); left: max(16px, env(safe-area-inset-left, 0px)); align-items: stretch; } }
.toast { pointer-events: auto; background: var(--ink); color: var(--paper); padding: 11px 14px; border-radius: 9px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; max-width: 440px; font-weight: 500; animation: tin .18s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

.modal-back { position: fixed; inset: 0; z-index: 90; background: rgba(6, 13, 20, .55); display: flex; align-items: center; justify-content: center; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.modal.wide { max-width: 760px; }
.modal-head { padding: 20px 22px 0; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.modal-body { padding: 16px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 0 22px 20px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ---------- auth */
.auth-box { max-width: 400px; margin: 10vh auto 0; display: flex; flex-direction: column; gap: 18px; }
.auth-box .wm-pard { color: var(--ink); font-size: 34px; }
.auth-box form { display: flex; flex-direction: column; gap: 14px; }
.err { color: var(--bad); font-weight: 600; font-size: 14px; }

/* ---------- home */
.setup-list { display: flex; flex-direction: column; }
.setup-item { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.setup-item:first-child { border-top: 0; }
.setup-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--hover); color: var(--ink-2); }
.setup-item.done .setup-num { background: var(--ok); color: #fff; }
.setup-item.done .setup-num svg { width: 16px; height: 16px; }
.setup-item.done b { text-decoration: line-through; color: var(--ink-3); }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 980px) { .home-grid { grid-template-columns: minmax(0, 1fr); } }
.today { display: flex; gap: 28px; flex-wrap: wrap; }
.today .big { font-family: var(--font-display); font-size: 40px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.today .big small { font-size: 18px; color: var(--ink-3); font-weight: 600; }
.bars { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 5px; align-items: end; height: 110px; padding-top: 6px; }
.bars div { background: var(--accent); border-radius: 4px 4px 1px 1px; min-height: 2px; opacity: .85; position: relative; }
.bars div.today-bar { background: var(--gold); opacity: 1; }
.bars-x { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); }
.mini-list { display: flex; flex-direction: column; }
.mini-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.mini-row:first-child { border-top: 0; }
.mini-row:hover b { color: var(--accent); }
.mini-row .progress { grid-column: 1 / -1; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--hover); }
table.t .r { text-align: right; }
table.t input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.camp-name b { display: block; }
.camp-name span { font-size: 13px; color: var(--ink-3); }
@media (max-width: 720px) {
  table.t.stack thead { display: none; }
  table.t.stack tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
  table.t.stack td { border: 0; padding: 0; }
  table.t.stack td.hide-sm { display: none; }
  table.t.stack td.full { grid-column: 1 / -1; grid-row: 2; }
  table.t.stack td.st { grid-column: 3; grid-row: 1; }
  table.t.stack td.first { grid-column: 1 / 3; grid-row: 1; }
}
.toolbar-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar-row .input { width: auto; flex: 1 1 200px; }
.bulkbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-tabs button { border: 0; background: none; padding: 7px 12px; border-radius: 7px; font-weight: 600; color: var(--ink-2); cursor: pointer; font-size: 14px; }
.filter-tabs button.on { background: var(--ink); color: var(--paper); }
.filter-tabs button small { opacity: .7; font-weight: 500; margin-left: 4px; }

/* ---------- campaign detail */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.stat { padding: 16px 18px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.stat:first-child { border-left: 0; }
.stat b { font-family: var(--font-display); font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--ink-2); }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat { border-left: 0; border-top: 1px solid var(--line); } .stat:nth-child(-n+2) { border-top: 0; } .stat:nth-child(even) { border-left: 1px solid var(--line); } .stat:last-child { grid-column: 1 / -1; border-left: 0; } }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 9px; background: var(--hover); font-size: 14px; }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--accent-soft); color: var(--accent); }
.notice b { color: inherit; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
@media (max-width: 1060px) { .detail-grid { grid-template-columns: minmax(0, 1fr); } }
.mini-phone { background: var(--stage); border-radius: var(--r); padding: 18px; display: flex; justify-content: center; max-height: 640px; overflow: auto; }

/* ---------- composer */
.compose { display: flex; flex-direction: column; min-height: 100vh; }
.compose-top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 10px max(20px, env(safe-area-inset-right, 0px)) 10px 20px; flex-wrap: wrap;
}
.compose-top .name { border: 0; background: transparent; font-family: var(--font-display); font-weight: 700; font-size: 18px; padding: 4px 6px; border-radius: 6px; min-width: 0; flex: 0 1 260px; width: 260px; overflow: hidden; text-overflow: ellipsis; }
.compose-top .name:hover, .compose-top .name:focus { background: var(--hover); outline: none; }
.save-state { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.steps { display: flex; gap: 4px; margin: 0 auto; counter-reset: s; }
.steps button {
  display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer;
  font-weight: 600; color: var(--ink-3); font-size: 14px; white-space: nowrap;
}
.steps button:hover { background: var(--hover); color: var(--ink); }
.steps button .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--hover); font-size: 12px; font-weight: 700; color: var(--ink-2); }
.steps button.done .n { background: var(--ok); color: #fff; }
.steps button.done .n svg { width: 14px; height: 14px; }
.steps button.on { color: var(--ink); }
.steps button.on .n { background: var(--gold); color: #1b1300; }
.compose-nav { display: flex; gap: 8px; }
@media (max-width: 1560px) { .steps button .t { display: none; } .steps button.on .t { display: inline; } }
@media (max-width: 860px) {
  .compose-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; padding: 6px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px)); }
  .compose-top .name { width: 100%; font-size: 16px; }
  .save-state { align-self: center; font-size: 12px; }
  .steps { margin: 0; gap: 0; min-width: 0; }
  .steps button { padding: 6px 6px; gap: 6px; }
  .compose-nav .btn { height: 36px; padding: 0 10px; }
  .compose-nav .btn .t { display: none; }
  body.composing .tabbar { display: none; }
  body.composing #view { padding-bottom: 0; }
  .rtb { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .rtb .tb { flex: none; }
}
.step-body { flex: 1; padding: 28px max(32px, env(safe-area-inset-right, 0px)) 48px 32px; }
.step-body.write { padding: 0; display: grid; grid-template-columns: minmax(340px, 470px) minmax(0, 1fr); height: calc(100vh - 61px); }
@media (max-width: 860px) {
  .step-body { padding: 18px max(16px, env(safe-area-inset-right, 0px)) 96px max(16px, env(safe-area-inset-left, 0px)); }
  .step-body.write { display: block; height: auto; padding: 0 0 96px; }
}

/* templates gallery */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.tpl { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; text-align: left; padding: 0; transition: transform .12s, box-shadow .12s; }
.tpl:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tpl.on { outline: 3px solid var(--gold); outline-offset: -1px; }
.tpl-img { aspect-ratio: 2 / 1; background: var(--stage); display: grid; place-items: center; color: #8fa6bb; max-width: 100%; }
.tpl-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tpl-img svg { width: 40px; height: 40px; }
.tpl-meta { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; }
.tpl-meta b { font-size: 15px; }
.tpl-meta span { font-size: 13px; color: var(--ink-2); }
.tpl-meta .chip { align-self: flex-start; margin-bottom: 2px; }
.tpl-del { margin-left: auto; }

/* write: editor column */
.editor-col { overflow-y: auto; border-right: 1px solid var(--line); background: var(--paper); display: flex; flex-direction: column; }
.editor-inner { padding: 18px 18px 60px; display: flex; flex-direction: column; gap: 18px; }
.ed-section { display: flex; flex-direction: column; gap: 12px; }
.ed-section > h3 { display: flex; justify-content: space-between; align-items: center; }
.subject-wrap { position: relative; }
.subject-wrap .input { padding-right: 76px; }
.subject-tools { position: absolute; right: 4px; top: 4px; display: flex; gap: 2px; }
.subject-tools .btn { height: 32px; width: 32px; padding: 0; border: 0; background: transparent; }
.subject-tools .btn:hover { background: var(--hover); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.swatch-custom { position: relative; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 1px var(--line); background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.swatch-custom input { position: absolute; inset: -8px; width: 46px; height: 46px; opacity: 0; cursor: pointer; }
.theme-pick { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.theme-opt { border: 1px solid var(--line); border-radius: 9px; padding: 0; background: var(--panel); cursor: pointer; overflow: hidden; text-align: center; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.theme-opt i { display: block; height: 34px; position: relative; }
.theme-opt i::after { content: ""; position: absolute; left: 30%; right: 30%; bottom: 7px; height: 7px; border-radius: 3px; background: var(--btn); }
.theme-opt span { display: block; padding: 4px 0 5px; }
.theme-opt.on { outline: 2px solid var(--ink); outline-offset: 1px; color: var(--ink); }

/* rich text toolbar */
.rtb {
  position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 10px; align-items: center;
}
.rtb.off .tb { opacity: .4; pointer-events: none; }
.rtb .tb { width: 32px; height: 32px; border: 0; background: transparent; border-radius: 6px; display: grid; place-items: center; cursor: pointer; color: var(--ink); position: relative; }
.rtb .tb:hover { background: var(--hover); }
.rtb .tb.on { background: var(--accent-soft); color: var(--accent); }
.rtb .tb svg { width: 17px; height: 17px; }
.rtb .tb.wide { width: auto; padding: 0 8px; gap: 4px; display: inline-flex; align-items: center; font-size: 13px; font-weight: 600; }
.rtb .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.rtb .tb .bar { position: absolute; left: 8px; right: 8px; bottom: 5px; height: 3px; border-radius: 2px; }
.rtb-hint { font-size: 12px; color: var(--ink-3); padding: 0 6px; }
@media (max-width: 860px) { .rtb { top: 0; position: sticky; } .rtb-hint { display: none; } }

.pop { position: absolute; z-index: 60; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 8px; display: flex; flex-direction: column; gap: 2px; min-width: 180px; }
.pop button.item { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 14px; font-size: 14px; }
.pop button.item:hover { background: var(--hover); }
.pop button.item code { font-size: 12px; color: var(--ink-3); }
.pop .colors { display: grid; grid-template-columns: repeat(6, 26px); gap: 6px; padding: 4px; }
.pop .colors button { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; padding: 0; }
.pop .emojis { display: grid; grid-template-columns: repeat(8, 34px); gap: 2px; }
.pop .emojis button { width: 34px; height: 34px; border: 0; background: none; font-size: 20px; cursor: pointer; border-radius: 6px; }
.pop .emojis button:hover { background: var(--hover); }
.pop .pop-label { font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 4px 6px 2px; }

/* blocks */
.blocks { display: flex; flex-direction: column; gap: 8px; }
.blk { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.blk.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.blk-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; cursor: pointer; min-height: 46px; }
.blk-ico { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; background: var(--hover); color: var(--ink-2); flex: none; }
.blk.sel .blk-ico { background: var(--accent); color: #fff; }
.blk-ico svg { width: 16px; height: 16px; }
.blk-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.blk-title b { font-size: 13px; }
.blk-title span { font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk-actions { display: flex; gap: 0; opacity: .55; }
.blk:hover .blk-actions, .blk.sel .blk-actions { opacity: 1; }
.blk-actions button { width: 30px; height: 30px; border: 0; background: none; border-radius: 6px; cursor: pointer; display: grid; place-items: center; color: var(--ink-2); }
.blk-actions button:hover { background: var(--hover); color: var(--ink); }
.blk-actions button.del:hover { color: var(--bad); }
.blk-actions svg { width: 16px; height: 16px; }
.blk-body { padding: 4px 14px 16px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.rte {
  min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); outline: none; line-height: 1.55;
  overflow-wrap: anywhere;
}
.rte:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.rte p { margin: 0 0 8px; }
.rte p:last-child { margin-bottom: 0; }
.rte ul, .rte ol { margin: 0 0 8px; padding-left: 22px; }
.rte a { color: var(--accent); }
.rte.big { font-size: 20px; font-weight: 700; font-family: var(--font-display); line-height: 1.25; }
.rte.mid { font-size: 17px; }
.rte:empty::before { content: attr(data-ph); color: var(--ink-3); }
.list-items { display: flex; flex-direction: column; gap: 6px; }
.list-item { display: grid; grid-template-columns: 18px minmax(0, 1fr) 30px; gap: 6px; align-items: start; }
.list-item .dot { padding-top: 11px; text-align: center; color: var(--ink-3); font-weight: 700; font-size: 13px; }
.list-item .rte { min-height: 40px; padding: 8px 10px; }
.list-item button { margin-top: 5px; width: 30px; height: 30px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--ink-3); display: grid; place-items: center; }
.list-item button:hover { color: var(--bad); background: var(--hover); }
.list-item button svg { width: 15px; height: 15px; }
.img-picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.img-picker button { padding: 0; border: 2px solid transparent; border-radius: 7px; overflow: hidden; cursor: pointer; background: var(--stage); aspect-ratio: 2 / 1; max-width: 100%; }
.img-picker.icons button { aspect-ratio: 1; }
.img-picker button.on { border-color: var(--gold); }
.img-picker img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-current { display: flex; gap: 10px; align-items: center; }
.img-current img { width: 96px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--stage); flex: none; }
.img-current.icon img { width: 48px; }
.add-block { border: 1.5px dashed var(--line); border-radius: 10px; background: transparent; padding: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 8px; }
.add-block:hover { border-color: var(--accent); color: var(--accent); }
.add-block svg { width: 18px; height: 18px; }
.palette { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.palette button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 14px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; color: var(--ink); }
.palette button:hover { border-color: var(--accent); color: var(--accent); }
.palette button svg { width: 22px; height: 22px; }
.palette button small { color: var(--ink-3); font-weight: 500; font-size: 11.5px; line-height: 1.3; text-align: center; }

/* write: preview stage — the one bold moment */
.stage {
  background: radial-gradient(ellipse 80% 60% at 50% 0%, var(--stage-2), var(--stage) 70%);
  overflow-y: auto; display: flex; flex-direction: column; min-width: 0; color: #dfe8f1;
}
.stage-bar { position: sticky; top: 0; z-index: 4; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 20px; background: rgba(6, 13, 20, .55); backdrop-filter: blur(8px); }
.stage-bar .seg { background: rgba(255, 255, 255, .08); }
.stage-bar .seg button { color: #9fb3c6; }
.stage-bar .seg button.on { background: rgba(255, 255, 255, .16); color: #fff; box-shadow: none; }
.stage-bar .switch { color: #b9c9d8; font-size: 13px; }
.stage-bar .switch input { background: rgba(255,255,255,.2); }
.stage-bar .switch input:checked { background: var(--accent); }
.stage-bar .btn { background: rgba(255,255,255,.1); border-color: transparent; color: #fff; }
.stage-bar .btn:hover { background: rgba(255,255,255,.18); }
.stage-bar .grow { flex: 1; }
.inbox {
  margin: 18px auto 0; width: min(760px, calc(100% - 40px)); background: #fff; color: #202124; border-radius: 10px; padding: 12px 16px;
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; font-family: Roboto, Arial, sans-serif; box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
.inbox .av { grid-row: span 2; width: 36px; height: 36px; border-radius: 50%; background: #0f212e; color: #fff; display: grid; place-items: center; font-weight: 800; font-style: italic; font-size: 15px; }
.inbox .from { font-weight: 700; font-size: 14px; }
.inbox .time { font-size: 12px; color: #5f6368; font-weight: 600; }
.inbox .line { grid-column: 2 / -1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #5f6368; }
.inbox .line b { color: #202124; font-weight: 700; }
.stage-label { text-align: center; font-size: 12px; color: #7f95aa; margin: 14px 0 6px; font-weight: 600; }
.frames { display: flex; gap: 32px; justify-content: center; align-items: flex-start; padding: 6px 20px 40px; flex-wrap: wrap; }
.frame-col { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.phone { border-radius: 46px; padding: 12px; background: #1b2733; box-shadow: 0 0 0 2px #2c3b49, 0 24px 60px rgba(0, 0, 0, .55); }
.phone-screen { border-radius: 34px; overflow: hidden; background: #000; position: relative; padding-top: 40px; }
.phone-screen::before { content: ""; position: absolute; z-index: 2; top: 9px; left: 50%; transform: translateX(-50%); width: 92px; height: 26px; border-radius: 20px; background: #000; }
.desk { border-radius: 12px; overflow: hidden; background: #1b2733; box-shadow: 0 0 0 1px #2c3b49, 0 24px 60px rgba(0, 0, 0, .55); }
.desk-bar { height: 30px; display: flex; gap: 7px; align-items: center; padding: 0 12px; background: #1b2733; }
.desk-bar i { width: 11px; height: 11px; border-radius: 50%; background: #3b4b5a; }
.frame-clip { overflow: hidden; position: relative; }
.frame-clip iframe { border: 0; display: block; transform-origin: 0 0; background: #fff; }
.stage-size { font-size: 12px; color: #7f95aa; margin-top: 10px; font-variant-numeric: tabular-nums; }
.mobile-switch { display: none; }
@media (max-width: 860px) {
  .mobile-switch { display: flex; position: sticky; top: 0; z-index: 8; padding: 10px 12px; background: var(--panel); border-bottom: 1px solid var(--line); justify-content: center; }
  .mobile-switch .seg { width: 100%; }
  .mobile-switch .seg button { flex: 1; justify-content: center; }
  .editor-col { border-right: 0; overflow: visible; }
  .write[data-mview="edit"] .stage { display: none; }
  .write[data-mview="preview"] .editor-col { display: none; }
  .stage { min-height: calc(100vh - 160px); overflow: visible; }
  .rtb { top: 58px; }
  .frames { padding: 6px 8px 40px; }
}

/* recipients + review */
.narrow { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.aud-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .aud-opts { grid-template-columns: minmax(0, 1fr); } }
.aud-opt { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 16px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 4px; }
.aud-opt.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.aud-opt b { font-size: 16px; }
.aud-total { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.aud-total .big { font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; }

.slip { display: grid; grid-template-columns: 120px minmax(0, 1fr); border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.slip > div { padding: 12px 16px; border-top: 1px solid var(--line); }
.slip > div:nth-child(-n+2) { border-top: 0; }
.slip .k { color: var(--ink-3); font-size: 13px; font-weight: 600; background: var(--paper); }
.slip .v { overflow-wrap: anywhere; }
@media (max-width: 560px) { .slip { grid-template-columns: minmax(0, 1fr); } .slip .k { border-top: 1px solid var(--line); padding-bottom: 2px; background: transparent; } .slip .v { border-top: 0; padding-top: 0; } .slip > div:first-child { border-top: 0; } }
.checks { display: flex; flex-direction: column; }
.check { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); align-items: start; }
.check:first-child { border-top: 0; }
.check .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; margin-top: 1px; }
.check .ic svg { width: 14px; height: 14px; }
.check.pass .ic { background: var(--ok-soft); color: var(--ok); }
.check.warn .ic { background: var(--warn-soft); color: var(--warn); }
.check.fail .ic { background: var(--bad-soft); color: var(--bad); }
.check p { font-size: 13.5px; color: var(--ink-2); }
.send-box { display: flex; flex-direction: column; gap: 14px; }
.send-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* import */
.dropzone { border: 1.5px dashed var(--line); border-radius: 12px; padding: 24px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; color: var(--ink-2); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.map-table td { padding: 8px 10px; }
.map-table select { height: 34px; }

/* help */
.guide { display: flex; flex-direction: column; gap: 18px; max-width: 760px; }
.guide ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.guide code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: var(--hover); padding: 2px 6px; border-radius: 5px; overflow-wrap: anywhere; }
.dns { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 6px 12px; font-size: 14px; }

/* sending methods */
.methods { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.methods .aud-opt b { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 15px; }
.methods .aud-opt .muted { font-size: 13px; }
.zsteps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 14px; }
.zsteps li { padding-left: 4px; }
.zsteps li::marker { font-weight: 700; color: var(--ink-2); }
.zsteps p { margin-bottom: 8px; }
.zsteps .code { display: inline-block; padding: 8px 10px; }
.banner-bad { display: flex; gap: 12px; align-items: flex-start; }
