/* Email Notifier by GoAstraX — mobile-first, dark by default, light via prefers-color-scheme.
   All styling lives here: no inline styles anywhere in the app. */

:root {
  --bg: #0f1216;
  --bg-elev: #171b21;
  --bg-elev-2: #1e242b;
  --line: #262d36;
  --line-soft: #1e242b;
  --text: #e8edf4;
  --text-dim: #9aa6b4;
  --text-faint: #6b7783;
  --accent: #ff7a59;
  --accent-ink: #1a0d08;
  --calm-bg: #1c2a33;
  --calm-fg: #8fc6de;
  --warn-bg: #33290f;
  --warn-fg: #e8bd63;
  --urgent-bg: #3a1a18;
  --urgent-fg: #ff9b86;
  --danger: #ff6b5a;
  --ok: #6fd39a;
  --focus: #7fb3ff;
  --radius: 14px;
  --radius-sm: 9px;
  --tap: 44px;
  --pad: 16px;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --bg-elev: #ffffff;
    --bg-elev-2: #eef1f5;
    --line: #dde2e9;
    --line-soft: #e8ecf1;
    --text: #131a21;
    --text-dim: #5b6773;
    --text-faint: #8b96a2;
    --accent: #d9482a;
    --accent-ink: #ffffff;
    --calm-bg: #e4f0f6;
    --calm-fg: #1f5f7a;
    --warn-bg: #fdf0d6;
    --warn-fg: #7a5510;
    --urgent-bg: #fde3de;
    --urgent-fg: #9c2c1c;
    --danger: #c33b2a;
    --ok: #1d7a4f;
    --focus: #1e5fd0;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: default; }

.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}

.btn--small {
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 550;
}

.btn--ghost {
  background: transparent;
  color: var(--text-dim);
}

.btn.is-busy { color: var(--text-faint); }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.iconbtn:hover { background: var(--bg-elev-2); color: var(--text); }
.iconbtn__glyph { font-size: 19px; line-height: 1; }
.iconbtn__svg {
  display: block;
  width: 22px;
  height: 22px;
  overflow: visible;
}
.iconbtn[aria-pressed="true"] { color: var(--accent); background: var(--bg-elev-2); }
.iconbtn.is-busy { color: var(--text-faint); }
.iconbtn.is-busy .iconbtn__glyph { animation: pulse 0.9s ease-in-out infinite; }

/* ---------- boot / gate ---------- */

.boot, .gate {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: calc(var(--pad) + var(--sat)) calc(var(--pad) + var(--sar))
           calc(var(--pad) + var(--sab)) calc(var(--pad) + var(--sal));
  text-align: center;
}

.boot__text { color: var(--text-faint); font-size: 14px; margin: 0; }

.boot__mark, .gate__mark {
  width: 52px;
  height: 36px;
  border: 2px solid var(--text-faint);
  border-radius: 6px;
  background:
    linear-gradient(to bottom right, transparent 48%, var(--text-faint) 48%, var(--text-faint) 52%, transparent 52%) no-repeat left top / 50% 100%,
    linear-gradient(to bottom left, transparent 48%, var(--text-faint) 48%, var(--text-faint) 52%, transparent 52%) no-repeat right top / 50% 100%;
}

.gate__mark { border-color: var(--accent); width: 64px; height: 44px; }

.gate__title { margin: 14px 0 0; font-size: 26px; letter-spacing: -0.02em; }
.gate__by {
  margin: -4px 0 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.gate__sub { margin: 0; max-width: 30ch; color: var(--text-dim); }
.gate__cta { margin-top: 18px; min-width: 220px; }
.gate__note { margin: 6px 0 0; max-width: 34ch; color: var(--text-faint); font-size: 13px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line-soft);
  padding: calc(var(--sat) + 6px) calc(var(--sar) + 10px) 6px calc(var(--sal) + 10px);
}

.topbar__row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 52px;
}

.topbar__id {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  padding-left: 6px;
}

