/* ============================================================
   Easy Email Filter: mobile-first, plain & friendly UI
   ============================================================ */

:root {
  --primary: #1a73e8;
  --primary-dark: #155bb5;
  --accent: #ff6b35;
  --accent-dark: #e85a25;
  --text: #1f2937;
  --text-muted: #5f6b7a;
  --text-soft: #8a93a1;
  --border: #e4e7ec;
  --border-strong: #cdd2da;
  --bg: #f6f8fb;
  --card: #ffffff;
  --success: #1e8e3e;
  --danger: #d93025;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --transition: 0.18s ease;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* , *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); }
code { font-family: 'SF Mono', 'Fira Code', Consolas, monospace; font-size: 0.9em; background: rgba(15,23,42,0.06); padding: 1px 5px; border-radius: 4px; }

/* ============================================================
   HEADER (shared)
   ============================================================ */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
}
.brand-mark {
  display: inline-flex;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  align-items: center; justify-content: center;
}

/* Account menu (header, signed-in) */
.account-menu { position: relative; }
.account-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  min-height: 44px;
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  max-width: 220px;
  transition: background var(--transition), border-color var(--transition);
}
.account-trigger:hover { background: #f1f3f7; }
.account-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.account-email {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-caret { font-size: 0.7rem; color: var(--text-muted); }
@media (max-width: 480px) {
  .account-email { max-width: 90px; font-size: 0.8rem; }
}

.account-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 60;
  animation: popIn 0.16s ease;
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.account-popover-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.account-popover-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  font-weight: 700;
  margin-bottom: 2px;
}
.account-popover-email {
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 600;
  word-break: break-all;
}
.account-popover-action {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--danger);
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}
.account-popover-action:hover { background: rgba(217, 48, 37, 0.06); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  min-height: 44px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: var(--shadow-md); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: #f1f3f7; }
.btn-secondary:active:not(:disabled) { transform: scale(0.98); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: #f1f3f7; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #b3251c; }

.btn-large { padding: 14px 28px; min-height: 52px; font-size: 1.05rem; }
.btn-compact { padding: 10px 16px; min-height: 44px; font-size: 0.9rem; }
.btn-center { display: flex; margin: 24px auto 0; max-width: 320px; }

.plus { font-size: 1.2em; line-height: 0; font-weight: 700; }

/* ============================================================
   MARKETING: HERO
   ============================================================ */
.hero {
  padding: 32px 18px 36px;
  background: linear-gradient(180deg, #ffffff 0%, #eef3fb 100%);
}
.hero-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: center;
}
.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(255, 107, 53, 0.1);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 14px;
}
.hero-title {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.15;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin: 0 0 22px;
  max-width: 520px;
}
.hero-foot { font-size: 0.85rem; color: var(--text-soft); margin: 12px 0 0; }

.preview-notice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
  padding: 9px 14px;
  background: #fff8e1;
  border: 1px solid #f9c84a;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: #7a5500;
}
.preview-badge {
  display: inline-block;
  padding: 2px 8px;
  background: #f9c84a;
  color: #5a3c00;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  flex-shrink: 0;
}

