/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg-primary:   #020c02;
  --bg-sidebar:   #030f03;
  --bg-hover:     #071407;
  --bg-active:    #0a1e0a;
  --accent-green: #00ff41;
  --accent-cyan:  #00e5b0;
  --accent-yellow:#c8ff00;
  --accent-orange:#00ff41;
  --text-primary: #a8ff8a;
  --text-muted:   #2a7a2a;
  --border:       #0d3a0d;
  --sidebar-width: 260px;
  --status-height: 24px;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #000;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', Consolas, 'Courier New', monospace;
  font-size: 13px;
  overflow: hidden;
  padding: 2px;
}

/* ── App shell ─────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 4px 1fr;
  grid-template-rows: 1fr;
  height: calc(100dvh - var(--status-height));
  border-radius: 4px;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────── */
#sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

#sidebar-header {
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.sidebar-title {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.sidebar-subtitle {
  display: block;
  font-size: 11px;
  color: var(--accent-green);
  margin-top: 2px;
}

#sidebar-section-label {
  padding: 8px 16px 4px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  user-select: none;
}

/* ── File list nav ─────────────────────────────────────── */
#file-list {
  display: flex;
  flex-direction: column;
  flex: 1;
}

#file-list a {
  display: block;
  padding: 5px 16px 5px 24px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.1s;
  border-left: 2px solid transparent;
  line-height: 1.6;
}

#file-list a:hover {
  background: var(--bg-hover);
}

#file-list a.active {
  background: var(--bg-active);
  border-left-color: var(--accent-green);
  color: var(--accent-green);
}

#file-list .file-icon {
  color: var(--text-muted);
  margin-right: 6px;
  font-size: 11px;
}

.sidebar-message {
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

/* ── Resize handle ─────────────────────────────────────── */
#resize-handle {
  background: var(--border);
  cursor: col-resize;
  transition: background 0.15s;
  position: relative;
  z-index: 10;
}

#resize-handle:hover,
#resize-handle.dragging {
  background: var(--accent-green);
}

/* ── Content area ──────────────────────────────────────── */
#content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
  position: relative;
  animation: crt-noise 8s infinite;
}

#content::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 140px;
  top: -140px;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(0, 255, 65, 0.02) 35%,
    rgba(0, 255, 65, 0.05) 50%,
    rgba(0, 255, 65, 0.02) 65%,
    transparent
  );
  animation: crt-beam 6s linear infinite;
  z-index: 90;
}

#content::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.18) 2px,
    rgba(0, 0, 0, 0.18) 4px
  );
  z-index: 100;
}

@keyframes crt-noise {
  0%, 100% { opacity: 1; transform: translateX(0); }
  92%       { opacity: 1; transform: translateX(0); }
  93%       { opacity: 0.94; transform: translateX(0); }
  94%       { opacity: 1; transform: translateX(-1px); }
  94.5%     { transform: translateX(1px); }
  95%       { transform: translateX(0); }
  96%       { opacity: 0.97; }
}

@keyframes crt-beam {
  0%   { transform: translateY(0); }
  100% { transform: translateY(calc(100vh + 140px)); }
}

#breadcrumb {
  padding: 6px 20px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb-prefix {
  color: var(--text-muted);
  margin-right: 4px;
}

#current-file {
  color: var(--text-primary);
}

#log-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 40px 48px;
  line-height: 1.75;
  position: relative;
  letter-spacing: 0.03em;
  isolation: isolate;
}

#log-body::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 55%,
    rgba(0, 0, 0, 0.55) 100%
  );
  z-index: -1;
}

/* ── Phosphor glow ─────────────────────────────────────── */
#log-body, #breadcrumb, #status-bar {
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.5);
}

/* ── Log content typography ────────────────────────────── */
.log-h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-orange);
  margin-bottom: 24px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  text-shadow: 0 0 12px rgba(0, 255, 65, 0.8);
}

.log-h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-top: 28px;
  margin-bottom: 12px;
  text-shadow: 0 0 8px rgba(0, 229, 176, 0.7);
}

.log-h2::before {
  content: '## ';
  color: var(--text-muted);
  font-weight: 400;
}

.log-ul {
  list-style: none;
  margin: 8px 0;
  padding: 0;
}

.log-ul li {
  padding: 2px 0 2px 20px;
  position: relative;
  color: var(--text-primary);
}

.log-ul li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--text-muted);
  font-size: 10px;
  top: 4px;
}

.log-p {
  margin: 6px 0;
  color: var(--text-primary);
}

.log-timestamp {
  color: var(--accent-yellow);
  font-weight: 500;
  text-shadow: 0 0 8px rgba(200, 255, 0, 0.8);
}

/* ── Welcome screen ────────────────────────────────────── */
#welcome {
  padding-top: 40px;
}

.welcome-line {
  margin: 4px 0;
  color: var(--accent-green);
}

.welcome-line.muted {
  color: var(--text-muted);
  margin-top: 12px;
}

.cursor {
  display: inline-block;
  animation: blink 1s step-end infinite;
  color: var(--accent-green);
}

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

.tw-cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--accent-green);
  box-shadow: 0 0 6px rgba(0, 255, 65, 0.8);
  animation: blink 0.7s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

/* ── Status bar ────────────────────────────────────────── */
#status-bar {
  height: var(--status-height);
  background: #011501;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 16px;
  font-size: 11px;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}

#status-branch {
  color: var(--accent-green);
  font-weight: 500;
}

.status-muted {
  color: var(--text-muted);
}

.status-spacer {
  flex: 1;
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Error state ───────────────────────────────────────── */
.log-error {
  color: #f85149;
  padding: 20px 0;
}

/* ── Menu toggle (hidden on desktop) ───────────────────── */
#menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--accent-green);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 8px 0 0;
  letter-spacing: 0.05em;
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.5);
}
#menu-toggle:hover { color: var(--accent-green); opacity: 0.8; }

/* ── Sidebar backdrop (mobile only) ─────────────────────── */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 199;
}
#sidebar-backdrop.open { display: block; }

/* ── Tablet (601–900px) ─────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-width: 200px; }
}

/* ── Mobile (≤600px) ────────────────────────────────────── */
@media (max-width: 600px) {
  #app {
    grid-template-columns: 0 0 1fr;
  }
  #sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: var(--status-height);
    width: 240px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #content       { grid-column: 3; }
  #resize-handle { display: none; }
  #menu-toggle   { display: inline; }
  #log-body      { padding: 20px 20px 36px; }
}
