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

:root {
  --bg:           #0f172a;
  --surface:      #1e293b;
  --surface2:     #263348;
  --border:       #334155;
  --text:         #e2e8f0;
  --text-muted:   #94a3b8;
  --accent:       #3b82f6;
  --accent-hover: #2563eb;
  --danger:       rgba(239, 68, 68, 0.15);
  --danger-border:rgba(239, 68, 68, 0.4);
  --danger-text:  #fca5a5;
  --code-inline-bg: rgba(148, 163, 184, 0.12);
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
}

/* ===== Header ===== */
header {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
}

.logo {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo:hover { color: var(--accent); }

.logout {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.15s;
}
.logout:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* ===== Main content ===== */
main {
  max-width: 920px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  margin-bottom: 28px;
  padding: 6px 0;
  transition: color 0.15s;
}
.back:hover { color: var(--accent); }

/* ===== Article / Markdown ===== */
article h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
article h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
article h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 28px 0 12px;
  color: var(--text);
}
article h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 20px 0 8px;
  color: var(--text-muted);
}

article p { margin-bottom: 16px; }

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

article ul,
article ol { margin: 0 0 16px 24px; }
article li { margin-bottom: 6px; }
article li > ul,
article li > ol { margin-top: 6px; margin-bottom: 0; }

/* Inline code */
article code {
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
  font-size: 0.85em;
  background: var(--code-inline-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  color: #93c5fd;
}

/* Code blocks */
article pre {
  background: #0d1117 !important;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  overflow-x: auto;
  margin-bottom: 20px;
}
article pre code {
  background: none !important;
  border: none !important;
  padding: 0;
  font-size: 0.875rem;
  color: inherit;
}

/* Blockquote */
article blockquote {
  border-left: 3px solid var(--accent);
  margin: 20px 0;
  padding: 14px 20px;
  background: var(--surface);
  border-radius: 0 8px 8px 0;
  color: var(--text-muted);
}
article blockquote p { margin-bottom: 0; }

/* Tables */
article table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 0.9rem;
}
article th {
  background: var(--surface);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}
article td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
article tr:hover td { background: rgba(255,255,255,0.025); }

/* HR */
article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

/* ===== Login page ===== */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  font-size: 2.5rem;
  margin-bottom: 14px;
  line-height: 1;
}
.login-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.login-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.alert-error {
  background: var(--danger);
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: var(--danger-text);
  text-align: left;
}

.login-card input {
  width: 100%;
  padding: 13px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 12px;
  letter-spacing: 0.04em;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.login-card input::placeholder { color: var(--text-muted); letter-spacing: 0; }

.login-card button {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.login-card button:hover { background: var(--accent-hover); }
.login-card button:active { transform: scale(0.99); }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  main { padding: 24px 16px 60px; }
  article h1 { font-size: 1.5rem; }
  article h2 { font-size: 1.2rem; }
  article pre { padding: 14px; font-size: 0.8rem; }
  article table { font-size: 0.82rem; }
  article th, article td { padding: 8px 10px; }
  .login-card { padding: 36px 24px; }
}