/* Phone mockup */
.hero-visual { display: flex; justify-content: center; }
.phone {
  width: 100%;
  max-width: 290px;
  aspect-ratio: 9 / 19.5;
  background: linear-gradient(160deg, #2a3140 0%, #11151d 100%);
  border-radius: 42px;
  padding: 11px;
  position: relative;
  box-shadow:
    0 30px 70px -20px rgba(15, 23, 42, 0.45),
    0 12px 24px rgba(15, 23, 42, 0.18),
    0 0 0 1px rgba(255,255,255,0.06) inset;
}
.phone-notch {
  position: absolute;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  width: 92px; height: 22px;
  background: #05080d;
  border-radius: 14px;
  z-index: 2;
}
.phone-screen {
  background: linear-gradient(180deg, #fbfcfe 0%, #eef3fb 100%);
  border-radius: 32px;
  height: 100%;
  padding: 38px 11px 64px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  position: relative;
  overflow: hidden;
}
.phone-statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  color: var(--text);
  font-weight: 700;
  padding: 0 6px 2px;
  letter-spacing: -0.01em;
}
.phone-signal { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; }
.phone-signal span {
  display: block;
  width: 2.5px;
  background: var(--text);
  border-radius: 1px;
}
.phone-signal span:nth-child(1) { height: 30%; }
.phone-signal span:nth-child(2) { height: 55%; }
.phone-signal span:nth-child(3) { height: 80%; }
.phone-signal span:nth-child(4) { height: 100%; }

.phone-app-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 2px 4px 4px;
}
.phone-app-title { font-weight: 800; font-size: 0.95rem; color: var(--text); letter-spacing: -0.01em; }
.phone-app-count {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(26,115,232,0.1);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mock-filter {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: white;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 12px;
  padding: 7px 9px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  font-size: 0.7rem;
  line-height: 1.3;
}
.mock-filter-icon {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ic, var(--primary));
  background: color-mix(in srgb, var(--ic, var(--primary)) 12%, white);
}
.mock-filter-body { flex: 1; min-width: 0; }
.mock-filter-when { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mock-filter-when strong { font-weight: 700; }
.mock-filter-then { color: var(--text-muted); margin-top: 1px; font-size: 0.66rem; }
.mock-filter-then em {
  font-style: normal;
  background: rgba(26,115,232,0.1);
  color: var(--primary);
  padding: 0 5px;
  border-radius: 4px;
  font-weight: 600;
}

.mock-fab {
  position: absolute;
  bottom: 14px; left: 14px; right: 14px;
  background: linear-gradient(135deg, var(--primary), #2b86f5);
  color: white;
  text-align: center;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 11px;
  border-radius: var(--radius-pill);
  box-shadow: 0 10px 22px -4px rgba(26,115,232,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.mock-fab-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  font-size: 0.95rem;
  line-height: 1;
}

@media (min-width: 768px) {
  .hero { padding: 56px 24px 64px; }
  .hero-inner { grid-template-columns: 1.2fr 1fr; gap: 48px; }
  .hero-title { font-size: 2.6rem; }
  .hero-subtitle { font-size: 1.15rem; }
  .phone { max-width: 310px; }
}
@media (min-width: 1024px) {
  .hero-title { font-size: 3rem; }
}

/* ============================================================
   MARKETING: SECTIONS
   ============================================================ */
.section { padding: 40px 18px; }
.section-inner { max-width: 1080px; margin: 0 auto; }
.section-inner.narrow { max-width: 680px; }

.section-problem { background: var(--card); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-problem .section-title { text-align: center; }
.section-lede { font-size: 1.1rem; color: var(--text); text-align: center; margin: 8px auto 0; max-width: 640px; line-height: 1.55; }

.section-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.section-sub {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 1rem;
}

.section-how .section-title, .section-how .section-sub,
.section-features .section-title,
.section-trust .section-title { text-align: center; }
.section-how .section-sub { text-align: center; max-width: 480px; margin-left: auto; margin-right: auto; }

.how-list {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.how-step {
  display: flex;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.how-step h3 { margin: 0 0 4px; font-size: 1.05rem; }
.how-step p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }
.how-num {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 700;
}

@media (min-width: 768px) {
  .section { padding: 64px 24px; }
  .section-title { font-size: 2rem; }
  .how-list { grid-template-columns: repeat(3, 1fr); gap: 20px; }
  .how-step { flex-direction: column; }
}

/* Features */
.section-features { background: var(--card); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 24px;
}
.feature {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.feature h4 { margin: 0 0 6px; font-size: 1rem; }
.feature p { margin: 0; color: var(--text-muted); font-size: 0.92rem; }
@media (min-width: 640px) { .feature-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .feature-grid { grid-template-columns: repeat(4, 1fr); } }

/* Trust */
.trust-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: grid;
  gap: 12px;
}
.trust-list li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.95rem;
  color: var(--text-muted);
}
.trust-list strong { color: var(--text); }

/* ============================================================
   APP PAGE
   ============================================================ */
.app-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 96px;
}
@media (min-width: 768px) {
  .app-main { padding: 36px 24px 64px; }
}

.signed-out {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 22px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  margin-top: 12px;
}
.app-h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
@media (min-width: 768px) { .app-h1 { font-size: 2rem; } }
.app-lede {
  color: var(--text-muted);
  margin: 0 auto 22px;
  max-width: 480px;
}
.muted-small {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin: 14px 0 0;
}

.alert {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  text-align: left;
}
.alert-error {
  background: rgba(217, 48, 37, 0.08);
  color: var(--danger);
  border: 1px solid rgba(217, 48, 37, 0.2);
}

/* Dashboard */
.dashboard-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.dashboard-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
}
@media (min-width: 768px) { .dashboard-title { font-size: 1.75rem; } }
.dashboard-sub { margin: 4px 0 0; color: var(--text-muted); font-size: 0.9rem; }

.desktop-only { display: none; }
@media (min-width: 768px) { .desktop-only { display: inline-flex; } }

/* Filter search (shown when many filters) */
.filter-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  margin-bottom: 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-search-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.18);
}
.filter-search-icon { color: var(--text-soft); display: inline-flex; }
.filter-search {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  padding: 11px 0;
  min-height: 44px;
  -webkit-appearance: none;
}
.filter-search::-webkit-search-cancel-button { display: none; }
.filter-search-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.filter-search-clear:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.state-search-empty { padding: 24px; }

/* States */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
}
.state h2 { margin: 0; color: var(--text); font-size: 1.2rem; }
.state p { margin: 0; max-width: 360px; }
.state-emoji { font-size: 2.5rem; line-height: 1; }
.state-error { color: var(--danger); border-color: rgba(217,48,37,0.3); }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Filter cards (plain-English sentences) */
.filters-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.filter-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  animation: cardIn 0.25s ease both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.filter-sentence p { margin: 0 0 6px; line-height: 1.5; }
.filter-sentence p:last-child { margin-bottom: 0; }
.filter-when { color: var(--text); }
.filter-then { color: var(--text-muted); }
.filter-then strong, .filter-when strong { color: var(--text); font-weight: 600; }
.filter-tag-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(26, 115, 232, 0.1);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  margin-right: 6px;
  vertical-align: 1px;
}
.filter-tag-label-then { background: rgba(255, 107, 53, 0.12); color: var(--accent-dark); }

