:root{
  --bg:#0b0f17;
  --panel:#101827;
  --panel2:#0f1624;
  --border:rgba(255,255,255,.08);
  --text:#e8eefc;
  --muted:rgba(232,238,252,.65);
  --muted2:rgba(232,238,252,.45);
  --good:#2ecc71;
  --warn:#f6c343;
  --bad:#ff4d4d;
  --accent:#6aa7ff;
  --shadow: 0 12px 30px rgba(0,0,0,.45);
  --radius:16px;
  --radius2:22px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:var(--font);
  background: radial-gradient(1200px 700px at 20% 0%, rgba(106,167,255,.10), transparent 60%),
              radial-gradient(1000px 700px at 80% 20%, rgba(46,204,113,.08), transparent 55%),
              var(--bg);
  color:var(--text);
}

.app{ min-height:100%; display:flex; flex-direction:column; }

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  background: rgba(11,15,23,.55);
  backdrop-filter: blur(10px);
  position:sticky;
  top:0;
  z-index:5;
}

.brand{ display:flex; align-items:center; gap:10px; }
.logoDot{
  width:12px; height:12px; border-radius:99px;
  background: linear-gradient(135deg, var(--accent), var(--good));
  box-shadow: 0 0 18px rgba(106,167,255,.25);
}
.brandName{ font-weight:800; letter-spacing:.2px; }
.brandSub{ font-size:12px; color:var(--muted); margin-top:2px; }

.iconBtn{
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-radius:12px;
  padding:10px 12px;
  cursor:pointer;
}
.iconBtn:hover{ background: rgba(255,255,255,.07); }

.layout{
  display:grid;
  grid-template-columns: 1.2fr .8fr;
  gap:16px;
  padding:16px;
  max-width: 1200px;
  width:100%;
  margin: 0 auto;
}

.left, .right{ display:flex; flex-direction:column; gap:12px; }

.controls{
  display:flex;
  gap:10px;
  align-items:flex-end;
}

.selectWrap{ flex:1; }
.label{ font-size:12px; color:var(--muted); display:block; margin:0 0 6px 2px; }

select{
  width:100%;
  padding:12px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  outline:none;
}
select option{
  background: #0f1624;
  color: var(--text);
}

.btn{
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding:12px 14px;
  border-radius:14px;
  cursor:pointer;
  font-weight:700;
}
.btn:hover{ background: rgba(255,255,255,.07); }

.btn.danger{
  border-color: rgba(255,77,77,.35);
  background: rgba(255,77,77,.08);
}
.btn.danger:hover{ background: rgba(255,77,77,.14); }

.scrambleCard{
  background: rgba(16,24,39,.7);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:14px 14px;
  box-shadow: var(--shadow);
}
.scrambleText{
  font-weight:900;
  font-size:18px;
  line-height:1.35;
  letter-spacing:.2px;
}
.scrambleHint{
  margin-top:8px;
  font-size:12px;
  color: var(--muted2);
}

.cubeBar{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(16,24,39,.45);
}
.cubeTitle{ font-weight:800; }
.cubeStatus{ font-size:12px; color:var(--muted); margin-top:2px; }
.cubeMoves{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size:13px;
  color: var(--text);
  text-align:right;
  max-width: 520px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.cubeTps{ font-size:12px; color:var(--muted); text-align:right; margin-top:2px; }

.timerCard{
  background: rgba(16,24,39,.7);
  border:1px solid var(--border);
  border-radius: var(--radius2);
  padding:16px 14px;
  box-shadow: var(--shadow);
  text-align:center;
}

.signal{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  color: var(--muted);
  background: rgba(255,255,255,.03);
  font-size:12px;
  margin-bottom:10px;
}
.signal.good{ border-color: rgba(46,204,113,.35); color: rgba(46,204,113,.95); }
.signal.warn{ border-color: rgba(246,195,67,.35); color: rgba(246,195,67,.95); }
.signal.bad{ border-color: rgba(255,77,77,.35); color: rgba(255,77,77,.95); }

.timeDisplay{
  font-weight:950;
  font-size:72px;
  letter-spacing:.6px;
  margin:8px 0 10px 0;
  user-select:none;
}
.timeDisplay.display-hold{ color: var(--bad); }
.timeDisplay.display-ready{ color: var(--good); }

.typingWrap{ width:100%; }
.typingWrap.hidden{ display:none; }
.typingInput{
  width:100%;
  padding:16px 14px;
  border-radius:16px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  outline:none;
  font-size:18px;
  font-weight:800;
}

.chipRow{
  display:flex;
  gap:8px;
  justify-content:center;
  flex-wrap:wrap;
  margin-top:8px;
}
.chip{
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  background: rgba(255,255,255,.03);
  font-size:12px;
  color: var(--muted);
  font-weight:700;
}

.right{
  background: rgba(16,24,39,.55);
  border:1px solid var(--border);
  border-radius: var(--radius2);
  padding:14px;
  box-shadow: var(--shadow);
  min-height: 360px;
}

.panelHead{ display:flex; align-items:baseline; justify-content:space-between; }
.panelTitle{ font-weight:950; font-size:16px; }
.panelMeta{ font-size:12px; color:var(--muted); }

.solvesList{
  margin-top:10px;
  display:flex;
  flex-direction:column;
  gap:8px;
  overflow:auto;
  max-height: 56vh;
  padding-right:4px;
}

.solveItem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 10px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  cursor:pointer;
}
.solveItem:hover{ background: rgba(255,255,255,.06); }

