/* ============================================================
   VR Mover · Source Code page — code.css
   ============================================================ */

:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --surface2: #21262d;
  --border:   #30363d;
  --text:     #c9d1d9;
  --muted:    #8b949e;
  --accent:   #58a6ff;
  --green:    #3fb950;
  --yellow:   #d29922;
  --hover:    #2d333b;
  --active-bg: #1c2940;
  --linenum:  #484f58;
  --logo-filter: brightness(0) invert(1);
  --radius:   8px;
  --font:     'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:     'SFMono-Regular', 'Cascadia Code', 'Fira Code', Consolas, monospace;
}

:root[data-theme="light"] {
  --bg:       #ffffff;
  --surface:  #f6f8fa;
  --surface2: #eaeef2;
  --border:   #d0d7de;
  --text:     #1f2328;
  --muted:    #57606a;
  --accent:   #0969da;
  --green:    #1a7f37;
  --yellow:   #9a6700;
  --hover:    #eaeef2;
  --active-bg: #ddeaff;
  --linenum:  #8c959f;
  --logo-filter: brightness(0);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* The hidden attribute must win over our explicit display rules below. */
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */
#header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
#header .logo {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--text);
  text-decoration: none;
}
/* The logo artwork is near-black — render it white on the dark theme */
#header .logo img {
  width: 26px;
  height: 26px;
  filter: var(--logo-filter);
}
#header .page-name { color: var(--muted); font-weight: 400; }
#header .spacer { flex: 1; }
.hbtn {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.82rem;
  text-decoration: none;
  transition: background .12s, border-color .12s;
}
.hbtn:hover { background: var(--hover); border-color: var(--accent); }

/* ── Layout ─────────────────────────────────────────────── */
#page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* ── Notices ────────────────────────────────────────────── */
.notice {
  display: flex;
  gap: 0.85rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 0.85rem;
  font-size: 0.88rem;
  line-height: 1.65;
}
.notice .n-icon {
  font-size: 1.1rem;
  line-height: 1.4;
  flex-shrink: 0;
}
.notice.blue   { border-left: 3px solid var(--accent); }
.notice.yellow { border-left: 3px solid var(--yellow); }
.notice h3 {
  font-size: 0.92rem;
  margin-bottom: 0.25rem;
  color: var(--text);
}
.notice p { color: var(--muted); }
.notice a { color: var(--accent); text-decoration: none; }
.notice a:hover { text-decoration: underline; }
.notice code {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ── Main split ─────────────────────────────────────────── */
#main {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 1rem;
  margin-top: 1.25rem;
  align-items: start;
}

/* ── File list ──────────────────────────────────────────── */
#files {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: sticky;
  top: 72px;
}
#files .files-head {
  padding: 10px 14px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.file-group {
  padding: 6px 14px 2px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 0.84rem;
  font-family: var(--font);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background .1s;
}
.file-item:hover { background: var(--surface2); }
.file-item.active {
  background: var(--active-bg);
  border-left-color: var(--accent);
  color: var(--accent);
}
.file-item .f-icon { font-size: 0.95rem; flex-shrink: 0; }
.file-item .f-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Line-count badge: never wraps, and only shown for the file currently open. */
.file-item .f-meta {
  display: none;
  font-size: 0.68rem; color: var(--muted);
  margin-left: auto; flex-shrink: 0; white-space: nowrap;
}
.file-item.active .f-meta { display: inline; }

/* ── Viewer ─────────────────────────────────────────────── */
#viewer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}
#viewer-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
#viewer-title {
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 600;
}
#viewer-desc {
  font-size: 0.75rem;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vbtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.78rem;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.vbtn:hover { border-color: var(--accent); color: var(--accent); }
.vbtn.copied { border-color: var(--green); color: var(--green); }

/* Code area: line numbers column + scrollable code */
#code-wrap {
  display: flex;
  max-height: calc(100vh - 130px);
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
}
#line-nums {
  flex-shrink: 0;
  padding: 12px 0;
  text-align: right;
  user-select: none;
  color: var(--linenum);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  left: 0;
  min-width: 52px;
}
#line-nums span {
  display: block;
  padding: 0 12px 0 8px;
}
#code-pre {
  margin: 0;
  padding: 12px 16px;
  flex: 1;
  overflow: visible;
}
#code-pre code {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: pre;
  background: transparent !important;
  padding: 0 !important;
  display: block;
}
/* Soft-wrap mode for prompt files with very long lines (assistant few-shot). */
#code-wrap.wrap #line-nums { display: none; }
#code-wrap.wrap #code-pre code { white-space: pre-wrap; word-break: break-word; }
#loading {
  padding: 3rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Header icon button (theme toggle) */
.hbtn-icon {
  padding: 5px 9px;
  cursor: pointer;
  font-family: var(--font);
  line-height: 1;
}

/* Markdown / Plain-text segmented switch in the viewer head */
.view-mode {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.view-mode .vm-btn {
  border: none;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.74rem;
  padding: 4px 10px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.view-mode .vm-btn + .vm-btn { border-left: 1px solid var(--border); }
.view-mode .vm-btn:hover { color: var(--text); }
.view-mode .vm-btn.active { background: var(--accent); color: #fff; }

/* Rendered Markdown view (the .txt prompts) */
.md-body {
  padding: 18px 24px;
  max-height: calc(100vh - 130px);
  overflow: auto;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text);
}
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  margin: 1.1em 0 0.5em;
  line-height: 1.3;
}
.md-body h1 { font-size: 1.4rem; }
.md-body h2 { font-size: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: 0.2em; }
.md-body h3 { font-size: 1.05rem; }
.md-body h1:first-child, .md-body h2:first-child, .md-body h3:first-child { margin-top: 0; }
.md-body p { margin: 0.6em 0; }
.md-body ul, .md-body ol { margin: 0.6em 0; padding-left: 1.6em; }
.md-body li { margin: 0.25em 0; }
.md-body a { color: var(--accent); text-decoration: none; }
.md-body a:hover { text-decoration: underline; }
.md-body strong { color: var(--text); font-weight: 600; }
.md-body code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.md-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow: auto;
  margin: 0.8em 0;
}
.md-body pre code { background: none; border: none; padding: 0; font-size: 0.82rem; }
.md-body blockquote {
  margin: 0.8em 0;
  padding-left: 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md-body table { border-collapse: collapse; margin: 0.8em 0; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: 5px 10px; }

/* ── Footer ─────────────────────────────────────────────── */
#footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 2rem 0 1.5rem;
}
#footer a { color: var(--accent); text-decoration: none; }

/* ── Scrollbars ─────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 820px) {
  #main { grid-template-columns: 1fr; }
  #files { position: static; }
  /* file list becomes horizontal chips */
  #files .files-head { display: none; }
  .file-group { display: none; }
  #files { display: flex; overflow-x: auto; padding: 6px; gap: 4px; }
  .file-item {
    flex-shrink: 0;
    width: auto;
    border-left: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 12px;
  }
  .file-item.active { border-color: var(--accent); }
  .file-item .f-meta { display: none; }
  #code-wrap { max-height: none; font-size: 11.5px; }
  #header .page-name { display: none; }
}
