/* =========================================================================
   Sendie — design system
   Light by default, dark on [data-theme="dark"] or system preference.
   ========================================================================= */

:root {
  --bg:            #f6f7fb;
  --bg-tint:       #eef0f8;
  --surface:       #ffffff;
  --surface-2:     #fafbfd;
  --surface-3:     #f2f4f9;
  --border:        #e4e7f0;
  --border-strong: #d2d7e6;

  --text:          #14161f;
  --text-soft:     #4c5364;
  --muted:         #838ba0;

  --accent:        #5b57e0;
  --accent-hover:  #4a45d6;
  --accent-soft:   #eeedfe;
  --accent-text:   #4b46cf;

  --green:         #0f9d6e;
  --green-soft:    #e3f7ef;
  --amber:         #b7791f;
  --amber-soft:    #fdf3e0;
  --red:           #d64550;
  --red-soft:      #fdeaec;
  --blue:          #2b7fd4;
  --blue-soft:     #e7f1fc;
  --violet:        #8b5cf6;
  --teal:          #0d9488;
  --rose:          #e11d68;
  --sky:           #0ea5e9;
  --lime:          #65a30d;

  --shadow-sm:  0 1px 2px rgba(18, 22, 40, .05);
  --shadow:     0 2px 6px rgba(18, 22, 40, .06), 0 1px 2px rgba(18, 22, 40, .04);
  --shadow-lg:  0 18px 40px -12px rgba(18, 22, 40, .22), 0 4px 10px rgba(18, 22, 40, .06);

  --r-sm: 7px;
  --r:    11px;
  --r-lg: 16px;

  --sidebar: 236px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg:            #0c0d12;
  --bg-tint:       #121420;
  --surface:       #14161e;
  --surface-2:     #181b25;
  --surface-3:     #1d2130;
  --border:        #262a38;
  --border-strong: #343a4c;

  --text:          #e8eaf2;
  --text-soft:     #b0b6c8;
  --muted:         #767e96;

  --accent:        #7c78f0;
  --accent-hover:  #8d89f5;
  --accent-soft:   #1f1f3d;
  --accent-text:   #a5a1ff;

  --green:      #34d399;  --green-soft: #0f2c24;
  --amber:      #fbbf24;  --amber-soft: #2e2413;
  --red:        #f87171;  --red-soft:   #33191c;
  --blue:       #60a5fa;  --blue-soft:  #14243a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow:    0 2px 8px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 48px -12px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Every icon from Icon::render() carries viewBox="0 0 24 24". Give them all a
   sane default size here, so a new icon dropped into any context is never
   rendered at its intrinsic size. Charts use their own viewBox and opt out.
   Context rules below this point override it by specificity or by order. */
svg[viewBox="0 0 24 24"] {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  vertical-align: -3px;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 640; letter-spacing: -.011em; line-height: 1.25; }
h1 { font-size: 23px; letter-spacing: -.02em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

hr { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }

::selection { background: var(--accent-soft); color: var(--accent-text); }

/* ---- layout ------------------------------------------------------------ */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 22px;
  font-weight: 700; font-size: 17px; letter-spacing: -.02em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent) 0%, #9b6bf5 100%);
  display: grid; place-items: center;
  color: #fff; font-size: 15px;
  box-shadow: 0 2px 8px rgba(91, 87, 224, .35);
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
  padding: 16px 10px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--text-soft);
  font-weight: 520;
  transition: background .13s, color .13s;
}
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav a svg { width: 17px; height: 17px; flex: 0 0 17px; stroke-width: 1.8; }
.nav a .count {
  margin-left: auto; font-size: 11.5px; font-variant-numeric: tabular-nums;
  color: var(--muted); font-weight: 600;
}

.sidebar-foot { margin-top: auto; padding-top: 18px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  position: sticky; top: 0; z-index: 40;
}
.topbar h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .sub { color: var(--muted); font-size: 13px; font-weight: 450; margin-left: 2px; }

.page { padding: 26px 28px 60px; max-width: 1360px; width: 100%; }
.page.wide { max-width: none; }

