:root{
  --bg:#0a0b10; --bg-soft:#0e1017; --card:#12141e; --card-soft:#171a25;
  --edge:#2b2f45; --edge-soft:#2a2e44; --txt:#e9ecf7; --muted:#9aa3ba;
  --accent:#ff924d; --accent-2:#ff4d4d; --ok:#2bc58e; --bad:#ff6b6b;
  --chip:#1a1e2c; --mono: ui-monospace,Menlo,Consolas,monospace;
}
body.light{
  --bg:#f6f7fb; --bg-soft:#ffffff; --card:#ffffff; --card-soft:#f3f5ff;
  --edge:#d9dcec; --edge-soft:#cfd5ef; --txt:#0e1320; --muted:#5a6277; --chip:#e8ecff;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;color:var(--txt);
  background:
    radial-gradient(1100px 520px at -15% -20%, rgba(255,77,77,.08), transparent),
    radial-gradient(1200px 600px at 120% 120%, rgba(255,146,77,.06), transparent),
    var(--bg);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  transition: background 200ms ease;
}

/* ===== Layout ===== */
.app{display:grid;grid-template-columns:280px 1fr;min-height:100%}

/* ===== Sidebar (desktop only) ===== */
.sidebar{
  background:linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01)), var(--bg-soft);
  border-right:1px solid var(--edge);
  padding:14px 12px;
  position:sticky; top:0;
  height:100vh; overflow:auto;
  transition: width .2s ease, transform .2s ease;
}
.sidebar.collapsed { width:72px; }
.sidebar.collapsed .brand h2 { display:none; }
.sidebar.collapsed .nav a { white-space:nowrap; overflow:hidden; text-overflow:clip; }

