:root {
  --bg: #070a09;
  --bg2: #0c1210;
  --surface: rgba(12, 20, 17, 0.92);
  --text: #dce8e2;
  --muted: #7a9488;
  --line: rgba(88, 230, 200, 0.12);
  --accent: #58e6c8;
  --accent-dim: rgba(88, 230, 200, 0.35);
  --accent-glow: rgba(88, 230, 200, 0.08);
  --danger: #ff6b6b;
  --chrome-h: 36px;
  --top-h: 40px;
  --marquee-h: 28px;
  --font-sans: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --radius: 10px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.theme-light {
  --bg: #e8ece9;
  --bg2: #f4f6f5;
  --surface: rgba(255, 255, 255, 0.94);
  --text: #142018;
  --muted: #5a6b62;
  --line: rgba(20, 80, 60, 0.12);
  --accent: #0d9b7a;
  --accent-dim: rgba(13, 155, 122, 0.35);
  --accent-glow: rgba(13, 155, 122, 0.06);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
body.screen-fullscreen .top-chrome { opacity: 0; pointer-events: none; }
body.screen-fullscreen .marquee-band { opacity: 0; }
body.screen-fullscreen .desktop { inset: 0; }
body.hide-names .icon-label { opacity: 0; }
body.hide-gas [data-id="gas"] { display: none; }

.mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.02em; }
a { color: var(--accent); }

.boot {
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-content: center; gap: 16px;
  background: var(--bg);
  transition: opacity 0.6s ease, visibility 0.6s;
}
.boot.done { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-label { text-align: center; color: var(--accent); letter-spacing: 0.3em; }
.boot-bar {
  width: min(280px, 70vw); height: 3px; background: var(--line); border-radius: 99px; overflow: hidden;
}
.boot-bar span {
  display: block; height: 100%; width: 0; background: var(--accent);
  transition: width 0.15s linear;
}
.boot-sub { text-align: center; color: var(--muted); }

.marquee-band {
  position: fixed; left: 0; right: 0; z-index: 50;
  height: var(--marquee-h); overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
}
.marquee-brand { top: 0; opacity: 0.55; }
.marquee-tag { top: var(--marquee-h); border-bottom-width: 0; }
.marquee-track {
  display: flex; width: max-content;
  animation: marquee 22s linear infinite;
  white-space: nowrap;
}
.marquee-track.slow { animation-duration: 48s; }
.marquee-track span {
  padding: 0 24px; line-height: var(--marquee-h);
  font-family: var(--font-mono); font-size: 11px;
}
.marquee-brand span { color: var(--muted); font-weight: 500; letter-spacing: 0.08em; }
.marquee-tag span { color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.top-chrome {
  position: fixed; top: calc(var(--marquee-h) * 2); left: 0; right: 0; z-index: 60;
  height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; gap: 8px;
  background: rgba(7, 10, 9, 0.85);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  transition: opacity 0.3s;
}
.theme-light .top-chrome { background: rgba(244, 246, 245, 0.9); }
.top-left, .top-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.top-center { display: flex; align-items: center; gap: 12px; }
.desk-id { color: var(--muted); font-size: 10px; }
.copy-ca {
  background: none; border: 1px solid var(--line); color: var(--accent);
  padding: 4px 10px; border-radius: 99px; cursor: pointer; font-size: 10px;
}
.copy-ca.copied { color: var(--text); border-color: var(--accent); }
.pill {
  background: var(--accent-glow); border: 1px solid var(--line);
  color: var(--text); padding: 4px 10px; border-radius: 99px;
  cursor: pointer; font-size: 10px; transition: background 0.2s, color 0.2s;
}
.pill:hover, .pill.active { background: var(--accent-dim); color: var(--accent); }
.pill.subtle { background: transparent; color: var(--muted); }
.pill.subtle:hover { color: var(--text); }
#live-clock { color: var(--muted); min-width: 140px; text-align: right; }

.desktop {
  position: fixed;
  inset: calc(var(--marquee-h) * 2 + var(--top-h)) 0 24px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, var(--accent-glow), transparent 60%),
    linear-gradient(180deg, var(--bg2), var(--bg));
}
.desktop::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.4;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
}

.icon-dock {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 20;
}
.desk-icon {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 6px; border-radius: 8px; transition: background 0.2s, color 0.2s;
}
.desk-icon:hover { background: var(--accent-glow); color: var(--accent); }
.icon-eye {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--accent-dim);
  background: radial-gradient(circle at 35% 35%, var(--accent), transparent 55%);
  box-shadow: 0 0 16px var(--accent-glow);
}
.icon-label { font-family: var(--font-mono); font-size: 9px; text-transform: lowercase; }

.welcome-toast {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); z-index: 30;
  display: flex; align-items: center; gap: 8px;
}
.welcome-toast.hidden { display: none; }

