/* ============================================================
   Remblo — design tokens + Material 3-friendly components
   ============================================================ */

/* ---- Fonts ---- */
@font-face { font-family: fallback; src: local("Arial"); }

:root {
  --font-sans: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* shape (M3) */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  /* accent hue (tweakable) */
  --accent: #2F6BFF;
  --accent-press: #2459DB;

  /* motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-emph: cubic-bezier(0.3, 0, 0, 1);
}

/* ============================ LIGHT ============================ */
[data-theme="light"] {
  --bg: #EEF1F6;
  --bg-grad-1: #EBEFF6;
  --bg-grad-2: #F3F1EC;
  --surface: #FFFFFF;
  --surface-2: #F7F8FB;
  --surface-3: #EFF2F7;
  --surface-inv: #14171F;

  --on-surface: #181B22;
  --on-surface-muted: #5B616E;
  --on-surface-faint: #8A909C;

  --outline: #DCE0E8;
  --outline-strong: #C4CAD5;

  --primary: var(--accent);
  --on-primary: #FFFFFF;
  --primary-container: #E1EAFF;
  --on-primary-container: #0B3D9E;
  --primary-soft: #EDF2FF;

  --success: #16A36A;
  --success-soft: #E4F6EE;
  --warning: #B8770A;
  --warning-soft: #FBF0DA;
  --danger: #D6453C;
  --danger-soft: #FBE7E5;

  --tg: #2AA3E0;
  --tg-soft: #E4F4FC;
  --email: #6B6F76;
  --email-soft: #EEEFF2;

  --shadow-sm: 0 1px 2px rgba(20,30,55,.06), 0 1px 3px rgba(20,30,55,.05);
  --shadow-md: 0 4px 10px rgba(20,30,55,.06), 0 10px 30px rgba(20,30,55,.07);
  --shadow-lg: 0 12px 28px rgba(20,30,55,.12), 0 30px 60px rgba(20,30,55,.10);
  --ring: rgba(47,107,255,.18);
}

/* ============================ DARK ============================ */
[data-theme="dark"] {
  --bg: #090B11;
  --bg-grad-1: #0A0D15;
  --bg-grad-2: #0E0F12;
  --surface: #14171F;
  --surface-2: #1A1E27;
  --surface-3: #222734;
  --surface-inv: #F4F5F8;

  --on-surface: #E9EBF0;
  --on-surface-muted: #9AA1AF;
  --on-surface-faint: #6B7280;

  --outline: #262C39;
  --outline-strong: #333B4B;

  --primary: #4D82FF;
  --on-primary: #06122E;
  --primary-container: #1B2640;
  --on-primary-container: #BFD2FF;
  --primary-soft: #161D2E;

  --success: #3DD08A;
  --success-soft: #122821;
  --warning: #E0A53A;
  --warning-soft: #2A2113;
  --danger: #F0726A;
  --danger-soft: #2B1715;

  --tg: #36ADE8;
  --tg-soft: #122430;
  --email: #A2A8B3;
  --email-soft: #1E222C;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 6px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.55);
  --ring: rgba(77,130,255,.30);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(120% 90% at 12% -8%, var(--bg-grad-1) 0%, transparent 55%),
    radial-gradient(110% 80% at 100% 0%, var(--bg-grad-2) 0%, transparent 50%),
    var(--bg);
  color: var(--on-surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  transition: background-color .4s var(--ease), color .3s var(--ease);
}

#root { min-height: 100vh; }

::selection { background: var(--ring); }

/* ---- typography helpers ---- */
.t-display { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.t-title { font-size: 21px; font-weight: 600; letter-spacing: -0.015em; }
.t-section { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--on-surface-muted); }
.t-body { font-size: 15px; font-weight: 400; line-height: 1.5; }
.t-label { font-size: 14px; font-weight: 500; }
.t-mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.muted { color: var(--on-surface-muted); }
.faint { color: var(--on-surface-faint); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: var(--r-full);
  padding: 0 22px;
  height: 46px;
  transition: transform .12s var(--ease), background-color .18s var(--ease),
              box-shadow .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .42; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }

.btn-filled { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn-filled:hover { background: var(--accent-press); box-shadow: var(--shadow-md); }
[data-theme="dark"] .btn-filled:hover { background: #5C8DFF; }

.btn-tonal { background: var(--primary-container); color: var(--on-primary-container); }
.btn-tonal:hover { filter: brightness(.97); }
[data-theme="dark"] .btn-tonal:hover { filter: brightness(1.15); }

.btn-outline { background: transparent; color: var(--on-surface); border: 1.5px solid var(--outline-strong); }
.btn-outline:hover { background: var(--surface-2); border-color: var(--on-surface-faint); }

.btn-text { background: transparent; color: var(--primary); padding: 0 14px; }
.btn-text:hover { background: var(--primary-soft); }

.btn-ghost { background: transparent; color: var(--on-surface-muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--on-surface); }

.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }

.btn-sm { height: 38px; font-size: 14px; padding: 0 16px; }
.btn-lg { height: 52px; font-size: 16px; padding: 0 28px; }
.btn-block { width: 100%; }

/* icon button */
.iconbtn {
  height: 42px; width: 42px;
  border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--on-surface-muted);
  transition: background-color .16s var(--ease), color .16s var(--ease), transform .12s var(--ease);
}
.iconbtn:hover { background: var(--surface-3); color: var(--on-surface); }
.iconbtn:active { transform: scale(.92); }
.iconbtn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.iconbtn.sm { height: 36px; width: 36px; }

/* ============================================================
   CARDS / SURFACES
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.sheet {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}

/* ============================================================
   CHIPS
   ============================================================ */
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 32px; padding: 5px 13px;
  border-radius: var(--r-md);
  font-size: 13.5px; font-weight: 500; line-height: 1.3;
  background: var(--surface-3); color: var(--on-surface);
  border: 1px solid transparent;
  transition: all .15s var(--ease);
  cursor: default;
}
.chip svg { flex: none; }
.chip-select { cursor: pointer; background: var(--surface); border: 1.5px solid var(--outline-strong); color: var(--on-surface-muted); }
.chip-select:hover { border-color: var(--on-surface-faint); color: var(--on-surface); }
.chip-select.on { background: var(--primary-container); color: var(--on-primary-container); border-color: transparent; }
.chip-removable { padding-right: 6px; }
.chip .x { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; opacity: .65; }
.chip .x:hover { opacity: 1; background: rgba(0,0,0,.08); }
[data-theme="dark"] .chip .x:hover { background: rgba(255,255,255,.12); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: var(--r-full);
  font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-neutral { background: var(--surface-3); color: var(--on-surface-muted); }

/* ============================================================
   FORM FIELDS (M3 outlined-ish)
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--on-surface); }
.field-hint { font-size: 13px; color: var(--on-surface-muted); line-height: 1.45; }

.input, .textarea, .select {
  font-family: var(--font-sans);
  font-size: 15.5px;
  color: var(--on-surface);
  background: var(--surface-2);
  border: 1.5px solid var(--outline);
  border-radius: var(--r-sm);
  padding: 13px 15px;
  width: 100%;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background-color .16s var(--ease);
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--on-surface-faint); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
  background: var(--surface);
}
.textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238A909C' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  padding-right: 42px;
}

/* ============================================================
   SEGMENTED BUTTON (M3)
   ============================================================ */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1.5px solid var(--outline);
  border-radius: var(--r-full);
  padding: 4px;
  gap: 2px;
}
.segmented.block { display: flex; width: 100%; }
.seg {
  flex: 1;
  border: none; background: transparent; cursor: pointer;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  color: var(--on-surface-muted);
  padding: 9px 16px; border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  white-space: nowrap;
  transition: color .16s var(--ease), background-color .16s var(--ease);
}
.seg:hover { color: var(--on-surface); }
.seg.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .seg.on { background: var(--surface-3); }

/* ============================================================
   SWITCH (M3)
   ============================================================ */
.switch {
  position: relative; width: 50px; height: 30px; flex: none;
  border-radius: var(--r-full); cursor: pointer;
  background: var(--surface-3); border: 2px solid var(--outline-strong);
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
  padding: 0;
}
.switch .knob {
  position: absolute; top: 50%; left: 5px; transform: translateY(-50%);
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--on-surface-faint);
  transition: all .22s var(--ease-emph);
}
.switch.on { background: var(--primary); border-color: var(--primary); }
.switch.on .knob { left: 22px; width: 22px; height: 22px; background: #fff; }
.switch:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }

/* ============================================================
   ICON TILE (for channel / reminder glyphs)
   ============================================================ */
.tile {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); flex: none;
}
.tile-tg { background: var(--tg-soft); color: var(--tg); }
.tile-email { background: var(--email-soft); color: var(--email); }

/* small channel pip on cards */
.pip {
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}

/* ============================================================
   misc
   ============================================================ */
.divider { height: 1px; background: var(--outline); border: none; margin: 0; }
.vstack { display: flex; flex-direction: column; }
.hstack { display: flex; align-items: center; }
.spread { display: flex; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.anim-up { animation: fadeUp .4s var(--ease) both; }
.anim-in { animation: fadeIn .3s var(--ease) both; }
.anim-pop { animation: pop .22s var(--ease-emph) both; }

/* scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--outline-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--outline-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