.solveLeft{ display:flex; flex-direction:column; gap:2px; }
.solveTime{ font-weight:950; font-size:18px; }
.solveMeta{ font-size:11px; color:var(--muted2); }

.solveTag{
  font-weight:900;
  font-size:12px;
  padding:7px 9px;
  border-radius:999px;
  border:1px solid var(--border);
  color: var(--muted);
}
.solveTag.good{ border-color: rgba(46,204,113,.35); color: rgba(46,204,113,.95); }
.solveTag.warn{ border-color: rgba(246,195,67,.35); color: rgba(246,195,67,.95); }
.solveTag.bad{ border-color: rgba(255,77,77,.35); color: rgba(255,77,77,.95); }

/* Overlays / modals */
.overlay{
  position:fixed; inset:0;
  background: rgba(0,0,0,.55);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  z-index:20;
}
.overlay.hidden{ display:none; }

.modal{
  width:min(640px, 100%);
  background: rgba(16,24,39,.92);
  border:1px solid var(--border);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.modalHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 14px;
  border-bottom:1px solid var(--border);
}
.modalTitle{ font-weight:950; font-size:16px; }

.modalBody{ padding:14px; display:flex; flex-direction:column; gap:12px; }

.segRow{
  display:flex;
  gap:8px;
}
.segBtn{
  flex:1;
  padding:12px 10px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color:var(--text);
  cursor:pointer;
  font-weight:900;
}
.segBtn.active{
  border-color: rgba(106,167,255,.45);
  background: rgba(106,167,255,.10);
}

.settingRow{
  display:flex;
  justify-content:space-between;
  gap:12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  border-radius:16px;
  padding:12px 12px;
  align-items:center;
}
.settingTitle{ font-weight:950; }
.settingDesc{ font-size:12px; color: var(--muted); margin-top:3px; }

.toggleBtn{
  min-width:72px;
  padding:10px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  cursor:pointer;
  font-weight:950;
}
.toggleBtn[aria-pressed="true"]{
  border-color: rgba(46,204,113,.45);
  background: rgba(46,204,113,.10);
  color: rgba(46,204,113,.95);
}

.rangeWrap{ display:flex; align-items:center; gap:10px; }
.rangeVal{ font-size:12px; color: var(--muted); width:60px; text-align:right; }

.divider{
  height:1px;
  background: var(--border);
  margin: 6px 0;
}

.settingGroupTitle{
  font-weight:950;
  color: var(--text);
  font-size:13px;
  margin-top:2px;
}

.btGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
  align-items:center;
}
.btState{
  font-size:12px;
  color: var(--muted);
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  border-radius:14px;
  padding:12px 12px;
}

/* Solve editor bits */
.editTime{
  text-align:center;
  font-weight:950;
  font-size:48px;
  margin:6px 0 2px 0;
}
.editScramble{
  font-size:12px;
  color: var(--muted);
  text-align:center;
  line-height:1.35;
}

.penRow{
  display:flex;
  gap:8px;
  margin-top:10px;
}
.penBtn{
  flex:1;
  padding:12px 10px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);
  color:var(--text);
  cursor:pointer;
  font-weight:950;
}
.penBtn.active{
  border-color: rgba(106,167,255,.45);
  background: rgba(106,167,255,.10);
}

.editBtns{
  display:flex;
  gap:10px;
  margin-top:10px;
}

/* Debug */
.debugWrap{
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  border-radius:16px;
  padding:10px;
}
.debugLog{
  width:100%;
  min-height:140px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(0,0,0,.20);
  color: var(--text);
  padding:10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size:12px;
  outline:none;
}
.debugBtns{
  display:flex;
  gap:10px;
  margin-top:10px;
  justify-content:flex-end;
}

/* Toast */
.toast{
  position:fixed;
  bottom:18px;
  left:50%;
  transform: translateX(-50%);
  background: rgba(16,24,39,.92);
  border:1px solid var(--border);
  color: var(--text);
  padding:10px 12px;
  border-radius:999px;
  box-shadow: var(--shadow);
  opacity:0;
  pointer-events:none;
  transition: opacity .15s ease;
  z-index:30;
}
.toast.show{ opacity:1; }

@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .timeDisplay{ font-size:64px; }
  .controls{ flex-wrap:wrap; }
  .btGrid{ grid-template-columns: 1fr; }
}
