:root {
  --bg: #0a0d12;
  --bg-soft: #121722;
  --panel: rgba(18, 23, 34, 0.9);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f5f7fb;
  --muted: #9ca7bb;
  --primary: #7c8cff;
  --primary-strong: #5e77ff;
  --accent: #9eb0ff;
  --success: #44d29f;
  --danger: #ff6b88;
  --warning: #ffbf69;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --container: 1180px;
  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(124, 140, 255, 0.12), transparent 28%),
    linear-gradient(180deg, #090c11 0%, #0b0f16 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 72px 72px;
  opacity: 0.35;
  mask-image: radial-gradient(circle at center, black 18%, transparent 86%);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: 0; }

.container { width: min(var(--container), calc(100% - 32px)); margin: 0 auto; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(16px);
  background: rgba(10, 13, 18, 0.82);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.site-header .container,
.footer-inner,
.hero-actions,
.nav-links,
.header-actions,
.section-head,
.script-meta,
.profile-grid,
.dashboard-grid,
.catalog-grid,
.card-meta,
.comment-head,
.stats-row,
.upload-actions,
.auth-switch {
  display: flex;
  align-items: center;
}

.site-header .container {
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(124, 140, 255, 0.96), rgba(94, 119, 255, 0.92));
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.2), 0 8px 22px rgba(94, 119, 255, 0.22);
  position: relative;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.36);
}

.brand-mark::after {
  inset: 15px;
  border-radius: 7px;
  border-width: 0 0 1px 1px;
}

.brand-copy strong { display: block; font-size: 1rem; }
.brand-copy span { display: block; font-size: 0.72rem; color: var(--muted); }

.nav-links,
.header-actions,
.auth-switch,
.hero-actions,
.upload-actions,
.stats-row,
.card-meta,
.section-head,
.comment-head {
  gap: 12px;
}

.nav-links { flex-wrap: wrap; }

.nav-link {
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 999px;
  transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.header-actions { justify-content: flex-end; }
.menu-toggle {
  display: none;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
}

.menu-toggle span {
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
}

.page { padding: 40px 0 72px; }
.hero { position: relative; padding: 56px 0 28px; }

.hero-grid,
.feature-grid,
.cards-grid,
.dashboard-grid,
.profile-layout,
.catalog-layout,
.script-layout,
.admin-layout,
.upload-layout,
.footer-inner {
  display: grid;
  gap: 24px;
}

.hero-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  align-items: stretch;
}

.glass-card,
.panel,
.metric-card,
.script-card,
.feature-card,
.author-card,
.comment-card,
.empty-state,
.hero-panel,
.auth-card,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-copy,
.hero-panel,
.panel,
.metric-card,
.feature-card,
.script-card,
.author-card,
.comment-card,
.empty-state,
.auth-card,
.table-wrap {
  border-radius: var(--radius-xl);
}

