:root{
  --bg:linear-gradient(145deg,#efe9ff,#f7ecff,#eefcff);
  --card:#ffffff;
  --title:#3b3b98;
  --shadow:0 14px 28px rgba(120,120,200,.18);
  --line:rgba(80,80,140,.14);
  --text:#4b5563;
  --btn1:linear-gradient(135deg,#8ec5fc,#c7d2fe);
  --btn2:linear-gradient(135deg,#ffd6a5,#ffb4b4);
  --btn3:linear-gradient(135deg,#b5f5d1,#7dd3fc);
  --btn4:linear-gradient(135deg,#c3f0ff,#fbcfe8);
  --btn5:linear-gradient(135deg,#e0e7ff,#d4f1f9);
  --ok:#13b26b;
  --warn:#ff9a1f;
  --bad:#ef4444;
}

*{box-sizing:border-box}
[hidden]{display:none !important}
body{
  margin:0;
  font-family:Inter,system-ui,sans-serif;
  background:var(--bg);
  padding:16px;
  color:#0f172a;
}

.shell{max-width:1300px;margin:auto}
.theme-page{padding-bottom:32px}

.utility-bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom:10px;
}

.back-link{
  display:inline-block;
  margin:10px 0;
  font-weight:700;
  color:#555;
  text-decoration:none;
}

.utility-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}

.mini-btn,.main-btn,.sub-btn,.card-btn{
  appearance:none;
  border:none;
  border-radius:14px;
  padding:10px 14px;
  font:700 13px/1 Inter,system-ui,sans-serif;
  cursor:pointer;
  text-decoration:none;
  transition:transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.mini-btn:hover,.main-btn:hover,.sub-btn:hover,.card-btn:hover{transform:translateY(-1px)}
.mini-btn:disabled,.main-btn:disabled,.sub-btn:disabled,.card-btn:disabled{opacity:.45;cursor:not-allowed;transform:none}

.mini-btn,.sub-btn{
  background:#fff;
  color:#374151;
  border:1px solid var(--line);
}

.connect-btn,.main-btn{
  background:var(--btn1);
  color:#263238;
  box-shadow:0 8px 18px rgba(0,0,0,.08);
}

.driver-btn{
  background:var(--btn2);
  color:#263238;
  border:none;
  box-shadow:0 8px 18px rgba(0,0,0,.08);
}

.mini-status{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding:10px 14px;
  border-radius:999px;
  background:#fff;
  border:1px solid var(--line);
  font-weight:700;
  color:#334155;
  font-size:13px;
}

.status-dot{
  width:10px;
  height:10px;
  border-radius:50%;
  background:#94a3b8;
  box-shadow:0 0 0 6px rgba(148,163,184,.18);
}

.mini-status.connected .status-dot{
  background:var(--ok);
  box-shadow:0 0 0 6px rgba(19,178,107,.18);
}

.mini-status.connecting .status-dot{
  background:var(--warn);
  box-shadow:0 0 0 6px rgba(255,154,31,.18);
}

.mini-status.disconnected .status-dot{
  background:var(--bad);
  box-shadow:0 0 0 6px rgba(239,68,68,.18);
}

.page-header{
  text-align:center;
  margin-bottom:14px;
}

.logo-round{
  width:72px;
  height:72px;
  border-radius:50%;
  background:linear-gradient(135deg,#fbc2eb,#a6c1ee);
  margin:8px auto;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow:0 10px 22px rgba(120,120,200,.25);
}

.logo-swap{font-size:34px}

.page-header h1{
  margin:0;
  font-size:1.6rem;
  font-weight:800;
  color:var(--title);
}

.page-header p{
  margin:4px auto 0;
  max-width:720px;
  font-size:13px;
  color:#555;
}

.empty-state{
  background:#fff;
  border-radius:26px;
  padding:20px;
  box-shadow:var(--shadow);
}

.theme-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:14px;
}

.theme-card{
  background:var(--card);
  border-radius:24px;
  padding:12px;
  box-shadow:var(--shadow);
  display:flex;
  flex-direction:column;
  gap:10px;
}

.theme-media{
  aspect-ratio:4/5;
  border-radius:18px;
  overflow:hidden;
  padding:10px;
  position:relative;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.screen-shell{
  position:relative;
  border-radius:16px;
  overflow:hidden;
  flex:1;
  background:linear-gradient(145deg,var(--bg1),var(--bg2));
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.12);
}

.screen-base,
.screen-bg-slide,
.screen-center-icon,
.screen-text,
.screen-clock{
  position:absolute;
}

.screen-base{
  inset:0;
  background:linear-gradient(145deg,var(--bg1),var(--bg2));
}

.screen-bg-slide{
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  opacity:0;
  transition:opacity .28s ease;
}

.screen-bg-slide.active{
  opacity:1;
}

.screen-center-stage{
  position:absolute;
  inset:0;
}

.screen-center-icon{
  left:50%;
  top:47%;
  transform:translate(-50%,-50%) scale(.96);
  width:var(--icon-size,60%);
  max-height:var(--icon-size,60%);
  object-fit:contain;
  filter:drop-shadow(0 10px 16px rgba(0,0,0,.28));
  opacity:0;
  transition:opacity .35s ease, transform .35s ease;
}

.screen-center-icon.active{
  opacity:1;
  transform:translate(-50%,-50%) scale(1);
}

.screen-nav{
  position:absolute;
  top:50%;
  transform:translateY(-50%);
  width:22px;
  height:22px;
  border:none;
  border-radius:999px;
  background:rgba(15,23,42,.5);
  color:#f8fafc;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:16px;
  cursor:pointer;
  opacity:0;
  transition:opacity .2s ease, transform .2s ease, background .2s ease;
  z-index:4;
}

.screen-nav-prev{
  left:8px;
}

.screen-nav-next{
  right:8px;
}

.screen-shell:hover .screen-nav{
  opacity:1;
}

.screen-nav:hover{
  background:rgba(15,23,42,.72);
  transform:translateY(-50%) scale(1.04);
}

.screen-clock{
  top:10px;
  left:50%;
  transform:translateX(-50%);
  border-radius:10px;
  padding:3px 10px;
  background:rgba(15,23,42,.5);
  color:#f8fafc;
  font-weight:800;
  font-size:12px;
  letter-spacing:.02em;
}

.screen-text{
  left:14px;
  right:14px;
  bottom:14px;
  font-size:11px;
  font-weight:800;
  line-height:1.25;
  text-align:center;
  text-shadow:0 3px 10px rgba(0,0,0,.5);
}

.screen-size{
  text-align:center;
  font-size:12px;
  font-weight:700;
  color:#64748b;
  letter-spacing:.03em;
}

.theme-title{
  margin:0;
  color:#20294f;
  font-size:.95rem;
  line-height:1.2;
  font-weight:800;
}

.theme-meta{
  font-size:12px;
  color:#9a6700;
  font-weight:700;
}

.theme-desc{
  color:var(--text);
  font-size:11px;
  line-height:1.45;
  min-height:30px;
}

.select-row{
  display:flex;
  gap:10px;
  align-items:center;
}

.select-row select,
.wakeword-row select{
  width:100%;
  padding:11px 12px;
  border-radius:14px;
  border:1px solid var(--line);
  background:#fff;
  font:600 13px/1.2 Inter,system-ui,sans-serif;
}

.wakeword-row{
  display:flex;
  align-items:center;
  gap:10px;
  position:relative;
  margin-bottom:8px;
}

.wakeword-label{
  white-space:nowrap;
  margin:0;
}

.wakeword-row select{
  appearance:none;
  -webkit-appearance:none;
  -moz-appearance:none;
  padding:10px 40px 10px 14px;
  border-radius:999px;
  border:1px solid rgba(148,163,184,.35);
  background:
    linear-gradient(180deg,#ffffff,#f8fbff);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.9),
    0 6px 12px rgba(148,163,184,.14);
  color:#0f172a;
  font-weight:700;
  font-size:12px;
  letter-spacing:.01em;
  transition:border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.wakeword-row::after{
  content:"⌄";
  position:absolute;
  right:14px;
  top:50%;
  transform:translateY(-48%);
  color:#334155;
  font-size:18px;
  line-height:1;
  pointer-events:none;
}

.wakeword-row select:hover{
  border-color:rgba(99,102,241,.35);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.92),
    0 10px 18px rgba(99,102,241,.14);
}

.wakeword-row select:focus{
  outline:none;
  border-color:rgba(99,102,241,.6);
  box-shadow:
    0 0 0 3px rgba(99,102,241,.14),
    0 10px 20px rgba(99,102,241,.2);
}

.card-btn{
  width:100%;
  background:var(--btn3);
  color:#0f172a;
  box-shadow:0 10px 18px rgba(0,0,0,.08);
  margin-top:2px;
}

.card-btn.flash-ready{background:var(--btn2)}

.flash-modal{
  position:fixed;
  inset:0;
  z-index:9999;
  display:grid;
  place-items:center;
}

.compat-modal{
  position:fixed;
  inset:0;
  z-index:9998;
  display:grid;
  place-items:center;
}

.compat-dialog{
  position:relative;
  z-index:1;
  width:min(92vw,560px);
  border-radius:28px;
  background:#ffffff;
  color:#0f172a;
  border:1px solid rgba(148,163,184,.32);
  box-shadow:0 24px 64px rgba(15,23,42,.35);
  padding:22px 22px 18px;
}

.compat-top{
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:10px;
  text-align:center;
}

.compat-model-image{
  width:120px;
  height:120px;
  border-radius:22px;
  object-fit:cover;
  border:1px solid rgba(148,163,184,.35);
  box-shadow:0 16px 28px rgba(15,23,42,.18);
}

.compat-title{
  font-size:1.24rem;
  font-weight:800;
  color:#1e293b;
}

.compat-message{
  margin-top:10px;
  color:#334155;
  line-height:1.45;
  text-align:center;
  font-size:1.03rem;
}

.compat-actions{
  margin-top:16px;
  display:flex;
  justify-content:center;
  gap:10px;
  flex-wrap:wrap;
}

.compat-yes-btn{
  background:linear-gradient(135deg,#86efac,#60a5fa);
  color:#082f49;
  box-shadow:0 10px 18px rgba(59,130,246,.24);
}

.compat-pick-btn{
  background:#f8fafc;
  border:1px solid rgba(148,163,184,.42);
  color:#334155;
}

.flash-backdrop{
  position:absolute;
  inset:0;
  background:rgba(17,24,39,.58);
  backdrop-filter:blur(8px);
}

.flash-dialog{
  position:relative;
  z-index:1;
  width:min(92vw,620px);
  border-radius:28px;
  background:#0f172ae8;
  color:#ecfeff;
  border:1px solid rgba(16,185,129,.7);
  box-shadow:0 0 0 1px rgba(16,185,129,.18),0 24px 70px rgba(0,0,0,.35);
  padding:26px 28px 22px;
}

.flash-icon{
  font-size:34px;
  line-height:1;
  margin-bottom:10px;
}

.flash-title{
  font-size:2rem;
  font-weight:900;
  color:#00f48b;
  letter-spacing:.02em;
}

.flash-subtitle{
  margin-top:10px;
  color:#cbd5e1;
  font-size:15px;
}

.modal-progress-shell{
  margin-top:22px;
  height:18px;
  border-radius:999px;
  overflow:hidden;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.08);
}

.modal-progress-bar{
  width:0%;
  height:100%;
  background:linear-gradient(90deg,#22d3ee,#00f48b);
  box-shadow:0 0 18px rgba(0,244,139,.35);
  transition:width .16s linear;
}

.modal-progress-meta{
  margin-top:12px;
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  color:#94a3b8;
  font-size:14px;
}

.modal-progress-meta span:last-child{
  color:#00f48b;
  font-size:1.1rem;
  font-weight:800;
}

.modal-progress-foot{
  margin-top:6px;
  color:#cbd5e1;
  font-size:14px;
}

.modal-actions{
  margin-top:16px;
  display:flex;
  justify-content:flex-end;
  gap:10px;
}

@media(max-width:1200px){
  .theme-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
}

@media(max-width:900px){
  .theme-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}

@media(max-width:768px){
  body{padding:14px}
  .utility-bar{flex-direction:column;align-items:flex-start}
  .utility-actions{width:100%}
  .theme-grid{grid-template-columns:1fr}
  .flash-title{font-size:1.6rem}
  .theme-media{aspect-ratio:5/6}
  .wakeword-row{flex-direction:column;align-items:stretch;gap:6px}
}
