:root {
  --bg: #0a0908;
  --bg-alt: #131110;
  --surface: #17140f;
  --surface-hi: #1f1a12;
  --border: #3a2f18;
  --border-bright: #6b5424;
  --text: #ede3cf;
  --text-dim: #a89878;
  --gold: #f0c419;
  --gold-soft: #d9ad3f;
  --gold-dim: #8a7128;
  --blue: #5a86b8;
  --blue-soft: #7ea3cc;
  --accent-grad: linear-gradient(135deg, #f6d976 0%, #d9ad3f 45%, #b8862c 100%);
  --success: #7ec98f;
  --danger: #d97a6c;
  --warn: #e0b84a;
  --radius: 10px;
  --radius-sm: 6px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  min-height: 100%;
}

body {
  background-image:
    radial-gradient(circle at 10% 5%, rgba(240, 196, 25, 0.05), transparent 40%),
    radial-gradient(circle at 90% 15%, rgba(90, 134, 184, 0.06), transparent 38%),
    repeating-linear-gradient(45deg, rgba(240, 196, 25, 0.015) 0px, rgba(240, 196, 25, 0.015) 1px, transparent 1px, transparent 26px);
  background-attachment: fixed;
  position: relative;
}

a { color: var(--gold-soft); text-decoration: underline dotted rgba(217, 173, 63, 0.5); text-underline-offset: 3px; }
a:hover { color: var(--blue-soft); text-decoration-color: var(--blue-soft); }

img { max-width: 100%; display: block; }

::selection { background: var(--gold); color: #0a0908; }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border: 3px solid var(--bg); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-soft); }

/* --- corner stickers ------------------------------------------------------ */

.corner-sticker {
  position: fixed;
  width: 74px;
  height: 74px;
  z-index: 200;
  pointer-events: none;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.6));
}
.sticker-tl { top: 46px; left: 10px; transform: rotate(-6deg); }
.sticker-tr { top: 46px; right: 10px; transform: rotate(6deg); }
.sticker-bl { bottom: 10px; left: 10px; transform: rotate(5deg); }
.sticker-br { bottom: 10px; right: 10px; transform: rotate(-5deg); }
@media (max-width: 780px) {
  .corner-sticker { width: 46px; height: 46px; }
}

/* --- marquee ticker -------------------------------------------------------- */

.marquee-bar {
  background: linear-gradient(90deg, #14110a, #1c1509, #14110a);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  white-space: nowrap;
  padding: 5px 0;
}
.marquee-track {
  display: inline-block;
  padding-left: 100%;
  color: var(--gold-dim);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  font-family: "Courier New", monospace;
  animation: marquee 32s linear infinite;
}
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* --- layout ------------------------------------------------------------- */

.page-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: rgba(10, 9, 8, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-decoration: none;
}

.brand .moon { font-size: 1.4rem; color: var(--gold); filter: drop-shadow(0 0 6px rgba(240, 196, 25, 0.5)); }
.brand .grad-text {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 18px rgba(240, 196, 25, 0.15);
}

.topbar-spacer { flex: 1; }

.topbar nav { display: flex; align-items: center; gap: 6px; }
.topbar nav a, .topbar nav button.linklike {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.86rem;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  cursor: pointer;
  font-family: Georgia, serif;
  text-decoration: none;
}
.topbar nav a:hover, .topbar nav button.linklike:hover { color: var(--gold); background: var(--surface); text-decoration: none; }

.avatar-mini {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-bright);
}

/* --- buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: Georgia, serif;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.btn-primary { background: var(--accent-grad); color: #1a1206; box-shadow: 0 3px 14px rgba(240, 196, 25, 0.25); border-color: #8a7128; }
.btn-primary:hover { filter: brightness(1.08); color: #1a1206; }

.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border-bright); }
.btn-ghost:hover { background: var(--surface-hi); color: var(--gold-soft); }

.btn-danger { background: rgba(217, 122, 108, 0.1); color: var(--danger); border: 1px solid rgba(217, 122, 108, 0.35); }
.btn-danger:hover { background: rgba(217, 122, 108, 0.2); color: var(--danger); }

.btn-sm { padding: 6px 12px; font-size: 0.76rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- forms ------------------------------------------------------------ */

.form-card {
  max-width: 460px;
  margin: 60px auto;
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 20px 50px rgba(0, 0, 0, 0.5);
}

