:root {
  --rb-rock-dark: #111820;
  --rb-rock-panel: #18222b;
  --rb-rock-panel-soft: rgba(37, 47, 56, 0.72);
  --rb-base-cyan: #009494;
  --rb-base-cyan-bright: #00d6d6;
  --rb-base-cyan-light: #25c2a0;
  --rb-alert-orange: #ff7e67;
  --rb-tech-silver: #b8c4ce;
  --rb-muted: #7f8d99;
  --rb-border: rgba(0, 148, 148, 0.24);
  --rb-border-strong: rgba(0, 214, 214, 0.46);
  --rb-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  --page-bg: #111820;
  --page-bg-rgb: 17, 24, 32;
  --panel-bg: rgba(24, 34, 43, 0.86);
  --panel-bg-soft: rgba(37, 47, 56, 0.68);
  --field-bg: rgba(12, 18, 24, 0.86);
  --text-primary: #eef6f8;
  --text-secondary: #b8c4ce;
  --text-muted: #7f8d99;
  --button-text: #0c161b;
  --terminal-bg: #070b0f;
  --terminal-text: #d6e2e5;
  --danger-bg: rgba(255, 126, 103, 0.14);
  --danger-border: rgba(255, 126, 103, 0.42);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 14% 8%, rgba(0, 148, 148, 0.12), transparent 28rem),
    radial-gradient(circle at 86% 0%, rgba(255, 126, 103, 0.08), transparent 24rem),
    linear-gradient(rgba(0, 148, 148, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 148, 148, 0.05) 1px, transparent 1px),
    var(--page-bg);
  background-size: auto, auto, 72px 72px, 72px 72px, auto;
  color: var(--text-primary);
  font-family: "Inter", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    radial-gradient(circle at 20% 20%, rgba(0, 214, 214, 0.08), transparent 18rem),
    radial-gradient(circle at 80% 32%, rgba(37, 194, 160, 0.07), transparent 16rem);
  opacity: 0.86;
}

a {
  color: var(--rb-base-cyan-bright);
  text-decoration: none;
}

a:visited {
  color: var(--rb-base-cyan-light);
}

a:hover {
  color: var(--rb-alert-orange);
}

p {
  margin: 0;
}

input,
select,
button,
label {
  font: inherit;
  font-weight: 600;
}

input,
select,
button {
  outline: none;
}

button,
select,
input {
  border-radius: 8px;
}

button {
  min-height: 36px;
  border: 1px solid var(--rb-border-strong);
  background: rgba(0, 148, 148, 0.12);
  color: var(--text-primary);
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

button:hover:not(:disabled) {
  border-color: var(--rb-base-cyan-bright);
  background: rgba(0, 214, 214, 0.18);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  border-color: rgba(127, 141, 153, 0.28);
  background: rgba(127, 141, 153, 0.14);
  color: var(--text-muted);
}

select,
input {
  min-height: 36px;
  border: 1px solid var(--rb-border);
  background: var(--field-bg);
  color: var(--text-primary);
  padding: 0 12px;
}

select:focus,
input:focus {
  border-color: var(--rb-base-cyan-bright);
  box-shadow: 0 0 0 3px rgba(0, 214, 214, 0.14);
}

.header {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 76px;
  margin: 0;
  padding: 12px clamp(18px, 4vw, 70px);
  border-bottom: 1px solid var(--rb-border);
  background: rgba(var(--page-bg-rgb), 0.86);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18);
}

div.left,
div.right {
  display: flex;
  align-items: center;
}

div.left {
  float: left;
}

div.right {
  float: right;
}

div.clear {
  clear: both;
}

.brand-area {
  height: 52px;
  gap: 14px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 156px;
  height: 52px;
  overflow: hidden;
  line-height: 1;
}

#projectLink {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.rockbase-logo {
  display: block;
  width: 156px;
  max-width: 32vw;
  height: 52px;
  max-height: 46px;
  object-fit: contain;
  object-position: left center;
}

.project-link {
  width: 38px;
  height: 38px;
  justify-content: center;
  border: 1px solid var(--rb-border);
  border-radius: 8px;
  background: var(--panel-bg-soft);
}

#projectLogo {
  max-width: 28px;
  max-height: 28px;
  object-fit: contain;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  max-width: calc(100% - 250px);
}

.control-field,
.switch-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text-secondary);
  white-space: nowrap;
}

.control-field span {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.control-field select {
  max-width: 190px;
}

#butConnect {
  min-width: 156px;
  padding: 0 18px;
  border-color: transparent;
  background: linear-gradient(135deg, var(--rb-base-cyan-bright), var(--rb-base-cyan-light));
  color: var(--button-text);
  font-weight: 700;
}

#butConnect:hover:not(:disabled) {
  border-color: transparent;
  background: linear-gradient(135deg, var(--rb-base-cyan-light), var(--rb-base-cyan-bright));
}

.main {
  position: relative;
  z-index: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 92px clamp(18px, 4vw, 70px) 0;
}

.hidden {
  display: none !important;
}

.notSupported {
  max-width: 1120px;
  margin: 18px auto;
  padding: 14px 18px;
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--text-primary);
}

.subheader {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  max-width: 1120px;
  min-height: 106px;
  margin: 0 auto;
  padding: 24px 0 20px;
  gap: 20px;
}

.subheader .title {
  display: block;
}

.subheader h1 {
  margin: 0;
  color: var(--text-primary);
  font-family: "Montserrat", "Inter", "Noto Sans SC", sans-serif;
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 800;
  line-height: 1.05;
}

.subheader .title p {
  margin-top: 8px;
  color: var(--rb-tech-silver);
  font-size: 15px;
  font-weight: 600;
}

.subheader-actions {
  padding-bottom: 5px;
}

