/* ═══════════════════════════════════════════════════════
   MIRRORTRACE STUDIO — Dark Cinematic Theme
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-deep: #07070B;
  --bg-surface: #0D0D14;
  --bg-card: #13131C;
  --bg-elevated: #1A1A26;
  --bg-hover: #1F1F2E;

  --accent: #F5A623;
  --accent-20: rgba(245, 166, 35, 0.20);
  --accent-10: rgba(245, 166, 35, 0.10);
  --accent-05: rgba(245, 166, 35, 0.05);
  --accent-warm: #FF8C00;
  --accent-warm-20: rgba(255, 140, 0, 0.20);

  --text-1: #F0F0F3;
  --text-2: #9494A0;
  --text-3: #5A5A68;
  --dim: #44444F;

  --border: rgba(255, 255, 255, 0.06);
  --border-active: rgba(255, 255, 255, 0.12);
  --border-accent: rgba(245, 166, 35, 0.25);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --font-display: 'Inter', sans-serif;
  --font-logo: 'Syne', sans-serif;
  --font-body: 'Figtree', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-glow: 0 0 40px rgba(245, 166, 35, 0.08);
  --shadow-card: 0 2px 20px rgba(0, 0, 0, 0.4);
  --shadow-elevated: 0 8px 40px rgba(0, 0, 0, 0.6);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* ── NOISE OVERLAY ── */
.noise {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px;
}

/* ── APP ── */
.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  position: relative;
  z-index: 1;
}

/* ── HEADER ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header__icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--accent-10);
  border: 1px solid var(--border-accent);
}

.header__title {
  font-family: var(--font-logo);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, var(--accent), #FFD080);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header__sub {
  font-size: 0.78rem;
  color: var(--text-3);
  font-weight: 400;
  margin-top: 1px;
}

/* ── LANGUAGE SWITCHER ── */
.header__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-switcher {
  display: flex;
  gap: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 3px;
}

.lang-btn {
  padding: 4px 10px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 100px;
  color: var(--text-3);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  font-family: var(--font-mono);
}

.lang-btn:hover {
  color: var(--text-2);
  background: var(--bg-elevated);
}

.lang-btn.active {
  color: var(--accent);
  background: var(--accent-10);
  border-color: var(--border-accent);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 100px;
}

.badge svg { color: var(--accent); }

/* ── FEATURE NAV ── */
.features {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 28px;
}

.feat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.feat::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--accent-10) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.feat:hover {
  border-color: var(--border-active);
  background: var(--bg-elevated);
}

.feat:hover::before { opacity: 1; }

.feat.active {
  border-color: var(--border-accent);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-glow);
}

.feat.active::before { opacity: 1; }

.feat__icon {
  position: relative;
  color: var(--text-3);
  transition: color 0.25s ease;
}

.feat.active .feat__icon { color: var(--accent); }
.feat:hover .feat__icon { color: var(--text-2); }

.feat__label {
  position: relative;
  font-size: 0.76rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}

.feat__desc {
  position: relative;
  font-size: 0.65rem;
  color: var(--text-3);
  text-align: center;
}

.feat.active .feat__label { color: var(--accent); }

/* ── WORKSPACE ── */
.workspace {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── UPLOADS ── */
.uploads {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.uploads.two-up {
  grid-template-columns: 1fr 1fr;
}

.zone {
  position: relative;
  border: 2px dashed var(--border-active);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
}

.zone:hover {
  border-color: var(--accent);
  background: var(--accent-05);
}

.zone.dragover {
  border-color: var(--accent);
  background: var(--accent-10);
  box-shadow: inset 0 0 40px var(--accent-05);
}

.zone.has-image {
  border-style: solid;
  border-color: var(--border-accent);
  cursor: default;
}

.zone__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 30px;
  text-align: center;
}

.zone__svg {
  color: var(--text-3);
  opacity: 0.6;
}

.zone__title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-2);
}

.zone__hint {
  font-size: 0.75rem;
  color: var(--text-3);
}

.zone__filled {
  width: 100%;
  height: 100%;
  min-height: 220px;
  position: relative;
}

.zone__img {
  width: 100%;
  height: 100%;
  min-height: 220px;
  max-height: 400px;
  object-fit: contain;
  background: var(--bg-deep);
  padding: 8px;
}

.zone__clear {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-1);
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.zone__clear:hover {
  background: rgba(255, 80, 80, 0.6);
  border-color: rgba(255, 80, 80, 0.4);
}

/* ── CONTROLS ── */
.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ctrl {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ctrl__label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctrl__label svg { color: var(--text-3); }

.dim { color: var(--text-3); font-weight: 400; }

.ctrl__input,
.ctrl__textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-1);
  transition: border-color 0.2s ease;
  width: 100%;
  resize: vertical;
}

