﻿:root,
.theme-dark {
  color-scheme: dark;
  --bg-main: #0b0e14;
  --bg-surface: rgba(22, 27, 34, 0.78);
  --bg-elevated: rgba(18, 24, 38, 0.82);
  --bg-muted: rgba(148, 163, 184, 0.10);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f0f6fc;
  --text-secondary: #c8d3df;
  --text-muted: #94a3b8;
  --accent: #00f3ff;
  --accent-soft: rgba(0, 243, 255, 0.12);
  --indigo: #6366f1;
  --amber: #f59e0b;
  --danger: #fb7185;
}

.theme-light {
  color-scheme: light;
  --bg-main: #f7f8fa;
  --bg-surface: rgba(255, 255, 255, 0.78);
  --bg-elevated: rgba(255, 255, 255, 0.92);
  --bg-muted: rgba(31, 35, 40, 0.06);
  --border-color: rgba(0, 0, 0, 0.08);
  --text-primary: #1f2328;
  --text-secondary: #475467;
  --text-muted: #667085;
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.12);
  --indigo: #4f46e5;
  --amber: #d97706;
  --danger: #e11d48;
}

* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body.low-gpu {
  transition: none;
}

.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.glass {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.24),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.08);
}

.glass::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  content: "";
  opacity: 0;
  transition: opacity 0.22s ease;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--accent) 16%, transparent);
}

.glass:hover::after {
  opacity: 1;
}

.theme-light .glass {
  box-shadow:
    0 10px 30px rgba(15, 23, 42, 0.06),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.4);
}

.bucket-tile {
  min-height: 118px;
  border-radius: 8px;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.stat-card,
.job-card,
.email-row,
.token-hud {
  transform: translateY(0);
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease, background-color 0.22s ease;
}

.stat-card {
  animation: fadeInUp 0.24s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.compact-panel summary::-webkit-details-marker {
  display: none;
}

.status-strip {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.stat-card:hover,
.email-row:hover,
.job-card:hover,
.token-hud:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border-color));
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 10%, transparent);
}

.metric-chip {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-muted);
  padding: 0.18rem 0.38rem;
}

.polling-dot {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent);
}

.status-badge {
  border-radius: 6px;
  padding: 0.18rem 0.42rem;
  background: var(--bg-muted);
}

.status-succeeded {
  color: #34d399;
}

.status-failed {
  color: var(--danger);
}

.status-retry {
  color: var(--amber);
}

.status-running,
.status-queued {
  color: var(--accent);
}

.bucket-tile:hover {
  transform: translateY(-2px) scale(1);
  border-color: color-mix(in srgb, var(--accent) 48%, transparent);
  box-shadow: 0 0 26px color-mix(in srgb, var(--accent) 16%, transparent);
}

.bucket-tile:active,
.pressable:active {
  transform: scale(0.97);
}

.neon-button {
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  background: linear-gradient(135deg, var(--indigo), color-mix(in srgb, var(--accent) 72%, var(--indigo)));
  box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 20%, transparent);
  color: white;
  background-size: 180% 180%;
}

.quiet-button {
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.neon-button,
.quiet-button,
.email-row,
.bucket-tile {
  outline: none;
}

.neon-button:focus-visible,
.quiet-button:focus-visible,
.email-row:focus-visible,
.bucket-tile:focus-visible,
.field:focus-visible {
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent),
    0 0 0 1px color-mix(in srgb, var(--accent) 60%, transparent);
}

.field {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 0.62rem 0.78rem;
  outline: none;
}

.field:focus {
  border-color: color-mix(in srgb, var(--accent) 72%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.priority-bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--text-muted) 18%, transparent);
}

.priority-bar--compact {
  height: 5px;
}

.priority-fill {
  position: relative;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #34d399, var(--accent), var(--amber));
}

.priority-fill::after {
  content: none;
}

.hud-meter {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 14%, transparent);
}

.hud-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--indigo));
  transition: width 0.28s ease;
}

[aria-busy="true"] {
  opacity: 0.74;
  transition: opacity 0.18s ease;
}

.htmx-request .priority-fill::after,
[aria-busy="true"] .priority-fill::after {
  animation-duration: 0.9s;
}

.skeleton {
  background: var(--bg-surface);
}

.low-gpu .glass {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}

.low-gpu .glass::after,
.low-gpu .priority-fill::after {
  content: none;
}

.low-gpu *,
.low-gpu *::before,
.low-gpu *::after {
  animation: none !important;
  transition-duration: 0.001ms !important;
}

.bottom-nav {
  padding-bottom: env(safe-area-inset-bottom);
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes livePulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent);
  }
  70% {
    box-shadow: 0 0 0 8px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@keyframes progressSheen {
  0% { transform: translateX(-120%); }
  55%, 100% { transform: translateX(120%); }
}

@keyframes buttonFlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}


.bucket-grid {
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
}

.sync-form {
  grid-template-columns: minmax(6rem, 1fr) auto;
  align-items: center;
}

.search-grid {
  grid-template-columns: minmax(14rem, 1.3fr) repeat(3, minmax(9rem, 0.75fr)) auto;
  align-items: center;
}

.email-detail-layout {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
}

.bucket-detail-layout {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.7fr);
}

.email-row {
  min-width: 0;
}

.email-row p,
.job-card p,
.stat-card p {
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 640px) {
  .desktop-only {
    display: none;
  }

  main {
    padding-bottom: 5.75rem;
  }

  .bucket-tile {
    min-height: 104px;
  }

  .email-row .w-28 {
    width: 5.5rem;
  }
}

@media (min-width: 641px) {
  .mobile-only {
    display: none;
  }
}
