*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: #010207;
  color: #f4f6ff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#sky-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  touch-action: manipulation;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Welcome screen overlay when no photo is loaded */
.welcome {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px))
    max(84px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  pointer-events: none;
  z-index: 2;
}

.welcome[hidden] {
  display: none;
}

.welcome-card {
  pointer-events: auto;
  width: min(440px, 100%);
  text-align: center;
  padding: 28px 24px;
  border-radius: 20px;
  background: rgba(10, 11, 22, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.welcome-card h1 {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 4vw, 2.05rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.welcome-card p {
  margin: 0 0 20px;
  font-size: 0.96rem;
  line-height: 1.5;
  color: rgba(235, 238, 255, 0.8);
  text-wrap: pretty;
}

.welcome-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.welcome-form input {
  width: 100%;
  min-block-size: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 0.95rem;
  text-align: center;
}

.welcome-form input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.welcome-form input:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 180px;
  min-block-size: 44px;
  padding: 11px 26px;
  border: 0;
  border-radius: 999px;
  background: #ffffff;
  color: #080912;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
}

@media (hover: hover) {
  .pill-btn:hover {
    background: rgba(255, 255, 255, 0.9);
  }
}

.pill-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

.drop-hint {
  margin: 14px 0 0 !important;
  font-size: 0.84rem !important;
  color: rgba(235, 238, 255, 0.55) !important;
}

/* Bottom-centre glass pill control bar */
.controls {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(10, 10, 18, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: 4;
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .controls {
    transition: opacity 0.4s ease;
  }
}

.controls.is-idle:not(:focus-within) {
  opacity: 0;
  pointer-events: none;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 42px;
  min-block-size: 42px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  cursor: pointer;
  flex-shrink: 0;
}

.ctrl-btn svg {
  display: block;
  pointer-events: none;
}

.ctrl-btn svg[hidden] {
  display: none;
}

@media (hover: hover) {
  .ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.2);
  }
}

.ctrl-btn[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
}

.ctrl-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

@media (forced-colors: active) {
  .ctrl-btn {
    border-color: ButtonText;
    color: ButtonText;
  }
  .ctrl-btn[aria-pressed="true"] {
    outline: 2px solid Highlight;
  }
}

/* Name edit dialog */
.name-dialog {
  width: min(360px, calc(100vw - 32px));
  padding: 20px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 13, 24, 0.94);
  color: #ffffff;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.name-dialog::backdrop {
  background: rgba(1, 2, 7, 0.65);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.dialog-close {
  min-inline-size: 32px;
  min-block-size: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.dialog-label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.88rem;
  color: rgba(235, 238, 255, 0.78);
}

.name-dialog input {
  width: 100%;
  min-block-size: 42px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 0.95rem;
}

.name-dialog input:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.dialog-btn {
  min-inline-size: 76px;
  min-block-size: 38px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 0;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.dialog-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.dialog-btn-primary {
  background: #ffffff;
  color: #080912;
}

/* Drag-over indicator */
body.is-dragging::after {
  content: "";
  position: fixed;
  inset: 14px;
  border-radius: 18px;
  border: 2px dashed rgba(255, 220, 180, 0.55);
  background: rgba(10, 11, 26, 0.3);
  pointer-events: none;
  z-index: 10;
}
