:root {
  --bg: #0b1220;
  --bg-2: #0f172a;
  --card: #131c30;
  --card-2: #18243d;
  --line: #243149;
  --ink: #e8eef7;
  --ink-2: #9fb0c8;
  --muted: #6b7c98;
  --accent: #2dd4bf;
  --accent-2: #14b8a6;
  --ig: #e1306c;
  --fb: #1877f2;
  --wa: #25d366;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #16223c 0%, var(--bg) 55%) fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12.5px; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px calc(14px);
  padding-top: calc(14px + env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(11, 18, 32, 0.92), rgba(11, 18, 32, 0.72));
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.35), 0 6px 16px rgba(20, 184, 166, 0.35);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 6px 6px auto 6px; height: 6px;
  border-radius: 99px; background: rgba(7, 18, 18, 0.55);
}
.brand-name { font-weight: 700; letter-spacing: 0.2px; font-size: 16px; }
.appbar-right { display: flex; align-items: center; gap: 12px; }
.today-total {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px;
  color: var(--ink); background: var(--card-2); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 99px;
}
.live {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--muted); text-transform: lowercase;
}
.live i { width: 8px; height: 8px; border-radius: 99px; background: var(--muted); display: inline-block; }
.live-on { color: var(--accent); }
.live-on i { background: var(--accent); box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.7); animation: pulse 1.8s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(45, 212, 191, 0); }
  100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0); }
}

/* ---------- Layout ---------- */
.wrap {
  max-width: 760px; margin: 0 auto; padding: 16px 14px 40px;
  display: flex; flex-direction: column; gap: 16px;
}
.card {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase; color: var(--ink-2); }

/* ---------- Map ---------- */
.map-card #map { height: 240px; width: 100%; background: #0d1526; }
.leaflet-container { background: #0d1526; font: inherit; }
.leaflet-control-attribution { background: rgba(11,18,32,0.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--ink-2) !important; }

/* ---------- Summary ---------- */
.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 4px 16px 16px; }
.app-card {
  border: 1px solid var(--line); border-radius: 13px; padding: 12px;
  background: var(--card-2); position: relative; overflow: hidden;
}
.app-card .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.app-card .name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.app-card .big { font-size: 22px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }
.app-card .sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.swatch { width: 9px; height: 9px; border-radius: 99px; flex: none; }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.evt {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 16px; border-top: 1px solid var(--line);
  animation: slidein 0.35s ease;
}
.evt:first-child { border-top: none; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.evt .rail { display: flex; flex-direction: column; align-items: center; padding-top: 3px; }
.evt .dot { width: 11px; height: 11px; border-radius: 99px; box-shadow: 0 0 0 3px rgba(255,255,255,0.04); }
.evt-main { flex: 1; min-width: 0; }
.evt-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.evt-app { font-weight: 700; font-size: 15px; }
.evt-time { color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; flex: none; }
.evt-sub { color: var(--ink-2); font-size: 12.5px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pill { padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; border: 1px solid var(--line); }
.pill.dur { color: var(--accent); border-color: rgba(45,212,191,0.3); background: rgba(45,212,191,0.08); }
.pill.open { color: #fbbf24; border-color: rgba(251,191,36,0.3); background: rgba(251,191,36,0.08); }
.pill.loc { color: var(--ink-2); cursor: pointer; }
.pill.loc:hover { color: var(--ink); }
.empty { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(900px 500px at 50% 0%, #16223c, var(--bg));
}
.gate-card {
  width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 26px 22px; box-shadow: var(--shadow); text-align: center;
}
.gate-card h1 { margin: 0 0 4px; font-size: 22px; }
.gate-card p { margin: 0 0 18px; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
.gate-card input, .gate-card button {
  width: 100%; padding: 13px 14px; border-radius: 12px; font-size: 15px; border: 1px solid var(--line);
}
.gate-card input { background: var(--bg-2); color: var(--ink); margin-bottom: 12px; }
.gate-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45,212,191,0.15); }
.gate-card button {
  background: linear-gradient(145deg, var(--accent), var(--accent-2)); color: #04211d;
  font-weight: 800; border: none; cursor: pointer; transition: transform 0.1s ease, filter 0.2s;
}
.gate-card button:active { transform: translateY(1px); }
.gate-card button:hover { filter: brightness(1.05); }
.gate-error { color: #fb7185; font-size: 12.5px; margin-top: 10px; min-height: 16px; }

.ghost-btn {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 99px; font-size: 11.5px; cursor: pointer;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--ink-2); }
