:root {
  --bg: #0e0f13;
  --panel: #181a21;
  --panel-2: #1f222b;
  --border: #2a2e3a;
  --text: #e8ebf3;
  --muted: #8a90a2;
  --accent: #7c5cff;
  --accent-2: #4ad7d1;
  --danger: #ff6b6b;
  --ok: #5fd17a;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent-2); }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Topbar — always on top */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: rgba(14, 15, 19, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: 0.5px; }
.user-area { justify-self: end; display: flex; gap: 12px; align-items: center; color: var(--muted); }
.user-area a { text-decoration: none; }

/* Mode switch */
.mode-switch {
  justify-self: center;
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}
.mode-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 600;
  transition: background .15s, color .15s;
}
.mode-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 92, 255, 0.35);
}

/* Main */
.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 120px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* History grid */
.history h2, .composer h2 { margin: 0 0 12px; font-size: 18px; }
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  min-height: 120px;
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .badge {
  position: absolute;
  top: 6px; left: 6px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
}
.tile .status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,.2), rgba(0,0,0,.5));
}

/* Composer */
.composer {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.composer textarea, .composer input[type="number"], .composer input[type="text"] {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}
.composer textarea:focus, .composer input:focus { outline: 2px solid var(--accent); }
.row { display: flex; gap: 12px; margin-top: 10px; }
.mode-hint { margin-top: 8px; font-size: 13px; }
.mode-hint strong { color: var(--accent-2); }
.row label { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.row input[type="number"] { width: 90px; }

.dropzone {
  margin-top: 10px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  transition: border-color .12s, background .12s;
}
.dropzone.drag { border-color: var(--accent); background: rgba(124,92,255,0.08); }
.dropzone .link { color: var(--accent-2); cursor: pointer; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; justify-content: center; }
.thumb {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .x {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,.7); color: #fff;
  border: 0; border-radius: 999px; width: 20px; height: 20px;
  line-height: 18px; padding: 0; font-size: 14px;
}

/* Video slots */
.slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}
.slot {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  background: var(--panel-2);
  transition: border-color .12s, background .12s;
}
.slot.drag { border-color: var(--accent); background: rgba(124,92,255,0.08); }
.slot.has-image { border-style: solid; }
.slot-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.slot-inner { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); }
.slot.has-image .slot-inner { padding: 0; }
.slot .preview { max-width: 100%; max-height: 220px; border-radius: 6px; }
.slot .x {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,.7); color: #fff;
  border: 0; border-radius: 999px; width: 24px; height: 24px;
  line-height: 22px; padding: 0; font-size: 16px;
}

/* Buttons */
.primary {
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
  transition: filter .12s, transform .06s;
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .6; cursor: not-allowed; }

/* Modal — always on top */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 920px;
  width: 100%;
  max-height: 92vh;
  overflow: auto;
  position: relative;
  padding: 18px;
}
.modal-close {
  position: absolute; top: 10px; right: 12px;
  background: transparent; color: var(--muted); border: 0;
  font-size: 28px; line-height: 1;
}
.modal-body img, .modal-body video { max-width: 100%; border-radius: 10px; display: block; margin: 0 auto 12px; }
.modal-body .meta { color: var(--muted); margin-bottom: 12px; }
.modal-body .corr { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.modal-body textarea { width: 100%; min-height: 90px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font: inherit; }
.modal-body .actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-body .danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 10px 16px;
  border-radius: 10px;
}

/* Login */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 0 0 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 14px; }
.login-card input { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 10px; border-radius: 8px; font: inherit; }
.login-card button { background: var(--accent); color: #fff; border: 0; padding: 12px; border-radius: 10px; font-weight: 600; }
.login-card .err { background: rgba(255,107,107,.12); color: var(--danger); padding: 8px 10px; border-radius: 8px; font-size: 14px; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); padding: 10px 14px; border-radius: 10px;
  z-index: 1100; opacity: 0; transition: opacity .2s;
  pointer-events: none; max-width: 90vw;
}
.toast.show { opacity: 1; }
.toast.err { border-color: var(--danger); color: var(--danger); }

/* Loading state */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
