/* ============================================================
   Pagent — global styles
   Inspired by Notion / Bear: content-first, minimal chrome
   ============================================================ */

:root {
  --bg: #ffffff;
  --surface: #f9f9f7;
  --text: #1a1a1a;
  --text-secondary: #6b6b6b;
  --border: #e8e8e4;
  --accent: #5c5ce0;
  --code-bg: #f4f4f2;
  --code-text: #c7254e;
  --header-h: 44px;
  --max-w: 720px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --surface: #1e1e1e;
    --text: #e8e8e8;
    --text-secondary: #888888;
    --border: #2e2e2e;
    --accent: #7c7cff;
    --code-bg: #222222;
    --code-text: #f08d75;
  }
}

/* Theme overrides (set by <body data-theme="..."> ) */
[data-theme="dark"] {
  --bg: #141414;
  --surface: #1e1e1e;
  --text: #e8e8e8;
  --text-secondary: #888888;
  --border: #2e2e2e;
  --accent: #7c7cff;
  --code-bg: #222222;
  --code-text: #f08d75;
}

[data-theme="minimal"] {
  --bg: #fafaf8;
  --surface: #f0f0ec;
  --text: #222222;
  --text-secondary: #777777;
  --border: #ddddd8;
  --accent: #333333;
  --code-bg: #ececea;
  --code-text: #c7254e;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.75;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

/* ---- Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(var(--bg-rgb, 255,255,255), 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header .brand {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.site-header .brand span { color: var(--accent); }

.btn-copy {
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.btn-copy:hover { border-color: var(--accent); color: var(--accent); }
.btn-copy.copied { color: #22a06b; border-color: #22a06b; }

/* ---- Main content ---- */
.page-wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: 32px;
  color: var(--text);
}

/* ---- Markdown rendered content ---- */
.content h1, .content h2, .content h3,
.content h4, .content h5, .content h6 {
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 1.8em 0 0.6em;
  color: var(--text);
}
.content h1 { font-size: 1.75rem; }
.content h2 { font-size: 1.4rem; }
.content h3 { font-size: 1.15rem; }
.content h4 { font-size: 1rem; }

.content p { margin: 0 0 1.2em; }

.content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.content a:hover { opacity: 0.8; }

.content ul, .content ol { padding-left: 1.5em; margin: 0 0 1.2em; }
.content li { margin-bottom: 0.3em; }

.content blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 16px;
  margin: 1.2em 0;
  color: var(--text-secondary);
  font-style: italic;
}

.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1em 0;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 0.9em;
}

.content th, .content td {
  padding: 8px 12px;
  text-align: left;
  border: 1px solid var(--border);
}

.content th { background: var(--surface); font-weight: 600; }
.content tr:hover td { background: var(--surface); }

/* ---- Code ---- */
.content code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 2px 6px;
  border-radius: 4px;
}

.content pre {
  margin: 1.2em 0;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.88em;
  line-height: 1.6;
  border: 1px solid var(--border);
}

.content pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

/* highlight.js theme wrap */
.content pre > code.hljs {
  padding: 16px 20px;
  border-radius: 7px;
}

/* ---- Footer ---- */
.page-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.page-footer a { color: var(--text-secondary); text-decoration: none; }
.page-footer a:hover { color: var(--accent); }

/* ---- State screens ---- */
.state-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-h));
  gap: 12px;
  text-align: center;
  padding: 24px;
}

.state-screen .icon { font-size: 3rem; }

.state-screen h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.state-screen p { color: var(--text-secondary); font-size: 0.95rem; }

.state-screen a {
  margin-top: 8px;
  color: var(--accent);
  font-size: 0.9rem;
}

/* ---- Loading spinner ---- */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Fade in ---- */
.fade-in { animation: fadeIn 0.35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Index page ---- */
.hero {
  max-width: 680px;
  margin: 80px auto 0;
  padding: 0 24px 100px;
}

.hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 16px;
}

.hero h1 .accent { color: var(--accent); }

.hero .tagline {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 40px;
  line-height: 1.6;
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0 0 48px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.95rem;
}

.feature-list .icon { font-size: 1.1rem; flex-shrink: 0; padding-top: 2px; }

.code-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  margin: 24px 0;
  overflow-x: auto;
}

.code-block pre {
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.7;
  color: var(--text);
  margin: 0;
  border: none;
  border-radius: 0;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 36px 0 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.78rem;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .page-title { font-size: 1.5rem; }
  .hero h1 { font-size: 1.8rem; }
  .page-wrap { padding: 32px 16px 80px; }
}
