:root {
  --bg: #ffffff; --fg: #1f2937; --muted: #6b7280; --accent: #2563eb; --border: #e5e7eb;
  --nav-bg: #0f172a; --nav-fg: #e2e8f0; --nav-muted: #94a3b8; --code-bg: #f3f4f6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  color: var(--fg); background: var(--bg); display: flex; min-height: 100vh;
}

/* ---------- left navigator ---------- */
.gx-nav {
  flex: 0 0 280px; background: var(--nav-bg); color: var(--nav-fg);
  display: flex; flex-direction: column; padding: 1rem 0.9rem; gap: 0.8rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.gx-head { display: flex; flex-direction: column; gap: 0.5rem; border-bottom: 1px solid #1e293b; padding-bottom: 0.7rem; }
.gx-title { color: #fff; text-decoration: none; font-size: 1.15rem; font-weight: 700; }
.gx-account { position: relative; font-size: 0.9rem; }
.gx-signin { color: var(--nav-fg); text-decoration: none; border: 1px solid #334155; border-radius: 6px; padding: 0.25rem 0.6rem; display: inline-block; }
.gx-signin:hover { background: #1e293b; }
.user-menu-btn {
  display: inline-flex; align-items: center; gap: 0.3rem; max-width: 100%; cursor: pointer;
  background: transparent; color: var(--nav-fg); border: 1px solid #334155; border-radius: 6px; padding: 0.25rem 0.6rem; font-size: 0.9rem;
}
.user-menu-btn:hover { background: #1e293b; }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12rem; }
.caret { color: var(--nav-muted); font-size: 0.7rem; }
.user-menu {
  position: absolute; left: 0; top: 100%; z-index: 30; min-width: 12rem; margin-top: 0.3rem;
  background: #fff; color: var(--fg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.3); overflow: hidden;
}
.user-menu[hidden] { display: none; }
.user-menu button { display: block; width: 100%; text-align: left; background: transparent; border: none; padding: 0.5rem 0.8rem; font-size: 0.88rem; color: var(--fg); cursor: pointer; }
.user-menu button:hover { background: var(--code-bg); }
.user-menu button.danger { color: #dc2626; }
.user-menu button.danger:hover { background: #fee2e2; }

.gx-tree { display: flex; flex-direction: column; gap: 0.15rem; }
.gx-folder { text-align: left; background: transparent; border: none; color: var(--nav-fg); padding: 0.45rem 0.55rem; border-radius: 6px; cursor: pointer; font-size: 0.92rem; line-height: 1.35; }
.gx-folder:hover { background: #1e293b; }
.gx-folder.active { background: var(--accent); color: #fff; }

/* ---------- main ---------- */
.gx-main { flex: 1; min-width: 0; padding: 1.2rem 1.6rem 3rem; }
.gx-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.gx-folder-title { margin: 0; font-size: 1.3rem; }
.gx-modes button { background: #fff; border: 1px solid var(--border); padding: 0.35rem 0.7rem; cursor: pointer; font-size: 0.85rem; }
.gx-modes button:first-child { border-radius: 6px 0 0 6px; }
.gx-modes button:last-child { border-radius: 0 6px 6px 0; }
.gx-modes button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.gx-desc { color: var(--muted); margin: 0.6rem 0 1rem; font-size: 0.95rem; }
.gx-desc h1, .gx-desc h2, .gx-desc h3 { color: var(--fg); margin: 0.6rem 0 0.3rem; }
.gx-desc h1 { font-size: 1.1rem; } .gx-desc h2 { font-size: 1rem; } .gx-desc h3 { font-size: 0.95rem; }
.gx-desc ul { margin: 0.3rem 0; padding-left: 1.2rem; }

/* ---------- tile ---------- */
.gx-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; }
.gx-tile { position: relative; cursor: pointer; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #000; aspect-ratio: 4/3; }
.gx-tile img, .gx-tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.gx-tile .gx-badge { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 0.7rem; padding: 1px 6px; border-radius: 4px; }
.gx-tile .gx-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 2.4rem; text-shadow: 0 2px 8px rgba(0,0,0,.6); pointer-events: none; }
.gx-tile-cap { padding: 0.35rem 0.5rem; font-size: 0.8rem; color: var(--fg); background: #fff; }

/* ---------- list ---------- */
.gx-list { display: flex; flex-direction: column; gap: 0.2rem; }
.gx-list-item { display: flex; gap: 0.6rem; align-items: center; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.gx-list-item:hover { background: var(--code-bg); }
.gx-list-item .gx-li-icon { color: var(--muted); }
.gx-list-item .gx-li-cap { color: var(--muted); font-size: 0.85rem; margin-left: auto; }

/* ---------- single ---------- */
.gx-single { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; }
.gx-stage { position: relative; width: 100%; max-width: 900px; display: flex; align-items: center; justify-content: center; background: #000; border-radius: 10px; min-height: 240px; }
.gx-stage img, .gx-stage video { max-width: 100%; max-height: 70vh; display: block; border-radius: 10px; }
.gx-stage iframe { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 10px; }
.gx-arrow { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.5); color: #fff; border: none; font-size: 1.6rem; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; }
.gx-arrow:hover { background: rgba(0,0,0,.75); }
.gx-arrow.prev { left: 8px; } .gx-arrow.next { right: 8px; }
.gx-arrow:disabled { opacity: 0.3; cursor: default; }
.gx-caption { max-width: 900px; width: 100%; text-align: center; color: var(--fg); }
.gx-caption .gx-cap-title { font-weight: 600; }
.gx-counter { color: var(--muted); font-size: 0.85rem; }

/* ---------- comments ---------- */
.gx-comments { max-width: 900px; width: 100%; margin-top: 0.5rem; border-top: 1px solid var(--border); padding-top: 0.8rem; }
.gx-comments h3 { margin: 0 0 0.6rem; font-size: 1rem; }
.gx-comment { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.gx-comment .gx-c-meta { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.15rem; }
.gx-comment .gx-c-author { color: var(--fg); font-weight: 600; }
.gx-comment .gx-c-body { white-space: pre-wrap; }
.gx-cform { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.7rem; }
.gx-cform textarea { width: 100%; min-height: 64px; padding: 0.5rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; resize: vertical; }
.gx-cform .gx-c-actions { display: flex; gap: 0.6rem; align-items: center; }
.gx-cform button { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 0.45rem 1rem; cursor: pointer; }
.gx-c-signin { color: var(--muted); font-size: 0.9rem; }
.gx-c-signin a { color: var(--accent); }
.gx-c-msg { font-size: 0.85rem; color: #dc2626; min-height: 1em; }
.gx-empty { color: var(--muted); padding: 2rem 0; }

/* ---------- modals (account self-service) ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.45); }
.modal[hidden] { display: none; }
.modal-card { width: min(92vw, 360px); background: #fff; color: var(--fg); border-radius: 12px; padding: 1.2rem 1.3rem 1rem; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal-card h3 { margin: 0 0 0.8rem; font-size: 1.1rem; }
.modal-card label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.6rem; }
.modal-card input[type=text], .modal-card input[type=password] { padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; font-size: 1rem; }
.modal-card label.modal-show { flex-direction: row; align-items: center; gap: 0.4rem; }
.modal-card label.modal-show input { width: auto; }
.modal-msg { min-height: 1.1em; margin: 0.2rem 0 0.6rem; font-size: 0.85rem; color: #dc2626; }
.modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; }
.modal-actions button { cursor: pointer; border-radius: 8px; padding: 0.45rem 0.9rem; font-size: 0.9rem; font-weight: 600; border: none; background: var(--accent); color: #fff; }
.modal-actions button.ghost { background: transparent; color: var(--fg); border: 1px solid var(--border); font-weight: 500; }
.modal-actions button.danger { background: #dc2626; color: #fff; }

/* ---------- mobile ---------- */
#navToggle { display: none; position: fixed; top: 0.6rem; left: 0.6rem; z-index: 50; background: var(--nav-bg); color: #fff; border: none; border-radius: 6px; width: 38px; height: 38px; font-size: 1.1rem; cursor: pointer; }
@media (max-width: 820px) {
  body { display: block; }
  #navToggle { display: block; }
  .gx-nav { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; z-index: 49; }
  .gx-nav.open { transform: translateX(0); }
  .gx-main { padding-top: 3.2rem; }
  .gx-grid { grid-template-columns: repeat(2, 1fr); }
}
