:root{
  --bg0:#070A12; --bg1:#0B1020;
  --card:rgba(255,255,255,.06); --card2:rgba(255,255,255,.08);
  --stroke:rgba(255,255,255,.14); --stroke2:rgba(255,255,255,.10);
  --text:rgba(255,255,255,.92); --muted:rgba(255,255,255,.68); --muted2:rgba(255,255,255,.55);
  --shadow:0 14px 40px rgba(0,0,0,.35);
  --radius:18px; --radius2:14px;
  --accent:#8A7CFF; --accent2:#38D6B0;
  --focus:0 0 0 3px rgba(138,124,255,.28);
  --max:980px; --gap:14px;
}
html[data-theme="light"]{
  --bg0:#F7F8FF; --bg1:#EFF1FF;
  --card:rgba(0,0,0,.04); --card2:rgba(0,0,0,.06);
  --stroke:rgba(0,0,0,.10); --stroke2:rgba(0,0,0,.08);
  --text:rgba(0,0,0,.88); --muted:rgba(0,0,0,.62); --muted2:rgba(0,0,0,.52);
  --shadow:0 14px 40px rgba(0,0,0,.12);
  --focus:0 0 0 3px rgba(138,124,255,.22);
}

*{box-sizing:border-box}

/* === PATCH WEBVIEW: sfondo opaco sempre, niente “bianco dietro” === */
html,body{
  height:100%;
  margin:0;
  background-color: var(--bg0);
  -webkit-text-size-adjust: 100%;
}

body{
  min-height:100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color:var(--text);
  background:
    radial-gradient(1200px 650px at 20% -10%, rgba(138,124,255,.35), transparent 55%),
    radial-gradient(900px 600px at 90% 0%, rgba(56,214,176,.20), transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1)),
    var(--bg1); /* fallback solido */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

a{color:inherit; text-decoration:none}
button{font:inherit}

.wrap{max-width:var(--max); margin:0 auto; padding:18px 16px 28px; display:grid; gap:16px}

.topbar{display:flex; align-items:center; justify-content:space-between; gap:12px}
.brand{display:flex; align-items:center; gap:10px; min-width:0}
.logo{
  width:38px; height:38px; border-radius:14px;
  background: linear-gradient(135deg, rgba(138,124,255,.95), rgba(56,214,176,.75));
  box-shadow:var(--shadow);
  border:1px solid rgba(255,255,255,.10);
}
.brandText{display:flex; flex-direction:column; line-height:1.1; min-width:0}
.brandText strong{font-size:15px; letter-spacing:.2px}
.brandText span{font-size:12.5px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}

.topActions{display:flex; gap:10px; align-items:center}
.iconBtn{
  border:1px solid var(--stroke);
  background:var(--card);
  border-radius:14px;
  padding:10px 12px;
  box-shadow:var(--shadow);
  cursor:pointer;
  display:flex; align-items:center; gap:10px;
  transition: transform .08s ease, background .18s ease, border-color .18s ease;
}
.iconBtn:hover{border-color:var(--stroke2); background:var(--card2)}
.iconBtn:active{transform:scale(.98)}
.icon{width:18px; height:18px; display:inline-block}
.iconLabel{font-size:12.5px; color:var(--muted)}

.card{
  border:1px solid var(--stroke);
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
}
.cardHeader{padding:16px 16px 10px; display:flex; align-items:flex-end; justify-content:space-between; gap:12px}
.cardHeader h2{margin:0; font-size:14px; letter-spacing:.22px; text-transform:uppercase; color:var(--muted)}
.hint{font-size:12.5px; color:var(--muted2)}
.cardBody{padding:0 16px 16px}

