/* ScentCircle styles — same Material look as ScentLog (toolbar, FAB, chips,
 * dialogs), rebuilt on CSS variables so dark mode needs no per-component overrides. */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --md-primary: #7B3FE4;
  --md-primary-rgb: 123,63,228;
  --md-primary-dark: #5E2BB8;
  --accent-text: var(--md-primary);
  --md-secondary: #03dac6;
  --md-background: #f6f4fa;
  --md-surface: #ffffff;
  --md-surface-2: #f0ecf7;
  --md-error: #b00020;
  --md-success: #2e7d32;
  --md-warn: #b26a00;
  --md-text-primary: rgba(0,0,0,0.87);
  --md-text-secondary: rgba(0,0,0,0.60);
  --md-text-hint: rgba(0,0,0,0.38);
  --md-divider: rgba(0,0,0,0.12);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --nav-h: 64px;
}
[data-theme="dark"] {
  --accent-text: var(--accent-text-dark, #B793FF);
  --md-background: #121212;
  --md-surface: #1e1e1e;
  --md-surface-2: #2a2a2e;
  --md-error: #cf6679;
  --md-success: #81c784;
  --md-warn: #ffb74d;
  --md-text-primary: rgba(255,255,255,0.87);
  --md-text-secondary: rgba(255,255,255,0.60);
  --md-text-hint: rgba(255,255,255,0.38);
  --md-divider: rgba(255,255,255,0.12);
}

html { background: var(--md-primary); }
body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--md-background);
  color: var(--md-text-primary);
  overflow: hidden;
  padding-left: var(--sal); padding-right: var(--sar);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ── Screens ─────────────────────────────────────────────────────────────── */
.screen {
  display: none; position: fixed; inset: 0;
  background: var(--md-background);
  z-index: 100; overflow: hidden;
  padding-bottom: var(--sab);
}
.screen.active { display: flex; flex-direction: column; }
#sub { z-index: 150; }

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.md-toolbar {
  background: var(--md-primary); color: #fff;
  height: calc(56px + var(--sat)); padding-top: var(--sat);
  display: flex; align-items: center;
  padding-right: calc(4px + var(--sar)); padding-left: calc(4px + var(--sal));
  box-shadow: 0 2px 4px -1px rgba(0,0,0,.2), 0 4px 5px 0 rgba(0,0,0,.14);
  position: relative; z-index: 10; flex: none;
  transition: background .3s ease;
}
.md-toolbar.home { padding-left: calc(16px + var(--sal)); }
.md-toolbar-title { flex: 1; font-size: 20px; font-weight: 500; letter-spacing: .0125em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px; }
.md-toolbar.home .md-toolbar-title { padding-left: 0; }
.md-icon-button {
  width: 48px; height: 48px; border-radius: 50%; border: none; background: transparent;
  color: inherit; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex: none;
}
.md-icon-button:active { background: rgba(255,255,255,.2); }
.md-icon-button i { font-size: 24px; }

/* ── Bottom navigation ───────────────────────────────────────────────────── */
.bottom-nav {
  flex: none; height: calc(var(--nav-h) + var(--sab)); padding-bottom: var(--sab);
  background: var(--md-surface); border-top: 1px solid var(--md-divider);
  display: flex; margin-bottom: calc(-1 * var(--sab));
}
.nav-btn {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--md-text-secondary); font-size: 12px; font-weight: 500;
}
.nav-btn i { font-size: 24px; padding: 2px 20px; border-radius: 16px; transition: background .2s; }
.nav-btn.active { color: var(--accent-text); }
.nav-btn.active i { background: rgba(var(--md-primary-rgb), .16); }

.tab-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(88px + var(--sab)); }

/* ── FAB ─────────────────────────────────────────────────────────────────── */
.md-fab {
  position: fixed; z-index: 120;
  right: calc(16px + var(--sar)); bottom: calc(var(--nav-h) + 16px + var(--sab));
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--md-primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 5px -1px rgba(0,0,0,.2), 0 6px 10px 0 rgba(0,0,0,.14);
}
.md-fab:active { background: var(--md-primary-dark); }
.md-fab i { font-size: 24px; }