.tag {
  display: inline-block;
  font-size: 0.8rem;
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text);
  margin: 0 2px;
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
}

.filter-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.btn-card {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-card-edit:hover { background: var(--primary); color: white; border-color: var(--primary); }
.btn-card-delete:hover { background: var(--danger); color: white; border-color: var(--danger); }
.btn-card:active { transform: scale(0.98); }

@media (min-width: 768px) {
  .btn-card { flex: 0 0 auto; min-width: 110px; }
}

/* Mobile sticky FAB */
.mobile-fab {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  z-index: 40;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(26, 115, 232, 0.35);
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
}
.mobile-fab:active { transform: scale(0.98); }
@media (min-width: 768px) { .mobile-fab { display: none !important; } }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  text-align: center;
  padding: 24px 16px calc(24px + var(--safe-bottom));
  font-size: 0.82rem;
  color: var(--text-soft);
  border-top: 1px solid var(--border);
  background: var(--card);
}
.site-footer p { margin: 0 0 4px; }
.footer-links a { color: var(--text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--primary); }
.footer-sep { margin: 0 6px; opacity: 0.5; }
.page-app .site-footer { margin-bottom: 80px; }
@media (min-width: 768px) { .page-app .site-footer { margin-bottom: 0; } }

/* ============================================================
   MODAL (slide-up sheet on mobile, dialog on desktop)
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}
@media (min-width: 768px) { .modal-overlay { align-items: center; } }
.modal-overlay.modal-visible { opacity: 1; visibility: visible; }

.modal {
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: var(--safe-bottom);
}
@media (min-width: 768px) {
  .modal {
    max-width: 600px;
    border-radius: var(--radius);
    transform: translateY(20px) scale(0.97);
  }
}
.modal-visible .modal { transform: translateY(0); }
@media (min-width: 768px) {
  .modal-visible .modal { transform: translateY(0) scale(1); }
}

.modal-grabber {
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 8px auto 0;
}
@media (min-width: 768px) { .modal-grabber { display: none; } }

.modal-confirm {
  max-width: 420px;
  margin: 0 16px;
  border-radius: var(--radius);
  align-self: center;
  transform: scale(0.92);
}
.modal-visible .modal-confirm { transform: scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 6px;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}
.modal-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.7rem;
  line-height: 1;
  width: 44px; height: 44px;
  border-radius: 50%;
  color: var(--text-muted);
  -webkit-tap-highlight-color: transparent;
}
.modal-close:hover { background: rgba(0,0,0,0.05); }

.confirm-message { padding: 6px 20px 0; color: var(--text-muted); }

/* ============================================================
   FORM
   ============================================================ */
.form-section {
  padding: 14px 18px 4px;
}
.form-section + .form-section { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 18px; }

.form-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}
.form-section-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 14px;
}

.form-group { margin-bottom: 12px; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text);
}
.form-input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 16px; /* prevent iOS zoom */
  color: var(--text);
  font-family: inherit;
  -webkit-appearance: none;
  min-height: 44px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.18);
}
.form-input::placeholder { color: var(--text-soft); }

.form-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-row { display: flex; gap: 12px; }
.form-group-half { flex: 1; }

.form-select {
  cursor: pointer;
  -webkit-appearance: none;
  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='%235f6b7a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
  min-height: 44px;
}
.checkbox-row input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.checkbox-row .muted { color: var(--text-soft); font-style: normal; font-size: 0.85em; }

.form-advanced {
  margin: 6px 0 0;
  border-top: 1px solid var(--border);
  background: rgba(15,23,42,0.02);
}
.form-advanced > summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary);
  list-style: none;
  user-select: none;
}
.form-advanced > summary::-webkit-details-marker { display: none; }
.form-advanced > summary::before {
  content: '+ ';
  font-weight: 700;
  margin-right: 4px;
}
.form-advanced[open] > summary::before { content: '− '; }
.form-advanced .form-section { padding-top: 0; }
.form-advanced .form-section + .form-section { border-top: 1px dashed var(--border); }

.form-actions {
  display: flex;
  gap: 10px;
  padding: 16px 18px calc(18px + var(--safe-bottom));
  justify-content: flex-end;
  background: var(--card);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
}
.form-actions .btn { flex: 1; min-width: 100px; }
@media (min-width: 768px) {
  .form-actions .btn { flex: 0 0 auto; min-width: 130px; }
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
  position: fixed;
  left: 50%;
  bottom: calc(86px + var(--safe-bottom)); /* above mobile FAB */
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 420px;
  pointer-events: none;
}
@media (min-width: 768px) {
  .toast-container { bottom: 28px; }
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  color: white;
  font-size: 0.92rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
}
.toast-visible { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