.searchBox{display:flex; gap:10px; align-items:center; padding:14px}
.searchInput{
  flex:1; min-width:0;
  border:1px solid var(--stroke);
  background:transparent;
  color:var(--text);
  padding:12px 14px;
  border-radius:14px;
  outline:none;
}
html[data-theme="light"] .searchInput{background:rgba(255,255,255,.45)}
.searchInput:focus{box-shadow:var(--focus); border-color: rgba(138,124,255,.55)}
.searchGo{
  border:1px solid rgba(138,124,255,.40);
  background:linear-gradient(135deg, rgba(138,124,255,.95), rgba(138,124,255,.55));
  color:#fff;
  padding:12px 14px;
  border-radius:14px;
  cursor:pointer;
  white-space:nowrap;
}

/* ====== TABS / PANELS (mancavano nel css “brutto”) ====== */
.tabs{display:flex; gap:10px; flex-wrap:wrap; margin:6px 0 14px}
.tab{
  border:1px solid var(--stroke);
  background:transparent;
  color:var(--text);
  padding:10px 12px;
  border-radius:999px;
  cursor:pointer;
}
html[data-theme="light"] .tab{background:rgba(255,255,255,.35)}
.tab.isActive{border-color: rgba(138,124,255,.45); box-shadow:var(--focus)}

.panel{display:none}
.panel.isActive{display:block}

.rangeRow{display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:12px}
.pill{
  border:1px solid var(--stroke);
  background:transparent;
  color:var(--text);
  padding:8px 10px;
  border-radius:999px;
  cursor:pointer;
  font-size:12.5px;
}
html[data-theme="light"] .pill{background:rgba(255,255,255,.35)}
.pill.isActive{border-color: rgba(56,214,176,.45); box-shadow:0 0 0 3px rgba(56,214,176,.18)}
.miniHint{color:var(--muted2); font-size:12.5px; margin-left:auto}

.topsites{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}
@media (max-width:520px){ .topsites{grid-template-columns:1fr} }

.site{
  border:1px solid var(--stroke);
  background:transparent;
  border-radius:var(--radius2);
  padding:12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  cursor:pointer;
  transition: transform .08s ease, background .18s ease, border-color .18s ease;
}
html[data-theme="light"] .site{background:rgba(255,255,255,.30)}
.site:hover{border-color:var(--stroke2); background:var(--card2)}
.site:active{transform:scale(.99)}
.site .left{display:flex; align-items:center; gap:10px; min-width:0}
.fav{
  width:28px; height:28px;
  border-radius:10px;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.06);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
  flex:0 0 auto;
}
.fav img{width:100%; height:100%; object-fit:cover}
.name{display:flex; flex-direction:column; min-width:0}
.name strong{font-size:13.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.name span{font-size:12px; color:var(--muted2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.badge{
  font-size:12px;
  color:var(--muted);
  border:1px solid var(--stroke);
  padding:6px 10px;
  border-radius:999px;
  flex:0 0 auto;
}

.list{display:grid; gap:10px; margin-top:8px}
.step{
  border:1px solid var(--stroke);
  background:transparent;
  border-radius:var(--radius2);
  padding:12px;
}
html[data-theme="light"] .step{background:rgba(255,255,255,.30)}

details{
  border:1px solid var(--stroke);
  border-radius:var(--radius2);
  padding:10px 12px;
  background:transparent;
}
html[data-theme="light"] details{background:rgba(255,255,255,.30)}
summary{cursor:pointer; font-weight:600}
details p{margin:10px 0 2px; color:var(--muted); font-size:13.5px; line-height:1.35}

/* Utility bits */
.toolsRow{display:flex; gap:10px; flex-wrap:wrap; margin-top:12px}
.ghostBtn{
  border:1px solid var(--stroke);
  background:transparent;
  color:var(--text);
  padding:10px 12px;
  border-radius:14px;
  cursor:pointer;
}
html[data-theme="light"] .ghostBtn{background:rgba(255,255,255,.35)}
.ghostBtn:hover{background:var(--card2); border-color:var(--stroke2)}
.microNote{color:var(--muted2); font-size:12.5px; margin:12px 2px 0}

.footer{text-align:center; color:var(--muted2); font-size:12.5px; padding:6px 0 2px}
