* { box-sizing: border-box; }

:root {
  --orange: #ff7a1a;
  --orange-dark: #e6650a;
  --orange-pale: #fff1e5;
  --ink: #1c1c1c;
  --ink-soft: #6b6b6b;
  --border: #eee0d4;
  --white: #ffffff;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--white);
  color: var(--ink);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 1.2rem;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

#back-link {
  font-size: 1.3rem;
  color: var(--ink-soft);
  padding: 0.2rem 0.4rem;
}

#logo-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--orange);
  white-space: nowrap;
}

#logo-mark { font-size: 1.5rem; }

#search-form {
  flex: 1;
  display: flex;
  max-width: 520px;
  margin: 0 auto;
}

#search-input {
  flex: 1;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 999px 0 0 999px;
  font-size: 0.95rem;
  outline: none;
  background: var(--white);
  color: var(--ink);
}

#search-input:focus { border-color: var(--orange); }

#search-form button {
  border: 1px solid var(--border);
  border-left: none;
  background: var(--orange-pale);
  border-radius: 0 999px 999px 0;
  padding: 0 1rem;
  cursor: pointer;
}

.pill-btn {
  border: none;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--orange-pale);
  color: var(--orange-dark);
  white-space: nowrap;
}

.pill-btn:hover { filter: brightness(0.97); }
.pill-btn.primary { background: var(--orange); color: var(--white); }
.pill-btn.primary:disabled { opacity: 0.5; cursor: default; }
.pill-btn.danger { background: #ffe3e3; color: #c0392b; }

#account-area { display: flex; align-items: center; gap: 0.6rem; white-space: nowrap; }
#account-name { font-weight: 700; font-size: 0.9rem; color: var(--ink-soft); cursor: pointer; white-space: nowrap; }
#account-name:hover { color: var(--orange-dark); }

.icon-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 0.3rem 0.5rem;
}

/* ---------- Main / layout ---------- */
#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.2rem;
}

.state-msg {
  text-align: center;
  color: var(--ink-soft);
  padding: 3rem 1rem;
  font-size: 1rem;
}

.state-msg .pill-btn { margin-top: 0.8rem; }

/* ---------- Video grid ---------- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.4rem 1rem;
}

.video-card { cursor: pointer; }

.video-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--orange-pale);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--orange);
  font-size: 2rem;
}

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

.video-card-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.video-card-avatar { width: 32px; height: 32px; font-size: 0.9rem; margin-top: 0.1rem; }

.video-card-title {
  margin-top: 0;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-card-meta {
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin-top: 0.2rem;
}

.video-card-channel {
  color: var(--orange-dark);
  font-weight: 600;
}

/* ---------- Watch page ---------- */
.watch-layout { max-width: 960px; margin: 0 auto; }

.watch-player-wrap {
  width: 100%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.watch-player-wrap video { width: 100%; max-height: 70vh; display: block; }

.watch-title { font-size: 1.3rem; font-weight: 800; margin: 0.9rem 0 0.3rem; }

.watch-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.watch-stats { color: var(--ink-soft); font-size: 0.9rem; }

.watch-actions { display: flex; gap: 0.5rem; }

.like-btn.liked { background: var(--orange); color: var(--white); }

.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}

.channel-link { display: flex; align-items: center; gap: 0.7rem; font-weight: 700; }

.channel-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--orange);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
  object-fit: cover;
}

