:root {
  color-scheme: light;
  --paper: #fbfbf8;
  --ink: #141414;
  --panel: rgba(255, 255, 255, 0.9);
  --line: rgba(20, 20, 20, 0.14);
  --accent: #006d77;
  --danger: #b23a48;
  --warm: #f0a202;
  --shadow: 0 14px 42px rgba(17, 24, 39, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.app,
#eguiCanvas,
#leptosRoot {
  position: fixed;
  inset: 0;
}

#eguiCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  background: var(--paper);
}

#leptosRoot {
  pointer-events: none;
  z-index: 10;
}

.toolbar,
.aboutOverlay {
  pointer-events: auto;
}

.toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  width: min(298px, calc(100dvw - 32px));
  max-width: calc(100dvw - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.toolbar[data-open="false"] {
  width: min(286px, calc(100dvw - 32px));
  overflow: hidden;
}

.panelToggle {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.brandMark {
  width: 25px;
  height: 21px;
  flex: 0 0 auto;
  border-radius: 13px;
  background: #b8adf1 url("/favicon.svg") center / cover no-repeat;
}

.brandText {
  min-width: 0;
  display: grid;
  gap: 2px;
  flex: 1 1 auto;
}

.brandName {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.08;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tagline,
.panelCue {
  min-width: 0;
  overflow: hidden;
  color: rgba(20, 20, 20, 0.66);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 620;
  text-overflow: ellipsis;
}

.toolbar[data-open="false"] .tagline {
  display: none;
}

.chevron {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  font-weight: 800;
}

.panelBody {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding-top: 12px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.toolbar[data-open="false"] .panelBody {
  display: none;
}

.toolRow {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(4, 36px);
}

.swatch {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(20, 20, 20, 0.18);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.72);
  cursor: pointer;
}

.swatch[data-active="true"] {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.slider {
  min-width: 0;
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  color: rgba(20, 20, 20, 0.78);
  font-size: 12px;
  font-weight: 700;
}

.slider input {
  min-width: 0;
  width: 100%;
  accent-color: var(--accent);
}

.commands {
  justify-content: space-between;
}

.commandButton {
  min-width: 38px;
  width: 38px;
  min-height: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 760;
}

.commandButton:hover,
.commandButton:focus-visible {
  border-color: rgba(0, 109, 119, 0.48);
  background: #fff;
}

.commandIcon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.poweredButton {
  min-width: 0;
  min-height: 36px;
  width: 100%;
  border: 1px solid rgba(0, 109, 119, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: rgba(20, 20, 20, 0.72);
  cursor: pointer;
  font-size: 12px;
  font-weight: 720;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.08);
  font-size: 10px;
  font-weight: 800;
}

.status[data-state="live"] {
  color: var(--accent);
}

.status[data-state="offline"] {
  color: var(--danger);
}

.backendBadge {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.78);
  color: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.10);
  backdrop-filter: blur(14px);
  font-size: 11px;
  font-weight: 760;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.backendState {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 17px;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.backendState[data-state="live"] {
  background: #008a5b;
}

.backendState[data-state="connecting"],
.backendState[data-state="offline"] {
  background: #b23a48;
}

.aboutOverlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 20, 20, 0.24);
  backdrop-filter: blur(2px);
}

.aboutDialog {
  width: min(430px, calc(100vw - 32px));
  max-height: min(650px, calc(100vh - 32px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 24px 72px rgba(17, 24, 39, 0.24);
}

.aboutDialog h2 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.18;
}

.aboutDialog p {
  margin: 8px 0 0;
  color: rgba(20, 20, 20, 0.72);
  font-size: 13px;
  line-height: 1.52;
}

.aboutDialog a {
  color: var(--accent);
  font-size: 13px;
  font-weight: 760;
  text-decoration: none;
}

.closeButton {
  min-height: 36px;
  margin-top: 16px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 760;
}

[data-ready="false"] .toolbar {
  opacity: 0.55;
}

@media (max-width: 720px) {
  .toolbar {
    top: 10px;
    left: 10px;
    width: calc(100dvw - 20px);
    max-width: calc(100dvw - 20px);
    max-height: calc(100dvh - 20px);
  }

  .panelBody {
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
  }

  .swatches,
  .commands,
  .poweredButton,
  .backendBadge {
    grid-column: 1 / -1;
  }
}

@media (orientation: landscape) and (max-height: 560px) and (max-width: 960px) {
  .toolbar {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    width: min(286px, calc(100dvw - 16px));
    max-width: calc(100dvw - 16px);
    max-height: calc(100dvh - 16px);
    padding: 10px;
  }

  .toolbar[data-open="false"] {
    width: min(116px, calc(100dvw - 16px));
    padding: 5px 6px;
  }

  .toolbar[data-open="false"] .panelToggle {
    min-height: 20px;
    gap: 4px;
  }

  .toolbar[data-open="false"] .brandMark {
    display: none;
  }

  .toolbar[data-open="false"] .brandName {
    font-size: 12px;
    line-height: 1;
  }

  .toolbar[data-open="false"] .chevron {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }

  .panelBody {
    max-height: calc(100dvh - 66px);
    overflow: auto;
    grid-template-columns: 1fr;
    gap: 8px;
    padding-top: 9px;
  }

  .tagline {
    display: none;
  }

  .backendBadge {
    min-height: 24px;
    padding: 0 8px;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
  }
}
