:root {
  color-scheme: dark;
  --bg: #101012;
  --bg-elevated: #1a1a1d;
  --border: #2c2c30;
  --text: #f1f1f2;
  --text-muted: #9a9aa2;
  --accent: #7c5cff;
  --accent-hover: #9277ff;
  --discord: #5865f2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.logout {
  color: var(--accent);
}

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px;
}

h1 {
  margin-top: 0;
  font-size: 1.6rem;
}

.breadcrumb {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.breadcrumb a {
  color: var(--accent);
}

.empty {
  color: var(--text-muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.card {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.thumb {
  position: relative;
  aspect-ratio: 2 / 3;
  background: #232326;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.cache-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  backdrop-filter: blur(2px);
}

.cache-badge-hit {
  background: rgba(46, 204, 113, 0.85);
}

.cache-badge-estimate {
  background: rgba(0, 0, 0, 0.6);
  color: var(--text-muted);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-placeholder {
  padding: 10px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.card-title {
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-detail {
  display: flex;
  gap: 32px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.video-thumb {
  width: 280px;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: #232326;
  flex-shrink: 0;
}

.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-placeholder.large {
  width: 100%;
  height: 100%;
  font-size: 1.2rem;
}

.video-info {
  flex: 1;
  min-width: 260px;
}

.overview {
  color: var(--text-muted);
  line-height: 1.5;
}

.meta {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.download-btn {
  display: inline-block;
  margin-top: 16px;
  padding: 12px 26px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
}

.download-btn:hover {
  background: var(--accent-hover);
}

.center-box {
  max-width: 420px;
  margin: 15vh auto 0;
  text-align: center;
}

.discord-btn {
  display: inline-block;
  margin-top: 20px;
  padding: 12px 28px;
  background: var(--discord);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
}

.discord-id {
  font-family: monospace;
  font-size: 1.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  display: inline-block;
  margin: 10px 0;
}

.nav {
  display: flex;
  gap: 18px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.nav a:hover {
  color: var(--text);
}

.nav-search {
  position: relative;
}

.nav-search input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--text);
  font-size: 0.85rem;
  width: 160px;
}

.nav-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.nav-search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 20;
}

.nav-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.nav-search-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.nav-search-thumb {
  position: relative;
  flex-shrink: 0;
  width: 32px;
  height: 48px;
  border-radius: 4px;
  overflow: hidden;
  background: #232326;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-search-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav-search-thumb .thumb-placeholder {
  font-size: 0.55rem;
  padding: 2px;
}

.nav-search-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-search-item .cache-badge {
  position: static;
  flex-shrink: 0;
  font-size: 0.6rem;
  padding: 2px 6px;
}

.nav-search-empty {
  padding: 14px 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.nav-search-all {
  display: block;
  padding: 10px 12px;
  text-align: center;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}

.search-page-form {
  display: flex;
  gap: 10px;
  max-width: 480px;
  margin-top: 16px;
}

.search-page-form input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text);
  font: inherit;
}

.search-page-form button {
  padding: 10px 20px;
  border-radius: 6px;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
}

.request-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 480px;
  margin-top: 18px;
}

.request-form label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 10px;
}

.request-form input,
.request-form textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.request-form button {
  align-self: flex-start;
  margin-top: 16px;
}

.success-box {
  background: rgba(46, 204, 113, 0.12);
  border: 1px solid #2ecc71;
  color: #2ecc71;
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 16px;
}

.error-box {
  background: rgba(231, 76, 60, 0.12);
  border: 1px solid #e74c3c;
  color: #e74c3c;
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 16px;
}

.admin-section {
  margin-top: 36px;
}

.admin-section h2 {
  font-size: 1.15rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.admin-section h3 {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.stat-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-tables {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.stat-tables .admin-table td:last-child {
  text-align: right;
  color: var(--text-muted);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 0.9rem;
}

.admin-table tr {
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 10px 8px;
  vertical-align: middle;
}

.admin-table .mono {
  font-family: monospace;
  color: var(--text-muted);
}

.admin-table .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-approve,
.btn-decline {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
}

.btn-approve {
  background: #2ecc71;
}

.btn-decline {
  background: #e74c3c;
}

.add-user-form {
  display: flex;
  gap: 10px;
  margin: 14px 0 20px;
  flex-wrap: wrap;
}

.add-user-form input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--text);
  font: inherit;
}

.add-user-form button {
  padding: 9px 18px;
  border-radius: 6px;
}

.vrc-section {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  max-width: 560px;
}

.vrc-section h2 {
  font-size: 1.1rem;
}

.inline-form {
  display: inline-block;
  margin: 0 8px 0 0;
}

.download-area {
  margin-top: 20px;
}

#progress-stage {
  max-width: 320px;
}

.progress-track {
  width: 100%;
  max-width: 320px;
  height: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

#progress-text {
  display: block;
  margin-top: 8px;
}

.vrc-link-area {
  margin-top: 18px;
}

.vrc-link-box {
  display: flex;
  gap: 8px;
}

.vrc-link-box input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--text);
  font-family: monospace;
  font-size: 0.85rem;
}

.vrc-link-box button {
  padding: 9px 16px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
