* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #050505;
  overflow: hidden;
  font-family: Arial, sans-serif;
}

.menu-btn {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 320;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.52);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 310;
  width: min(280px, 82vw);
  padding: 72px 22px 24px;
  background: rgba(12, 12, 12, 0.98);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  transform: translateX(-100%);
  transition: transform 180ms ease;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.drawer a {
  color: #fff;
  text-decoration: none;
  font-size: 15px;
}

.drawer .drawer-brand {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 14px;
}

body.drawer-open .drawer {
  transform: translateX(0);
}

body.drawer-open .drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

#controls {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 100;
  width: min(720px, calc(100vw - 24px));
  background: rgba(18, 18, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
}

.steps {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.step {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  text-align: center;
}

.step.active {
  background: rgba(255, 255, 255, 0.92);
  color: #111;
}

.control-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.8fr 0.8fr 0.8fr;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

#controls input[type="file"] {
  color: #fff;
  font-size: 12px;
  width: 100%;
}

#countryInput {
  width: 100%;
  min-width: 0;
  min-height: 56px;
  padding: 7px 8px;
  font-size: 14px;
  line-height: 1.25;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  outline: none;
  resize: none;
  font-family: inherit;
}

.speed-label {
  color: rgba(255, 255, 255, 0.72);
}

#speedSlider { width: 100%; }

#textSpeedSlider { width: 100%; }

#fontSelect {
  width: 100%;
  padding: 7px 8px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  outline: none;
}

#fontSelect option {
  color: #111;
}

.pos-group {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.pos-label {
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
  flex: 0 0 auto;
}

.pos-group label {
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-btn,
.rec-btn {
  flex: 0 0 auto;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 700;
  background: #fff;
  border: 1px solid #fff;
  color: #111;
  cursor: pointer;
  border-radius: 999px;
}

.preview-btn {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.32);
  color: #fff;
}

.rec-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.rec-btn.recording {
  background: #f44;
  border-color: #f44;
  color: #fff;
}

.rec-status {
  font-size: 12px;
  color: #aaa;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#viewer {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  width: 90vw;
  height: 50.625vw;
  background: #050505;
  overflow: hidden;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.55);
}

#mediaVideo, #mediaImage {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
  background: #050505;
}

#earthRing {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  pointer-events: none;
  z-index: 10;
}

#earthCanvas {
  position: absolute;
  pointer-events: none;
  z-index: 20;
}

.slide-line {
  display: inline-block;
  will-change: transform;
}

@media (max-width: 640px) {
  #controls {
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100vw;
    min-height: 32vh;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    padding: 12px 12px max(12px, env(safe-area-inset-bottom));
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .step {
    font-size: 11px;
    padding: 5px 6px;
  }

  .action-row {
    margin-top: auto;
  }

  .rec-btn {
    flex: 1;
    padding: 12px 18px;
    font-size: 15px;
  }

  .preview-btn {
    flex: 0 0 auto;
    padding: 12px 14px;
  }
}
