/* ============================================================
   jadeStage — "Terminal Window" design system
   Shared across: index, about, signin, upload, profile,
   account-settings, editprofile, manage-videos, legal.
   Self-contained + responsive (does NOT depend on style.css
   or mobile-responsive.css).
   ============================================================ */

:root {
  --bg:        #050605;
  --titlebar:  #0b120e;
  --border:    #1b3d2c;
  --tile:      #080c0a;
  --tile-2:    #0a0f0c;
  --accent:    #00A86B;
  --accent-hi: #00c07c;
  --heading:   #eafff2;
  --body:      #9fd8bb;
  --body-2:    #7fd9b0;
  --muted:     #4f8a6c;
  --nav-muted: #5c9c81;
  --faint:     #2f6b4f;
  --faint-2:   #3f6e57;
  --danger:    #ff5f56;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: 'Inconsolata', monospace;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body { min-height: 100vh; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--body-2); text-decoration: underline; }
::selection { background: var(--accent); color: #000; }

@keyframes blink { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }

/* ---------- Window shell ---------- */
.tw-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 20px;
}

.window {
  width: 100%;
  max-width: 1000px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  background: var(--bg);
}
.window.narrow { max-width: 560px; }
.window.mid    { max-width: 700px; }
.window.wide   { max-width: 900px; }

.titlebar {
  background: var(--titlebar);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot.r { background: #ff5f56; }
.dot.y { background: #ffbd2e; }
.dot.g { background: #27c93f; }
.tb-file { margin-left: 10px; font-size: 12px; color: var(--muted); }

.win-body { padding: 34px 44px 40px; }

/* ---------- Top nav (in-window) ---------- */
.topnav {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 28px;
  gap: 16px;
}
.topnav .brand { color: var(--nav-muted); font-weight: 700; font-size: 14px; }
.topnav .brand.active { color: var(--accent); }
.topnav .links { display: flex; gap: 22px; font-size: 12px; color: var(--nav-muted); }
.topnav .links a { color: var(--nav-muted); }
.topnav .links a.active { color: var(--accent); }
.topnav .links a:hover { color: var(--body-2); }

/* ---------- Type ---------- */
.cmd { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
h1.tw { font-size: 28px; font-weight: 700; color: var(--heading); margin: 0 0 22px; line-height: 1.2; }
h1.tw.lg { font-size: 30px; }
.cursor { color: var(--accent); animation: blink 1s step-end infinite; }
.lead { color: var(--body-2); font-size: 13px; line-height: 1.7; margin: 0 0 26px; }
.para { color: var(--body); font-size: 14px; line-height: 1.7; margin: 0; }
code { color: var(--accent); font-family: inherit; }

.section-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

/* ---------- Buttons ---------- */
.btn, .btn-ghost, .btn-danger {
  font-family: inherit;
  font-size: 13px;
  border-radius: 3px;
  padding: 12px 22px;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  border: 1px solid transparent;
  line-height: 1.2;
}
.btn { background: var(--accent); color: #000; font-weight: 700; }
.btn:hover { background: var(--accent-hi); color: #000; text-decoration: none; }
.btn:disabled { background: #2a3a32; color: #6f8f80; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--body-2); }
.btn-ghost:hover { border-color: var(--accent); color: var(--body-2); text-decoration: none; }
.btn-danger { background: transparent; border-color: #6b241f; color: #ff8b84; }
.btn-danger:hover { background: rgba(255,95,86,.12); color: #ffb0aa; text-decoration: none; }
.btn-block { display: block; width: 100%; padding: 13px 0; }

.btn-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }

.tip { font-size: 11px; color: var(--faint-2); margin-bottom: 26px; }
.tip .key {
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field-label { color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.field-label .opt { color: var(--faint); }
.tw-input, .tw-textarea {
  width: 100%;
  background: var(--tile);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--heading);
  font-family: inherit;
  font-size: 14px;
  padding: 11px 12px;
  -webkit-appearance: none;
  appearance: none;
}
.tw-textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.tw-input::placeholder, .tw-textarea::placeholder { color: var(--faint); }
.tw-input:focus, .tw-textarea:focus { outline: none; border-color: var(--accent); }
.hint { color: var(--faint); font-size: 11px; margin-top: 6px; }

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  color: var(--body);
  line-height: 1.6;
  cursor: pointer;
  user-select: none;
}
.check-row input[type="checkbox"] {
  width: auto;
  margin-top: 3px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- Toggle switch ---------- */
.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--body);
  line-height: 1.5;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--tile);
  border: 1px solid var(--border);
  transition: background .2s, border-color .2s;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .2s, background .2s;
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(20px); background: #000; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Segmented tabs ---------- */
.seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 26px;
}
.seg > div {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 13px;
  cursor: pointer;
  background: var(--tile);
  color: var(--nav-muted);
}
.seg > div.active { background: var(--accent); color: #000; font-weight: 700; }

/* ---------- Divider ---------- */
.or-div {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--faint);
  font-size: 11px;
}
.or-div::before, .or-div::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- Google button ---------- */
.google-btn {
  width: 100%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--body);
  font-family: inherit;
  font-size: 13px;
  padding: 12px 0;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.google-btn:hover { border-color: var(--accent); color: var(--body-2); }
.google-btn:disabled { opacity: .5; cursor: not-allowed; }
.google-icon { width: 16px; height: 16px; }

/* ---------- Tile / content blocks ---------- */
.block {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px 22px;
  background: var(--tile);
  margin-bottom: 20px;
}
.block-title { color: var(--accent); font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.block .para { color: var(--body); }
.steps { color: var(--body); font-size: 14px; line-height: 2; }
.steps .n, .steps .arrow { color: var(--muted); }
.rules { color: var(--body); font-size: 13px; line-height: 1.9; }
.rules .arrow { color: var(--muted); }

/* ---------- Stat grid ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.stat { background: var(--tile); padding: 14px 18px; }
.stat-k { color: var(--muted); font-size: 12px; }
.stat-v { color: var(--heading); font-size: 15px; font-weight: 700; }

/* ---------- Video frame (home / profile) ---------- */
.video-frame {
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}
.video-embed { position: relative; width: 100%; aspect-ratio: 16 / 9; background: var(--tile-2); }
.video-embed iframe,
.video-embed .placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-embed .placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 12px;
}
.video-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--nav-muted);
}
.video-meta .date { color: var(--muted); }

/* ---------- Home action band (buttons + tip + mascot on one line) ---------- */
.action-band { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 28px; }
.action-left { min-width: 0; }
.home-mascot { width: 92px; height: auto; transform: scaleX(-1); display: block; flex-shrink: 0; }

/* ---------- Profile bits ---------- */
.profile-head { display: flex; gap: 22px; align-items: center; margin-bottom: 24px; flex-wrap: wrap; }
.avatar {
  width: 64px; height: 64px; border-radius: 6px; flex-shrink: 0;
  border: 1px solid var(--border);
  background: repeating-linear-gradient(45deg,#0a0f0c,#0a0f0c 6px,#101812 6px,#101812 12px);
  display: flex; align-items: center; justify-content: center;
  color: var(--faint-2); font-size: 9px; text-align: center;
  object-fit: cover;
}
.profile-name { color: var(--heading); font-size: 20px; font-weight: 700; word-break: break-word; }
.profile-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.profile-actions { margin-left: auto; display: flex; gap: 10px; }
.social-row { display: flex; gap: 16px; font-size: 12px; color: var(--accent); flex-wrap: wrap; margin-bottom: 28px; }
.uploads-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.upload-thumb {
  aspect-ratio: 16/9;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--tile-2);
  position: relative;
  display: block;
}
.upload-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Messages ---------- */
.msg { padding: 11px 14px; border-radius: 3px; font-size: 13px; margin-bottom: 16px; border: 1px solid; }
.msg.success { background: rgba(0,168,107,.12); border-color: var(--accent); color: var(--body-2); }
.msg.error   { background: rgba(255,95,86,.10); border-color: #6b241f; color: #ff8b84; }

/* ---------- Collapsible (starred users) ---------- */
.collapse-head {
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--tile); margin-bottom: 10px;
}
.collapse-head:hover { border-color: var(--accent); }
.collapse-head .h { color: var(--body-2); font-size: 13px; font-weight: 700; }
.collapse-count {
  background: var(--accent); color: #000; font-weight: 700;
  padding: 2px 10px; border-radius: 12px; font-size: 12px;
}
.collapse-icon { color: var(--muted); font-size: 12px; transition: transform .25s; }
.collapse-icon.expanded { transform: rotate(180deg); }
.collapse-body { max-height: 300px; overflow-y: auto; display: none; }
.collapse-body.show { display: block; }
.row-item {
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 3px;
  background: var(--tile); margin-bottom: 8px; cursor: pointer; color: var(--body-2); font-size: 13px;
}
.row-item:hover { border-color: var(--accent); }
.empty { color: var(--muted); font-style: italic; padding: 16px; text-align: center; font-size: 13px; }

/* ---------- Popup (home) ---------- */
.tw-popup {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--titlebar); border: 1px solid var(--accent); border-radius: 6px;
  padding: 20px 28px; color: var(--body-2); font-size: 14px; text-align: center;
  z-index: 10000; box-shadow: 0 20px 60px rgba(0,0,0,.6); max-width: 380px;
}

/* ---------- Misc ---------- */
.stack > * + * { margin-top: 14px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.divline { height: 1px; background: var(--border); margin: 26px 0; }
.tw-foot { color: var(--muted); font-size: 11px; text-align: center; padding: 22px; }
.back-link { color: var(--muted); font-size: 12px; display: inline-block; margin-bottom: 20px; }
.hidden { display: none !important; }

/* ---------- Prose (legal) ---------- */
.prose h2 { color: var(--heading); font-size: 18px; font-weight: 700; margin: 30px 0 12px; }
.prose h3 { color: var(--accent); font-size: 14px; font-weight: 700; margin: 22px 0 8px; }
.prose p  { color: var(--body); font-size: 13px; line-height: 1.8; margin: 0 0 12px; }
.prose ul { color: var(--body); font-size: 13px; line-height: 1.8; margin: 0 0 14px; padding-left: 20px; }
.prose li { margin-bottom: 4px; }
.prose .updated { color: var(--muted); font-size: 12px; font-style: italic; margin-bottom: 8px; }

/* ---------- Manage-videos cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.vcard {
  border: 1px solid var(--border); border-radius: 6px; padding: 14px;
  background: var(--tile); position: relative;
}
.vcard.pinned { border-color: #b9922b; }
.pin-badge {
  position: absolute; top: 8px; right: 8px;
  background: #b9922b; color: #000; font-weight: 700;
  padding: 3px 8px; border-radius: 3px; font-size: 11px;
}
.vcard .thumb { width: 100%; aspect-ratio: 16/9; background: var(--tile-2); border-radius: 4px; overflow: hidden; margin-bottom: 12px; }
.vcard .thumb iframe { width: 100%; height: 100%; border: 0; }
.vcard .v-title { color: var(--heading); font-size: 14px; font-weight: 700; margin-bottom: 3px; word-break: break-word; }
.vcard .v-date { color: var(--muted); font-size: 11px; margin-bottom: 12px; }
.vcard .v-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.vcard .v-actions .btn, .vcard .v-actions .btn-ghost, .vcard .v-actions .btn-danger { flex: 1; padding: 9px 10px; min-width: 90px; }

/* ---------- Modal ---------- */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.78); }
.modal.show { display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box {
  background: var(--titlebar); border: 1px solid #6b241f; border-radius: 8px;
  padding: 28px; width: 100%; max-width: 420px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-box h3 { color: #ff8b84; font-size: 16px; margin: 0 0 14px; }
.modal-box p { color: var(--body); font-size: 13px; line-height: 1.6; margin: 0 0 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }
.modal-actions .btn, .modal-actions .btn-ghost, .modal-actions .btn-danger { flex: 1; }

/* ---------- Toast ---------- */
@keyframes toastIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast {
  position: fixed; top: 24px; right: 24px; z-index: 2000;
  padding: 12px 18px; border-radius: 4px; font-size: 13px;
  border: 1px solid; animation: toastIn .25s ease-out;
}
.toast.success { background: rgba(0,168,107,.14); border-color: var(--accent); color: var(--body-2); }
.toast.error   { background: rgba(255,95,86,.14); border-color: #6b241f; color: #ff8b84; }

/* ---------- Avatar preview (editprofile) ---------- */
.pic-preview { display: flex; justify-content: center; margin-top: 12px; }
.pic-preview img, .pic-placeholder {
  width: 84px; height: 84px; border-radius: 6px; object-fit: cover;
  border: 1px solid var(--border); background: var(--tile-2);
}
.pic-placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--faint-2); font-size: 11px; border-style: dashed;
}
.char-count { color: var(--muted); font-size: 11px; text-align: right; margin-top: 6px; }
.sub-head { color: var(--accent); font-size: 13px; font-weight: 700; margin: 26px 0 14px; padding-top: 22px; border-top: 1px solid var(--border); }
.page-title { color: var(--heading); font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.page-sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }

/* ---------- Responsive ---------- */
@media (max-width: 680px) {
  /* Compact spacing so the home window is self-contained (no page scroll). */
  .win-body { padding: 18px 16px 20px; }
  .tw-wrap { padding: 10px 10px; }
  h1.tw, h1.tw.lg { font-size: 22px; margin-bottom: 12px; }
  .cmd { margin-bottom: 4px; }
  .topnav { flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
  .topnav .links { gap: 16px; }
  .video-frame { margin-bottom: 10px; }
  .action-band { gap: 12px; margin-bottom: 14px; }
  .tw-foot { padding: 12px; }
  /* Keep the three stat tiles on one row (3 columns) on mobile; tighten so they fit. */
  .stat { padding: 10px 9px; }
  .stat-k { font-size: 10px; }
  .stat-v { font-size: 13px; }
  .uploads-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-actions { margin-left: 0; width: 100%; }
  .btn, .btn-ghost, .btn-danger { padding: 12px 16px; }
  .tw-input, .tw-textarea { font-size: 16px; } /* avoid iOS zoom */
}

/* Home heading: clamp a long title to one line (ellipsis) so it can never
   grow the layout; the blinking cursor stays visible right after it. */
.home-window h1.tw { display: flex; align-items: baseline; }
.home-window #videoTitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.home-window .cursor { flex: none; }

/* Mobile home refinements */
@media (max-width: 680px) {
  /* No mouse on mobile, so the "press Enter" tip is irrelevant. */
  .tip { display: none; }

  /* The window fills ~90% of the screen (small breathing margin around it) and
     never scrolls. dvh accounts for the mobile browser chrome. */
  .home-wrap { height: 100vh; height: 100dvh; min-height: 0; justify-content: flex-start; overflow: hidden; padding: 3dvh 12px; }
  .home-window { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
  .home-window .win-body { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; padding: 20px 18px 22px; }
  .home-window h1.tw { margin-bottom: 12px; }

  /* The video BOX grows tall to fill the space, and the 16:9 thumbnail is
     letterboxed inside it (black bars top/bottom) so the full horizontal
     thumbnail shows uncropped while the box occupies the room. */
  .home-window .video-frame { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; margin: 10px 0; }
  .home-window .video-embed {
    flex: 1 1 auto; min-height: 0; aspect-ratio: auto;
    background: #000; display: grid; place-items: center; overflow: hidden;
  }
  .home-window .video-embed iframe {
    position: static; width: 100%; height: auto; aspect-ratio: 16 / 9;
    max-width: 100%; max-height: 100%;
  }

  /* Keep the mascot on mobile too — smaller, right-aligned above the stats. */
  .home-mascot { display: block; width: 54px; margin-left: auto; }
  .action-band { flex-wrap: wrap; margin: 6px 0 14px; }
}
