* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  font-family: Arial, sans-serif;
  background: #101820;
  color: #ffffff;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
}

.tb-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.9em;
}

.tb-logo {
  height: 22px;
}

.tb-badge {
  font-size: 0.7em;
  background: #ff3131;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  vertical-align: middle;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  background-color: #ff3131;
  border: none;
  color: white;
  font-size: 0.95em;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s ease;
  text-decoration: none;
}

.btn:hover {
  background-color: #e62828;
}

.tb-layout {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.tb-panel {
  width: 320px;
  min-width: 280px;
  overflow-y: auto;
  background: #151d28;
  border-right: 1px solid #23303f;
  padding: 0 16px 16px 16px;
}

.tb-group {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid #23303f;
}

.tb-group:last-of-type {
  border-bottom: none;
}

.tb-group h2 {
  font-size: 1em;
  color: #ff3131;
  margin: 0 0 12px 0;
}

.tb-group h2 small {
  color: #8a97a8;
  font-weight: normal;
  font-size: 0.75em;
}

.tb-field {
  display: block;
  margin-bottom: 14px;
}

.tb-field span {
  display: flex;
  justify-content: space-between;
  font-size: 0.85em;
  color: #cdd6e0;
  margin-bottom: 4px;
}

.tb-field em {
  font-style: normal;
  color: #ff3131;
  font-weight: bold;
}

.tb-field input[type="range"] {
  width: 100%;
  height: 28px;
  accent-color: #ff3131;
  touch-action: pan-y;
}

.tb-field.is-disabled {
  opacity: 0.45;
}

.tb-field select {
  width: 100%;
  padding: 8px;
  background: #1a2431;
  color: #fff;
  border: 1px solid #2c3b4d;
  border-radius: 6px;
}

.tb-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85em;
  color: #cdd6e0;
  margin-bottom: 4px;
  padding: 8px 0;
  cursor: pointer;
}

.tb-checkbox input {
  accent-color: #ff3131;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.tb-reset {
  width: 100%;
  margin-bottom: 16px;
}

.tb-specs {
  font-size: 0.8em;
  color: #8a97a8;
  background: #0b1119;
  border-radius: 6px;
  padding: 10px 12px;
  line-height: 1.6;
}

.tb-specs div {
  display: flex;
  justify-content: space-between;
}

.tb-specs span.v {
  color: #fff;
}

.tb-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  padding-top: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #23303f;
  position: sticky;
  top: 0;
  z-index: 2;
  background: #151d28;
}

.tb-viewport {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: radial-gradient(circle at 50% 30%, #16222f 0%, #0b1119 100%);
}

#canvas-container {
  width: 100%;
  height: 100%;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#canvas-container canvas {
  display: block;
  touch-action: none;
}

.tb-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8em;
  color: #8a97a8;
  background: rgba(0,0,0,0.4);
  padding: 6px 14px;
  border-radius: 20px;
  pointer-events: none;
}

@media (max-width: 800px) {
  .tb-layout {
    flex-direction: column;
  }
  .tb-panel {
    width: 100%;
    flex: 0 1 auto;
    max-height: 38%;
    border-right: none;
    border-bottom: 1px solid #23303f;
    -webkit-overflow-scrolling: touch;
  }
  .tb-viewport {
    flex: 1 1 auto;
    min-height: 160px;
  }
  .tb-hint {
    font-size: 0.7em;
    padding: 5px 10px;
    max-width: 92%;
    text-align: center;
    white-space: normal;
  }
}

@media (max-width: 420px) {
  .tb-panel {
    padding: 12px;
  }
  .tb-group {
    margin-bottom: 16px;
    padding-bottom: 14px;
  }
  .tb-brand {
    font-size: 0.9em;
  }
  .btn {
    padding: 9px 14px;
    font-size: 0.85em;
  }
}

@supports (padding: max(0px)) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }
}
