:root {
  --gold: #d4a017;
  --purple: #7c3aed;
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #1c1c1c;
  --line: #2a2a2a;
  --text: #f5f5f5;
  --muted: #8a8a8a;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior: none;
}

#app { display: flex; flex-direction: column; min-height: 100vh; max-width: 720px; margin: 0 auto; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 18px 14px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(10,10,10,.82); backdrop-filter: blur(14px); z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  font-weight: 800; font-size: 22px; letter-spacing: -1px;
  color: var(--gold); background: #000; width: 40px; height: 40px;
  display: grid; place-items: center; border-radius: 11px; border: 1px solid var(--line);
}
.logo .w { color: var(--purple); }
.brand h1 { font-size: 16px; font-weight: 700; letter-spacing: -.3px; }
.status { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status[data-state="online"]::before { background: #34d399; box-shadow: 0 0 8px #34d399; }
.status[data-state="local"]::before { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.status[data-state="offline"]::before { background: #ef4444; }

.voice-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); display: grid; place-items: center;
  cursor: pointer; transition: .2s; flex-shrink: 0;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.voice-btn.enabled { color: var(--gold); border-color: var(--gold); }
.voice-btn:active { transform: scale(.92); }
.voice-btn.listening {
  background: linear-gradient(135deg, var(--gold), var(--purple));
  color: #000; border-color: transparent; animation: pulse 1.3s infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(124,58,237,.5); } 50% { box-shadow: 0 0 0 12px rgba(124,58,237,0); } }

/* Views */
.view { display: none; flex: 1; padding: 18px; padding-bottom: calc(86px + var(--safe-bottom)); }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero { margin-bottom: 20px; }
.hero h2 { font-size: 26px; font-weight: 800; letter-spacing: -.6px; }
.hero h2::after { content: ""; display: block; width: 46px; height: 3px; margin-top: 8px;
  background: linear-gradient(90deg, var(--gold), var(--purple)); border-radius: 2px; }
.hero p { color: var(--muted); margin-top: 10px; font-size: 14px; }

/* Grid + cards */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h3 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.badge { font-size: 12px; font-weight: 700; color: var(--gold); background: rgba(212,160,23,.12);
  padding: 2px 9px; border-radius: 20px; min-width: 22px; text-align: center; }
.list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.list li { font-size: 14px; line-height: 1.4; padding-left: 14px; position: relative; }
.list li:not(.muted)::before { content: ""; position: absolute; left: 0; top: 7px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--purple); }
.list li b { color: var(--text); }
.list li small { color: var(--muted); display: block; font-size: 12px; margin-top: 2px; }
.muted { color: var(--muted); font-size: 13px; }

.world { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.world .temp { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.world .news { flex: 1; min-width: 180px; font-size: 13px; color: var(--muted); line-height: 1.5; }

/* Chat */
#view-chat { display: none; flex-direction: column; }
#view-chat.active { display: flex; }
.chat { flex: 1; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding-bottom: 12px; }
.msg { max-width: 82%; padding: 11px 15px; border-radius: 16px; font-size: 15px; line-height: 1.45; }
.msg.bot { background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; align-self: flex-start; }
.msg.me { background: linear-gradient(135deg, var(--gold), var(--purple)); color: #000; font-weight: 500;
  border-bottom-right-radius: 5px; align-self: flex-end; }
.composer { display: flex; gap: 10px; position: sticky; bottom: calc(82px + var(--safe-bottom)); padding-top: 8px; }
.composer input { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 24px;
  padding: 13px 18px; color: var(--text); font-size: 15px; outline: none; }
.composer input:focus { border-color: var(--purple); }
.composer button { width: 48px; border: none; border-radius: 50%; font-size: 18px; cursor: pointer;
  background: linear-gradient(135deg, var(--gold), var(--purple)); color: #000; }

/* Tabbar */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 720px;
  display: flex; border-top: 1px solid var(--line); background: rgba(10,10,10,.92); backdrop-filter: blur(14px);
  padding-bottom: var(--safe-bottom);
}
.tab { flex: 1; background: none; border: none; color: var(--muted); padding: 11px 0 9px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; cursor: pointer; }
.tab.active { color: var(--gold); }
.tab.active svg { filter: drop-shadow(0 0 6px rgba(212,160,23,.4)); }