#app {
  max-width: 1120px;
  margin: 0 auto;
}

#product {
  display: block;
  margin: 0 auto 18px;
  padding: 18px;
  border: 1px solid var(--rb-border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--rb-shadow);
  text-align: center;
}

#product:hover {
  border-color: rgba(0, 148, 148, 0.42);
  box-shadow: 0 8px 32px rgba(0, 148, 148, 0.12);
}

.device-image {
  display: block;
  width: min(100%, 480px);
  height: 170px;
  margin: 0 auto;
  object-fit: contain;
}

#app.connected #commands {
  height: 104px;
}

#app.connected #log {
  height: calc(100vh - 510px);
}

#app.console #log {
  height: calc(100vh - 390px);
}

#app #commands {
  height: 0;
}

#app #log {
  height: calc(100vh - 560px);
}

#commands,
#log {
  transition: height 0.35s ease;
}

#commands {
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
}

#commands .upload {
  display: grid;
  grid-template-columns: minmax(130px, 220px) minmax(200px, 1fr);
  align-items: center;
  width: 100%;
  max-width: 760px;
  gap: 14px;
  margin: 16px auto;
  padding: 14px;
  border: 1px solid var(--rb-border);
  border-radius: 8px;
  background: var(--panel-bg-soft);
}

.firmware {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid rgba(0, 214, 214, 0.34);
  border-radius: 8px;
  color: var(--rb-base-cyan-bright);
  overflow: hidden;
}

#flashFileLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.firmware > input {
  position: absolute;
  z-index: -1;
  width: 0.1px;
  height: 0.1px;
  overflow: hidden;
  opacity: 0;
}

.firmware > svg {
  margin-right: 10px;
}

.progress-bar {
  width: 100%;
  height: 18px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(0, 214, 214, 0.44);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
}

.progress-bar > div {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--rb-base-cyan), var(--rb-base-cyan-bright));
  box-shadow: 0 0 18px rgba(0, 214, 214, 0.34);
}

#log {
  max-width: 100%;
  min-height: 260px;
  margin-bottom: 16px;
  overflow-x: auto;
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--rb-border);
  border-radius: 8px;
  background: var(--terminal-bg);
  color: var(--terminal-text);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  font-style: normal;
  font-weight: 400;
  line-height: 1.55;
  scrollbar-color: var(--rb-base-cyan) transparent;
}

.log-entry {
  white-space: pre;
}

.debug-function,
.timestamp {
  color: var(--rb-base-cyan-light);
}

.error-message {
  color: var(--rb-alert-orange);
}

#act,
#wificonfig {
  max-width: 1120px;
  margin: 14px auto;
  padding: 16px;
  border: 1px solid var(--rb-border);
  border-radius: 8px;
  background: var(--panel-bg);
}

#act label,
#wificonfig label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px;
  color: var(--text-secondary);
}

#act input,
#wificonfig input {
  width: min(560px, 70vw);
  max-width: 100%;
}

#wificonfig #ssid,
#wificonfig #password {
  width: min(260px, 70vw);
}

#wificonfig #address {
  width: min(430px, 70vw);
}

.footer {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 clamp(18px, 4vw, 70px) 26px;
  color: var(--text-secondary);
  font-size: 14px;
}

.footer .controls {
  align-items: center;
  min-height: 54px;
  margin: 8px 0 16px;
  padding: 10px 0;
  border-top: 1px solid var(--rb-border);
  border-bottom: 1px solid var(--rb-border);
}

.footer button {
  min-height: 34px;
  padding: 0 14px;
  font-size: 14px;
}

.separator {
  color: var(--text-muted);
  margin: 0 8px;
}

.remix {
  position: relative;
  display: flex;
  justify-content: center;
  height: 60px;
}

.remix button {
  position: absolute;
  bottom: 11px;
}

#templates {
  display: none;
}

.onoffswitch {
  position: relative;
  display: inline-block;
  width: 52px;
  margin: 0;
  user-select: none;
}

.onoffswitch-checkbox {
  display: none;
}

.onoffswitch-label {
  position: relative;
  display: block;
  width: 52px;
  height: 28px;
  margin: 0;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(127, 141, 153, 0.42);
  border-radius: 999px;
  background: rgba(127, 141, 153, 0.18);
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.onoffswitch-inner {
  display: none;
}

.onoffswitch-switch {
  position: absolute;
  top: 3px;
  left: 3px;
  display: block;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  transition:
    left 0.2s ease,
    border-color 0.2s ease;
}

.onoffswitch-checkbox:checked + .onoffswitch-label {
  border-color: rgba(0, 214, 214, 0.62);
  background: rgba(0, 148, 148, 0.52);
}

.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
  left: 27px;
  border-color: var(--rb-base-cyan-bright);
}

.justify {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.center {
  text-align: center;
}

@media (max-width: 1120px) {
  .header {
    position: sticky;
  }

  div.left,
  div.right {
    float: none;
  }

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

  .toolbar {
    justify-content: flex-start;
    max-width: 100%;
  }

  .main {
    padding-top: 18px;
  }
}

@media (max-width: 720px) {
  .brand-area,
  .subheader,
  .justify {
    align-items: flex-start;
    flex-direction: column;
  }

  .control-field {
    align-items: flex-start;
    flex-direction: column;
    width: min(100%, 320px);
    gap: 4px;
  }

  .control-field select,
  #butConnect {
    width: 100%;
    max-width: 100%;
  }

  .switch-field {
    min-height: 36px;
  }

  #commands .upload {
    grid-template-columns: 1fr;
  }

  #app.connected #commands {
    height: 128px;
  }

  #app #log,
  #app.connected #log,
  #app.console #log {
    height: 320px;
  }

  .footer {
    padding-bottom: 22px;
  }
}
