/* Oasis Relay */
:root {
  --brand: #7555de;
  --brand-dark: #5b3fc0;
  --brand-soft: #efebfc;
  --ink: #16222b;
  --ink-2: #4a5a66;
  --muted: #73828d;
  --line: #dfe5ea;
  --bg: #f4f7f9;
  --card: #ffffff;
  --out: #7555de;
  --out-ink: #ffffff;
  --in: #eef2f5;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1e7b45;
  --ok-soft: #e7f5ec;
  --warn: #8a5a00;
  --warn-soft: #fff5d9;
  --link: #7555de;
  --brand-hover: #5b3fc0;
  --top: #7555de;
  --field: #ffffff;
  --hover: #f1f4f6;
  --hover-2: #f8fafb;
  --subtle: #fafbfc;
  --divider: #eef1f4;
  --chip: #e8edf1;
  --pill-bg: #eceff2;
  --avatar-bg: #e4ddfa;
  --danger-line: #f5c2bd;
  --ok-line: #bfe3cc;
  --warn-line: #f0dca0;
  --toast: #1d2a33;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 34, 43, .06), 0 4px 16px rgba(16, 34, 43, .06);
  color-scheme: light;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.45; }
a { color: var(--link); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
code, .mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- forms & buttons */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search], input[type=number], input:not([type]), select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--field);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
label { display: block; font-weight: 600; font-size: .9rem; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; margin: .35rem 0; }
label.check input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .9rem .7rem; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }
.stack > * + * { margin-top: .9rem; }
.narrow { max-width: 560px; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .75rem 0; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 200px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .55rem 1rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); cursor: pointer;
  text-decoration: none; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-small { padding: .3rem .65rem; font-size: .85rem; }
.btn-danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }
.btn-row .inline-form select { flex: 0 1 auto; min-width: 180px; }
.icon-btn { width: 38px; height: 38px; padding: 0; border-radius: 50%; border: 0; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); }
.icon-btn:hover { background: var(--hover); }
/* Default size for every icon; more specific rules below (placeholder, inbox switcher) still win. */
.ico { width: 20px; height: 20px; flex: none; }
.menu .ico, .media .file .ico, .att .ico { width: 18px; height: 18px; color: var(--ink-2); }
.icon-btn svg, .btn svg { width: 20px; height: 20px; }
.flash { padding: .7rem .9rem; border-radius: 8px; margin: 0 0 1rem; border: 1px solid; }
.flash p { margin: 0 0 .5rem; }
.flash-error { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.flash-ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.flash-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 99px; background: var(--brand-soft); color: var(--brand-dark); vertical-align: middle; }
.pill-muted { background: var(--pill-bg); color: var(--muted); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.copy-field { font-family: Consolas, monospace; font-size: .85rem; cursor: copy; }

/* ---------------------------------------------------------------- sign-in pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 1.75rem; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.auth-card .brand { margin-bottom: 1.5rem; }
.logo-lockup { height: 48px; width: auto; display: block; }
.logo-sm { height: 30px; width: auto; display: block; }
.top-mark { height: 30px; width: auto; flex: none; }
.top-logo { height: 30px; width: auto; flex: none; margin-right: .5rem; display: none; }
@media (min-width: 1180px) { .top-mark { display: none; } .top-logo { display: block; } }
.btn-ms { width: 100%; background: var(--card); border-color: #8c8c8c; font-weight: 600; padding: .65rem; }
.ms-logo { display: inline-grid; grid-template-columns: 9px 9px; gap: 2px; }
.ms-logo i { width: 9px; height: 9px; display: block; }
.ms-logo i:nth-child(1) { background: #f25022; } .ms-logo i:nth-child(2) { background: #7fba00; }
.ms-logo i:nth-child(3) { background: #00a4ef; } .ms-logo i:nth-child(4) { background: #ffb900; }
.or { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1.1rem 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.code-input { font-size: 1.6rem !important; letter-spacing: .3em; text-align: center; font-family: Consolas, monospace; }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: .75rem; }
.qr { margin: .75rem 0; display: flex; justify-content: center; }
.qr img, .qr canvas { width: 196px; height: 196px; image-rendering: pixelated; border: 8px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.key { font-size: .95rem; word-spacing: .2em; }

/* ---------------------------------------------------------------- admin */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .55rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); min-height: 56px; }
.topbar-right { margin-left: auto; display: flex; gap: .25rem; align-items: center; }
.topbar-right form { margin: 0; }
.admin-nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.admin-nav a { padding: .4rem .7rem; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 600; }
.admin-nav a:hover { background: var(--bg); }
.admin-main { max-width: 1060px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin: 1rem 0; }
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--subtle); }
.table td form { margin: 0; }
.table tr:last-child td { border-bottom: 0; }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .table { display: block; overflow-x: auto; }
}