/* ---- cards ------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { flex: 1; }
.card-head > svg { color: var(--muted); }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px 18px; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1080px) { .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px)  { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }

/* ---- stat tiles -------------------------------------------------------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat .label {
  font-size: 11.5px; font-weight: 650; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.stat .label svg { width: 14px; height: 14px; vertical-align: 0; opacity: .9; }
.stat .value {
  font-size: 27px; font-weight: 680; letter-spacing: -.028em;
  margin-top: 7px; font-variant-numeric: tabular-nums;
}
.stat .value small { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.stat .foot { margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.stat.accent .value { color: var(--accent-text); }
.stat.good .value { color: var(--green); }
.stat.bad .value { color: var(--red); }

/* ---- buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 580;
  cursor: pointer;
  white-space: nowrap;
  transition: background .13s, border-color .13s, transform .06s, box-shadow .13s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; stroke-width: 1.9; }

.btn.primary {
  background: var(--accent); border-color: transparent; color: #fff;
  box-shadow: 0 1px 2px rgba(91, 87, 224, .3), 0 2px 8px -2px rgba(91, 87, 224, .4);
}
.btn.primary:hover { background: var(--accent-hover); }

.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.lg { padding: 11px 20px; font-size: 15px; }
.btn.block { width: 100%; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- forms ------------------------------------------------------------- */

label { display: block; font-size: 12.5px; font-weight: 620; color: var(--text-soft); margin-bottom: 6px; }
label .hint { font-weight: 450; color: var(--muted); }

input[type=text], input[type=email], input[type=number], input[type=password],
input[type=url], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 14px;
  transition: border-color .13s, box-shadow .13s;
}
textarea { line-height: 1.5; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23838ba0' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.field { margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1; min-width: 0; }

.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 10px; cursor: pointer; }
.check input { margin: 2px 0 0; width: 15px; height: 15px; accent-color: var(--accent); flex: 0 0 15px; }
.check span { font-size: 13.5px; color: var(--text); font-weight: 500; }
.check small { display: block; color: var(--muted); font-weight: 450; font-size: 12.5px; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 36px; height: 21px; border-radius: 99px;
  background: var(--border-strong); position: relative; transition: background .18s;
  flex: 0 0 36px;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform .18s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(15px); }

/* ---- tables ------------------------------------------------------------ */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 680; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .strong { font-weight: 600; color: var(--text); }
table.data .dim { color: var(--muted); font-size: 12.5px; }
table.data input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); }
table.data svg { width: 14px; height: 14px; vertical-align: 0; }

/* ---- pills / badges ---------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
  background: var(--surface-3); color: var(--text-soft);
  white-space: nowrap;
}
.pill::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.plain::before { display: none; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red   { background: var(--red-soft);   color: var(--red); }
.pill.blue  { background: var(--blue-soft);  color: var(--blue); }
.pill.accent{ background: var(--accent-soft);color: var(--accent-text); }

.tag {
  display: inline-block; padding: 1.5px 7px; border-radius: 5px;
  background: var(--surface-3); color: var(--text-soft);
  font-size: 11.5px; font-weight: 560;
}

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- segmented filter -------------------------------------------------- */

.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border-radius: var(--r-sm);
}
.segmented a {
  padding: 5px 11px; border-radius: 5px;
  font-size: 13px; font-weight: 570; color: var(--text-soft);
}
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented a .n { color: var(--muted); font-size: 11.5px; margin-left: 3px; font-variant-numeric: tabular-nums; }

/* ---- flash / callouts -------------------------------------------------- */

.flash-stack { position: fixed; top: 16px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 15px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  max-width: 420px; font-size: 13.5px; font-weight: 520;
  animation: slideIn .28s cubic-bezier(.2, .9, .3, 1.2);
}
.flash .bar { width: 3px; border-radius: 3px; align-self: stretch; background: var(--green); flex: 0 0 3px; }
.flash.error .bar { background: var(--red); }
.flash.warn .bar { background: var(--amber); }
.flash .x { margin-left: auto; cursor: pointer; color: var(--muted); background: none; border: 0; font-size: 16px; line-height: 1; padding: 0 2px; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

.callout {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 15px; border-radius: var(--r);
  background: var(--blue-soft); color: var(--text);
  font-size: 13.5px; border: 1px solid color-mix(in srgb, var(--blue) 22%, transparent);
}
.callout.warn  { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 28%, transparent); }
.callout.error { background: var(--red-soft);   border-color: color-mix(in srgb, var(--red) 28%, transparent); }
.callout.good  { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 26%, transparent); }
.callout svg { width: 17px; height: 17px; flex: 0 0 17px; margin-top: 1px; }
.callout .t { font-weight: 640; }