/* ── Search / filters ────────────────────────────────────────────────────── */
.search-row {
  display: flex; align-items: center; gap: 8px; margin: 12px 16px 8px;
  background: var(--md-surface); border: 1px solid var(--md-divider); border-radius: 28px; padding: 0 14px; height: 46px;
}
.search-row i { color: var(--md-text-secondary); font-size: 22px; }
.search-row input { flex: 1; border: none; outline: none; background: none; height: 100%; min-width: 0; }
.filter-row { display: flex; gap: 8px; padding: 0 16px 8px; overflow-x: auto; scrollbar-width: none; align-items: center; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row select { height: 32px; border-radius: 16px; border: 1px solid var(--md-divider); background: var(--md-surface); padding: 0 8px; font-size: 14px; margin-left: auto; flex: none; }

/* ── Chips ───────────────────────────────────────────────────────────────── */
.md-chip {
  height: 32px; padding: 0 12px; border-radius: 16px; flex: none;
  border: 1px solid var(--md-divider); background: var(--md-surface); color: var(--md-text-primary);
  font-size: 14px; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none;
  transition: background .15s;
}
.md-chip:active { transform: scale(.96); }
.md-chip.selected { background: var(--md-primary); border-color: var(--md-primary); color: #fff; }
.md-chip.avoid.selected { background: var(--md-error); border-color: var(--md-error); }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 12px;
  font-size: 12px; background: rgba(var(--md-primary-rgb), .12); color: var(--accent-text); white-space: nowrap;
}
.tag.avoid { background: rgba(176,0,32,.1); color: var(--md-error); }
.tag.muted { background: var(--md-surface-2); color: var(--md-text-secondary); }
.tag.new { background: var(--md-primary); color: #fff; font-weight: 600; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; vertical-align: middle; text-transform: uppercase; letter-spacing: .04em; }
.badge.strong { background: var(--md-primary); color: #fff; }
.badge.good { background: rgba(var(--md-primary-rgb), .18); color: var(--accent-text); }
.badge.possible { background: var(--md-surface-2); color: var(--md-text-secondary); }

/* ── List ────────────────────────────────────────────────────────────────── */
.list { padding: 0 0 8px; }
.list-item {
  display: flex; gap: 14px; align-items: center; padding: 12px 16px;
  background: var(--md-surface); border-bottom: 1px solid var(--md-divider); cursor: pointer;
}
.list-item:active { background: var(--md-surface-2); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  background: rgba(var(--md-primary-rgb), .16); color: var(--accent-text); font-weight: 600; font-size: 16px;
}
.li-main { flex: 1; min-width: 0; }
.li-title { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: 13px; color: var(--md-text-secondary); margin-top: 1px; }
.li-main .tag-list { margin-top: 6px; }
.li-icon { font-size: 22px; color: var(--md-text-hint); flex: none; }
.li-icon.ok { color: var(--accent-text); }
.empty { text-align: center; padding: 56px 32px; color: var(--md-text-secondary); }
.empty i { font-size: 56px; color: var(--md-text-hint); display: block; margin-bottom: 8px; }
.empty h3 { color: var(--md-text-primary); font-weight: 500; margin-bottom: 6px; }
.empty .md-button { margin-top: 16px; }

.banner { margin: 4px 16px 8px; padding: 10px 12px; border-radius: 8px; font-size: 13px; display: flex; gap: 10px; align-items: center;
  background: rgba(var(--md-primary-rgb), .1); color: var(--md-text-primary); }
.banner i { color: var(--accent-text); font-size: 20px; }
.banner .grow { flex: 1; }
.banner.warn { background: rgba(255,152,0,.14); }
.banner.warn i { color: var(--md-warn); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.md-button {
  height: 40px; padding: 0 18px; border-radius: 20px; border: 1px solid var(--md-primary);
  background: transparent; color: var(--accent-text); font-size: 14px; font-weight: 500;
  letter-spacing: .4px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.md-button:active { background: rgba(var(--md-primary-rgb), .12); }
.md-button.primary { background: var(--md-primary); color: #fff; border-color: var(--md-primary); }
.md-button.primary:active { background: var(--md-primary-dark); }
.md-button.danger { color: var(--md-error); border-color: var(--md-error); }
.md-button.text { border-color: transparent; }
.md-button.block { width: 100%; height: 48px; font-size: 16px; }
.md-button[disabled] { opacity: .45; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row.end { justify-content: flex-end; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-scroll { flex: 1; overflow-y: auto; padding: 16px 16px calc(96px + var(--sab)); -webkit-overflow-scrolling: touch; }
.card { background: var(--md-surface); border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.card h3 { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-text); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h3 .grow { flex: 1; }
.card h3 .md-button { height: 28px; padding: 0 10px; font-size: 12px; text-transform: none; letter-spacing: 0; }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field-label { display: block; font-size: 12px; color: var(--md-text-secondary); margin-bottom: 4px; font-weight: 500; }
.field input[type=text], .field input[type=tel], .field input[type=email], .field input[type=date], .field input[type=number],
.field input[type=url], .field select, .field textarea, .chip-input {
  width: 100%; border: 1px solid var(--md-divider); border-radius: 8px; background: var(--md-surface);
  padding: 10px 12px; font-size: 16px; outline: none; min-height: 44px;
}
.field input:focus, .field select:focus, .field textarea:focus, .chip-input:focus-within { border-color: var(--md-primary); box-shadow: 0 0 0 1px var(--md-primary); }
.field textarea { resize: vertical; min-height: 88px; line-height: 1.4; }
.field .hint { font-size: 12px; color: var(--md-text-hint); margin-top: 4px; }
.field .err { font-size: 12px; color: var(--md-error); margin-top: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chip-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; }
.chip-input input { flex: 1; min-width: 120px; border: none !important; box-shadow: none !important; outline: none; background: none; padding: 6px 4px; font-size: 16px; min-height: 0 !important; }
.chip-input .chip, .chip { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 4px 0 10px; border-radius: 14px; font-size: 14px; background: rgba(var(--md-primary-rgb), .14); color: var(--accent-text); }
.chip-input.avoid .chip { background: rgba(176,0,32,.12); color: var(--md-error); }
.chip-x { border: none; background: none; color: inherit; width: 22px; height: 22px; border-radius: 50%; font-size: 16px; line-height: 1; cursor: pointer; opacity: .7; }
.switch-row { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.switch-row .grow { flex: 1; }
.switch-row .t { font-size: 15px; }
.switch-row .s { font-size: 12px; color: var(--md-text-secondary); margin-top: 1px; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 14px; background: rgba(128,128,128,.4); transition: background .2s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked ~ .track { background: var(--md-primary); }
.switch input:checked ~ .thumb { transform: translateX(18px); }
.save-bar {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + var(--sab));
  background: var(--md-surface); border-top: 1px solid var(--md-divider); display: flex; gap: 8px; z-index: 5;
}
.save-bar .md-button { flex: 1; }

/* ── Detail rows ─────────────────────────────────────────────────────────── */
.kv { display: flex; gap: 12px; padding: 8px 0; align-items: flex-start; border-bottom: 1px solid var(--md-divider); }
.kv:last-child { border-bottom: none; }
.kv .k { width: 96px; flex: none; font-size: 13px; color: var(--md-text-secondary); padding-top: 2px; }
.kv .v { flex: 1; min-width: 0; word-break: break-word; }
.kv .v a { color: var(--accent-text); text-decoration: none; }
.kv .acts { display: flex; gap: 4px; }
.icon-link { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(var(--md-primary-rgb), .12); color: var(--accent-text) !important; font-size: 20px; }
.hist-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--md-divider); align-items: flex-start; }
.hist-item:last-child { border-bottom: none; }
.hist-item > i { font-size: 22px; color: var(--accent-text); margin-top: 2px; }
.hist-item .grow { flex: 1; min-width: 0; }
.hist-item .t { font-weight: 500; }
.hist-item .s { font-size: 13px; color: var(--md-text-secondary); }
.link-btn { border: none; background: none; color: var(--md-text-hint); cursor: pointer; padding: 4px; font-size: 20px; }
.muted-text { color: var(--md-text-secondary); font-size: 14px; }

/* ── Announce / recipients ───────────────────────────────────────────────── */
.rcpt { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--md-divider); cursor: pointer; }
.rcpt:last-child { border-bottom: none; }
.rcpt input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--md-primary); flex: none; }
.rcpt.disabled { opacity: .55; cursor: default; }
.rcpt .grow { flex: 1; min-width: 0; }
.rcpt .t { font-weight: 500; }
.rcpt .s { font-size: 13px; color: var(--md-text-secondary); margin-top: 2px; }
.rcpt .w { font-size: 12px; color: var(--md-error); margin-top: 2px; }
.rcpt .w.soft { color: var(--md-warn); }
details.group { margin-top: 8px; }
details.group > summary { cursor: pointer; padding: 10px 0; font-size: 14px; color: var(--accent-text); font-weight: 500; list-style: none; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::before { content: '▸ '; }
details.group[open] > summary::before { content: '▾ '; }
.var-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.var-chips .md-chip { height: 28px; font-size: 13px; }
.preview { background: var(--md-surface-2); border-radius: 16px 16px 16px 4px; padding: 12px 14px; white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.4; }
.counter { font-size: 12px; color: var(--md-text-secondary); margin-top: 6px; display: flex; justify-content: space-between; gap: 8px; }
.counter.warn { color: var(--md-warn); }
.summary-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.summary-line .grow { flex: 1 1 100%; font-size: 14px; }
.summary-line .md-button.text { height: 32px; padding: 0 10px; }

/* ── Send queue ──────────────────────────────────────────────────────────── */
.progress { height: 6px; background: var(--md-surface-2); border-radius: 3px; overflow: hidden; margin: 6px 0 4px; }
.progress > div { height: 100%; background: var(--md-primary); transition: width .3s; }
.q-card .name { font-size: 22px; font-weight: 500; }
.q-card .phone { color: var(--md-text-secondary); }
.q-card .reason { color: var(--md-text-hint); font-size: 13px; margin-top: 2px; }
.q-card .preview { margin-top: 12px; }
.q-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.status { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.status.sent { color: var(--md-success); }
.status.skipped { color: var(--md-text-hint); }
.status.pending { color: var(--md-warn); }
.q-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--md-divider); }
.q-row:last-child { border-bottom: none; }
.q-row .grow { flex: 1; min-width: 0; }
.q-row.current { background: rgba(var(--md-primary-rgb), .08); margin: 0 -16px; padding: 10px 16px; }

/* ── Swatches ────────────────────────────────────────────────────────────── */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: #fff; padding: 0; }
.swatch.sel { box-shadow: 0 0 0 2px var(--md-surface), 0 0 0 4px var(--md-text-primary); }
.swatch i { font-size: 18px; }
input[type=color].swatch-custom { -webkit-appearance: none; appearance: none; width: 36px; height: 36px; border: 2px dashed var(--md-text-hint); padding: 0; background: none; cursor: pointer; border-radius: 50%; overflow: hidden; }
input[type=color].swatch-custom::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color].swatch-custom::-webkit-color-swatch { border: none; border-radius: 50%; }
input[type=color].swatch-custom::-moz-color-swatch { border: none; border-radius: 50%; }

/* ── Dialog / toast ──────────────────────────────────────────────────────── */
.md-dialog-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 400; display: flex; align-items: center; justify-content: center; padding: 16px; }
.md-dialog { background: var(--md-surface); border-radius: 16px; max-width: 480px; width: 100%; max-height: 90%; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 11px 15px -7px rgba(0,0,0,.2), 0 24px 38px 3px rgba(0,0,0,.14); }
.md-dialog-header { padding: 20px 20px 8px; font-size: 20px; font-weight: 500; }
.md-dialog-content { padding: 8px 20px 16px; overflow-y: auto; flex: 1; color: var(--md-text-primary); line-height: 1.45; }
.md-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 12px 12px; flex-wrap: wrap; }
.welcome-opt { display: flex; gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--md-divider); border-radius: 12px; margin-top: 10px; cursor: pointer; }
.welcome-opt:active { background: var(--md-surface-2); }
.welcome-opt i { font-size: 28px; color: var(--accent-text); }
.welcome-opt b { display: block; margin-bottom: 2px; }
.welcome-opt span { font-size: 13px; color: var(--md-text-secondary); }
.welcome-head { text-align: center; padding-bottom: 4px; }
.welcome-head i { font-size: 48px; color: var(--accent-text); }
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px + var(--sab)); transform: translate(-50%, 20px); background: #323232; color: #fff; padding: 12px 18px; border-radius: 8px; z-index: 500; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90%; font-size: 14px; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 720px) {
  .tab-body, .form-scroll { padding-left: max(16px, calc((100vw - 720px) / 2)); padding-right: max(16px, calc((100vw - 720px) / 2)); }
  .search-row, .filter-row, .banner { margin-left: 0; margin-right: 0; }
  .list-item { border-radius: 0; }
  .md-fab { right: max(16px, calc((100vw - 720px) / 2)); }
}