/* ---------------------------------------------------------------- messenger layout */
body.messenger { height: 100vh; height: 100dvh; overflow: hidden; }
.app { display: grid; grid-template-rows: auto 1fr; grid-template-columns: 100%; height: 100%; overflow: hidden; }
.app-top { display: flex; align-items: center; gap: .5rem; padding: .45rem .75rem; background: var(--top); color: #fff; padding-top: max(.45rem, env(safe-area-inset-top)); }
.app-top .icon-btn { color: #fff; }
.app-top .icon-btn:hover { background: rgba(255,255,255,.15); }
.inbox-switch { position: relative; }
.inbox-btn { display: flex; align-items: center; gap: .5rem; background: rgba(255,255,255,.12); border: 0; color: #fff; padding: .4rem .75rem; border-radius: 8px; cursor: pointer; text-align: left; max-width: 60vw; }
.inbox-btn:hover { background: rgba(255,255,255,.2); }
.inbox-btn .ib-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-btn .ib-num { font-size: .8rem; opacity: .85; white-space: nowrap; }
.inbox-btn .badge { background: #ffb020; color: #3a2600; }
.inbox-btn svg { width: 18px; height: 18px; flex: none; }
.menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.18); min-width: 290px; max-height: 70vh; overflow: auto; padding: .35rem; }
.menu.right { left: auto; right: 0; }
.menu a, .menu button { display: flex; width: 100%; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 7px; border: 0; background: none; text-align: left; text-decoration: none; color: inherit; cursor: pointer; }
.menu a:hover, .menu button:hover, .menu .current { background: var(--bg); }
.menu .m-sub { font-size: .8rem; color: var(--muted); }
.menu .m-main { flex: 1; min-width: 0; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: .3rem 0; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: .75rem; font-weight: 700; background: var(--brand); color: #fff; }
.spacer { flex: 1; }
.top-new { background: var(--card); color: var(--link); border-color: var(--card); }
.top-new:hover { background: var(--brand-soft); border-color: var(--brand-soft); }

.panes { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); min-height: 0; }
.panes > * { min-width: 0; }
.list-pane { border-right: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; min-height: 0; }
.list-tools { padding: .6rem; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: .25rem; margin-top: .5rem; }
.tabs button { flex: 1; border: 0; background: none; padding: .4rem; border-radius: 7px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tabs button[aria-pressed=true] { background: var(--brand-soft); color: var(--brand-dark); }
.conv-list { overflow-y: auto; flex: 1; list-style: none; margin: 0; padding: 0; }
.conv { display: flex; gap: .65rem; padding: .7rem .8rem; border-bottom: 1px solid var(--divider); cursor: pointer; align-items: flex-start; }
.conv:hover { background: var(--hover-2); }
.conv.active { background: var(--brand-soft); }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--avatar-bg); color: var(--brand-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; }
.conv-main { min-width: 0; flex: 1; }
.conv-top { display: flex; gap: .5rem; align-items: baseline; }
.conv-name { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: .75rem; color: var(--muted); flex: none; }
.conv-prev { font-size: .87rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { font-size: .75rem; color: var(--muted); margin-top: .15rem; }
.conv.unread .conv-name, .conv.unread .conv-prev { font-weight: 700; color: var(--ink); }
.conv.unread .avatar { box-shadow: 0 0 0 2px var(--brand); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); flex: none; margin-top: .45rem; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

.thread-pane { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.thread-head { display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; background: var(--card); border-bottom: 1px solid var(--line); min-height: 58px; }
.thread-title { flex: 1; min-width: 0; }
.thread-title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-title span { font-size: .82rem; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-actions { display: flex; gap: .25rem; align-items: center; position: relative; }
.thread-actions select { width: auto; padding: .35rem .5rem; font-size: .85rem; }
.back-btn { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 1rem .9rem; display: flex; flex-direction: column; gap: .35rem; }
.day { align-self: center; font-size: .75rem; color: var(--muted); background: var(--chip); padding: .15rem .65rem; border-radius: 99px; margin: .6rem 0 .3rem; }
.msg { max-width: min(560px, 78%); display: flex; flex-direction: column; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.in { align-self: flex-start; align-items: flex-start; }
.bubble { padding: .5rem .75rem; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.in .bubble { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.out .bubble { background: var(--out); color: var(--out-ink); border-bottom-right-radius: 5px; }
.msg.out .bubble a { color: #fff; }
.msg.failed .bubble { background: var(--card); color: var(--danger); border: 1px solid var(--danger-line); }
.msg-meta { font-size: .72rem; color: var(--muted); margin-top: .15rem; padding: 0 .3rem; }
.msg-meta .err { color: var(--danger); }
.media { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .2rem; }
.media img { max-width: 260px; max-height: 260px; border-radius: 12px; display: block; cursor: zoom-in; background: var(--chip); }
.media video { max-width: 280px; border-radius: 12px; }
.media .file { display: inline-flex; gap: .4rem; align-items: center; padding: .45rem .7rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); font-size: .85rem; }
.media .pending { font-size: .8rem; color: var(--muted); padding: .4rem .6rem; background: var(--card); border-radius: 10px; border: 1px dashed var(--line); }
.notice { margin: .5rem .9rem 0; }
.composer { background: var(--card); border-top: 1px solid var(--line); padding: .55rem .7rem; padding-bottom: max(.55rem, env(safe-area-inset-bottom)); }
.composer-row { display: flex; gap: .4rem; align-items: flex-end; }
.composer textarea { resize: none; min-height: 42px; max-height: 180px; border-radius: 20px; padding: .55rem .9rem; }
.composer .send { border-radius: 50%; width: 42px; height: 42px; padding: 0; flex: none; }
.composer-info { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); padding: .2rem .5rem 0; gap: .5rem; }
.attachments { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .4rem; }
.att { position: relative; border: 1px solid var(--line); border-radius: 8px; padding: .25rem .45rem; font-size: .8rem; display: flex; gap: .35rem; align-items: center; background: var(--bg); }
.att img { width: 40px; height: 40px; object-fit: cover; border-radius: 5px; }
.att button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; }
.placeholder { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; color: var(--muted); text-align: center; padding: 2rem; }
.placeholder svg { width: 56px; height: 56px; opacity: .5; margin-bottom: .5rem; }
.new-form { padding: 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.new-form .row { display: grid; grid-template-columns: 2fr 1fr; gap: .6rem; }

.sheet-back { position: fixed; inset: 0; background: rgba(10, 20, 26, .4); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.sheet { background: var(--card); border-radius: 14px; width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; padding: 1.2rem; box-shadow: var(--shadow); }
.sheet h2 { display: flex; justify-content: space-between; align-items: center; }
.tpl-item { display: flex; gap: .5rem; align-items: flex-start; padding: .55rem; border-radius: 8px; cursor: pointer; }
.tpl-item:hover { background: var(--bg); }
.tpl-item .t { flex: 1; min-width: 0; }
.tpl-item .t b { display: block; }
.tpl-item .t span { font-size: .85rem; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 90; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 95vh; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--toast); color: #fff; padding: .6rem 1rem; border-radius: 8px; z-index: 100; box-shadow: var(--shadow); max-width: 90vw; }
.toast.error { background: var(--danger); }
.install-tip { background: var(--warn-soft); color: var(--warn); font-size: .85rem; padding: .5rem .8rem; display: flex; gap: .5rem; align-items: center; }
.install-tip button { margin-left: auto; }

@media (max-width: 760px) {
  .panes { grid-template-columns: minmax(0, 1fr); }
  .thread-actions select { max-width: 112px; }
  .thread-head { gap: .35rem; padding: .5rem .4rem; }
  .thread-head .avatar { display: none; }
  .inbox-btn { max-width: calc(100vw - 190px); }
  .app.show-thread .list-pane { display: none; }
  .app:not(.show-thread) .thread-pane { display: none; }
  .back-btn { display: inline-flex; }
  .inbox-btn .ib-num { display: none; }
  .top-new span { display: none; }
  .msg { max-width: 88%; }
  .composer-info span:last-child { display: none; }
  .new-form .row { grid-template-columns: 1fr; }
}

/* Admin > Settings */
.field-help { display: block; margin-top: .25rem; }
label + .field-help { margin-top: .25rem; }
.settings-tests { margin-top: .8rem; }
.settings-tests:empty { display: none; }
.settings-danger { margin-top: 1rem; }
.settings-danger summary { cursor: pointer; color: var(--muted, #666); font-size: .9rem; }
.settings-danger form { margin-top: .5rem; }

/* ---------------------------------------------------------------- dark theme
   Dark applies when the user picked Dark (<html data-theme="dark">), or picked nothing
   and the device is in dark mode. The public home page forces data-theme="light".
   The two variable blocks below must stay identical. */
:root[data-theme=dark] {
  --brand-dark: #c0b2f7;
  --brand-soft: #2b2450;
  --link: #a995f5;
  --brand-hover: #8468e6;
  --top: #3a2b7c;
  --ink: #e3e8ec;
  --ink-2: #b3bec7;
  --muted: #8c9aa5;
  --line: #2d3943;
  --bg: #0f161b;
  --card: #172128;
  --field: #111a20;
  --out: #6449d4;
  --in: #1f2a32;
  --danger: #ff8f84;
  --danger-soft: #3b1d1b;
  --ok: #72d39c;
  --ok-soft: #142c1d;
  --warn: #f1c75e;
  --warn-soft: #30270e;
  --hover: #22303a;
  --hover-2: #1c2830;
  --subtle: #1b262e;
  --divider: #222e37;
  --chip: #24313b;
  --pill-bg: #26323c;
  --avatar-bg: #3a3070;
  --danger-line: #6e2c27;
  --ok-line: #24553a;
  --warn-line: #5e4a14;
  --toast: #2c3a45;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --brand-dark: #c0b2f7;
    --brand-soft: #2b2450;
    --link: #a995f5;
    --brand-hover: #8468e6;
    --top: #3a2b7c;
    --ink: #e3e8ec;
    --ink-2: #b3bec7;
    --muted: #8c9aa5;
    --line: #2d3943;
    --bg: #0f161b;
    --card: #172128;
    --field: #111a20;
    --out: #6449d4;
    --in: #1f2a32;
    --danger: #ff8f84;
    --danger-soft: #3b1d1b;
    --ok: #72d39c;
    --ok-soft: #142c1d;
    --warn: #f1c75e;
    --warn-soft: #30270e;
    --hover: #22303a;
    --hover-2: #1c2830;
    --subtle: #1b262e;
    --divider: #222e37;
    --chip: #24313b;
    --pill-bg: #26323c;
    --avatar-bg: #3a3070;
    --danger-line: #6e2c27;
    --ok-line: #24553a;
    --warn-line: #5e4a14;
    --toast: #2c3a45;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
/* Logos: dark artwork on light backgrounds, white artwork in dark mode. */
.on-dark { display: none !important; }
:root[data-theme=dark] .on-light { display: none !important; }
:root[data-theme=dark] .on-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .on-light { display: none !important; }
  :root:not([data-theme]) .on-dark { display: block !important; }
}

/* Theme switcher (user menu and admin header) */
.theme-switch { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.theme-switch button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; border: 0; background: none; color: var(--ink-2); padding: .3rem .55rem; border-radius: 6px; cursor: pointer; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.theme-switch button:hover { background: var(--hover); }
.theme-switch button[aria-pressed=true] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.theme-switch .ico { width: 16px; height: 16px; }
.menu .theme-row { padding: .4rem .7rem .5rem; }
.menu .theme-row .m-sub { margin-bottom: .3rem; }
.menu .theme-switch button { width: auto; padding: .3rem .55rem; display: inline-flex; justify-content: center; }
.menu .theme-switch button:hover { background: var(--hover); }

/* Email in the inbox */
.bubble .subj { font-weight: 700; margin-bottom: .3rem; white-space: normal; }
.msg.email { max-width: min(680px, 86%); }
.msg-meta .orig { color: inherit; }
.subj-row { margin-top: .6rem; }
.code-box { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: .8rem; white-space: pre; overflow: auto; }
.from-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: .5rem; margin-top: .3rem; }
.table .copy-field { min-width: 12rem; padding: .35rem .5rem; }

/* Email campaigns */
.campaign-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); gap: 1.25rem; align-items: start; }
.campaign-main { min-width: 0; }
.campaign-side { position: sticky; top: 1rem; }
.preview-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .4rem; }
.preview-frame { width: 100%; height: 680px; border: 1px solid var(--line); border-radius: var(--radius); background: #f4f7f9; }
.editor-tabs { max-width: 260px; margin-top: 1rem; }
.ed-toolbar { display: flex; flex-wrap: wrap; gap: .25rem; padding: .35rem; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--subtle); }
.ed-toolbar button, .ed-toolbar select, .ed-color { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 6px; padding: .25rem .5rem; font-size: .85rem; cursor: pointer; width: auto; }
.ed-toolbar button:hover { background: var(--hover); }
.ed-color { display: inline-flex; align-items: center; gap: .25rem; font-weight: 700; margin: 0; }
.ed-color input { width: 22px; height: 22px; padding: 0; border: 0; background: none; }
/* The editing area looks like the email (always light, like the real thing). */
.ed-area { min-height: 380px; max-height: 70vh; overflow: auto; padding: 1.25rem 1.5rem; border: 1px solid var(--line); border-radius: 0 0 8px 8px; background: #fff; color: #16222b; font-family: "Segoe UI", Arial, sans-serif; font-size: 16px; line-height: 1.55; outline: none; }
.ed-area:focus { border-color: var(--brand); }
.ed-area p, .ed-area div { margin: 0 0 16px; }
.ed-area h1 { font-size: 26px; margin: 0 0 16px; } .ed-area h2 { font-size: 21px; margin: 0 0 14px; } .ed-area h3 { font-size: 17px; margin: 0 0 12px; }
.ed-area a { color: #5b3fc0; }
.ed-area a.ebtn { display: inline-block; background: #7555de; color: #fff; text-decoration: none; padding: 12px 24px; border-radius: 6px; font-weight: 600; }
.ed-area img { max-width: 100%; height: auto; }
.ed-area img[align=center] { display: block; margin: 0 auto 16px; float: none; }
.ed-area blockquote { margin: 0 0 16px; padding: 4px 0 4px 14px; border-left: 3px solid #dfe5ea; color: #4a5a66; }
.campaign-actions { position: sticky; bottom: 0; z-index: 5; }
.schedule-row label { display: flex; align-items: center; gap: .5rem; font-weight: 600; margin: 0; }
.schedule-row input[type=datetime-local] { width: auto; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; margin: 1rem 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; }
.stat-n { font-size: 1.5rem; font-weight: 700; }
.stat-l { color: var(--muted); font-size: .85rem; }
ul.tight { margin: 0; padding-left: 1.2rem; }
@media (max-width: 1100px) {
  .campaign-grid { grid-template-columns: minmax(0, 1fr); }
  .campaign-side { position: static; }
  .preview-frame { height: 520px; }
}

/* Inbox switcher: customer groups + filter */
.menu .menu-group { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem .7rem .25rem; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.menu .menu-group:first-child { padding-top: .3rem; }
.menu .menu-filter { width: 100%; margin: .15rem 0 .35rem; }
.menu .menu-empty { padding: .6rem .7rem; }
.access-block { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 .8rem; }
.access-block legend { font-weight: 700; padding: 0 .3rem; }
.page-actions { margin: .75rem 0; }

/* Website chat settings */
.row-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.row-2 input[type="color"] { width: 100%; height: 2.4rem; padding: .15rem; }
.danger-zone { margin-top: 1rem; }
#chat h3 { margin: 1rem 0 .25rem; font-size: 1rem; }

/* Website chat in the inbox */
.chat-bar { display: flex; gap: .55rem; align-items: flex-start; margin: .5rem .9rem 0; padding: .5rem .75rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: .85rem; color: var(--ink-2); }
.chat-bar.online { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ink); }
.chat-bar a { word-break: break-all; }
.live-dot { flex: none; width: .6rem; height: .6rem; margin-top: .35rem; border-radius: 50%; background: var(--muted); }
.chat-bar.online .live-dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-line); }
.via { display: inline-flex; align-items: center; gap: .3rem; }
.via button { border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); border-radius: 6px; padding: .05rem .5rem; font-size: .75rem; font-weight: 600; cursor: pointer; }
.via button[aria-pressed=true] { background: var(--brand); border-color: var(--brand); color: #fff; }
.via button:disabled { opacity: .45; cursor: default; }
.composer-info .via + span { margin-right: auto; }
.msg.chat.in .bubble { border-left: 3px solid var(--brand); }

/* Copy buttons next to copy fields (added by common.js) */
.copy-wrap { display: flex; gap: .4rem; align-items: center; width: 100%; }
.copy-wrap > .copy-field { flex: 1; min-width: 0; }
.copy-wrap-block { align-items: flex-start; }
.copy-btn { flex: none; }
.copy-btn.copied { color: var(--ok); border-color: var(--ok-line); background: var(--ok-soft); }
.dns-table td { vertical-align: top; }
.dns-table .copy-wrap { min-width: 16rem; }
.dns-table td .small.muted { margin-top: .3rem; }
.chat-answers { display: grid; grid-template-columns: max-content 1fr; gap: .1rem .6rem; margin: .35rem 0 0; }
.chat-answers dt { color: var(--muted); }
.chat-answers dd { margin: 0; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Website chat settings: icon picker and extra questions */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon-grid { display: flex; flex-wrap: wrap; gap: .5rem; margin: .25rem 0 .5rem; }
.icon-choice { position: relative; cursor: pointer; border-radius: 50%; padding: 3px; border: 2px solid transparent; }
.icon-choice input { position: absolute; opacity: 0; }
.icon-choice:has(input:checked) { border-color: var(--brand); }
.icon-choice:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.chat-preview { display: block; }
.icon-color-row { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin-bottom: .5rem; }
.icon-color-row input[type="color"] { width: 2.4rem; height: 1.7rem; padding: .1rem; margin-left: .3rem; vertical-align: middle; }
.icon-uploaded { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; margin: .25rem 0 .5rem; }
.fields-table input, .fields-table select { width: 100%; min-width: 7rem; }
.fields-table td.center, .fields-table th:last-child { text-align: center; }
#chat .narrow { max-width: 760px; }