/* ---- empty state ------------------------------------------------------- */

.empty { text-align: center; padding: 56px 24px; }
.empty .icon {
  width: 52px; height: 52px; margin: 0 auto 16px;
  border-radius: 15px; background: var(--accent-soft); color: var(--accent-text);
  display: grid; place-items: center;
}
.empty .icon svg { width: 25px; height: 25px; }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 400px; margin: 0 auto 18px; }

/* ---- progress ---------------------------------------------------------- */

.bar {
  height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden;
}
.bar > i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #9b6bf5);
  transition: width .5s cubic-bezier(.3, .8, .3, 1);
}
.bar.thin { height: 5px; }
.bar.green > i { background: var(--green); }

/* ---- modal ------------------------------------------------------------- */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow-lg);
  max-width: 520px; width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(14, 16, 26, .45); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .18s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
dialog .card-head { border-radius: var(--r-lg) var(--r-lg) 0 0; }
dialog .modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ---- composer (campaign editor) ---------------------------------------- */

.composer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; height: calc(100vh - 57px); }
.composer .pane { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.composer .pane + .pane { border-left: 1px solid var(--border); }
.pane-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); min-height: 45px;
}
.pane-head .title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.pane-head .title svg { width: 14px; height: 14px; vertical-align: 0; }
.pane-body { flex: 1; overflow: auto; min-height: 0; }
.pane-body.pad { padding: 18px; }

/* The preview pane fills its column edge to edge. */
.pane-body.flush { padding: 0; }

/* Both composer columns scroll. Without a tail of empty space the last field
   (or last line of code) sits flush against the bottom of the viewport, which
   reads as clipped content. */
.composer .pane-body { padding-bottom: 36px; }
.composer .pane-body.flush { padding-bottom: 0; }

/* The settings rail under the preview scrolls independently, so it needs its
   own tail. */
.composer-side {
  border-top: 1px solid var(--border);
  max-height: 46vh;
  overflow: auto;
  padding-bottom: 44px;
  overscroll-behavior: contain;
}

