/* Minimal, clean, mobile-first styling */
:root{
  --bg:#fff;
  --panel:#0f172a;
  --card:#111827;
  --muted:#94a3b8;
  --text:#141f78;
  --accent:#111827;
  --primary:#0f172a;
  --primary-contrast:#e5e7eb;
  --ok:#10b981;
  --danger:#ef4444;
  --ring: rgba(59,130,246,.35);
  --radius:16px;
  --shadow:0 10px 24px rgba(2,6,23,.25);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font:16px/1.4 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,"Helvetica Neue",Arial;
  color:#141f78;
  background:#ffffff;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
    max-width: 600px;
    margin: 0 auto;
}
a{color:#000;text-decoration:none}
a:hover{text-decoration:underline}
.muted{color:var(--muted)} .small{font-size:.9rem} .center{text-align:center}
.pad{padding:1rem}
.container{padding:16px}
.row{display:flex; gap:12px; flex-wrap:wrap}
.between{justify-content:space-between} .center-v{align-items:center}

.app-bar{
  position:sticky; top:0; z-index:20;
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 0px; background:#ffffff;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.brand{display:flex; gap:10px; align-items:center; margin: 0 auto;}
.logo{font-size:28px}
.brand-text .title{font-weight:700; font-size:18px}
.brand-text .subtitle{font-size:12px; color:var(--muted)}
.app-actions{display:flex; gap:8px}
.icon-btn{
  background:#fff; border:1px solid black;
  color:#000; border-radius:12px; padding:8px 10px; cursor:pointer;
}
.icon-btn.danger{border-color:#fff; background:#fff;border: 1px solid black;}
.icon-btn:active{transform:scale(.98)}

.route{display:none; padding-bottom:72px}
.route.active{display:block}

.auth-card{
  max-width:520px; margin:24px auto; padding:24px; background:#fff;
  border:1px solid rgba(255,255,255,.08); border-radius:var(--radius); 
}
.logo-lg{
  width:150px; height:60px; margin:10px auto 10px; border-radius:12px;
  background:#2b344a; display:grid; place-items:center; color:#cbd5e1;
}
.logo-lg.secondary{background:#3b445c}
h1,h2{margin:.4rem 0 .6rem}
.form{display:flex; flex-direction:column; gap:12px; margin-top:10px}
label{display:flex; flex-direction:column; gap:6px; font-weight:600}
input,button,select{
  font:inherit; color:#fff;
}
input{
  background:lightgray; border:1px solid rgba(255,255,255,.12);
  padding:12px 14px; border-radius:12px; outline:none;
}
input:focus{border-color:#3b82f6; }
.check{
  font-weight:400;
  gap:10px;
  flex-direction:row;
  align-items:flex-start;
}

.check input[type="checkbox"]{
  margin-top:3px;
}
.btn,.primary{
  display:inline-flex; align-items:center; justify-content:center;
  padding:12px 16px; border-radius:14px;  border: 1px solid rgba(0, 0, 0) ;
  color: black !important;
    background: white !important;
    border-color: black !important; cursor:pointer;
}

.primary {color: black !important;
    background: white !important;
    border-color: black !important;}


.primary.w-full,.btn.w-full{width:100%}
.add{padding:10px 14px; border-radius:14px; background:#0f172a; color:#fff; border:1px solid rgba(255,255,255,.08)}

.cards{display:grid; gap:12px}
.card, .device-card{
  background:#fff; border:1px solid rgba(255,255,255,.08);
  border-radius:16px; padding:14px; 
}
.device-card{display:flex; align-items:center; justify-content:space-between; gap:12px}
.device-meta{display:flex; gap:12px; align-items:center}
.device-icon{width:48px; height:48px; border-radius:12px; background:#fff; display:grid; place-items:center; font-size:24px}
.badge{margin-top:4px; color:#cbd5e1; font-size:12px}

.quick-actions{margin:18px 0; display:flex; gap:12px}

.back{display:inline-block; margin-bottom:6px; color:#cbd5e1}
.search-box{display:flex; gap:8px; align-items:center}
.search-box input{flex:1}

.hint{margin:16px 0; padding:12px; border-radius:12px; background:white; border:1px solid rgba(255,255,255,.08)}

.device-detail .device-header{display:flex; gap:12px; align-items:center; margin-bottom:12px}

.switch{position:relative; display:inline-block; width:56px; height:32px}
.switch input{display:none}
.slider{position:absolute; cursor:pointer; inset:0; background:#334155; border-radius:32px; transition:all .2s}
.slider:before{content:""; position:absolute; height:24px; width:24px; left:4px; top:4px; background:white; border-radius:50%; transition:all .2s}
.switch input:checked + .slider{background:#16a34a}
.switch input:checked + .slider:before{transform:translateX(24px)}

.slider-wrap{display:flex; align-items:center; gap:10px}
.slider-wrap input[type=range]{flex:1}
#speedVal{min-width:36px; text-align:right}

.swatches{display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin:10px 0}
.swatches button{height:56px; border-radius:12px; border:1px solid rgba(255,255,255,.15); background:#6b7280}
.swatches button[data-color]{background:var(--c);}
.swatches button[data-color]::before{display:none}
.swatches button:hover{outline:2px solid rgba(255,255,255,.25)}

.open-palette{margin-top:6px}
.open-palette input[type=color]{position:absolute; opacity:0; pointer-events:none}

.footer-actions{display:flex; gap:12px; position:sticky; bottom:0; background:#fff; padding:18px 0}
.footer-actions .primary{flex:1}

#toast{
  position:fixed; bottom:20px; left:50%; transform:translateX(-50%);
  background:#111827; color:#e5e7eb; padding:10px 14px; border-radius:10px;
  border:1px solid rgba(255,255,255,.1); display:none; z-index:99;
}

/* ---------- NEW: Device topbar / hub / sub-pages ---------- */

/* Top bar on device page: logo center, buttons left/right */
.device-topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:4px 0 12px;
  margin-bottom:4px;
}

.device-top-logo{
  flex:1;
  text-align:center;
}
.device-top-logo img{
  height:32px;
  width:auto;
  display:inline-block;
}

/* Round action buttons (top-left / top-right) */
.device-top-btn{
  flex:0 0 auto;
  width:40px;
  height:119px;
  border-radius:999px;
  border:1px solid rgba(15,23,42,.16);
  background:#0f172a;
  color:#e5e7eb;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  font-size:18px;
}
.device-top-btn:active{
  transform:scale(.96);
}

/* Hub with the 4 mode buttons */
.device-hub{
  margin-top:16px;
  margin-bottom:8px;
}

.device-mode-selector{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:center;
}

.device-mode-pill{
  padding:8px 12px;
  border-radius:999px;
  border:1px solid rgba(15,23,42,.16);
  background:#ffffff;
  color:#0f172a;
  font-size:1.2rem;
  font-weight:700;
  cursor:pointer;
  transition:background .15s ease, color .15s ease, transform .1s ease, border-color .15s ease;
  width: 160px;
    height: 100px;
}
.device-mode-pill.is-active{
  background:#0f172a;
  color:#e5e7eb;
  border-color:#0f172a;
}
.device-mode-pill:active{
  transform:scale(.97);
}

/* Sub-page containers on device screen */
.device-subview{
  margin-top:12px;
}

/* Small text for readback panel if used */
.small-text{
  font-size:0.85rem;
}

/* Top bar buttons now live in the global header */
.device-top-btn{
  flex:0 0 auto;
  width:80px;
  height:80px;
  border-radius:999px;
  border:1px solid rgba(15,23,42,.16);
  background:#0f172a;
  color:#e5e7eb;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  font-size:18px;
}
.device-top-btn:active{
  transform:scale(.96);
}

/* Hub with the 4 mode buttons */
.device-hub{
  margin-top:16px;
  margin-bottom:8px;
}

.device-mode-selector{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:center;
}

.device-mode-pill{
  padding:8px 12px;
  border-radius:999px;
  border:1px solid rgba(15,23,42,.16);
  background:#ffffff;
  color:#0f172a;
  font-size: 1.5rem;
  cursor:pointer;
  transition:background .15s ease, color .15s ease, transform .1s ease, border-color .15s ease;
}
.device-mode-pill.is-active{
  background:#0f172a;
  color:#e5e7eb;
  border-color:#0f172a;
}
.device-mode-pill:active{
  transform:scale(.97);
}

/* Sub-page containers on device screen */
.device-subview{
  margin-top:12px;
}

.small-text{
  font-size:0.85rem;
}

/* ---- Sliders sub-page styling ---- */
.sliders-card{
  padding-top: 18px;
  padding-bottom: 20px;
}

.sliders-colour-title{
  text-align:center;
  font-weight:600;
  color:#141f78;
  margin-bottom:8px;
}

.sliders-preview{
  width:80%;
  max-width:260px;
  height:70px;
  margin:0 auto 18px;
  border-radius:20px;
  background:#ff66cc; /* initial fallback */
  box-shadow:0 0 0 2px #e5e7eb;
}

/* Rows with label + slider */
.slider-row{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:10px;
}

.slider-row-spaced{
  margin-top:18px;
}

.slider-label{
  width:90px;
  font-weight:600;
  color:#141f78;
  font-size:0.95rem;
}

.slider-label-red{   color:#ef4444; }
.slider-label-green{ color:#84cc16; }
.slider-label-blue{  color:#1d4ed8; }
.slider-label-white{ color:#d4d4d8; }

/* Range slider styling */
.slider-line{
  flex:1;
  -webkit-appearance:none;
  appearance:none;
  height:4px;
  background:#e5e7eb;
  border-radius:2px;
  outline:none;
}

/* WebKit thumb */
.slider-line::-webkit-slider-thumb{
  -webkit-appearance:none;
  appearance:none;
  width:20px;
  height:20px;
  border-radius:50%;
  background:#d9ff00;
  border:3px solid #141f78;
  cursor:pointer;
  margin-top:-8px; /* centres thumb on 4px track */
}

/* Firefox thumb */
.slider-line::-moz-range-thumb{
  width:20px;
  height:20px;
  border-radius:50%;
  background:#d9ff00;
  border:3px solid #141f78;
  cursor:pointer;
}

/* Firefox track */
.slider-line::-moz-range-track{
  height:4px;
  background:#e5e7eb;
  border-radius:2px;
}


/* ----- Piano (Buttons sub-page) ----- */

.piano-card{
  padding-top: 10px;
  padding-bottom: 16px;
}

/* Container for all keys */
.piano-wrapper{
  margin-top: 4px;
  position: relative;
}

/* Shared geometry: must match JS (WHITE_H = 44) */
.piano-white,
.piano-black{
  position: absolute;
  left: 0;
  right: 0;
  height: 44px;
  border-radius: 14px;
  border: 1px solid #000;
  cursor: pointer;
}

/* White keys = full width */
.piano-white{
  z-index: 1;
}

/* Black keys = shorter, on the right, above whites */
.piano-black{
  right: 8px;
  width: 45%;
  z-index: 2;
}

/* Subtle press feedback */
.piano-white:active,
.piano-black:active{
  transform: translateY(1px);
  box-shadow: 0 0 0 2px rgba(15,23,42,0.15) inset;
}

/* sound toggle buttons */
.piano-sound-toggle{
  margin-top: 16px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.piano-sound-btn{
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #000;
  background:#ffffff;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:22px;
  cursor:pointer;
}

.piano-sound-btn.is-active{
  background:#0f172a;
  color:#ffffff;
}

.mode-back-btn {
  margin-top: 40px;
  width: 140px;
  padding: 12px 18px;
  font-size: 16px;
  border-radius: 16px;
  border: 1px solid black;
  background: white;
  color: black;
  display: block;
  margin-left: auto;
  margin-right: auto;
  cursor: pointer;
}

.mode-back-btn:active{
  transform: scale(0.97);
}

canvas{
      margin: 0 auto;
}

#installPwaBtn {
  margin-left: auto;
}
.badge.offline { opacity: 0.85; }

#device-view-colourflip.device-subview{
  padding: 0;
}