.live-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s ease infinite;
}
.live-dot.big { width: 10px; height: 10px; margin-top: 8px; }
.live-dot.pulse { animation: pulse 1s ease infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.widget {
  position: absolute;
  left: var(--x); top: var(--y);
  width: var(--w); height: var(--h);
  min-width: 160px; min-height: 100px;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  z-index: 10;
  resize: both; overflow: hidden;
}
.widget.focused { z-index: 100; border-color: var(--accent-dim); }
.widget.minimized { height: var(--chrome-h) !important; resize: none; overflow: hidden; }
.widget.minimized .widget-body { display: none; }
.widget.dragging { opacity: 0.92; cursor: grabbing; }

.widget-chrome {
  height: var(--chrome-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  cursor: grab; user-select: none;
  background: rgba(0, 0, 0, 0.15);
}
.theme-light .widget-chrome { background: rgba(0, 0, 0, 0.03); }
.widget-chrome:active { cursor: grabbing; }
.traffic { display: flex; gap: 5px; }
.traffic span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--line);
}
.traffic span:nth-child(1) { background: #ff5f57; }
.traffic span:nth-child(2) { background: #febc2e; }
.traffic span:nth-child(3) { background: #28c840; }
.widget-title {
  flex: 1; font-family: var(--font-mono); font-size: 11px;
  text-transform: lowercase; color: var(--muted);
}
.widget-min {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px;
}
.widget-min:hover { color: var(--text); }

.widget-body {
  flex: 1; overflow: auto; padding: 12px;
  font-size: 12px; line-height: 1.55;
}
.widget-kicker { color: var(--accent); margin-bottom: 8px; font-size: 10px; }

.prose h2 { font-size: 14px; margin-bottom: 10px; color: var(--accent); }
.prose p { color: var(--muted); margin-bottom: 8px; font-size: 12px; line-height: 1.65; }

.scroll-log {
  max-height: 100%; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  font-size: 10px; line-height: 1.5; color: var(--muted);
}
.scroll-log p { margin: 0; }
.scroll-log .time { color: var(--accent); }

.changelog p { padding-bottom: 8px; border-bottom: 1px solid var(--line); }

.viz-status { color: var(--muted); margin-bottom: 8px; font-size: 10px; }
.viz-chart { width: 100%; height: 80px; margin-bottom: 10px; }
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px;
  font-size: 10px; color: var(--muted);
}
.stat-grid strong { display: block; color: var(--text); font-weight: 500; font-size: 13px; }
.viz-sub { font-size: 9px; color: var(--muted); margin-bottom: 6px; }
.viz-sub.token-head { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.token-list { font-size: 10px; line-height: 1.7; color: var(--muted); max-height: 88px; overflow-y: auto; }
.token-list span { color: var(--accent); }

.widget-3d { display: flex; flex-direction: column; padding: 8px !important; }
.widget-3d canvas { flex: 1; min-height: 160px; border-radius: 6px; background: #050807; cursor: grab; }
.widget-3d canvas:active { cursor: grabbing; }
.watchers-count { font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.controls-hint { font-size: 9px; color: var(--muted); margin-top: 6px; opacity: 0.7; }

.chatroom { display: flex; flex-direction: column; padding: 8px !important; }
.chat-msgs { flex: 1; overflow-y: auto; font-size: 10px; color: var(--muted); margin-bottom: 8px; }
.chat-msgs p { margin-bottom: 4px; }
.chat-msgs .who { color: var(--accent); }
.chat-form {
  display: flex; align-items: center; gap: 6px;
  border-top: 1px solid var(--line); padding-top: 8px;
}
.chat-form input {
  flex: 1; background: transparent; border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; color: var(--text);
  font-family: var(--font-mono); font-size: 10px;
}
.chat-form button {
  background: var(--accent-glow); border: 1px solid var(--line);
  color: var(--accent); padding: 6px 10px; border-radius: 6px;
  cursor: pointer; font-family: var(--font-mono); font-size: 10px;
}

.clock-face { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.clock-time { font-size: 28px; color: var(--accent); letter-spacing: 0.05em; }
.clock-date { color: var(--muted); margin-top: 4px; font-size: 10px; }

.weather-body { font-size: 10px; line-height: 1.6; color: var(--muted); }
.weather-body .temp { font-size: 22px; color: var(--text); margin-bottom: 4px; }

.confirm { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 10px; color: var(--muted); }

.radio-body { text-align: center; }
.radio-status { color: var(--muted); margin-bottom: 8px; font-size: 10px; }
.radio-controls { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; }
.radio-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--accent-glow);
  color: var(--text); cursor: pointer; font-size: 10px;
}
.radio-btn.big { width: 40px; height: 40px; color: var(--accent); }
.radio-track { font-size: 10px; color: var(--muted); }

.viz-foot { margin-top: 10px; font-size: 9px; color: var(--muted); opacity: 0.7; }

.gas-body { font-size: 10px; line-height: 1.65; color: var(--muted); }
.gas-body .gas-main { font-size: 22px; color: var(--text); margin-bottom: 6px; }
.gas-body .gas-tier { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid var(--line); }
.gas-body .gas-tier strong { color: var(--accent); font-weight: 500; }

.snitch-form h3 { font-size: 13px; color: var(--accent); margin-bottom: 8px; letter-spacing: 0.08em; }
.snitch-form p { font-size: 10px; color: var(--muted); margin-bottom: 8px; }
.snitch-tags { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; font-size: 10px; color: var(--muted); }
.snitch-tags label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.snitch-form textarea {
  width: 100%; background: transparent; border: 1px solid var(--line);
  border-radius: 6px; padding: 8px; color: var(--text);
  font-family: var(--font-mono); font-size: 10px; resize: vertical; margin-bottom: 8px;
}
.submit-snitch {
  width: 100%; padding: 8px; border-radius: 6px;
  border: 1px solid var(--accent-dim); background: var(--accent-glow);
  color: var(--accent); cursor: pointer;
}
.submit-snitch:hover { background: var(--accent-dim); }

.legal {
  position: fixed; bottom: 4px; left: 0; right: 0; text-align: center;
  font-size: 9px; color: var(--muted); opacity: 0.6; z-index: 5;
}

@media (max-width: 900px) {
  .top-right .pill.subtle { display: none; }
  .icon-dock { flex-direction: row; flex-wrap: wrap; right: 8px; top: auto; bottom: 8px; transform: none; max-width: 50%; }
  .widget { max-width: calc(100vw - 24px); }
}
