:root {
  color-scheme: dark;
  --bg: #0f1117;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --card: #1a1d27;
  --border: #2a2d3a;
  --accent: #f59e0b;
  --accent2: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --purple: #a855f7;
  --input-bg: #151821;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

.container { width: min(960px, 92vw); margin: 0 auto; padding: 0 1rem; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15,17,23,0.95); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0; margin-bottom: 2rem;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; }
.logo { font-weight: 700; font-size: 0.95rem; }
.logo-spark { color: var(--accent); }

.nav { display: flex; gap: 1rem; align-items: center; }
.nav a, .nav button {
  color: var(--muted); text-decoration: none; font-size: 0.85rem;
  padding: 0.3rem 0.6rem; border-radius: 4px; transition: color 0.2s, background 0.2s;
}
.nav a:hover, .nav button:hover { color: var(--text); background: rgba(255,255,255,0.05); text-decoration: none; }
.inline-form { margin: 0; }
.inline-form button { background: none; border: none; cursor: pointer; font-size: 0.85rem; padding: 0.3rem 0.6rem; color: var(--muted); }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1.5rem; margin-bottom: 1.5rem; }

h1, h2, h3 { margin-top: 0; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }

/* Forms */
label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 0.9rem; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px;
  margin-top: 6px; background: var(--input-bg); color: var(--text); font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(245,158,11,0.15); }
select { background: var(--input-bg); }

button {
  background: var(--accent); color: #0f1117; border: none; padding: 10px 18px;
  border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 0.9rem; transition: opacity 0.2s;
}
button:hover { opacity: 0.9; }
.button-secondary { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.button-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* Lists */
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: none; }
.muted { color: var(--muted); }
.error { color: var(--red); font-weight: 600; }
.success { color: var(--green); font-weight: 600; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.05em; }

/* Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; background: rgba(255,255,255,0.08); color: var(--muted); }
.badge-success { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--accent2); }
.align-right { text-align: right; }

/* Form grid */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; margin-bottom: 16px; }
.form-actions { align-self: end; }
.input-compact { width: 100%; padding: 6px 8px; font-size: 0.85rem; }
.mono { font-family: "SFMono-Regular", ui-monospace, "Cascadia Code", Menlo, monospace; font-size: 0.85rem; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* Feature grid */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 12px 0; }
.feature-toggle { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg); }
.checkbox { display: flex; align-items: center; gap: 10px; margin: 0; }
.checkbox input[type="checkbox"] { width: auto; margin-top: 0; }
.text-capitalize { text-transform: capitalize; }

/* Permissions */
.permissions-row { grid-column: 1 / -1; display: flex; align-items: center; gap: 1.5rem; margin: 0.5rem 0; }
.permissions-label { font-weight: 600; font-size: 0.9rem; white-space: nowrap; margin-right: 0.5rem; }
span.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
span.checkbox-inline input[type="checkbox"] { margin: 0; }
span.checkbox-inline label { display: inline; margin: 0; cursor: pointer; font-size: 0.9rem; color: var(--text); }

/* Project cards (dashboard) */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.project-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.2rem 1.5rem; transition: border-color 0.2s; display: block; color: var(--text); text-decoration: none;
}
.project-card:hover { border-color: var(--accent); text-decoration: none; }
.project-card .project-name { font-weight: 700; font-size: 1.1rem; margin-bottom: 0.3rem; }
.project-card .project-desc { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.6rem; }
.project-card .project-perms { font-size: 0.75rem; color: var(--muted); }
.project-card .project-features { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; }
.feature-pill { font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; background: rgba(245,158,11,0.12); color: var(--accent); }

/* Login */
.login-card { max-width: 400px; margin: 4rem auto; }
.login-card h1 { text-align: center; margin-bottom: 1.5rem; }
.logo-big { text-align: center; font-size: 1.8rem; font-weight: 700; margin-bottom: 0.3rem; }
.logo-big span { color: var(--accent); }