.topbar__email {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__sync { font-size: 12.5px; color: var(--text-faint); }

.topbar__actions { display: flex; align-items: center; gap: 2px; flex: none; }

/* ---------- notices ---------- */

.notices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px calc(var(--pad) + var(--sar)) 0 calc(var(--pad) + var(--sal));
}

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.banner--warn {
  border-color: color-mix(in srgb, var(--warn-fg) 45%, transparent);
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.banner__text { margin: 0; flex: 1; min-width: 12ch; font-size: 14px; }

/* ---------- hero: the count is the whole app ---------- */

.main {
  padding: 10px calc(var(--pad) + var(--sar)) calc(28px + var(--sab)) calc(var(--pad) + var(--sal));
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  padding: 26px 8px 24px;
}

.hero__count {
  margin: 0;
  font-size: 76px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.hero.is-clear .hero__count { color: var(--ok); }

.hero__label {
  margin: 8px 0 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hero__line {
  margin: 2px 0 0;
  max-width: 34ch;
  color: var(--text-dim);
  font-size: 14.5px;
}

.hero__cta { margin-top: 20px; min-width: 220px; }

/* ---------- grouped no-reply list ---------- */

.groups {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 8px;
}

.group__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 8px;
  border-bottom: 1px solid var(--line-soft);
}

.group__title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.group--urgent .group__title { color: var(--urgent-fg); }
.group--warn .group__title { color: var(--warn-fg); }
.group--calm .group__title { color: var(--calm-fg); }

.group__count {
  margin: 0;
  flex: none;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

.group__empty {
  margin: 0;
  padding: 12px 4px;
  color: var(--text-faint);
  font-size: 14px;
}

/* ---------- one line per email ---------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row { border-bottom: 1px solid var(--line-soft); }

.row__link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 11px 4px;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.row__link:hover { background: var(--bg-elev); }

.row__sender {
  flex: 0 1 auto;
  max-width: 38%;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__subject {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__badges { display: flex; align-items: center; gap: 4px; flex: none; }

.badge {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: var(--text-dim);
}

.badge--unread { border-color: color-mix(in srgb, var(--focus) 40%, transparent); color: var(--focus); }
.badge--noreply { border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }

.chip {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  background: var(--calm-bg);
  color: var(--calm-fg);
}

.chip--calm   { background: var(--calm-bg);   color: var(--calm-fg); }
.chip--warn   { background: var(--warn-bg);   color: var(--warn-fg); }
.chip--urgent { background: var(--urgent-bg); color: var(--urgent-fg); }

/* Very narrow phones: the subject keeps the room, badges shrink to a dot-sized label. */
@media (max-width: 380px) {
  .row__sender { max-width: 32%; }
  .badge { padding: 1px 4px; font-size: 10.5px; }
}

/* ---------- loading skeletons ---------- */

.skeletons { display: flex; flex-direction: column; gap: 1px; margin-top: 6px; }

.sk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 11px 4px;
  border-bottom: 1px solid var(--line-soft);
}

.sk { background: var(--bg-elev-2); border-radius: 6px; animation: pulse 1.5s ease-in-out infinite; }
.sk--line { height: 12px; flex: 0 1 auto; }
.sk--chip { width: 34px; height: 18px; border-radius: 999px; flex: none; margin-left: auto; }
.sk--w40 { width: 40%; } .sk--w55 { width: 55%; }
.sk--w65 { width: 65%; } .sk--w70 { width: 70%; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

@media (prefers-reduced-motion: reduce) {
  .sk, .iconbtn.is-busy .iconbtn__glyph { animation: none; }
  .btn:active { transform: none; }
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  z-index: 60;
  left: calc(12px + var(--sal));
  right: calc(12px + var(--sar));
  bottom: calc(14px + var(--sab));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent);
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  color: var(--text);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
}

.toast__text { flex: 1; font-size: 14px; }

.toast__close {
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- wider screens: stay a narrow, quiet column ---------- */

@media (min-width: 620px) {
  .topbar__row, .notices, .main { max-width: 680px; margin-inline: auto; }
  .toast { left: auto; right: calc(16px + var(--sar)); max-width: 420px; }
  .hero__count { font-size: 92px; }
  .row__link { padding: 12px 6px; }
}
