/* Haven design system — soft lavender ground, white rounded surfaces, pastel gradient
   stat cards and black pill actions. Shared by the dashboard, popup and block page. */
:root {
  --ground: #e4e1ec;
  --shell: #f7f6fb;
  --card: #ffffff;
  --ink: #16151d;
  --ink-2: #3b3a47;
  --muted: #7d7b8c;
  --line: #ebe9f2;
  --line-2: #dcd9e6;
  --accent: #8b7cf6;
  --accent-ink: #5b4bd6;
  --accent-soft: #e6e2fd;
  --pink: #df4a7f;
  --pink-soft: #fbe4ee;
  --green: #2f9e6e;
  --green-soft: #ddf3e8;
  --amber: #c98a12;
  --amber-soft: #fbf0d6;
  --grad-1: linear-gradient(100deg, #f8dde8 0%, #ebdcf3 100%);
  --grad-2: linear-gradient(100deg, #f2dbec 0%, #dfdcf6 100%);
  --grad-3: linear-gradient(100deg, #e1ddf7 0%, #dbe2fa 100%);
  --hatch: repeating-linear-gradient(135deg, #f1f0f7 0 6px, #f8f7fc 6px 12px);
  --shadow: 0 1px 2px rgba(22, 21, 29, 0.04), 0 8px 24px rgba(22, 21, 29, 0.05);
  --radius: 20px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0e0d13;
    --shell: #16151d;
    --card: #1f1e28;
    --ink: #f3f2f8;
    --ink-2: #d6d4e2;
    --muted: #9896aa;
    --line: #2b2a36;
    --line-2: #383747;
    --accent: #9d90ff;
    --accent-ink: #b9b0ff;
    --accent-soft: #2e2a4d;
    --pink: #f0719d;
    --pink-soft: #3d2231;
    --green: #5cc995;
    --green-soft: #1d3a2d;
    --amber: #e3b04b;
    --amber-soft: #3b3020;
    --grad-1: linear-gradient(100deg, #3a2432 0%, #312843 100%);
    --grad-2: linear-gradient(100deg, #36263a 0%, #2a2a48 100%);
    --grad-3: linear-gradient(100deg, #2b2a4a 0%, #25304a 100%);
    --hatch: repeating-linear-gradient(135deg, #262531 0 6px, #2b2a37 6px 12px);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 400 14px/1.45 var(--font);
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 500; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--ink); font-weight: 500; cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--ink); color: var(--card); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line); }
.btn.danger { color: var(--pink); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 0; background: transparent; color: var(--muted);
  display: inline-grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: var(--line); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- inputs ---------- */
.input, select.input, textarea.input {
  height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--card); outline: none; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 96px; padding: 10px 14px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input::placeholder { color: var(--muted); opacity: .8; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); }
.suffix { position: relative; }
.suffix .input { padding-right: 46px; }
.suffix::after { content: attr(data-suffix); position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12.5px; pointer-events: none; }

/* toggle */
.toggle { position: relative; width: 40px; height: 24px; flex: none; }
.toggle input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-2); transition: background .2s; }
.toggle span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.toggle input:checked + span { background: var(--ink); }
.toggle input:checked + span::after { transform: translateX(16px); }
.toggle input:focus-visible + span { box-shadow: 0 0 0 4px var(--accent-soft); }
@media (prefers-color-scheme: dark) { .toggle input:checked + span { background: var(--accent); } }

/* ---------- surfaces ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card-head h2 { font-size: 20px; }
.card-head .spacer { flex: 1; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; background: var(--card); border: 1px solid var(--line); white-space: nowrap;
}
.pill svg { width: 14px; height: 14px; }
.pill.purple { color: var(--accent-ink); background: var(--accent-soft); border-color: transparent; }
.pill.pink { color: var(--pink); background: var(--pink-soft); border-color: transparent; }
.pill.green { color: var(--green); background: var(--green-soft); border-color: transparent; }
.pill.amber { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.pill.gray { color: var(--muted); background: var(--line); border-color: transparent; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 12px; border-radius: 999px;
  background: var(--shell); border: 1px solid var(--line); font-size: 13px;
}
.chip button { border: 0; background: transparent; color: var(--muted); width: 20px; height: 20px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.chip button:hover { background: var(--line-2); color: var(--ink); }
.chip.add { padding: 0 12px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.chip svg { width: 14px; height: 14px; flex: none; }
.chip.add:hover { border-color: var(--muted); }

.ring { --p: 0; --c: var(--accent); width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; }
.ring::before { content: ''; width: 30px; height: 30px; border-radius: 50%; background: var(--card); grid-area: 1/1; }
.ring > * { grid-area: 1/1; position: relative; font-size: 11px; font-weight: 600; }

.logo { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 600; letter-spacing: -0.03em; }
.logo-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--ink); color: var(--card); display: grid; place-items: center; }
.logo-mark svg { width: 22px; height: 22px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--card); padding: 10px 18px; border-radius: 999px; font-weight: 500;
  transition: all .25s ease; z-index: 1000; box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--pink); color: #fff; }

.hidden { display: none !important; }
