:root{
  --bg:#1b0b32;
  --panel:#28134c;
  --panel2:#172054;
  --text:#f6f1ff;
  --muted:#b7ccff;
  --accent:#9f5cff;
  --blue:#36a9ff;
  --danger:#ff4d8d;
  --warn:#ffd36a;
  --border:rgba(91,188,255,.46);
  --shadow:0 10px 30px rgba(0,0,0,.34);
  --radius:8px;
}

*{ box-sizing:border-box; }
html,body{ min-height:100%; }
body{
  margin:0;
  background:radial-gradient(1200px 700px at 20% 0%, rgba(174,115,255,.30), transparent 55%),
             radial-gradient(900px 600px at 90% 10%, rgba(76,181,255,.22), transparent 60%),
             linear-gradient(180deg, #140525, var(--bg));
  color:var(--text);
  font-family:ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

.app{
  max-width:1100px;
  margin:0 auto;
  padding:18px;
}

.topbar{
  position:sticky;
  top:0;
  z-index:20;
  backdrop-filter:blur(10px);
  background:linear-gradient(180deg, rgba(42,17,78,.94), rgba(24,14,58,.86));
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:10px 12px;
}

.tabbar{
  position:sticky;
  top:74px;
  z-index:19;
  margin-top:10px;
  backdrop-filter:blur(10px);
  background:linear-gradient(180deg, rgba(42,17,78,.94), rgba(24,14,58,.86));
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:8px 10px;
}

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

.topbarRow{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
}

.brand{
  display:flex;
  gap:10px;
  align-items:center;
  user-select:none;
}

.logoDot{
  width:12px;
  height:12px;
  background:var(--blue);
  border-radius:999px;
  box-shadow:0 0 18px rgba(91,188,255,.72);
}

.brandTitle{
  font-weight:800;
  letter-spacing:.6px;
}

.brandSub{
  color:var(--muted);
  font-size:12px;
  margin-top:1px;
}

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

.topbarActions{
  flex:1;
  display:flex;
  align-items:center;
  gap:10px;
  min-width:160px;
  padding-left:38px;
}

.navLabel{
  color:var(--muted);
  font-size:13px;
  font-weight:700;
}

.btn{
  border:1px solid var(--border);
  background:linear-gradient(180deg, rgba(56,27,103,.94), rgba(28,27,77,.94));
  color:var(--text);
  border-radius:8px;
  padding:9px 12px;
  cursor:pointer;
  transition:transform .05s ease, box-shadow .12s ease, border-color .12s ease;
  font-weight:700;
  font-size:13px;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.btn:hover{
  border-color:rgba(91,188,255,.72);
  box-shadow:0 8px 22px rgba(0,0,0,.35);
}

.btn:active{ transform:translateY(1px); }
.btn.primary{ border-color:rgba(91,188,255,.78); box-shadow:0 0 18px rgba(91,188,255,.20); }
.btn.ghost{ background:rgba(31,26,78,.74); }
.btn.tab{
  background:rgba(31,26,78,.74);
  border-color:rgba(91,188,255,.42);
}
.btn.tab.active{
  border-color:rgba(91,188,255,.86);
  background:linear-gradient(180deg, rgba(36,112,190,.86), rgba(92,38,180,.84));
  box-shadow:0 0 18px rgba(91,188,255,.18);
}
.btn.tabRight{
  margin-left:auto;
}
.versionLabel{
  margin-left:auto;
  color:var(--muted);
  font-size:13px;
  font-weight:700;
}
.versionLabel + .btn.tabRight{
  margin-left:0;
}
.btn.adm{
  min-width:46px;
  padding:8px 10px;
  border-color:rgba(91,188,255,.62);
  background:rgba(31,26,78,.74);
  font-size:12px;
}
.btn.update{
  border-color:rgba(91,188,255,.78);
  background:linear-gradient(180deg, rgba(36,112,190,.86), rgba(92,38,180,.84));
  box-shadow:0 0 18px rgba(91,188,255,.18);
}
.btn.danger{
  border-color:rgba(255,77,141,.54);
  background:linear-gradient(180deg, rgba(96,26,88,.78), rgba(56,14,58,.84));
}
.btn.powerToggle{
  position:relative;
  overflow:hidden;
}
.btn.powerToggle::after{
  content:"";
  position:absolute;
  left:50%;
  bottom:4px;
  width:24px;
  height:4px;
  border-radius:3px;
  transform:translateX(-50%);
  pointer-events:none;
}
.btn.powerLedOn.ledLit::after{
  background:linear-gradient(180deg, #c9ffd4, #24ff73 48%, #04973a);
  box-shadow:0 0 7px rgba(36,255,115,.95), 0 0 15px rgba(36,255,115,.45);
}
.btn.powerLedOn.ledDim::after{
  background:linear-gradient(180deg, rgba(145,210,160,.58), rgba(41,128,67,.55));
  box-shadow:inset 0 0 4px rgba(7,28,14,.72);
  opacity:.72;
}
.btn.powerLedOff.ledLit::after{
  background:linear-gradient(180deg, #ffd1d8, #ff3159 48%, #a5082a);
  box-shadow:0 0 7px rgba(255,49,89,.95), 0 0 15px rgba(255,49,89,.45);
}
.btn.powerLedOff.ledDim::after{
  background:linear-gradient(180deg, rgba(230,126,145,.58), rgba(126,35,58,.58));
  box-shadow:inset 0 0 4px rgba(35,6,14,.72);
  opacity:.72;
}
.btn[disabled]{ opacity:.55; cursor:not-allowed; }

.updateMessage{
  color:var(--muted);
  font-size:12px;
  max-width:280px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.badge{
  padding:6px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  font-size:12px;
  color:var(--muted);
  background:rgba(31,26,78,.74);
}

.badge.on{
  color:#041425;
  background:rgba(91,188,255,.92);
  border-color:rgba(91,188,255,.78);
}

.badge.warn{
  color:#221900;
  background:rgba(255,211,90,.92);
  border-color:rgba(255,211,90,.65);
}

.content{
  margin-top:14px;
  padding-bottom:32px;
}

.grid{
  display:grid;
  grid-template-columns:repeat(12, 1fr);
  gap:12px;
}

.card{
  grid-column:span 12;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:linear-gradient(180deg, rgba(43,19,82,.95), rgba(22,28,78,.95));
  box-shadow:var(--shadow);
  overflow:hidden;
}

.card.half{ grid-column:span 6; }

.cardHeader{
  padding:12px 14px;
  border-bottom:1px solid rgba(91,188,255,.30);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.cardTitle{
  font-weight:800;
  letter-spacing:.4px;
  flex-shrink:0;
}

.cardBody{ padding:14px; }

.emptyState{
  min-height:220px;
}

.imagesPanel{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.fileList{
  border:1px solid rgba(91,188,255,.28);
  border-radius:8px;
  overflow:hidden;
}

.fileRow{
  display:grid;
  grid-template-columns:58px minmax(0, 1fr) 90px;
  gap:10px;
  align-items:center;
  padding:9px 10px;
  border-bottom:1px solid rgba(91,188,255,.18);
  background:rgba(17,15,55,.38);
}

.fileRow:last-child{
  border-bottom:0;
}

.fileType{
  color:var(--muted);
  font-size:11px;
  font-weight:800;
}

.fileName{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-weight:700;
}

.fileSize{
  color:var(--muted);
  font-size:12px;
  text-align:right;
}

.errorText{
  color:#ffd35a;
  font-size:13px;
}

.kv{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  color:var(--muted);
  font-size:13px;
}

.kv b{ color:var(--text); }

.panelHeaderControls{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:wrap;
  color:var(--muted);
  font-size:13px;
}

.previewToggle{
  white-space:nowrap;
}

.smallInput{
  width:76px;
}

.panelHeaderControls .inlineField{
  display:flex;
  flex-direction:row;
  align-items:center;
  gap:8px;
  white-space:nowrap;
}

.panelHeaderControls .inlineField span{
  display:inline;
}

.displayPreview{
  width:720px;
  max-width:100%;
  min-width:min(240px, 100%);
  margin:0 auto;
  aspect-ratio:3 / 2;
  border:1px solid rgba(91,188,255,.38);
  border-radius:8px;
  background:linear-gradient(135deg, #382078, #17103d 58%, #0f3a67);
  display:grid;
  place-items:center;
  position:relative;
  overflow:hidden;
  resize:horizontal;
}

.displayPreview:before{
  content:"";
  position:absolute;
  inset:0;
  background:linear-gradient(transparent 50%, rgba(91,188,255,.10) 50%);
  background-size:100% 8px;
  opacity:.55;
}

.displayPreviewImage{
  position:relative;
  z-index:1;
  width:100%;
  height:100%;
  object-fit:contain;
  image-rendering:auto;
}

.previewText{
  position:relative;
  text-align:center;
  z-index:1;
}

.previewTitle{
  font-size:34px;
  line-height:1.1;
  font-weight:900;
}

.previewSub{
  margin-top:8px;
  color:var(--muted);
  font-size:13px;
}

.tileGrid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:10px;
}

.tile{
  border:1px solid rgba(91,188,255,.38);
  border-radius:8px;
  background:linear-gradient(180deg, rgba(40,23,86,.88), rgba(20,24,69,.95));
  padding:12px;
  min-height:92px;
}

.tileName{
  font-weight:800;
  font-size:14px;
}

.tileMeta{
  margin-top:8px;
  color:var(--muted);
  font-size:12px;
  line-height:1.45;
}

.actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.controlLine{
  display:grid;
  grid-template-columns:repeat(10, minmax(0, 1fr));
  gap:8px;
  align-items:stretch;
}

.controlLine .controlButton{
  grid-column:span 2;
  min-height:34px;
  padding:7px 8px;
  white-space:normal;
  text-align:center;
}

.controlLine .swatch{
  min-height:34px;
  margin:0;
}

.modeButtons{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.modeButtonGroup{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.modeFunctions{
  border-top:1px solid rgba(91,188,255,.28);
  padding-top:10px;
}

.modeFunctionRow{
  display:flex;
  gap:8px;
  align-items:end;
  margin-top:10px;
}

.modeFunctionButton{
  flex:0 0 auto;
  width:auto;
  min-width:0;
}

.modeFunctionRow .modeRun{
  margin-left:auto;
}

.settingsGrid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:12px;
}

.dynamicBackgroundGrid .input{
  width:100%;
  box-sizing:border-box;
}

.screenSettings{
  display:flex;
  flex-direction:column;
  gap:12px;
  min-height:248px;
}

.modeTypeRow{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.settingsTodo{
  grid-column:1 / -1;
  color:var(--muted);
  font-size:13px;
  font-weight:800;
  letter-spacing:.4px;
}

.settingsSection{
  display:flex;
  flex-direction:column;
  gap:12px;
  min-height:170px;
}

.sectionTitle{
  padding-bottom:8px;
  border-bottom:1px solid rgba(91,188,255,.28);
  color:var(--text);
  font-weight:800;
}

.spiSpeedInput{
  width:132px;
}

.settingsInlineField{
  display:flex;
  flex-direction:row;
  align-items:center;
  gap:10px;
  color:var(--muted);
  font-size:13px;
  font-weight:700;
  flex-wrap:wrap;
}

.unitLabel{
  color:var(--muted);
}

.settingsAction{
  display:flex;
  justify-content:flex-end;
  align-items:flex-end;
  margin-top:auto;
}

.configManageActions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.configManagePaths{
  flex-direction:column;
  align-items:flex-start;
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
  color:var(--muted);
  font-size:13px;
  font-weight:700;
}

.input{
  min-height:38px;
  border:1px solid rgba(91,188,255,.38);
  border-radius:8px;
  background:rgba(18,15,50,.74);
  color:var(--text);
  padding:8px 10px;
  font:inherit;
}

.checkField{
  min-height:38px;
  display:flex;
  align-items:center;
  gap:8px;
  color:var(--text);
  font-size:13px;
  font-weight:700;
}

.checkRow{
  display:flex;
  gap:14px;
  flex-wrap:wrap;
  align-items:center;
}

.clockLabelsGrid{
  grid-column:1 / -1;
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:14px;
  align-items:center;
}

.clockLabelRow{
  min-height:38px;
  display:grid;
  grid-template-columns:auto auto minmax(0, 1fr);
  align-items:center;
  gap:8px;
  min-width:0;
  color:var(--text);
  font-size:13px;
  font-weight:700;
}

.clockLabelRow .input{
  width:100%;
  min-width:0;
  box-sizing:border-box;
}

.checkField input{
  width:18px;
  height:18px;
}

.disabledCheckField{
  opacity:.46;
  cursor:not-allowed;
}

.disabledCheckField input{
  cursor:not-allowed;
}

.systemInfoClockBackgroundRow{
  min-height:38px;
  display:grid;
  grid-template-columns:auto minmax(0, 250px);
  gap:10px;
  align-items:end;
  justify-content:space-between;
}

.systemInfoClockBackgroundRow .checkField{
  margin-bottom:0;
}

.systemInfoClockBackgroundRow .field{
  min-width:0;
  width:250px;
  max-width:100%;
}

.systemInfoClockBackgroundRow .input{
  min-height:32px;
}

@media (max-width:720px){
  .systemInfoClockBackgroundRow{
    grid-template-columns:1fr;
  }
}

.swatches{
  display:grid;
  grid-template-columns:repeat(6, 1fr);
  gap:8px;
  margin-top:12px;
}

.swatch{
  min-height:42px;
  border:1px solid rgba(91,188,255,.44);
  border-radius:8px;
  background:var(--swatch);
  cursor:pointer;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.12), 0 8px 18px rgba(0,0,0,.20);
}

.swatch span{
  display:block;
  overflow:hidden;
  width:1px;
  height:1px;
}

.swatch:disabled{
  opacity:.55;
  cursor:not-allowed;
}

.swatch:hover{
  border-color:rgba(166,221,255,.86);
}

@media (max-width:900px){
  .controlLine{
    grid-template-columns:repeat(4, minmax(0, 1fr));
  }
  .controlLine .controlButton{
    grid-column:span 2;
  }
}

@media (max-width:560px){
  .controlLine{
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }
  .controlLine .controlButton{
    grid-column:span 2;
  }
}

pre{
  margin:0;
  padding:12px;
  border:1px solid rgba(91,188,255,.32);
  border-radius:8px;
  background:#120b28;
  color:#c6e3ff;
  overflow:auto;
  min-height:140px;
}

.footerNote{
  margin-top:10px;
  color:var(--muted);
  font-size:12px;
}

@media (max-width:900px){
  .card.half{ grid-column:span 12; }
  .tileGrid{ grid-template-columns:1fr; }
  .settingsGrid{ grid-template-columns:1fr; }
}

@media (max-width:560px){
  .app{ padding:12px; }
  .topbar{ position:static; }
  .previewTitle{ font-size:26px; }
  .swatches{ grid-template-columns:repeat(3, 1fr); }
}


.systemInfoClockColorGrid{
  grid-column:1 / -1;
  display:grid;
  grid-template-columns:repeat(4,minmax(170px,1fr));
  gap:10px 16px;
  align-items:end;
}
.systemInfoClockColorGrid .field{
  margin:0;
}
.systemInfoClockColorGrid .input{
  min-height:32px;
}
@media (max-width: 980px){
  .systemInfoClockColorGrid{
    grid-template-columns:repeat(2,minmax(180px,1fr));
  }
}

.systemInfoMetricSettings{
  grid-column:1 / -1;
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-top:2px;
}

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

.systemInfoMetricField{
  min-height:30px;
}

@media (max-width:980px){
  .clockLabelsGrid{
    grid-template-columns:1fr;
  }
  .systemInfoMetricGrid{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
}

@media (max-width:720px){
  .systemInfoMetricGrid{ grid-template-columns:1fr; }
}

.systemInfoParamSettings{
  grid-column:1 / -1;
  margin-top:14px;
  padding-top:12px;
  border-top:1px solid var(--border);
}
.systemInfoParamTitle{
  margin-top:0;
}
.systemInfoParamGrid{
  display:grid;
  grid-template-columns:repeat(4,minmax(170px,1fr));
  gap:10px 16px;
  align-items:end;
}
.systemInfoParamGrid .field{
  margin:0;
}
.systemInfoParamGrid .input{
  min-height:32px;
}
@media (max-width: 980px){
  .systemInfoParamGrid{
    grid-template-columns:repeat(2,minmax(180px,1fr));
  }
}

.weatherCheckGrid{
  grid-column:1 / -1;
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:10px 16px;
  align-items:center;
}

.weatherLocationGrid{
  grid-column:1 / -1;
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:10px 16px;
  align-items:end;
}

.weatherActionGrid{
  grid-column:1 / -1;
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:10px 16px;
  align-items:end;
}

.weatherLocationGrid .field,
.weatherActionGrid .field{
  margin:0;
}

.weatherLocationGrid .input,
.weatherActionGrid .input{
  width:100%;
  box-sizing:border-box;
}

.weatherUpdateNowRow{
  display:flex;
  justify-content:flex-end;
  align-items:end;
}

.weatherUpdateNowRow .btn{
  min-height:38px;
  min-width:180px;
  white-space:nowrap;
}

.weatherRefreshInput{
  width:100%;
}

.weatherPlaceholderRow{
  grid-column:1 / -1;
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:10px 16px;
  align-items:end;
  margin-top:22px;
}

.weatherPlaceholderRow .input:disabled{
  opacity:.55;
  cursor:not-allowed;
}

.systemInfoWeatherSettings{
  grid-column:1 / -1;
  margin-top:14px;
  padding-top:12px;
  border-top:1px solid var(--border);
}

.systemInfoWeatherActiveRow{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:10px 16px;
  align-items:center;
  margin-bottom:10px;
}

.systemInfoWeatherGrid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:10px 16px;
  align-items:center;
}

.systemInfoWeatherColorGrid{
  display:grid;
  grid-template-columns:repeat(4, minmax(190px, 1fr));
  gap:10px 16px;
  align-items:end;
  margin-top:10px;
}

.systemInfoWeatherColorGrid .field{
  margin:0;
}

.systemInfoWeatherColorGrid .input{
  min-height:32px;
}

.systemInfoWeatherSpacer{
  min-height:30px;
}

.systemInfoExtraSettings{
  margin-top:14px;
  padding-top:12px;
  border-top:1px solid var(--border);
}

.systemInfoExtraTitle{
  margin-top:0;
}

.systemInfoExtraGrid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:10px 16px;
  align-items:end;
}

.systemInfoExtraGrid .field{
  margin:0;
}

.systemInfoExtraGrid .input{
  width:100%;
  box-sizing:border-box;
  min-height:32px;
}

@media (max-width:980px){
  .weatherCheckGrid,
  .weatherLocationGrid,
  .weatherActionGrid,
  .systemInfoWeatherActiveRow,
  .systemInfoWeatherGrid,
  .systemInfoExtraGrid{
    grid-template-columns:1fr;
  }
  .weatherPlaceholderRow{
    grid-template-columns:1fr;
  }
  .systemInfoWeatherColorGrid{
    grid-template-columns:repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width:720px){
  .systemInfoWeatherColorGrid{
    grid-template-columns:1fr;
  }
}
