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

:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --card-top: #fff7ee;
  --ink: #2b2620;
  --muted: #8a8177;
  --accent: #e8843c;
  --accent-dark: #c96a26;
  --line: #ece5da;
  --banner-bg: #fdf3e3;
  --banner-line: #f0ddb8;
  --banner-ink: #7a5c1e;
  --banner-code: #f7e8c8;
  --error-bg: #fdeaea;
  --error-line: #f2c4c4;
  --error-ink: #9b3535;
  --glow: rgba(232, 132, 60, 0.45);
}

[data-theme="dark"] {
  --bg: #101216;
  --card: #191c22;
  --card-top: #232028;
  --ink: #eceef2;
  --muted: #9298a4;
  --accent: #f08a42;
  --accent-dark: #ffa262;
  --line: #262b34;
  --banner-bg: #221f18;
  --banner-line: #3d3623;
  --banner-ink: #d9c084;
  --banner-code: #322c1d;
  --error-bg: #2b1a1a;
  --error-line: #52302f;
  --error-ink: #e89a9a;
  --glow: rgba(240, 138, 66, 0.4);
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  transition: background 0.25s ease, color 0.25s ease;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 46px;
  height: 58px;
  border-radius: 13px;
  background: linear-gradient(135deg, #f3c98a, var(--accent));
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Emilio's photo covers the letter when public/emilio.jpg exists.
   The photo is a tall phone screenshot — bias the square crop toward the
   upper part where the face is. */
.brand-mark img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
}

.brand h1 {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--muted);
  font-size: 0.85rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* --- scanning indicator ------------------------------------------------ */

.scan-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  white-space: nowrap;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.scan-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.2s;
}

.scan-indicator.active {
  color: #2e9e6b;
  border-color: rgba(46, 158, 107, 0.4);
}

.scan-indicator.active .dot {
  background: #2e9e6b;
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

/* --- X profile link -------------------------------------------------------- */

.x-link {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, transform 0.15s;
}

.x-link:hover {
  color: var(--ink);
  border-color: var(--muted);
  transform: translateY(-1px);
}

.x-link svg {
  width: 15px;
  height: 15px;
}

/* --- theme toggle (emoji slider switch) ---------------------------------- */

.theme-switch {
  position: relative;
  width: 54px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s ease;
}

.theme-switch:hover {
  border-color: var(--muted);
}

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.25s ease;
}

/* \FE0E forces the plain monochrome text glyph instead of the color emoji */
.switch-knob::after {
  content: "\2600\FE0E";
}

[data-theme="dark"] .switch-knob {
  transform: translateX(26px);
}

[data-theme="dark"] .switch-knob::after {
  content: "\263E\FE0E";
}

/* --- post button -------------------------------------------------------- */

.post-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent), #d9702a);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  padding: 12px 24px;
  border-radius: 999px;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: pulse-glow 2.8s ease-out infinite;
}


.post-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 18px var(--glow);
  animation-play-state: paused;
}

.post-btn:active {
  transform: translateY(0) scale(0.98);
}

/* soft ring that radiates outward, like a notification asking for attention */
@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 var(--glow); }
  60% { box-shadow: 0 0 0 12px rgba(232, 132, 60, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 132, 60, 0); }
}

/* periodic shine sweeping across the button */
.post-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -80%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    105deg,
    transparent,
    rgba(255, 255, 255, 0.35),
    transparent
  );
  animation: shine 3.6s ease-in-out infinite;
}

@keyframes shine {
  0%, 55% { left: -80%; }
  85%, 100% { left: 130%; }
}

@media (prefers-reduced-motion: reduce) {
  .post-btn { animation: none; }
  .post-btn::after { animation: none; display: none; }
  .scan-indicator.active .dot { animation: none; }
}

/* --- main layout --------------------------------------------------------- */

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* --- mission banner ------------------------------------------------------ */

.mission {
  position: relative;
  overflow: hidden;
  margin-bottom: 22px;
  padding: 24px 26px;
  border-radius: 16px;
  text-align: center;
  background: linear-gradient(
    135deg,
    rgba(232, 132, 60, 0.12),
    rgba(232, 132, 60, 0.03) 55%,
    rgba(232, 132, 60, 0.08)
  );
  border: 1px solid rgba(232, 132, 60, 0.35);
}

.mission-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-dark);
  margin-bottom: 7px;
}

.mission-text {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.mission-text .accent {
  color: var(--accent-dark);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .mission-text {
    font-size: 1.1rem;
  }
}

.statsbar {
  display: flex;
  gap: 14px;
  margin-bottom: 22px;
}

.stat-block {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  text-align: center;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 2px;
}

.last-scan {
  text-align: right;
  font-size: 0.78rem;
  color: var(--muted);
  margin: -12px 4px 14px;
}

.demo-banner {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--banner-bg);
  border: 1px solid var(--banner-line);
  color: var(--banner-ink);
  font-size: 0.88rem;
}

.demo-banner code {
  background: var(--banner-code);
  padding: 1px 5px;
  border-radius: 4px;
}

.early-banner {
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(232, 132, 60, 0.12), rgba(232, 132, 60, 0.04));
  border: 1px solid rgba(232, 132, 60, 0.35);
  color: var(--accent-dark);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
}

.status {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.status.error {
  background: var(--error-bg);
  border: 1px solid var(--error-line);
  color: var(--error-ink);
}

.hidden {
  display: none;
}

/* --- poster cards --------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 18px 18px;
  text-align: center;
  position: relative;
  transition: box-shadow 0.15s, transform 0.15s, background 0.25s ease,
    border-color 0.25s ease;
}

.card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.card .rank {
  position: absolute;
  top: 12px;
  left: 14px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--muted);
}

.card.top .rank {
  color: var(--accent-dark);
}

.card.top {
  border-color: rgba(232, 132, 60, 0.4);
  background: linear-gradient(180deg, var(--card-top), var(--card) 60%);
}

.avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin: 0 auto 10px;
  background: linear-gradient(135deg, #f3c98a, var(--accent));
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card .name {
  font-weight: 700;
  font-size: 0.98rem;
}

.card .handle {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 12px;
}

.followers {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.followers-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 12px;
}

.card .meta {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 0.78rem;
  color: var(--muted);
}

.card .meta strong {
  color: var(--ink);
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 50px 0;
  font-size: 0.95rem;
}

@media (max-width: 760px) {
  .topbar {
    padding: 12px 16px;
  }
  .tagline,
  .scan-indicator #scan-text {
    display: none;
  }
  .scan-indicator {
    padding: 7px 9px;
  }
  .statsbar {
    flex-direction: column;
  }
}