/* Light theme overrides */
body.theme-light {
  color-scheme: light;
  --bg: #f8f9fa;
  --text: #1a1d27;
  --muted: #5c6b77;
  --card: #ffffff;
  --border: #e1e5ea;
  --accent: #d97706;
  --accent2: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --purple: #9333ea;
  --input-bg: #ffffff;
}
body.theme-light .site-header {
  background: rgba(255,255,255,0.95);
  border-bottom-color: #e1e5ea;
}
body.theme-light .nav a, body.theme-light .nav button,
body.theme-light .inline-form button {
  color: #5c6b77;
}
body.theme-light .nav a:hover, body.theme-light .nav button:hover {
  color: #1a1d27;
  background: rgba(0,0,0,0.05);
}
body.theme-light input, body.theme-light select, body.theme-light textarea {
  background: #fff;
  border-color: #d1d5db;
  color: #1a1d27;
}
body.theme-light .logo { color: #1a1d27; }

/* Feature pill links */
a.feature-pill { text-decoration: none !important; cursor: pointer; }
a.feature-pill:hover { opacity: 0.85; text-decoration: none !important; }
.feature-pill-settings { background: var(--border) !important; color: var(--muted) !important; }
body.theme-light .feature-pill-settings { background: #e5e7eb !important; color: #6b7280 !important; }

/* Project card name link */
.project-card .project-name { display: block; text-decoration: none; color: var(--text); font-weight: 600; font-size: 1.1rem; margin-bottom: 0.3rem; }
.project-card .project-name:hover { text-decoration: underline; }
.project-card { cursor: default; }

/* Project toolbar buttons */
.toolbar-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text); text-decoration: none;
  font-size: 0.9rem; font-weight: 500; transition: all 0.15s;
  cursor: pointer;
}
.toolbar-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }
.toolbar-btn-settings { color: var(--muted); }
.toolbar-btn-settings:hover { background: var(--border); color: var(--text); border-color: var(--border); }

/* Research Portal */
.research-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.research-card {
  display: block; background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.2rem 1.5rem; text-decoration: none; color: var(--text); transition: border-color 0.2s;
}
.research-card:hover { border-color: var(--accent); text-decoration: none; }

.tier-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
}
.tier-badge.tier-t1 { background: rgba(148,163,184,0.15); color: #94a3b8; }
.tier-badge.tier-t2 { background: rgba(59,130,246,0.15); color: #60a5fa; }
.tier-badge.tier-t3 { background: rgba(34,197,94,0.15); color: #4ade80; }
.tier-badge.tier-t4 { background: rgba(251,146,60,0.15); color: #fb923c; }
.tier-badge.tier-t5 { background: rgba(168,85,247,0.15); color: #c084fc; }

.research-content { line-height: 1.8; font-size: 0.95rem; }
.research-content h1 { font-size: 1.5rem; margin: 2rem 0 0.8rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.research-content h2 { font-size: 1.25rem; margin: 1.8rem 0 0.6rem; }
.research-content h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.research-content p { margin: 0.8rem 0; }
.research-content ul, .research-content ol { margin: 0.8rem 0; padding-left: 1.5rem; }
.research-content li { margin: 0.3rem 0; }
.research-content blockquote {
  border-left: 3px solid var(--accent); margin: 1rem 0; padding: 0.5rem 1rem;
  background: rgba(245,158,11,0.05); border-radius: 0 6px 6px 0;
}
.research-content code {
  background: rgba(255,255,255,0.06); padding: 2px 6px; border-radius: 4px;
  font-family: "SFMono-Regular", ui-monospace, monospace; font-size: 0.85em;
}
.research-content pre {
  background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem; overflow-x: auto; margin: 1rem 0;
}
.research-content pre code { background: none; padding: 0; }
.research-content table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; }
.research-content th, .research-content td {
  text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.research-content th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.research-content strong { color: var(--accent); }
.research-content hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.research-content a { color: var(--accent2); }

body.theme-light .research-content pre { background: rgba(0,0,0,0.04); }
body.theme-light .research-content code { background: rgba(0,0,0,0.06); }
body.theme-light .research-content blockquote { background: rgba(245,158,11,0.08); }

/* Plugin navigation bar */
.plugin-nav { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0; margin-bottom: 1.2rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.plugin-nav-back { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 0.95rem; white-space: nowrap; }
.plugin-nav-back:hover { text-decoration: underline; }
.plugin-nav-links { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-left: auto; }
.plugin-nav-link { color: var(--muted); text-decoration: none; font-size: 0.85rem; padding: 0.25rem 0.5rem; border-radius: 6px; transition: background 0.15s, color 0.15s; white-space: nowrap; }
.plugin-nav-link:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.plugin-nav-link.active { color: var(--accent); background: rgba(255,255,255,0.04); }
body.theme-light .plugin-nav-link:hover { background: rgba(0,0,0,0.05); }
body.theme-light .plugin-nav-link.active { background: rgba(0,0,0,0.04); }
