@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400;500;600&family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;1,400&display=swap');

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

:root {
  --bg:            #060a0e;
  --surface:       #090e14;
  --surface-2:     #0c1219;
  --border:        #162030;
  --border-bright: #243348;
  --text:          #7a95af;
  --text-bright:   #c0d8f0;
  --text-dim:      #304050;
  --accent:        #00e5c0;
  --accent-dim:    rgba(0, 229, 192, 0.08);
  --accent-glow:   rgba(0, 229, 192, 0.18);
  --error:         #ff4060;
  --error-dim:     rgba(255, 64, 96, 0.08);
  --success:       #00e5c0;
  --mono: 'IBM Plex Mono', 'Courier New', monospace;
  --sans: 'IBM Plex Sans', sans-serif;
}

html { font-size: 15px; }

/* ── Background: dark grid ── */
body {
  font-family: var(--mono);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(22, 32, 48, 0.6) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 32, 48, 0.6) 1px, transparent 1px);
  background-size: 48px 48px;
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.04) 3px,
    rgba(0, 0, 0, 0.04) 4px
  );
  pointer-events: none;
  z-index: 9998;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── Layout ── */
#app { max-width: 880px; margin: 0 auto; padding: 0 1.5rem 5rem; }

/* ── Nav ── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.nav-brand {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.01em;
  text-decoration: none;
}
.nav-brand::before { content: '> '; color: var(--accent); }
.nav-brand span { color: var(--accent); }
.nav-brand:hover { text-decoration: none; }

.nav-links { display: flex; gap: 1.75rem; }
.nav-links a {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--accent); text-decoration: none; }

/* ── Page header ── */
.page-header { margin-bottom: 2rem; }

.page-header h1 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-bright);
  font-family: var(--mono);
}
.page-header h1::before { content: '// '; color: var(--accent); opacity: 0.6; }

.page-header p {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

/* ── Doc list ── */
.doc-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.doc-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem 0.875rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: background 0.12s, border-color 0.12s;
}
.doc-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: transparent;
  transition: background 0.12s;
}
.doc-item:hover { background: var(--surface-2); border-color: var(--border-bright); }
.doc-item:hover::before { background: var(--accent); }

.doc-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-author { font-size: 0.75rem; color: var(--accent); white-space: nowrap; flex-shrink: 0; }
.doc-time   { font-size: 0.7rem;  color: var(--text-dim); white-space: nowrap; flex-shrink: 0; }
.doc-size   { font-size: 0.7rem;  color: var(--text-dim); white-space: nowrap; flex-shrink: 0; }

/* ── Buttons ── */
.load-more-wrap { text-align: center; margin-top: 1.5rem; }

.btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  border: 1px solid var(--border-bright);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { background: transparent; color: var(--accent); }

/* ── Doc detail ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  transition: color 0.12s;
}
.back-link::before { content: '<< '; color: var(--accent); }
.back-link:hover { color: var(--accent); text-decoration: none; }

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  margin-bottom: 1.5rem;
  font-size: 0.73rem;
  font-family: var(--mono);
  color: var(--text-dim);
}
.doc-meta strong { color: var(--text); }
.doc-meta a { color: var(--accent); }

/* ── Markdown body ── */
.markdown-body {
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  line-height: 1.8;
  overflow-wrap: break-word;
  font-family: var(--sans);
  font-size: 0.9375rem;
  color: var(--text);
}
.markdown-body :first-child { margin-top: 0; }

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text-bright);
  margin: 2rem 0 0.75rem;
  line-height: 1.3;
}
.markdown-body h1 { font-size: 1.45rem; }
.markdown-body h2 {
  font-size: 1.15rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.markdown-body h3 { font-size: 0.975rem; color: var(--accent); }
.markdown-body h4, .markdown-body h5, .markdown-body h6 { font-size: 0.9rem; }

.markdown-body p { margin: 0.875rem 0; }
.markdown-body ul, .markdown-body ol { margin: 0.875rem 0; padding-left: 1.5rem; }
.markdown-body li { margin: 0.3rem 0; }

.markdown-body code {
  font-family: var(--mono);
  font-size: 0.83em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 0.1em 0.4em;
}
.markdown-body pre {
  margin: 1.25rem 0;
  padding: 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  overflow-x: auto;
}
.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-bright);
  font-size: 0.86rem;
}
.markdown-body blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 2px solid var(--border-bright);
  color: var(--text-dim);
  font-style: italic;
}
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.875rem; }
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.markdown-body th {
  background: var(--surface-2);
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text-bright);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.markdown-body a { color: var(--accent); }
.markdown-body strong { color: var(--text-bright); font-weight: 600; }
.markdown-body em { font-style: italic; }
.markdown-body img { max-width: 100%; }

/* ── Plain text fallback ── */
.plain-body {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.84rem;
  color: var(--text);
  overflow-x: auto;
  line-height: 1.7;
}

/* ── Upload form ── */
.upload-form { display: flex; flex-direction: column; gap: 1.25rem; }
.field { display: flex; flex-direction: column; gap: 0.375rem; }

.field label {
  font-size: 0.7rem;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.field input, .field textarea {
  padding: 0.625rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-bright);
  font-size: 0.875rem;
  font-family: var(--mono);
  width: 100%;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
  caret-color: var(--accent);
}
.field input:focus, .field textarea:focus {
  border-color: var(--accent);
  background: var(--surface-2);
}
.field textarea {
  min-height: 320px;
  resize: vertical;
  line-height: 1.6;
}
.field-hint {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-family: var(--mono);
}

.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 0.25rem; }

.upload-status { font-size: 0.78rem; font-family: var(--mono); }
.upload-status.success { color: var(--success); }
.upload-status.error   { color: var(--error); }

/* ── States ── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.84rem;
}
.empty-state p { margin-bottom: 1.5rem; }

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  font-family: var(--mono);
}
/* blinking block cursor on loading text */
.loading::after {
  content: '█';
  color: var(--accent);
  margin-left: 0.35em;
  animation: blink-cursor 1s step-end infinite;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.error-state {
  padding: 1.25rem 1.5rem;
  color: var(--error);
  font-family: var(--mono);
  font-size: 0.84rem;
  background: var(--error-dim);
  border: 1px solid rgba(255, 64, 96, 0.25);
  border-left: 2px solid var(--error);
  text-align: left;
}
.error-state::before { content: '[ERROR] '; opacity: 0.6; }

/* ── Author filter bar ── */
.author-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  margin-bottom: 1.5rem;
  font-size: 0.75rem;
  font-family: var(--mono);
}
.author-filter-bar > span:first-child { color: var(--text-dim); }
.author-name { color: var(--accent); font-weight: 500; }
.author-filter-bar a { color: var(--text-dim); font-size: 0.7rem; margin-left: auto; transition: color 0.12s; }
.author-filter-bar a:hover { color: var(--error); text-decoration: none; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .doc-item { grid-template-columns: 1fr auto; }
  .doc-size, .doc-time { display: none; }
  .doc-meta { flex-direction: column; gap: 0.3rem; }
  body { background-size: 24px 24px; }
  .markdown-body { padding: 1.25rem; }
}
