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

:root {
  --bg: #171009;
  --surface: #251a10;
  --border: #3a2a17;
  --accent: #f0a43e;
  --accent2: #10b981;
  --text: #f7f1e6;
  --muted: #a89a83;
  --gold: #f59e0b;
  --feed-h: calc(100vh - 60px);
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
}

/* ---- Stats Bar ---- */
#stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
}

.stat-num {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

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

.board-title {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--text);
  flex: 1;
}

/* ---- Main Layout ---- */
#main {
  display: grid;
  /* 60/40 split: globe | analytics | visitor wall */
  grid-template-columns: 60% 14% 26%;
  grid-template-rows: var(--feed-h);
  height: var(--feed-h);
  gap: 0;
}

/* ---- Globe ---- */
#globe-wrap {
  position: relative;
  overflow: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #241708 0%, var(--bg) 70%);
}

#globe-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#globe-label {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ---- Analytics ---- */
#analytics-wrap {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 20px 16px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  gap: 12px;
  overflow: hidden;
}

#analytics-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 4px;
}

#analytics-bars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.bar-row {
  display: grid;
  grid-template-columns: 28px 1fr 36px;
  align-items: center;
  gap: 8px;
}

.bar-flag {
  font-size: 1.2rem;
  text-align: center;
}

.bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease;
}

.bar-count {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
}

/* Today box */
#today-box {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 8px;
}

#today-num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent2);
}

#today-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* QR */
#qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: auto;
}

#qr-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

#qr-img {
  width: 160px;
  height: 160px;
  border-radius: 8px;
  background: white;
  padding: 6px;
}

#qr-url {
  font-size: 0.6rem;
  color: var(--muted);
  text-align: center;
}

#qr-link { display: block; line-height: 0; }
#qr-tap-hint { display: none; }

/* ---- Feed ---- */
#feed-wrap {
  display: flex;
  min-height: 0;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--border);
}

#feed-header {
  padding: 14px 16px 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#feed-list {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  animation: slideIn 0.5s ease;
  transition: opacity 0.3s;
}

.feed-item.new-highlight {
  background: rgba(240, 164, 62, 0.12);
  border-left: 3px solid var(--accent);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.feed-pen {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

.feed-flag {
  font-size: 1.7rem;
  flex-shrink: 0;
  line-height: 1;
}

.feed-flag img {
  width: 34px;
  height: 24px;
  object-fit: cover;
  border-radius: 2px;
}

.feed-info {
  flex: 1;
  min-width: 0;
}

.feed-name {
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-origin {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 1px;
}

.feed-greeting {
  font-size: 0.85rem;
  color: var(--accent2);
  margin-top: 2px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-time {
  font-size: 0.7rem;
  color: var(--muted);
  flex-shrink: 0;
  margin-top: 4px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 0 30px rgba(240, 164, 62, 0.3);
  z-index: 100;
  transition: opacity 0.5s;
}

.toast.hidden { opacity: 0; pointer-events: none; }

#toast-flag { font-size: 1.5rem; }

/* ---- Status dot ---- */
#status-dot {
  position: fixed;
  top: 14px;
  right: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent2);
  z-index: 200;
  transition: background 0.5s;
  box-shadow: 0 0 6px currentColor;
}

#status-dot.yellow { background: var(--gold); }
#status-dot.red    { background: #ef4444; }


/* ---- Phone layout: QR first, tappable, everything stacks ---- */
@media (max-width: 820px) {
  html, body { overflow: auto; }

  #stats-bar {
    height: auto;
    padding: 10px 14px;
    gap: 6px;
  }
  .board-title { font-size: 1rem; }
  .stat { min-width: 70px; }
  .stat-num { font-size: 1.3rem; }

  #main {
    display: flex;
    flex-direction: column;
    height: auto;
  }

  /* QR panel first */
  #analytics-wrap {
    order: 1;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 18px 16px 22px;
  }
  #qr-wrap {
    order: -1;
    margin-top: 0;
    margin-bottom: 18px;
  }
  #qr-img {
    width: min(62vw, 260px);
    height: auto;
  }
  #qr-label { font-size: 0.9rem; color: var(--text); }
  #qr-tap-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--accent);
    text-align: center;
    margin-top: 6px;
    font-weight: 600;
  }
  #today-box { justify-content: center; }
  #analytics-title { text-align: center; }
  .bar-row { max-width: 420px; margin: 0 auto; }

  /* Globe second, shorter */
  #globe-wrap {
    order: 2;
    height: 46vh;
    min-height: 280px;
  }

  /* Visitor wall third, natural height */
  #feed-wrap {
    order: 3;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  #feed-list { overflow: visible; }
}