.brand{display:flex;align-items:center;gap:12px;padding:8px 10px;margin-bottom:8px}
.logo-box{
  width:28px;height:28px;display:grid;place-items:center;border-radius:8px;
  background:linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow:0 6px 20px rgba(255,146,77,.35)
}
/* square logo img baseline (kept for fallback) */
.logo-img{width:100%;height:100%;object-fit:contain;border-radius:6px;display:block}
.logo-fallback{color:#000;font-weight:900;font-size:14px;letter-spacing:.4px}
.brand h2{margin:0;font-size:18px;letter-spacing:.2px}

.sectionTitle{color:var(--muted);font-size:12px;letter-spacing:.4px;margin:18px 10px 8px}
.nav{display:flex;flex-direction:column;gap:6px}
.nav a{
  display:flex;align-items:center;gap:10px;padding:10px 12px;margin:0 6px;border-radius:12px;
  color:var(--txt);text-decoration:none;border:1px solid transparent;background:transparent;
}
.nav a.active,.nav a:hover{background:var(--card-soft);border-color:var(--edge-soft)}
.nav a.active{box-shadow:inset 2px 0 0 var(--accent)}

/* ===== Content ===== */
.content{min-width:0}

/* ===== Topbar ===== */
.topbar{
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(10,11,16,.6);
  backdrop-filter: saturate(120%) blur(6px);
  border-bottom: 1px solid var(--edge);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
}
body.light .topbar{ background:rgba(255,255,255,.7) }

/* Stronger, non-grey topbar on phones (no blur translucency on iOS) */
@media (max-width:1100px){
  .topbar{ background: var(--bg-soft); backdrop-filter:none }
}

.topactions{margin-left:auto;display:flex;gap:8px;align-items:center}

/* Phone-first: show brand in TOPBAR */
.topbar .topbrand{
  display:flex; align-items:center; gap:10px; text-decoration:none; color:inherit;
}

/* ===== Buttons / Pills ===== */
.pill{padding:8px 12px;border-radius:999px;border:1px solid var(--edge);background:#1619250f;color:#cfe0ff;font-weight:600}
body.light .pill{ color:#1a2a44; background:#e9eeff }
.btn{
  padding:8px 12px;border-radius:10px;border:1px solid var(--edge);
  background:linear-gradient(180deg,rgba(255,255,255,.05),rgba(0,0,0,.08));
  color:inherit;font-weight:600;cursor:pointer
}
.btn:hover{border-color:var(--accent)}
.btn.ghost{background:transparent}
.me{max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.btn.connected{ border-color:var(--ok); color:var(--ok) }
#btnKeplrTop.connected::before{
  content:"";width:8px;height:8px;border-radius:50%;background:var(--ok);
  display:inline-block;margin-right:6px;vertical-align:middle
}

/* ===== Cards / Misc ===== */
.wrap{width:min(1280px,100%);margin:0 auto;padding:18px 18px 28px}
.card{
  background:linear-gradient(180deg,rgba(255,255,255,.02),rgba(255,255,255,.01));
  border:1px solid var(--edge);border-radius:16px;padding:14px;box-shadow:0 18px 50px rgba(0,0,0,.45)
}
body.light .card{ box-shadow:0 28px 60px rgba(10,18,60,.08) }
.mono{font-family:var(--mono)} .muted{color:var(--muted)}
.status{position:fixed;right:14px;bottom:14px;display:flex;flex-direction:column;gap:8px;z-index:3500}
.toast{background:#0b0f26;border:1px solid #26305c;padding:10px 12px;border-radius:12px;font-size:13px}
.hidden{display:none}

/* ===== Mobile layout ===== */
@media (max-width:1100px){
  .app{grid-template-columns:1fr}
  .sidebar{display:none !important}
}

/* ===== Topics Drawer (mobile) ===== */
.topicsBtn{
  display:none; padding:8px 10px; border-radius:10px; border:1px solid var(--edge);
  background:linear-gradient(180deg,rgba(255,255,255,.05),rgba(0,0,0,.06));
}
@media (max-width:1100px){ .topicsBtn{ display:inline-flex; align-items:center; gap:8px } }

.topicsBackdrop{
  position:fixed; inset:0; background:rgba(0,0,0,.35);
  opacity:0; pointer-events:none; transition:opacity .15s ease; z-index:30;
}
.topicsBackdrop.show{ opacity:1; pointer-events:auto }

.topicsMenu{
  position:fixed; right:12px; top:58px; z-index:31;
  width:min(92vw, 480px);
  max-height:70vh; overflow:auto;
  border:1px solid var(--edge); border-radius:14px;
  background:var(--bg-soft);
  box-shadow:0 10px 30px rgba(0,0,0,.35);
  transform:translateY(-6px); opacity:0; pointer-events:none;
  transition:transform .16s ease, opacity .16s ease;
}
.topicsMenu.show{ transform:translateY(0); opacity:1; pointer-events:auto }
.topicsMenu .tm-head{
  padding:10px 12px; border-bottom:1px solid var(--edge);
  display:flex; justify-content:space-between; align-items:center;
}
.topicsMenu .tm-body{ padding:10px 12px; display:grid; gap:14px }
.topicsMenu .tm-title{ font-size:11px; color:var(--muted); margin-bottom:6px; }
.topicsMenu .tm-links{ display:grid; gap:6px }
.topicsMenu .tm-links a{
  display:flex; align-items:center; gap:10px;
  padding:10px 12px; border:1px solid var(--edge); border-radius:10px;
  text-decoration:none; color:inherit; background:rgba(255,255,255,.02);
}
.topicsMenu .tm-links a.active{
  border-color:var(--accent);
  box-shadow:0 0 0 1px var(--accent) inset;
}

/* (legacy) toplinks hidden now; all navigation via sidebar or topics menu */
.toplinks{ display:none !important; }

/* ===== ONE BRAND AT A TIME ===== */
/* Phone (<1100px): show brand in TOPBAR, hide in SIDEBAR (safe guard) */
@media (max-width:1099.98px){
  .topbar .topbrand{ display:flex !important; }
  .sidebar .brand{ display:none !important; } /* sidebar already hidden but explicit */
}

/* Desktop (≥1100px): hide brand in TOPBAR, show in SIDEBAR */
@media (min-width:1100px){
  .topbar .topbrand{ display:none !important; }
  .sidebar .brand{ display:flex !important; }
}

/* Ensure actions stay right-aligned regardless of brand visibility */
.topbar .topactions{ margin-left:auto; }

/* =========================================================
   THEME-AWARE WIDE TIMPI LOGOS + CONSISTENT SIDEBAR LABELS
   ========================================================= */

/* Show correct wide logo per theme (we replace the default square look) */
.logo-img { display:none; height:auto; }
body:not(.light) .logo-dark  { display:block; }
body.light .logo-light       { display:block; }

/* Wide banner container (override small square styling) */
.logo-box.wide { background:none; box-shadow:none; }
.sidebar .logo-box.wide { width:100%; max-width:190px; }
.sidebar .logo-box.wide .logo-img { width:100%; border-radius:10px; }

/* Topbar banner sizing */
.topbar .logo-box.wide { max-width:170px; }
.topbar .logo-box.wide .logo-img { width:100%; border-radius:10px; }

/* Keep sidebar item text size consistent (fixes Stake shrinking) */
.nav a .label,
.nav a.active .label{
  font-size:14px;
  line-height:1.2;
  font-weight:500;
  letter-spacing:.2px;
}

/* Optional: subtle accent outline on active nav (keeps existing inset bar) */
.nav a.active{
  box-shadow:
    inset 2px 0 0 var(--accent),
    0 0 0 2px color-mix(in oklab, var(--accent) 20%, transparent);
}

/* Completely remove wallet address pill from topbar */
#me{
  display: none !important;
}

/* =========================
   Sidebar must NOT inherit .card spacing
   ========================= */

.sidebar .card{
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  border: 0 !important;
}

/* =========================
   NEW TOPBAR UI (Search + icon buttons)
   ========================= */

.topbar{
  gap: 12px;
}

.topbarLeft{
  display:flex;
  align-items:center;
  gap:12px;
  min-width: 260px;
  flex: 1 1 520px;
}

.topSearch{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border-radius:14px;
  border:1px solid var(--edge);
  background: color-mix(in oklab, var(--bg-soft) 80%, transparent);
  box-shadow: 0 10px 26px rgba(0,0,0,.10);
  min-width: 260px;
  max-width: 720px;
  flex: 1 1 auto;
}

body.light .topSearch{
  box-shadow: 0 14px 34px rgba(10,18,60,.06);
}

.topSearch .sicon{
  width:18px;
  height:18px;
  opacity:.8;
  flex: 0 0 auto;
}

.topSearch input{
  border:0;
  outline:none;
  background:transparent;
  color:var(--txt);
  width:100%;
  font-size:14px;
  line-height:1.2;
}

.topSearch input::placeholder{
  color: color-mix(in oklab, var(--muted) 80%, transparent);
}

.topSearch .slashHint{
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: rgba(255,255,255,.02);
  color: var(--muted);
  user-select:none;
}

.topbarRight{
  display:flex;
  align-items:center;
  gap:10px;
  flex: 0 0 auto;
}

.iconBtn{
  width:38px;
  height:38px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  border:1px solid var(--edge);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.08));
  color: inherit;
  cursor:pointer;
}

.iconBtn:hover{ border-color: var(--edge-soft); }
.iconBtn svg{ width:18px; height:18px; opacity:.9; }

.iconBtn.connected{
  border-color: rgba(43,197,142,.55);
  box-shadow: 0 0 0 2px rgba(43,197,142,.15) inset;
}

@media (max-width:560px){
  .topSearch{ min-width: 0; }
  .topbarLeft{ min-width: 0; }
}

