* {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #e7edf0;
  color: #172026;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#app {
  position: relative;
}

#viewport {
  position: fixed;
  inset: 0;
}

#viewport canvas {
  display: block;
}

.auth-gate {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #e7edf0;
}

.auth-card {
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid rgb(20 28 34 / 12%);
  border-radius: 8px;
  background: #f8faf9;
  box-shadow: 0 18px 40px rgb(19 32 42 / 16%);
}

.auth-card div,
.auth-card label {
  display: grid;
  gap: 6px;
}

.auth-card strong {
  font-size: 1rem;
}

.auth-card span,
.auth-card label {
  color: #60707b;
  font-size: 0.82rem;
  font-weight: 700;
}

.auth-card input {
  min-height: 40px;
  border: 1px solid #c5d0d3;
  border-radius: 7px;
  padding: 0 10px;
  color: #172026;
  font: inherit;
}

.auth-card button {
  min-height: 40px;
  border: 1px solid #2b6f6a;
  border-radius: 7px;
  background: #2b6f6a;
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.auth-error {
  min-height: 18px;
  margin: 0;
  color: #a32929;
  font-size: 0.78rem;
  font-weight: 700;
}

.menu-toggle {
  position: fixed;
  z-index: 1001;
  top: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  display: grid;
  place-content: center;
  gap: 5px;
  border: 1px solid #c5d0d3;
  border-radius: 8px;
  background: #f8faf9;
  box-shadow: 0 12px 28px rgb(19 32 42 / 14%);
  cursor: pointer;
}

.menu-toggle span {
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: #183034;
}

.menu-toggle:hover,
.menu-toggle.is-active {
  border-color: #2b6f6a;
  background: #dcefeb;
}

.panel {
  position: fixed;
  z-index: 1000;
  top: 72px;
  left: 16px;
  width: min(340px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgb(20 28 34 / 12%);
  border-radius: 8px;
  background: #f8faf9;
  box-shadow: 0 18px 40px rgb(19 32 42 / 16%);
  transition: opacity 160ms ease, transform 160ms ease;
}

.panel.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(-100% - 24px));
}

.panel__title {
  display: grid;
  gap: 2px;
}

.panel__title span {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
}

.panel__title small {
  color: #60707b;
  font-size: 0.78rem;
}

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

.icon-button {
  min-height: 38px;
  border: 1px solid #c5d0d3;
  border-radius: 7px;
  background: #ffffff;
  color: #223038;
  font-weight: 800;
  cursor: pointer;
}

.icon-button:hover,
.icon-button.is-active {
  border-color: #2b6f6a;
  background: #dcefeb;
  color: #123f3b;
}

.control {
  display: grid;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: #2b6f6a;
}

.switches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  font-size: 0.82rem;
  color: #283942;
}

.switches label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.switches input {
  accent-color: #2b6f6a;
}

.label-editor {
  display: grid;
  gap: 10px;
  padding-top: 4px;
  color: #283942;
  font-size: 0.82rem;
}

.label-editor summary {
  cursor: pointer;
  font-weight: 800;
}

.label-editor__fields {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.label-editor label {
  display: grid;
  gap: 5px;
  color: #60707b;
  font-weight: 700;
}

.label-editor input {
  min-height: 34px;
  border: 1px solid #c5d0d3;
  border-radius: 7px;
  padding: 0 9px;
  color: #172026;
  font: inherit;
}

.label-editor__button {
  min-height: 36px;
  border: 1px solid #2b6f6a;
  border-radius: 7px;
  background: #ffffff;
  color: #123f3b;
  font-weight: 800;
  cursor: pointer;
}

.label-editor__button:hover {
  background: #dcefeb;
}

.facts {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid rgb(20 28 34 / 10%);
  font-size: 0.78rem;
}

.facts div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.facts dt {
  color: #60707b;
}

.facts dd {
  margin: 0;
  font-weight: 750;
}

@media (max-width: 720px) {
  .menu-toggle {
    top: 12px;
    left: 12px;
  }

  .panel {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-height: 48vh;
    overflow: auto;
  }

  .panel.is-hidden {
    transform: translateY(calc(100% + 24px));
  }
}