.hero-copy {
  padding: 40px;
  background: rgba(15, 19, 28, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: #dbe2f3;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.02;
}

h1 {
  font-size: clamp(2.9rem, 6vw, 5rem);
  letter-spacing: -0.05em;
  margin-top: 18px;
}

h2 { font-size: clamp(2rem, 3vw, 2.8rem); letter-spacing: -0.04em; }
h3 { font-size: 1.12rem; }

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.lead {
  font-size: 1.05rem;
  max-width: 62ch;
  margin-top: 18px;
}

.hero-actions {
  margin-top: 26px;
  flex-wrap: wrap;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.stat-chip {
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-chip strong,
.metric-value {
  display: block;
  font-size: 1.45rem;
  color: var(--text);
  font-family: var(--font-display);
}

.hero-panel {
  padding: 22px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.hero-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.preview-card {
  min-height: 170px;
  border-radius: var(--radius-lg);
  padding: 18px;
  background: rgba(255, 255, 255, 0.025);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.preview-card.large { min-height: 210px; }
.preview-card span { color: #d9e1ff; font-size: 0.88rem; }
.preview-card strong { font-family: var(--font-display); font-size: 1.12rem; margin-top: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 14px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary { color: white; background: linear-gradient(135deg, var(--primary), var(--primary-strong)); box-shadow: 0 10px 24px rgba(94, 119, 255, 0.18); }
.btn-secondary { color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.08); }
.btn-ghost { color: var(--muted); background: transparent; border: 1px solid rgba(255, 255, 255, 0.06); }
.btn-danger { color: white; background: linear-gradient(135deg, #ff5f7d, #f43f5e); }

.section { margin-top: 24px; }
.section-head { justify-content: space-between; margin-bottom: 18px; }
.section-copy p { margin-top: 8px; }
.cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.script-card,
.feature-card,
.author-card,
.metric-card,
.comment-card {
  padding: 18px;
}

.script-cover {
  aspect-ratio: 4 / 5;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(8, 10, 14, 0.1), rgba(8, 10, 14, 0.82)),
    linear-gradient(135deg, rgba(124, 140, 255, 0.28), rgba(255, 255, 255, 0.04));
  display: flex;
  align-items: flex-end;
  padding: 18px;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.script-card h3,
.author-card h3,
.feature-card h3,
.metric-card h3,
.comment-card h4 {
  margin-top: 14px;
}

.tag,
.badge,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #d6defa;
  font-size: 0.82rem;
}

.card-meta {
  flex-wrap: wrap;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.feature-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  color: #e9edff;
  font-size: 1rem;
}

.author-card .avatar,
.profile-hero .avatar,
.comment-avatar,
.mini-avatar {
  border-radius: 50%;
  background: linear-gradient(135deg, #7c8cff, #5e77ff);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: var(--font-display);
}

.author-card .avatar,
.profile-hero .avatar {
  width: 72px;
  height: 72px;
  font-size: 1.4rem;
}

.avatar-image {
  display: block;
  object-fit: cover;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.comment-avatar,
.mini-avatar {
  width: 40px;
  height: 40px;
  font-size: 0.95rem;
}

.footer {
  padding: 34px 0 44px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(8, 10, 15, 0.6);
}

.footer-inner { grid-template-columns: 1.15fr 1fr 1fr; }
.footer-links { display: grid; gap: 10px; }
.table-wrap { overflow-x: auto; }

.auth-layout {
  display: grid;
  min-height: calc(100vh - 76px - 116px);
  place-items: center;
}

.auth-card {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  overflow: hidden;
}

.auth-aside,
.auth-main {
  padding: 32px;
}

.auth-aside { background: rgba(13, 17, 25, 0.95); }
.auth-main { background: rgba(16, 20, 28, 0.96); }

.auth-note-list {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

.notice-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.notice-line strong { color: var(--text); font-size: 0.95rem; }
.notice-line span { color: var(--muted); font-size: 0.92rem; }

.form-grid { display: grid; gap: 16px; }
.field { display: grid; gap: 8px; }
.field label { color: #d4dbf7; font-size: 0.92rem; }

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.textarea {
  min-height: 140px;
  resize: vertical;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: rgba(124, 140, 255, 0.8);
  background: rgba(255, 255, 255, 0.05);
}

.text-link {
  padding: 0;
  background: transparent;
  color: #c9d2e6;
  font-size: 0.9rem;
}

.text-link:hover { color: white; }

.form-hint,
.helper {
  color: var(--muted);
  font-size: 0.9rem;
}

.form-error { color: #ff9db0; min-height: 20px; font-size: 0.9rem; }
.form-success { color: #9ff3cb; min-height: 20px; font-size: 0.9rem; }
.hidden { display: none !important; }
.auth-inline-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.auth-quiz {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.panel { padding: 22px; }
.dashboard-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card small { display: block; margin-top: 6px; color: var(--muted); }
.profile-layout { grid-template-columns: 340px minmax(0, 1fr); }
.profile-hero { display: grid; gap: 18px; }
.profile-grid { justify-content: space-between; }

.xp-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent), var(--primary-strong));
}

.list-stack { display: grid; gap: 16px; }
.catalog-layout { grid-template-columns: 300px minmax(0, 1fr); }
.filters { position: sticky; top: 96px; display: grid; gap: 16px; }
.catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.script-layout { grid-template-columns: 340px minmax(0, 1fr); }

.script-cover-large {
  aspect-ratio: 4 / 5;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(8, 10, 14, 0.06), rgba(8, 10, 14, 0.8)),
    linear-gradient(135deg, rgba(124, 140, 255, 0.24), rgba(255, 255, 255, 0.04));
  background-size: cover;
  background-position: center;
}

.script-meta { flex-wrap: wrap; margin: 20px 0; }
.script-actions-stack { display: grid; gap: 12px; }
.inline-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.version-card {
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  display: grid;
  gap: 8px;
}
.version-card span {
  color: var(--muted);
  font-size: 0.92rem;
}
.version-card.active {
  border-color: rgba(124, 140, 255, 0.55);
  background: rgba(124, 140, 255, 0.08);
}
.script-preview-shell {
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}
.script-preview-frame {
  width: 100%;
  min-height: 820px;
  border: 0;
  background: #fff;
}
.rating-stars { display: flex; gap: 10px; flex-wrap: wrap; }

.star-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: white;
  background: rgba(255, 255, 255, 0.06);
}

.star-btn.active,
.star-btn:hover { background: linear-gradient(135deg, #ffbf69, #ff8a5b); }

.comment-form { display: grid; gap: 12px; margin-top: 18px; }
.comment-head { justify-content: space-between; }
.admin-layout, .upload-layout { grid-template-columns: minmax(0, 1fr); }
.table-wrap { overflow: hidden; }
table { width: 100%; border-collapse: collapse; }

th,
td {
  padding: 16px 18px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

th { color: #dfe6ff; font-size: 0.9rem; }
td { color: var(--muted); }

.empty-state { padding: 26px; text-align: center; }

.loader {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
  margin: 10px auto;
}

.toast-area {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 12px;
  z-index: 90;
}

.toast {
  padding: 14px 16px;
  border-radius: 14px;
  min-width: 260px;
  background: rgba(18, 23, 34, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
}

.toast.success { border-color: rgba(68, 210, 159, 0.4); }
.toast.error { border-color: rgba(255, 107, 136, 0.4); }
.toast.info { border-color: rgba(124, 140, 255, 0.4); }

.notice {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(124, 140, 255, 0.08);
  border: 1px solid rgba(124, 140, 255, 0.18);
}

.page-hero { display: grid; gap: 14px; margin-bottom: 24px; }
.divider { height: 1px; background: rgba(255, 255, 255, 0.06); margin: 22px 0; }
.progress-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.progress-grid-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.progress-card {
  padding: 22px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 12px;
}

.progress-card.compact {
  gap: 10px;
}

.progress-card strong {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

@media (max-width: 1100px) {
  .hero-grid,
  .profile-layout,
  .catalog-layout,
  .script-layout,
  .footer-inner,
  .auth-card {
    grid-template-columns: 1fr;
  }

  .cards-grid,
  .feature-grid,
  .dashboard-grid,
  .progress-grid,
  .progress-grid-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters { position: static; }
}

@media (max-width: 760px) {
  .site-header .container,
  .section-head,
  .profile-grid,
  .field-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .menu-toggle {
    display: inline-flex;
    position: absolute;
    top: 14px;
    right: 16px;
  }

  .site-header {
    position: sticky;
  }

  .site-header .container {
    position: relative;
    min-height: auto;
    padding-top: 14px;
    padding-bottom: 14px;
    padding-right: 64px;
  }

  .brand {
    max-width: calc(100% - 16px);
  }

  .nav-links,
  .header-actions {
    width: 100%;
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: stretch;
  }

  .site-header.menu-open .nav-links,
  .site-header.menu-open .header-actions {
    display: grid;
  }

  .cards-grid,
  .catalog-grid,
  .hero-panel-grid,
  .feature-grid,
  .dashboard-grid,
  .hero-stats,
  .progress-grid,
  .progress-grid-compact {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .hero-panel,
  .panel,
  .auth-main,
  .auth-aside {
    padding: 20px;
  }

  .header-actions .btn,
  .nav-links .nav-link,
  .hero-actions .btn,
  .upload-actions .btn,
  .auth-inline-actions .btn,
  .inline-actions .btn {
    width: 100%;
  }

  .nav-link,
  .header-actions .btn {
    justify-content: center;
    text-align: center;
  }

  .footer-inner {
    gap: 18px;
  }

  .brand-copy span {
    display: none;
  }

  .page { padding-top: 24px; }
  h1 { font-size: 2.7rem; }
  .footer { padding-top: 18px; }
  .script-preview-frame { min-height: 520px; }

  th,
  td {
    padding: 12px;
    font-size: 0.9rem;
  }
}