.subscribe-btn {
  background: linear-gradient(to bottom, #ffe8a3, #e8a93a);
  border: 1px solid #c98a1f;
  color: #4a3300;
  border-radius: 6px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.subscribe-btn:hover { filter: brightness(1.04); }

.subscribe-btn.subscribed {
  background: var(--orange-pale);
  color: var(--orange-dark);
  border: 1px solid var(--border);
  box-shadow: none;
}

.watch-description {
  background: var(--orange-pale);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin-top: 0.9rem;
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.comments-section { margin-top: 1.3rem; }
.comments-heading { font-weight: 800; margin-bottom: 0.8rem; }

.comment-form { display: flex; gap: 0.6rem; margin-bottom: 1.2rem; }

.comment-form input {
  flex: 1;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  font-size: 0.9rem;
}

.comment-form input:focus { border-color: var(--orange); }

.comment {
  display: flex;
  gap: 0.7rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--orange-pale);
  color: var(--orange-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.comment-body { flex: 1; }
.comment-author { font-weight: 700; font-size: 0.85rem; }
.comment-time { color: var(--ink-soft); font-size: 0.75rem; margin-left: 0.4rem; font-weight: 400; }
.comment-text { font-size: 0.9rem; margin-top: 0.1rem; word-break: break-word; }

.comment-edit-btn {
  background: none;
  border: none;
  color: var(--orange-dark);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.15rem 0;
  margin-top: 0.15rem;
}

.comment-edit-form { display: flex; gap: 0.4rem; margin-top: 0.2rem; flex-wrap: wrap; }

.comment-edit-input {
  flex: 1;
  min-width: 140px;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  font-size: 0.85rem;
}

.comment-edit-input:focus { border-color: var(--orange); }

/* ---------- Channel page ---------- */
.channel-banner {
  width: 100%;
  aspect-ratio: 6 / 1;
  min-height: 90px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--orange), #ffb47a) center / cover no-repeat;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0.7rem;
  margin-bottom: 1rem;
}

.channel-banner.empty { background: linear-gradient(135deg, var(--orange-pale), #ffe2c8); }

.channel-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.4rem;
}

.channel-header .channel-avatar, .channel-header-avatar { width: 64px; height: 64px; font-size: 1.6rem; }

.channel-header-avatar-wrap { position: relative; flex-shrink: 0; }

#avatar-upload-label {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--orange);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  border: 2px solid var(--white);
}
.channel-header-name { font-size: 1.3rem; font-weight: 800; }
.channel-header-subs { color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- Live streaming ---------- */
.live-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #e0202e;
  color: var(--white);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.video-thumb { position: relative; }

.category-pills {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
  margin-bottom: 1.2rem;
}

.category-pill {
  flex-shrink: 0;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: var(--orange-pale);
  color: var(--orange-dark);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.category-pill.active { background: var(--orange); color: var(--white); }

.live-section { margin-bottom: 1.8rem; }
.live-section-heading { font-weight: 800; font-size: 1.05rem; margin-bottom: 0.8rem; }

.live-card-meta { color: var(--ink-soft); font-size: 0.82rem; margin-top: 0.2rem; }

#golive-body { padding: 1.2rem; display: flex; flex-direction: column; gap: 0.8rem; }

#golive-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  object-fit: contain;
}

#golive-title-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  outline: none;
}

#golive-title-input:focus { border-color: var(--orange); }

#golive-record-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

#golive-source-row { display: flex; gap: 0.6rem; }
#golive-source-row .pill-btn { flex: 1; }

#golive-status { font-size: 0.85rem; color: var(--ink-soft); min-height: 1.1em; }
#golive-body .hint { font-size: 0.82rem; color: var(--ink-soft); margin: 0; }

#golive-live-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

#golive-viewer-count { font-weight: 700; font-size: 0.9rem; margin-right: auto; }

.watch-live-badge {
  display: inline-block;
  background: #e0202e;
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}

.live-dot {
  color: #e0202e;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

/* 1M+ subscribers — see verifiedBadgeHtml() in videos.js */
.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #1d9bf0;
  color: var(--white);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  margin-left: 0.25rem;
  vertical-align: middle;
}

.channel-header-name .verified-badge { width: 18px; height: 18px; font-size: 12px; }

/* ---------- Floating live chat (bottom-right — pairs with #live-mini-widget at bottom-left)
   Fixed to the screen rather than embedded in any one page, see enableLiveChat()/disableLiveChat()
   in videos.js: available the whole time you're broadcasting or watching a live stream, toggled
   on/off with #live-chat-toggle-btn, independent of which page you're currently browsing. ---------- */
#live-chat-toggle-btn {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 35;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--orange);
  color: var(--white);
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

#live-chat-widget {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 36;
  width: min(320px, calc(100vw - 32px));
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}

#live-chat-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--orange-pale);
  color: var(--orange-dark);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.5rem 0.5rem 0.5rem 0.8rem;
  cursor: move;
  touch-action: none;
  user-select: none;
}

#live-chat-messages {
  height: 260px;
  overflow-y: auto;
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.live-chat-message { font-size: 0.85rem; line-height: 1.4; word-break: break-word; }
.live-chat-author { font-weight: 700; color: var(--orange-dark); margin-right: 0.3rem; }

#live-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  border-top: 1px solid var(--border);
}

