:root {
  --bg: #0b0b12;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --surface-solid: #141422;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f8fafc;
  --muted: #9ca3af;
  --input-bg: rgba(255, 255, 255, 0.05);
  --accent-start: #7c3aed;
  --accent-end: #2563eb;
  --accent-grad: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  --btn-text: #ffffff;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: light) {
  body:not(.tg-miniapp) {
    --bg: #f6f7fb;
    --surface: rgba(255, 255, 255, 0.85);
    --surface-hover: rgba(255, 255, 255, 0.98);
    --surface-solid: #ffffff;
    --border: rgba(15, 23, 42, 0.1);
    --text: #0f172a;
    --muted: #475569;
    --input-bg: #ffffff;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  }
}

body.tg-miniapp {
  --bg: var(--tg-theme-bg-color, #0b0b12);
  --surface: var(--tg-theme-secondary-bg-color, rgba(255, 255, 255, 0.05));
  --surface-solid: var(--tg-theme-secondary-bg-color, #141422);
  --text: var(--tg-theme-text-color, #f8fafc);
  --muted: var(--tg-theme-hint-color, #9ca3af);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --input-bg: var(--tg-theme-bg-color, #0b0b12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 45% at 50% -10%, rgba(124, 58, 237, 0.22), transparent 70%),
    radial-gradient(ellipse 60% 35% at 85% 5%, rgba(37, 99, 235, 0.14), transparent 70%);
  background-repeat: no-repeat;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

body.tg-miniapp {
  background-image: none;
}

:focus-visible {
  outline: 2px solid #8b5cf6;
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(11, 11, 18, 0.72);
  border-bottom: 1px solid var(--border);
}

@media (prefers-color-scheme: light) {
  body:not(.tg-miniapp) .site-header {
    background: rgba(246, 247, 251, 0.8);
  }
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-grad);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}

.brand-text {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* Tabs (Admin inside Mini App) */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px;
  border-radius: 14px;
  backdrop-filter: blur(12px);
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-btn.active {
  background: var(--accent-grad);
  color: #fff;
}

/* Hero */
.hero {
  text-align: center;
  padding: 16px 0 22px;
}

.hero-title {
  margin: 0 0 10px;
  font-size: clamp(24px, 4.4vw, 38px);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.03em;
}

.hero-sub {
  margin: 0 auto 18px;
  max-width: 600px;
  font-size: 15px;
  color: var(--muted);
}

.platforms-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.platform-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.platform-pill svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* Glass Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  animation: fadeUp 0.2s ease both;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Smart Input Bar */
.search-box {
  padding: 14px;
}

.smart-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px 6px 6px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.smart-input-wrap:focus-within {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.platform-indicator {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
}

.platform-indicator svg {
  width: 20px;
  height: 20px;
}

.smart-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 8px 4px;
  outline: none;
}

.smart-input::placeholder {
  color: var(--muted);
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

@media (max-width: 560px) {
  .smart-input-wrap {
    flex-wrap: wrap;
    padding: 8px 10px;
  }
  .input-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .btn-primary-submit {
    flex: 1;
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: 11px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, opacity 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn-primary {
  background: var(--accent-grad);
  color: var(--btn-text);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.28);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.94;
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.11);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 9px;
}

.btn-locked {
  background: var(--surface);
  color: var(--muted);
  border: 1px dashed var(--border);
  opacity: 0.8;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* Preview Card */
.preview-card {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}

@media (max-width: 700px) {
  .preview-card {
    grid-template-columns: 1fr;
  }
}

.preview-thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-solid);
  border: 1px solid var(--border);
}

.preview-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.duration-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
}

.preview-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}

.preview-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.limit-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.limit-note a {
  color: #8b5cf6;
  font-weight: 600;
  text-decoration: none;
}

.limit-note a:hover {
  text-decoration: underline;
}

/* Search Results Grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (max-width: 720px) {
  .results-grid {
    grid-template-columns: 1fr;
  }
}

.result-card {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  backdrop-filter: blur(12px);
  animation: fadeUp 0.2s ease both;
}

.result-thumb-wrap {
  position: relative;
  width: 128px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-solid);
  flex-shrink: 0;
  align-self: flex-start;
}

.result-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.result-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.result-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-author {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Jobs Panel */
.jobs-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.job-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  backdrop-filter: blur(12px);
  animation: fadeUp 0.2s ease both;
}

.job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.job-title {
  font-weight: 600;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-status-text {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent-grad);
  transition: width 0.25s ease;
}

.progress-fill.indeterminate {
  width: 40%;
  animation: indeterminate 1.2s ease-in-out infinite;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #7c3aed;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

/* Shimmer Skeleton */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 112px;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: shimmer 1.4s infinite;
}

/* How it works & FAQ */
.section-title {
  font-size: 19px;
  font-weight: 800;
  margin: 26px 0 12px;
  letter-spacing: -0.02em;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 720px) {
  .steps-grid {
    grid-template-columns: 1fr;
  }
}

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.step-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(124, 58, 237, 0.16);
  color: #a78bfa;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.step-title {
  font-weight: 700;
  font-size: 14px;
  margin: 0 0 4px;
}

.step-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

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

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item p {
  margin: 10px 0 2px;
  font-size: 13px;
  color: var(--muted);
}

/* Admin Panel */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.stat-val {
  font-size: 22px;
  font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-lbl {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.admin-input,
.admin-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

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

.field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 4px;
}

.user-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.user-row:last-child {
  border-bottom: none;
}

/* Footer */
.site-footer {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.site-footer a {
  color: #8b5cf6;
  text-decoration: none;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: calc(100% - 28px);
  background: #181826;
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 100;
  display: none;
}

.toast.show {
  display: block;
}

.toast.success {
  background: #065f46;
}

.toast.error {
  background: #991b1b;
}

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

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

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

@keyframes indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(260%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
