/* 2026 Vision — dark-only, glassmorphism, fluid transitions. Pure CSS, no framework. */

:root {
  --bg: #121217;
  --bg-2: #1a1a22;
  --panel: rgba(30, 31, 42, 0.55);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #ecedf2;
  --muted: #9a9aa8;
  --faint: #6c6c7a;
  --accent: #4c7cf3;
  --accent-2: #638cf5;
  --danger: #ff6b6b;
  --field: rgba(255, 255, 255, 0.04);
  --field-border: rgba(255, 255, 255, 0.12);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 78% -10%, rgba(76, 124, 243, 0.18), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(124, 92, 243, 0.14), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ---- Sidebar panel (glassmorphism) ---- */

.panel {
  width: 380px;
  flex-shrink: 0;
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  animation: panel-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.glass {
  background: var(--panel);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border-right: 1px solid var(--panel-border);
}

.panel-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---- Segmented mode control ---- */

.segmented {
  position: relative;
  display: flex;
  padding: 4px;
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: 12px;
}

.seg {
  flex: 1;
  position: relative;
  z-index: 1;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  border-radius: 9px;
  transition: color 0.25s ease;
}

.seg-active {
  color: #fff;
}

.seg-thumb {
  position: absolute;
  z-index: 0;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 9px;
  box-shadow: 0 6px 18px rgba(76, 124, 243, 0.35);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.segmented[data-mode="text"] .seg-thumb {
  transform: translateX(100%);
}

/* ---- Input panes ---- */

.pane {
  animation: fade-in 0.3s ease both;
}

.hidden {
  display: none !important;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 30px 18px;
  min-height: 180px;
  border: 1.5px dashed var(--field-border);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease;
}

.dropzone:hover {
  border-color: rgba(76, 124, 243, 0.6);
  background: rgba(76, 124, 243, 0.06);
}

.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(76, 124, 243, 0.12);
  transform: scale(1.01);
}

.dz-icon {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dz-text {
  font-size: 13.5px;
}

.dz-text strong {
  color: var(--accent-2);
}

.dz-hint {
  font-size: 11.5px;
  color: var(--faint);
}

.dz-file {
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
}

.text-input {
  width: 100%;
  resize: none;
  min-height: 120px;
  padding: 12px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
}

.text-input::placeholder {
  color: var(--faint);
}

.text-input:focus {
  outline: none;
  border-color: rgba(76, 124, 243, 0.7);
  box-shadow: 0 0 0 3px rgba(76, 124, 243, 0.16);
}

.counter {
  margin-top: 6px;
  text-align: right;
  font-size: 11.5px;
  color: var(--faint);
}

.counter.over {
  color: var(--danger);
}

/* ---- Validation ---- */

.validation {
  margin: 0;
  min-height: 16px;
  font-size: 12.5px;
  color: var(--danger);
}

/* ---- Generate button ---- */

.generate {
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.1s ease, opacity 0.2s ease;
  box-shadow: 0 8px 22px rgba(76, 124, 243, 0.3);
}

.generate:hover:not(:disabled) {
  filter: brightness(1.08);
}

.generate:active:not(:disabled) {
  transform: translateY(1px);
}

.generate:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.generate.busy {
  position: relative;
  color: transparent;
}

.generate.busy::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---- Status / progress ---- */

.status {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--field);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s ease;
}

.progress.indeterminate .progress-bar {
  width: 35%;
  animation: slide 1.1s ease-in-out infinite;
}

.status-text {
  margin: 0;
  min-height: 16px;
  font-size: 12.5px;
  color: var(--muted);
}

.status-text.error {
  color: var(--danger);
}

.recovery {
  display: flex;
  gap: 8px;
}

.btn-ghost {
  flex: 1;
  padding: 9px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--field);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ---- Recent models (history) ---- */

.history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
}

.history-clear {
  padding: 2px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--faint);
  font-size: 11px;
  font-weight: 550;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.history-clear:hover {
  color: var(--danger);
  background: rgba(255, 107, 107, 0.1);
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-item {
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--field-border);
  background: var(--field);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.history-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.history-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 6px 16px rgba(76, 124, 243, 0.35);
}

.history-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---- Viewer ---- */

.viewer {
  position: relative;
  flex: 1;
  min-width: 0;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---- Download button ---- */

.download-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(24, 25, 34, 0.92);
  border: 1px solid var(--panel-border);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.download-btn:hover {
  background: rgba(76, 124, 243, 0.16);
  border-color: rgba(76, 124, 243, 0.5);
}

.download-btn:active {
  transform: translateY(1px);
}

.download-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: var(--text);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Viewer settings menu (mock UI) ---- */

.settings-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3; /* sits in the popover's top-right corner, above the panel */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(24, 25, 34, 0.92);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.settings-btn:hover {
  background: rgba(76, 124, 243, 0.16);
  border-color: rgba(76, 124, 243, 0.5);
}

.settings-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: var(--text);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.settings-toggle:checked ~ .settings-btn {
  background: rgba(76, 124, 243, 0.2);
  border-color: var(--accent);
}

.settings-toggle:checked ~ .settings-btn svg {
  transform: rotate(60deg);
  stroke: var(--accent-2);
}

.settings-popover {
  position: absolute;
  top: 16px; /* aligns with the gear so it sits in this panel's top-right corner */
  right: 16px;
  z-index: 2;
  width: 232px;
  padding: 50px 14px 14px; /* clear the gear button occupying the top-right corner */
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-radius: var(--radius);
  /* Stay dark regardless of the scene background behind it (overrides .glass). */
  background: rgba(24, 25, 34, 0.95);
  border: 1px solid var(--panel-border);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.settings-toggle:checked ~ .settings-popover {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.settings-title {
  position: absolute;
  top: 0;
  left: 16px;
  height: 42px; /* spans the header strip; centers against the gear in the corner */
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* ---- Model details popover (same dropdown pattern as settings) ---- */

.info-btn {
  position: absolute;
  top: 66px; /* directly below the download button (top:16 + 40 height + 10 gap) */
  left: 16px;
  z-index: 3; /* sits in the popover's top-left corner, above the panel */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(24, 25, 34, 0.92);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.info-btn:hover {
  background: rgba(76, 124, 243, 0.16);
  border-color: rgba(76, 124, 243, 0.5);
}

.info-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: var(--text);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.info-toggle:checked ~ .info-btn {
  background: rgba(76, 124, 243, 0.2);
  border-color: var(--accent);
}

.info-toggle:checked ~ .info-btn svg {
  stroke: var(--accent-2);
}

.info-popover {
  position: absolute;
  top: 66px; /* aligns with the info button so it sits in this panel's top-left corner */
  left: 16px;
  z-index: 2;
  width: 232px;
  padding: 50px 14px 14px; /* clear the info button occupying the top-left corner */
  border-radius: var(--radius);
  /* Stay dark regardless of the scene background behind it (overrides .glass). */
  background: rgba(24, 25, 34, 0.95);
  border: 1px solid var(--panel-border);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  transform-origin: top left;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.info-toggle:checked ~ .info-popover {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.info-title {
  position: absolute;
  top: 0;
  left: 48px; /* header strip, to the right of the info button in the corner */
  height: 42px;
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 4px;
}

.switch,
.select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.18s ease;
}

.model-info {
  display: flex;
  flex-direction: column;
}

.mi-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 6px;
  font-size: 12.5px;
  border-radius: 6px;
}

.mi-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.025);
}

.mi-key {
  color: var(--faint);
}

.mi-val {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.switch:hover,
.select-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--field);
  border: 1px solid var(--field-border);
  transition: background 0.22s ease, border-color 0.22s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), background 0.22s ease;
}

.switch input:checked + .switch-track {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
  background: #fff;
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px rgba(76, 124, 243, 0.3);
}

.settings-select {
  flex-shrink: 0;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--field-border);
  background: var(--bg-2);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.settings-select:focus {
  outline: none;
  border-color: rgba(76, 124, 243, 0.7);
}

/* The native option popup: match the dark menu instead of the browser default white. */
.settings-select option {
  background: var(--bg-2);
  color: var(--text);
}

/* ---- Texture-map thumbnail previews ---- */

.tex-thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.tex-thumb {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tex-thumb canvas {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--field-border);
  background:
    repeating-conic-gradient(#2a2b35 0% 25%, #20212a 0% 50%) 50% / 12px 12px; /* checker for empty/alpha */
  object-fit: cover;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tex-thumb:not(.empty) canvas:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.tex-thumb.empty canvas {
  opacity: 0.5;
  cursor: default;
}

.tex-thumb figcaption {
  font-size: 10px;
  color: var(--faint);
  text-align: center;
}

.tex-thumb.empty figcaption::after {
  content: " · none";
}

/* ---- Full-size texture preview overlay ---- */

.tex-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 12, 16, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  /* Opacity-only fade — a translate here would shift this full-bleed overlay past the
     viewport edge and flash a scrollbar. */
  animation: overlay-in 0.2s ease both;
}

@keyframes overlay-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.tex-overlay-canvas {
  max-width: 90%;
  max-height: 84%;
  width: auto;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: repeating-conic-gradient(#2a2b35 0% 25%, #20212a 0% 50%) 50% / 22px 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

.tex-overlay-close {
  position: absolute;
  top: 18px;
  left: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 8px 10px;
  border-radius: 10px;
  background: rgba(24, 25, 34, 0.9);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.tex-overlay-close:hover {
  background: rgba(76, 124, 243, 0.16);
  border-color: rgba(76, 124, 243, 0.5);
}

.tex-overlay-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tex-overlay-caption {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(18, 18, 23, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
}

.viewer-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  font-size: 11.5px;
  color: var(--muted);
  background: rgba(18, 18, 23, 0.5);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.viewer:hover .viewer-hint {
  opacity: 1;
}

/* ---- Keyframe animations (AC-3) ---- */

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateX(-14px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}
