/* Base - No theme by default (system preference) */
:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666666;
  --link: #0066cc;
  --link-hover: #004499;
  --border: #e0e0e0;
  --code-bg: #f5f5f5;
  --max-width: 700px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="reader"]) {
    --bg: #1a1a1a;
    --text: #e0e0e0;
    --text-muted: #999999;
    --link: #6db3f2;
    --link-hover: #8ec5f5;
    --border: #333333;
    --code-bg: #2d2d2d;
  }
}

/* Explicit dark mode */
[data-theme="dark"] {
  --bg: #1a1a1a;
  --text: #e0e0e0;
  --text-muted: #999999;
  --link: #6db3f2;
  --link-hover: #8ec5f5;
  --border: #333333;
  --code-bg: #2d2d2d;
}

/* Explicit light mode */
[data-theme="light"] {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666666;
  --link: #0066cc;
  --link-hover: #004499;
  --border: #e0e0e0;
  --code-bg: #f5f5f5;
}


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

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Header */
header {
  margin-bottom: 3rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.site-title a {
  text-decoration: none;
  color: var(--text);
}

nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

nav a:hover {
  color: var(--link);
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  color: var(--text);
}

.theme-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
  display: none;
}

/* Show icon based on current theme */
:root[data-theme-icon="auto"] .icon-auto,
:root:not([data-theme-icon]) .icon-auto { display: block; }
:root[data-theme-icon="light"] .icon-light { display: block; }
:root[data-theme-icon="dark"] .icon-dark { display: block; }

/* Links */
a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

/* Article list */
.post-list {
  list-style: none;
}

.post-list li {
  margin-bottom: 2rem;
}

.post-list .post-title {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.post-list .post-title a {
  text-decoration: none;
  color: var(--text);
}

.post-list .post-title a:hover {
  color: var(--link);
}

.post-meta {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

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

/* Single post */
article h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

article .post-meta {
  margin-bottom: 2rem;
}

article .content {
  margin-bottom: 3rem;
}

article .content h2 {
  font-size: 1.5rem;
  margin: 2rem 0 1rem;
}

article .content h3 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.75rem;
}

article .content p {
  margin-bottom: 1rem;
}

article .content ul,
article .content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

article .content li {
  margin-bottom: 0.5rem;
}

article .content blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
  font-style: italic;
}

article .content pre {
  background: var(--code-bg);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

article .content code {
  font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
  font-size: 0.875em;
}

article .content p code {
  background: var(--code-bg);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
}

article .content img {
  max-width: 100%;
  height: auto;
}

article .content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

article .content th,
article .content td {
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

article .content th {
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

article .content tr:last-child td {
  border-bottom: none;
}

/* Tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 2rem;
}

.tags a {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
}

.tags a:hover {
  border-color: var(--link);
  color: var(--link);
}

/* Tag listing page */
.tag-list {
  list-style: none;
}

.tag-item {
  margin-bottom: 1.5rem;
}

.tag-title {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.tag-title a {
  text-decoration: none;
  color: var(--text);
}

.tag-title a:hover {
  color: var(--link);
}

.tag-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: normal;
}

.tag-count::before {
  content: "(";
}

.tag-count::after {
  content: ")";
}

.tag-description,
.section-description {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* Glossary */
.glossary-list {
  margin-top: 2rem;
}

.glossary-entry {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}

.glossary-entry:first-child {
  border-top: none;
}

.glossary-entry:target {
  background: rgba(59, 130, 246, 0.1);
  margin-left: -0.5rem;
  margin-right: -0.5rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  border-radius: 4px;
}

.glossary-entry dt {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.glossary-entry dt a {
  color: inherit;
  text-decoration: none;
}

.glossary-entry dt a:hover {
  color: inherit;
}

.glossary-entry dd {
  color: var(--text-muted);
  margin-left: 0;
}

/* Auto-linked glossary terms in content */
a.glossary-link {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

a.glossary-link:hover {
  text-decoration-style: solid;
}

/* Footer */
footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
}

footer a {
  color: var(--text-muted);
}

/* Feed links */
.feed-links {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.feed-links a {
  font-size: 0.8rem;
}

/* Human level chips */
.human-level-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  vertical-align: middle;
  text-decoration: none;
}

a.human-level-chip:hover {
  opacity: 0.85;
  text-decoration: none;
}

.hl-indicator,
.hl-label {
  font-size: 0.75rem;
  line-height: 1;
}

.hl-indicator {
  font-weight: 700;
}

/* Human level scale: AI -> collaborative -> fully human */
.hl-1 {
  background: rgba(148, 163, 184, 0.15);
  color: #64748b;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.hl-2 {
  background: rgba(99, 102, 241, 0.15);
  color: #4f46e5;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.hl-3 {
  background: rgba(217, 119, 6, 0.15);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.3);
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="reader"]) {
    .hl-1 { color: #94a3b8; }
    .hl-2 { color: #a5b4fc; }
    .hl-3 { color: #fbbf24; }
  }
}

[data-theme="dark"] {
  .hl-1 { color: #94a3b8; }
  .hl-2 { color: #a5b4fc; }
  .hl-3 { color: #fbbf24; }
}

/* Stream layout */
.stream-item {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

.stream-item:last-child {
  border-bottom: none;
}

.stream-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.stream-note-content {
  font-size: 1rem;
  line-height: 1.6;
}

.stream-note-content p:last-child {
  margin-bottom: 0;
}

.stream-title {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.stream-title a {
  text-decoration: none;
  color: var(--text);
}

.stream-title a:hover {
  color: var(--link);
}

.stream-summary {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.stream-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.stream-tags a {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

.stream-tags a:hover {
  border-color: var(--link);
  color: var(--link);
}

/* Post meta row */
.post-meta-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 600px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
  }
}