.ctrl__input:focus,
.ctrl__textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-10);
}

.ctrl__input::placeholder,
.ctrl__textarea::placeholder {
  color: var(--text-3);
}

/* ── RATIO BUTTONS ── */
.ratios {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ratio {
  padding: 7px 16px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 100px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-2);
  transition: all 0.2s ease;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.ratio:hover {
  background: var(--bg-elevated);
  border-color: var(--border-active);
}

.ratio.active {
  background: var(--accent-20);
  border-color: var(--border-accent);
  color: var(--accent);
}

/* ── MODE TOGGLE ── */
.mode-toggle {
  display: flex;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
}

.mode-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.25s ease;
}

.mode-btn:hover {
  color: var(--text-2);
  background: var(--bg-card);
}

.mode-btn.active {
  color: var(--accent);
  background: var(--accent-10);
  border-color: var(--border-accent);
  box-shadow: 0 0 12px var(--accent-05);
}

.mode-btn svg { flex-shrink: 0; }

/* ── GENERATE BUTTON ── */
.btn-gen {
  position: relative;
  width: 100%;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #00B8A3);
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn-gen:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: saturate(0.3);
}

.btn-gen:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 24px var(--accent-20);
}

.btn-gen:not(:disabled):active {
  transform: translateY(0);
}

.btn-gen__glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.15) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn-gen:not(:disabled):hover .btn-gen__glow { opacity: 1; }

.btn-gen__inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--bg-deep);
  letter-spacing: 0.01em;
}

/* ── RESULT ── */
.result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: resultReveal 0.5s ease;
}

@keyframes resultReveal {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.result__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.result__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
}

.result__btns {
  display: flex;
  gap: 8px;
}

.rbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.76rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--accent-10);
  border: 1px solid var(--border-accent);
  color: var(--accent);
  transition: all 0.2s ease;
}

.rbtn:hover {
  background: var(--accent-20);
}

.rbtn--alt {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-2);
}

.rbtn--alt:hover {
  background: var(--bg-hover);
  border-color: var(--border-active);
}

.result__canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  min-height: 200px;
  padding: 4px;
}

.result__img {
  max-width: 100%;
  max-height: 600px;
  object-fit: contain;
  border-radius: 4px;
}

.result__json {
  border-top: 1px solid var(--border);
  max-height: 400px;
  overflow: auto;
}

.result__json pre {
  padding: 16px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── LOADING OVERLAY ── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 7, 11, 0.85);
  backdrop-filter: blur(12px);
  animation: overlayIn 0.3s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 50px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-elevated);
  text-align: center;
  min-width: 300px;
}

/* ── SPINNER ── */
.spinner {
  position: relative;
  width: 56px;
  height: 56px;
}

.spinner__ring {
  position: absolute;
  inset: 0;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner__ring--2 {
  inset: 6px;
  border-top-color: transparent;
  border-right-color: var(--accent);
  animation-direction: reverse;
  animation-duration: 0.7s;
  opacity: 0.5;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.overlay__step {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-1);
}

.overlay__track {
  width: 200px;
  height: 3px;
  background: var(--bg-elevated);
  border-radius: 10px;
  overflow: hidden;
}

.overlay__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #FFD080);
  border-radius: 10px;
  transition: width 0.5s ease;
}

.overlay__hint {
  font-size: 0.72rem;
  color: var(--text-3);
}

/* ── TOASTS ── */
.toasts {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-1);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 4.7s forwards;
  max-width: 360px;
}

.toast--error {
  border-color: rgba(255, 80, 80, 0.3);
  background: rgba(255, 30, 30, 0.15);
}

.toast--success {
  border-color: var(--border-accent);
  background: var(--accent-10);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-active); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── RESPONSIVE ── */
@media (max-width: 520px) {
  .app { padding: 16px 12px 40px; }

  .features {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .feat { padding: 12px 6px; }
  .feat__desc { display: none; }
  .feat__label { font-size: 0.7rem; }

  .uploads.two-up { grid-template-columns: 1fr; }

  .header__right .badge { display: none; }

  .header {
    gap: 8px;
  }

  .header__brand {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .header__title {
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header__sub {
    font-size: 0.68rem;
  }

  .lang-switcher {
    padding: 2px;
    gap: 2px;
  }

  .lang-btn {
    padding: 3px 8px;
    font-size: 0.62rem;
  }

  .overlay__card {
    padding: 30px 24px;
    min-width: unset;
    margin: 0 16px;
  }

  .result__bar {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
}

@media (max-width: 400px) {
  .features {
    grid-template-columns: repeat(2, 1fr);
  }

  .ratios { gap: 4px; }

  .ratio {
    padding: 6px 12px;
    font-size: 0.72rem;
  }
}