.form-card h1 { margin-top: 0; font-size: 1.4rem; color: var(--gold-soft); }
.form-card p.sub { color: var(--text-dim); margin-top: -8px; font-size: 0.88rem; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.74rem; font-weight: 700; color: var(--gold-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }

input[type=text], input[type=password], input[type=email], input[type=file], textarea, select {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: Georgia, serif;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, textarea:focus, select:focus { outline: 1px solid var(--gold); outline-offset: 1px; border-color: var(--gold-dim); }

.checkbox-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.checkbox-row input { width: auto; }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  margin-bottom: 16px;
}
.alert-error { background: rgba(217, 122, 108, 0.1); color: #e8a89c; border: 1px solid rgba(217, 122, 108, 0.3); }
.alert-info { background: rgba(90, 134, 184, 0.1); color: var(--blue-soft); border: 1px solid rgba(90, 134, 184, 0.3); }

/* --- dividers -------------------------------------------------------------- */

.star-divider {
  height: 1px;
  margin: 40px auto 16px;
  max-width: 240px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

/* --- video grid ---------------------------------------------------------- */

.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 32px 0 16px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px;
}

.video-card { display: block; text-decoration: none; }
.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem;
  background: linear-gradient(135deg, #1c1712, #100d09);
  color: var(--gold-dim);
}
.video-card:hover .thumb-wrap { border-color: var(--gold-dim); box-shadow: 0 0 0 1px var(--gold-dim), 0 8px 24px rgba(240, 196, 25, 0.08); }

.video-card .meta { display: flex; gap: 10px; margin-top: 10px; }
.video-card .meta img.avatar-mini { flex-shrink: 0; }
.video-card .title { font-weight: 700; font-size: 0.92rem; line-height: 1.3; margin: 0 0 4px; color: var(--text); }
.video-card .sub-meta { color: var(--text-dim); font-size: 0.78rem; font-family: "Courier New", monospace; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state .big-emoji { font-size: 2.4rem; margin-bottom: 10px; color: var(--gold-dim); }

/* --- watch page ---------------------------------------------------------- */

.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  margin-top: 20px;
}
@media (max-width: 900px) {
  .watch-layout { grid-template-columns: 1fr; }
}

.player-shell {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-bright);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 20px 60px rgba(240, 196, 25, 0.06);
  position: relative;
}
.player-shell video { width: 100%; display: block; max-height: 74vh; background: #000; }

.quality-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.quality-bar .label { color: var(--text-dim); font-size: 0.76rem; margin-right: 4px; font-family: "Courier New", monospace; }
.quality-btn {
  background: var(--bg-alt);
  border: 1px solid var(--border-bright);
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 3px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  font-family: "Courier New", monospace;
}
.quality-btn.active { background: var(--accent-grad); color: #1a1206; border-color: #8a7128; }
.quality-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.processing-note { color: var(--warn); font-size: 0.8rem; padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--border); font-family: "Courier New", monospace; }
.p2p-note { color: var(--blue-soft); font-size: 0.76rem; padding: 8px 14px; background: var(--surface); border-top: 1px solid var(--border); font-family: "Courier New", monospace; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.peer-count-badge { background: rgba(90, 134, 184, 0.14); border: 1px solid rgba(90, 134, 184, 0.35); color: var(--blue-soft); padding: 2px 10px; border-radius: 999px; font-size: 0.72rem; white-space: nowrap; }

.watch-title { font-size: 1.3rem; font-weight: 700; margin: 18px 0 6px; color: var(--text); }
.watch-subrow { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.watch-owner { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.watch-owner .name { font-weight: 700; color: var(--gold-soft); }
.watch-owner .views { color: var(--text-dim); font-size: 0.78rem; font-family: "Courier New", monospace; }

.description-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  white-space: pre-wrap;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.5;
}

.owner-tools { display: flex; gap: 8px; }

.suggestion-list { display: flex; flex-direction: column; gap: 12px; }
.suggestion-card { display: flex; gap: 10px; text-decoration: none; }
.suggestion-card .thumb-wrap { width: 150px; flex-shrink: 0; aspect-ratio: 16/9; border-radius: var(--radius-sm); }
.suggestion-card .title { font-size: 0.82rem; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.suggestion-card .sub-meta { font-size: 0.74rem; }

/* --- space (profile) page ------------------------------------------------- */

.banner {
  width: 100%;
  aspect-ratio: 6 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, #1c1712, #241a0c);
  border: 1px solid var(--border-bright);
}
.banner img { width: 100%; height: 100%; object-fit: cover; }

.space-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: -46px 0 26px 24px;
  position: relative;
}
.space-avatar {
  width: 96px; height: 96px;
  border-radius: 50%;
  border: 4px solid var(--bg);
  outline: 2px solid var(--gold-dim);
  object-fit: cover;
  background: var(--surface);
}
.space-name { font-size: 1.3rem; font-weight: 700; margin: 6px 0 2px; color: var(--gold-soft); }
.space-bio { color: var(--text-dim); font-size: 0.86rem; max-width: 560px; }
.space-stats { color: var(--text-dim); font-size: 0.78rem; font-family: "Courier New", monospace; }

/* --- admin ---------------------------------------------------------------- */

.admin-grid { display: grid; grid-template-columns: 1fr; gap: 28px; margin-top: 20px; }
table.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
table.admin-table th, table.admin-table td { padding: 10px 14px; text-align: left; font-size: 0.82rem; border-bottom: 1px solid var(--border); }
table.admin-table th { color: var(--gold-dim); text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.05em; font-family: "Courier New", monospace; }
table.admin-table tr:last-child td { border-bottom: none; }
table.admin-table a { color: var(--gold-soft); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 3px; font-size: 0.68rem; font-weight: 700; font-family: "Courier New", monospace; }
.badge-admin { background: rgba(240, 196, 25, 0.15); color: var(--gold); }
.badge-disabled { background: rgba(217, 122, 108, 0.15); color: var(--danger); }
.badge-processing { background: rgba(224, 184, 74, 0.15); color: var(--warn); }
.badge-ready { background: rgba(126, 201, 143, 0.15); color: var(--success); }
.badge-failed { background: rgba(217, 122, 108, 0.15); color: var(--danger); }

/* --- playlists -------------------------------------------------------------- */

.playlist-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: block; text-decoration: none; }
.playlist-card h3 { margin: 0 0 6px; color: var(--gold-soft); }
.playlist-card p { color: var(--text-dim); font-size: 0.84rem; }

/* --- misc ------------------------------------------------------------------ */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.hint { color: var(--text-dim); font-size: 0.78rem; margin-top: -10px; margin-bottom: 14px; }
.footer-note { text-align: center; color: var(--text-dim); font-size: 0.76rem; margin-top: 8px; margin-bottom: 60px; opacity: 0.75; font-family: "Courier New", monospace; line-height: 1.6; }
.spacer-y { height: 24px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }
