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

:root {
  --bg: #0a0a0a;
  --surface: #111;
  --surface2: #1a1a1a;
  --border: #222;
  --text: #aaa;
  --text-bright: #ddd;
  --accent: #00ff88;
  --accent-dim: #004d29;
  --danger: #ff3366;
  --mono: 'Courier New', monospace;
}

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
}

/* Screens */
.screen { display: none; height: 100vh; }
.screen.active { display: flex; }

/* Splash / Auth */
#auth-screen {
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
  overflow: hidden;
}

.splash-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 50%, rgba(0, 255, 136, 0.04) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 50%, rgba(0, 100, 50, 0.03) 0%, transparent 60%);
  animation: splash-drift 8s ease-in-out infinite alternate;
}
@keyframes splash-drift {
  from { transform: scale(1) translate(0, 0); }
  to { transform: scale(1.1) translate(-2%, 1%); }
}

.splash-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  pointer-events: none;
  z-index: 1;
}

.auth-container {
  text-align: center;
  width: 340px;
  position: relative;
  z-index: 2;
}

.splash-logo { margin-bottom: 2.5rem; }

.splash-division {
  font-size: 0.6rem;
  letter-spacing: 0.5em;
  color: #444;
  margin-bottom: 0.5rem;
}

h1.glitch {
  font-size: 2.4rem;
  color: var(--accent);
  letter-spacing: 0.3em;
  margin-bottom: 0.4rem;
  text-shadow: 0 0 30px rgba(0, 255, 136, 0.25),
               0 0 60px rgba(0, 255, 136, 0.1);
  animation: glitch-flicker 4s step-end infinite;
}
@keyframes glitch-flicker {
  0%, 95%, 100% { opacity: 1; }
  96% { opacity: 0.8; transform: translateX(-1px); }
  97% { opacity: 1; transform: translateX(1px); }
  98% { opacity: 0.9; transform: translateX(0); }
}

.subtitle {
  font-size: 0.65rem;
  color: #444;
  margin-bottom: 0;
  letter-spacing: 0.2em;
}

.splash-line {
  width: 60px;
  height: 1px;
  background: var(--accent);
  margin: 1.5rem auto 0;
  opacity: 0.3;
}

#auth-form input {
  display: block;
  width: 100%;
  background: rgba(17, 17, 17, 0.8);
  border: 1px solid var(--border);
  color: var(--text-bright);
  padding: 12px 16px;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
}

#auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.12);
}

#auth-form input::placeholder { color: #444; }

.btn-login-full {
  width: 100%;
  margin-top: 4px;
}

.btn {
  padding: 12px;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  transition: all 0.2s;
}

.btn:hover {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.2);
}

.splash-footer {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  color: #333;
}
.splash-status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
  animation: pulse 2s infinite;
}

.error { color: var(--danger); font-size: 0.7rem; margin-top: 10px; }

/* App Layout */
#app-screen { position: relative; overflow: hidden; }

/* Map wrapper — 16:9 ratio, cover-fills viewport */
#map-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* Always cover the viewport while maintaining 16:9 */
  width: max(100vw, calc(100vh * 16 / 9));
  height: max(100vh, calc(100vw * 9 / 16));
}
#map {
  width: 100%;
  height: 100%;
}

/* Controls Panel */
#controls {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 280px;
  background: rgba(10, 10, 10, 0.92);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  z-index: 10;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--text-bright);
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.btn-icon {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
}
.btn-icon:hover { color: var(--danger); }

#geocoder-container { padding: 10px 14px; }
#geocoder-container .mapboxgl-ctrl-geocoder {
  width: 100%;
  max-width: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  box-shadow: none;
}
#geocoder-container .mapboxgl-ctrl-geocoder input {
  color: var(--text-bright);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.control-group {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}

.control-group label {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: #666;
  margin-bottom: 6px;
}

.control-group label span {
  color: var(--accent);
}

/* Sliders */
input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 2px;
  background: var(--border);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--accent);
  cursor: pointer;
  border-radius: 0;
}

/* Preset buttons */
.preset-buttons { display: flex; gap: 4px; }
.btn-preset {
  flex: 1;
  padding: 6px;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  transition: all 0.15s;
}
.btn-preset:hover { border-color: var(--text); }
.btn-preset.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* Capture button */
.btn-capture {
  width: 100%;
  padding: 12px;
  font-size: 0.8rem;
  border-color: var(--accent);
  color: var(--accent);
}
.btn-capture:hover {
  background: var(--accent);
  color: var(--bg);
}
.btn-capture.loading {
  pointer-events: none;
  opacity: 0.5;
  animation: pulse 1s infinite;
}

/* Render Status */
#render-result { padding: 8px 14px; }
#render-status {
  font-size: 0.7rem;
  color: var(--text);
}

/* Gallery */
#gallery { padding: 0; }
#gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 8px 14px;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
/* gallery item styles moved to .gallery-item */

/* Render Overlay — matches map-wrapper exactly (same 16:9 cover) */
#render-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: max(100vw, calc(100vh * 16 / 9));
  height: max(100vh, calc(100vw * 9 / 16));
  object-fit: fill;
  z-index: 5;
  pointer-events: none;
  transition: opacity 0.3s;
}

/* Render Toggle Button — to the left of ORACLE fab */
.render-toggle-btn {
  position: fixed;
  bottom: 20px;
  right: 76px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 100;
  transition: all 0.2s;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
  font-family: var(--mono);
}
.render-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.15);
}
.render-toggle-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

/* Style reference URL input */
#style-image-url {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-bright);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
}
#style-image-url:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.1);
}
#style-image-url::placeholder { color: #444; }

/* Loading screen */
#loading-screen {
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
  overflow: hidden;
}
.loading-container {
  text-align: center;
  position: relative;
  z-index: 2;
}
.loading-bar {
  width: 120px;
  height: 2px;
  background: var(--border);
  margin: 1.5rem auto 1rem;
  overflow: hidden;
}
.loading-bar-fill {
  width: 30%;
  height: 100%;
  background: var(--accent);
  animation: loading-sweep 1.2s ease-in-out infinite;
}
@keyframes loading-sweep {
  0% { transform: translateX(-100%); width: 30%; }
  50% { width: 60%; }
  100% { transform: translateX(400%); width: 30%; }
}
.loading-text {
  font-size: 0.55rem;
  letter-spacing: 0.15em;
  color: #444;
  animation: pulse 2s infinite;
}

/* Auth button states */
.btn-login-full:disabled {
  pointer-events: none;
  opacity: 0.5;
  border-color: var(--border);
  color: var(--text);
  animation: pulse 1s infinite;
}

/* Fade transition */
.screen.fade-out {
  animation: fadeOut 0.4s ease forwards;
}
@keyframes fadeOut {
  to { opacity: 0; }
}

/* Prompt preview + inline edit button */
.prompt-preview {
  font-size: 0.6rem;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-inline {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.15s;
}
.btn-inline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 500px;
  max-width: 90vw;
  max-height: 80vh;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--text-bright);
}
.modal textarea {
  width: 100%;
  padding: 14px;
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-bright);
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.5;
  resize: vertical;
}
.modal textarea:focus { outline: none; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.65rem;
}

/* Gallery delete button */
.gallery-item {
  position: relative;
}
.gallery-item img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s;
  display: block;
}
.gallery-item img:hover { border-color: var(--accent); }
.gallery-item img.gallery-active { border-color: var(--accent); box-shadow: 0 0 8px rgba(0, 255, 136, 0.2); }
.gallery-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.6rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-family: var(--mono);
}
.gallery-item:hover .gallery-delete { display: flex; }
.gallery-delete:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(0, 0, 0, 0.9);
}

/* Quick location suggestions */
.quick-suggestions {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  max-height: 200px;
  overflow-y: auto;
  position: relative;
  z-index: 10;
}
.quick-suggestion {
  display: block;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  transition: all 0.1s;
}
.quick-suggestion:last-child { border-bottom: none; }
.quick-suggestion:hover {
  background: rgba(0, 255, 136, 0.05);
  color: var(--accent);
}

.hidden { display: none !important; }

/* Mapbox overrides */
.mapboxgl-ctrl-attrib { display: none !important; }