.editor-host { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.CodeMirror { height: 100% !important; font-family: var(--mono) !important; font-size: 13px !important; line-height: 1.6 !important; }

.preview-frame { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.preview-shell { height: 100%; background: var(--bg-tint); display: flex; justify-content: center; padding: 0; overflow: auto; }
.preview-shell.mobile { padding: 20px 0; }
.preview-shell.mobile .preview-frame { width: 390px; max-width: 100%; border-radius: 14px; box-shadow: var(--shadow-lg); height: 760px; }

.inbox-preview {
  padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.inbox-preview .from { font-size: 13px; font-weight: 660; }
.inbox-preview .subj { font-size: 14px; font-weight: 600; margin-top: 2px; }
.inbox-preview .pre { font-size: 13px; color: var(--muted); margin-top: 1px; }

.tagpad { display: flex; flex-wrap: wrap; gap: 5px; }
.tagpad button {
  font: inherit; font-size: 11.5px; font-weight: 600; font-family: var(--mono);
  padding: 3px 8px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--accent-text);
  transition: background .12s, border-color .12s;
}
.tagpad button:hover { background: var(--accent-soft); border-color: var(--accent); }

.side-section { border-bottom: 1px solid var(--border); padding: 16px 18px; }
.side-section:last-child { border-bottom: 0; }
.side-section > h3 { font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }

/* ---- charts ------------------------------------------------------------ */

.chart { width: 100%; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .area-open { fill: color-mix(in srgb, var(--accent) 16%, transparent); }
.chart .line-open { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .area-click { fill: color-mix(in srgb, var(--green) 14%, transparent); }
.chart .line-click { stroke: var(--green); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .axis { fill: var(--muted); font-size: 10.5px; }
.chart .bar-fill { fill: var(--accent); }

.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

.sparkline { width: 100%; height: 34px; display: block; }
.sparkline path { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.sparkline .fill { fill: color-mix(in srgb, var(--accent) 13%, transparent); stroke: none; }

/* country meter rows */
.meter-row { display: grid; grid-template-columns: 24px 1fr auto; gap: 11px; align-items: center; padding: 6px 0; }
/* No icon to show — drop the column rather than leave an empty gutter. */
.meter-row.bare { grid-template-columns: 1fr auto; }
.meter-row .flag { font-size: 16px; text-align: center; line-height: 1; }
.meter-row .name { font-size: 13.5px; font-weight: 520; }
.meter-row .track { height: 5px; border-radius: 99px; background: var(--surface-3); margin-top: 4px; overflow: hidden; }
.meter-row .track > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter-row .n { font-size: 13px; font-weight: 640; font-variant-numeric: tabular-nums; color: var(--text-soft); }

/* ---- misc -------------------------------------------------------------- */

.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.soft { color: var(--text-soft); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.sm { gap: 9px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.center { text-align: center; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), #9b6bf5);
  text-transform: uppercase;
}

kbd {
  font-family: var(--mono); font-size: 11px;
  padding: 1.5px 5px; border-radius: 5px;
  background: var(--surface-3); border: 1px solid var(--border);
  color: var(--text-soft);
}

code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--surface-3); padding: 1.5px 5px; border-radius: 5px;
  color: var(--accent-text);
}

.copy-url {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--r-sm);
  background: var(--surface-3); font-family: var(--mono); font-size: 12px;
  color: var(--text-soft);
}
.copy-url .u { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* list colour accents */
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 9px; }
.dot.indigo { background: var(--accent); }
.dot.violet { background: var(--violet); }
.dot.teal   { background: var(--teal); }
.dot.amber  { background: var(--amber); }
.dot.rose   { background: var(--rose); }
.dot.sky    { background: var(--sky); }
.dot.lime   { background: var(--lime); }

/* ---- public pages ------------------------------------------------------ */

.public-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: 40px 20px; background: var(--bg);
}
.public-card {
  width: 100%; max-width: 460px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 34px 32px;
}
.public-card h1 { font-size: 21px; margin-bottom: 8px; }
.public-card .brandline {
  font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent-text); margin-bottom: 14px;
}
.public-foot { text-align: center; margin-top: 20px; font-size: 12.5px; color: var(--muted); }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .page { padding: 20px 16px 48px; }
  .topbar { padding: 14px 16px; }
  .composer { grid-template-columns: 1fr; height: auto; }
  .composer .pane + .pane { border-left: 0; border-top: 1px solid var(--border); }
  .composer .pane { height: 70vh; }
}

@media print { .sidebar, .topbar .btn-row { display: none; } }

/* ---- delivery log ------------------------------------------------------ */

.logview {
  margin: 0;
  padding: 12px 14px;
  max-height: 420px;
  overflow: auto;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre;
  color: var(--text-soft);
}
.logview span { display: block; }
.logview span.w { color: var(--amber); }
.logview span.e { color: var(--red); font-weight: 600; }

/* ---- login ------------------------------------------------------------- */

.login-body {
  background:
    radial-gradient(1100px 520px at 12% -10%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 60%),
    radial-gradient(900px 480px at 110% 110%, color-mix(in srgb, #9b6bf5 11%, transparent), transparent 60%),
    var(--bg);
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 34px 32px 30px;
}
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; margin-bottom: 26px; }
.login-brand .mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #9b6bf5 100%);
  box-shadow: 0 2px 8px rgba(91, 87, 224, .35);
}
.login-brand .mark svg { width: 16px; height: 16px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card > .muted { margin-bottom: 20px; }
.login-card .callout { margin-bottom: 16px; }
.login-form { margin-top: 4px; }
.login-form .check { margin: 4px 0 20px; }

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer;
}
.pw-toggle:hover { background: var(--surface-3); color: var(--text); }
.pw-toggle.on { color: var(--accent-text); }

/* ---- signed-out notice (session expired mid-edit) ---------------------- */

.session-banner {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 300;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px 11px 16px; border-radius: var(--r);
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--red) 35%, var(--border));
  box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 520; max-width: calc(100% - 32px);
}
.session-banner svg { color: var(--red); width: 17px; height: 17px; }

.signed-in {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 6px 8px 10px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
}
.signed-in .who { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; }
.signed-in form { margin: 0; }