#live-chat-form input {
  flex: 1;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  font-size: 0.85rem;
}

#live-chat-form input:focus { border-color: var(--orange); }

.live-banner {
  display: block;
  background: #fff0ee;
  border: 1px solid #ffc9c2;
  color: #b3271c;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  margin-bottom: 1.2rem;
}

.live-banner:hover { background: #ffe3df; }

/* ---------- Upload modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(30, 20, 10, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: var(--white);
  border-radius: 16px;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { margin: 0; font-size: 1.1rem; }

#upload-body, #edit-body { padding: 1.2rem; display: flex; flex-direction: column; gap: 0.8rem; }

#file-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  background: var(--orange-pale);
  border: 2px dashed var(--orange);
  border-radius: 12px;
  cursor: pointer;
  color: var(--orange-dark);
  font-weight: 700;
  overflow: hidden;
}

#upload-preview { width: 100%; height: 100%; object-fit: contain; background: #000; }

#upload-title-input, #upload-description-input, #edit-title-input, #edit-description-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
}

#upload-title-input:focus, #upload-description-input:focus,
#edit-title-input:focus, #edit-description-input:focus { border-color: var(--orange); }
#upload-description-input, #edit-description-input { resize: vertical; min-height: 70px; }

#upload-category-select, #edit-category-select {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  background: var(--white);
  color: var(--ink);
}

#upload-status, #edit-status { font-size: 0.85rem; color: var(--ink-soft); min-height: 1.1em; }
#upload-submit-btn { align-self: flex-end; }

/* ---------- Scorpture admin panel ---------- */
#scorpture-admin-body { padding: 1.2rem; display: flex; flex-direction: column; gap: 0.7rem; }
#scorpture-admin-body label { font-size: 0.85rem; color: var(--ink-soft); }

#scorpture-admin-bonus-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  outline: none;
}

#scorpture-admin-bonus-input:focus { border-color: var(--orange); }
#scorpture-admin-status { font-size: 0.85rem; color: var(--ink-soft); min-height: 1.1em; }
#scorpture-admin-save-btn { align-self: flex-end; }

/* ---------- Floating live preview (bottom-left, survives navigating the rest of Scorpture
   while you're broadcasting — see #live-mini-widget in videos.html) ---------- */
#live-mini-widget {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 35;
  width: 220px;
  background: var(--ink);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

#live-mini-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  background: #000;
  object-fit: contain;
}

#live-mini-info {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--white);
  background: rgba(0, 0, 0, 0.5);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

#live-mini-info .live-dot { color: #ff5a5a; }

#live-mini-expand-btn, #live-mini-hide-btn {
  position: absolute;
  top: 6px;
  color: var(--white);
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
}

#live-mini-expand-btn { right: 34px; }
#live-mini-hide-btn { right: 6px; }

/* ---------- Stream overlays settings page ---------- */
.overlays-page { max-width: 640px; margin: 0 auto; }
.overlays-hint { color: var(--ink-soft); font-size: 0.9rem; margin: 0.2rem 0 1.2rem; }

.overlay-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.6rem;
}

.overlay-row-preview {
  width: 56px;
  height: 40px;
  border-radius: 6px;
  background: var(--orange-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--orange-dark);
  padding: 0.2rem;
  text-align: center;
  flex-shrink: 0;
}

.overlay-row-preview img { width: 100%; height: 100%; object-fit: contain; }
.overlay-row-info { flex: 1; }
.overlay-row-type { font-weight: 700; font-size: 0.88rem; }
.overlay-row-position { color: var(--ink-soft); font-size: 0.8rem; }

.overlay-form {
  margin-top: 1.2rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.overlay-form-row { display: flex; gap: 1.2rem; font-size: 0.9rem; }

#overlay-text-input, #overlay-position-select {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}

#overlay-text-input:focus, #overlay-position-select:focus { border-color: var(--orange); }
#overlay-form-status { font-size: 0.85rem; color: var(--ink-soft); min-height: 1.1em; }
#overlay-add-btn { align-self: flex-end; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  font-size: 0.88rem;
  z-index: 40;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  #topbar { flex-wrap: wrap; }
  #search-form { order: 3; max-width: none; width: 100%; }
  #logo-text { display: none; }
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem 0.7rem; }
}
