:root {
  color-scheme: dark;
  --bg: #07060f;
  --surface: #0c0b1a;
  --surface-2: #111026;
  --surface-3: #181730;
  --border: #1e1c38;
  --border-2: #2b294e;
  --text: #ddd9f5;
  --text-2: #7872a8;
  --text-3: #44405e;
  --accent: #9d7fff;
  --accent-dim: rgba(157, 127, 255, 0.12);
  --accent-glow: rgba(157, 127, 255, 0.28);
  --danger: #f87171;
  --danger-dim: rgba(248, 113, 113, 0.1);
  --amber: #fbbf24;
  --green: #4ade80;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.7);
  --transition: 150ms ease;
}

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

html { height: 100%; }

body {
  min-height: 100%;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 55% at 50% -5%, rgba(120, 80, 255, 0.11) 0%, transparent 65%),
    radial-gradient(ellipse 50% 35% at 90% 90%, rgba(100, 60, 220, 0.06) 0%, transparent 60%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 6, 15, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  height: 54px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}

.brand-icon {
  width: 20px;
  height: 20px;
  color: var(--accent);
  flex-shrink: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.025em;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  line-height: 1.6;
}

/* ── buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  padding: 0 14px;
  height: 36px;
  text-decoration: none;
  white-space: nowrap;
  transition: filter var(--transition), opacity var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
  border: 1px solid transparent;
  flex-shrink: 0;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: rgba(157, 127, 255, 0.5);
  font-weight: 700;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-dim);
  border-color: rgba(248, 113, 113, 0.25);
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.18); }

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.btn-lg {
  height: 42px;
  padding: 0 22px;
  font-size: 15px;
}

/* ── inputs ── */
input:not([type="file"]) {
  width: 100%;
  height: 40px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 0 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:not([type="file"]):focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(157, 127, 255, 0.15);
}
input:not([type="file"])::placeholder { color: var(--text-3); }

/* ── main layout ── */
.main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── auth ── */
.auth-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 44px;
  padding: 64px 0 24px;
}

.auth-hero { text-align: center; }

.auth-title {
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.08;
  margin-bottom: 14px;
  background: linear-gradient(140deg, var(--text) 30%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-sub {
  color: var(--text-2);
  font-size: 16px;
}

.auth-cards {
  display: grid;
  grid-template-columns: repeat(2, 320px);
  gap: 20px;
}

/* ── card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
  letter-spacing: -0.02em;
}

/* ── forms ── */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-stack .btn { width: 100%; height: 40px; }

/* ── app section ── */
.app-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── upload ── */
.upload-form { display: flex; flex-direction: column; gap: 10px; }

#imageInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-zone {
  position: relative;
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.upload-zone:hover {
  border-color: var(--accent);
  background: rgba(157, 127, 255, 0.03);
}

.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(157, 127, 255, 0.07);
  box-shadow: 0 0 0 4px var(--accent-dim);
}

.upload-zone-body {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 28px 30px;
}

.upload-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
  transition: background var(--transition), border-color var(--transition);
}

.upload-icon svg { width: 20px; height: 20px; }

.upload-zone:hover .upload-icon,
.upload-zone.drag-over .upload-icon {
  background: var(--accent-dim);
  border-color: var(--accent-glow);
}

.upload-zone-text { display: flex; flex-direction: column; gap: 3px; }
.upload-zone-text strong { font-size: 15px; font-weight: 600; color: var(--text); }
.upload-sub { font-size: 13px; color: var(--text-2); }

.upload-progress {
  height: 3px;
  background: var(--surface-2);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

.upload-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 200ms ease;
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px var(--accent-glow);
}

.upload-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
}

.selected-file {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-2);
  min-width: 0;
}

.selected-file svg { color: var(--accent); flex-shrink: 0; }
#selectedFileName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── section ── */
.section-block { display: flex; flex-direction: column; gap: 14px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

/* tighter margin for the standalone section-block (which has its own gap) */
.section-block > .section-header {
  margin-bottom: 0;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* ── media grid ── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.media-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  aspect-ratio: 4 / 3;
  transition: border-color var(--transition);
}

.media-card:hover { border-color: var(--border-2); }

.media-card img,
.media-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-card video {
  object-fit: contain;
  background: #000;
}

.media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.5) 45%, rgba(0, 0, 0, 0.1) 100%);
  opacity: 0;
  transition: opacity var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px;
  gap: 7px;
}

.media-card:hover .media-overlay { opacity: 1; }

.media-overlay-info { min-width: 0; }

.media-overlay-name {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-overlay-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 1px;
}

.media-overlay-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.media-overlay-actions .btn {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

/* ── two col ── */
.two-col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* ── compact list ── */
.compact-list { display: flex; flex-direction: column; gap: 8px; }

.compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  min-width: 0;
  transition: border-color var(--transition);
}

.compact-row:hover { border-color: var(--border-2); }

.compact-row-info { min-width: 0; flex: 1; }

.compact-row-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.compact-row-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.compact-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-row.is-banned {
  border-color: rgba(248, 113, 113, 0.28);
  background: rgba(248, 113, 113, 0.05);
}

/* ── badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  height: 17px;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

.badge-admin { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-glow); }
.badge-promoted { background: rgba(251, 191, 36, 0.1); color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.25); }
.badge-banned { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.28); }

/* ── notice ── */
.notice {
  border: 1px solid rgba(157, 127, 255, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(157, 127, 255, 0.07);
  color: #cec6ff;
  padding: 12px;
  font-size: 13px;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

/* ── code ── */
code {
  font-family: "SF Mono", "Fira Code", ui-monospace, Consolas, monospace;
  font-size: 0.875em;
  color: var(--accent);
}

/* ── toast ── */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 16px;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  max-width: min(380px, calc(100vw - 44px));
}

/* ── utils ── */
.muted { color: var(--text-2); }
.hidden { display: none !important; }

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

.docs-header {
  padding: 36px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.docs-header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
}

.docs-header p { color: var(--text-2); margin-top: 6px; }

.docs-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.docs-panel h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.docs-panel p { color: var(--text-2); font-size: 14px; }

pre {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.45);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.65;
}

pre code { color: var(--text); }

table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 14px;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(255, 255, 255, 0.025);
}

tr:last-child td { border-bottom: 0; }
td { color: var(--text); }

/* ── responsive ── */
@media (max-width: 720px) {
  .main { padding: 24px 16px 60px; }
  .auth-section { padding-top: 40px; gap: 32px; }
  .auth-cards { grid-template-columns: 1fr; max-width: 400px; }
  .two-col { grid-template-columns: 1fr; }
  .upload-zone-body { padding: 22px 18px; gap: 14px; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .compact-row { flex-direction: column; align-items: flex-start; }
  .compact-row-actions { justify-content: flex-start; }
  .header-inner { padding: 0 16px; }
  .docs-header { flex-direction: column; align-items: flex-start; }
}
