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

:root {
  --bg: #fafaf9;
  --bg-card: #ffffff;
  --text: #1c1917;
  --text-secondary: #57534e;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #e7e5e4;
  --border-light: #f5f5f4;
  --tag-praxis: #ccfbf1;
  --tag-praxis-text: #0f766e;
  --tag-stroemungen: #fef3c7;
  --tag-stroemungen-text: #92400e;
  --tag-stimmung: #e0e7ff;
  --tag-stimmung-text: #3730a3;
  --tag-forschung: #fce7f3;
  --tag-forschung-text: #9d174d;
  --tag-vertiefung: #e8e0f4;
  --tag-vertiefung-text: #5b21b6;
  --highlight: #fef9c3;
  --sidebar-width: 260px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

/* === Layout === */
.page-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header a {
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  display: block;
}

.sidebar-section {
  margin-bottom: 1rem;
}

.sidebar-section h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.sidebar-section a {
  display: block;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
  transition: background 0.15s;
}

.sidebar-section a.sub {
  padding-left: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.sidebar-section a:hover {
  background: var(--border-light);
  color: var(--accent);
}

.sidebar-section a.active {
  background: var(--tag-praxis);
  color: var(--tag-praxis-text);
  font-weight: 500;
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2.5rem 3rem;
  max-width: 900px;
}

/* === Mobile Sidebar Toggle === */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  line-height: 1;
}

/* === Typography === */
h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.5rem;
  color: var(--text);
}

h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
}

p { margin-bottom: 1rem; }

.page-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 2rem;
}

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

/* === Breadcrumb === */
.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { margin: 0 0.4rem; }

/* === Tags === */
.tag {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tag-praxis { background: var(--tag-praxis); color: var(--tag-praxis-text); }
.tag-stroemungen { background: var(--tag-stroemungen); color: var(--tag-stroemungen-text); }
.tag-stimmung { background: var(--tag-stimmung); color: var(--tag-stimmung-text); }
.tag-forschung { background: var(--tag-forschung); color: var(--tag-forschung-text); }
.tag-vertiefung { background: var(--tag-vertiefung); color: var(--tag-vertiefung-text); }

/* === Date badge === */
.date-badge {
  font-size: 0.75rem;
  color: var(--text-secondary);
  float: right;
}

/* === Search === */
.search-box {
  margin-bottom: 2rem;
}

.search-box input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-box input::placeholder {
  color: var(--text-secondary);
}

/* === Tables === */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.9rem;
}

th {
  background: var(--border-light);
  font-weight: 600;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:hover td { background: var(--border-light); }

/* === Blockquotes === */
blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin: 1rem 0;
  background: #f0f7ff;
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

blockquote strong { color: var(--text); }

/* === Lists === */
ul, ol {
  margin: 0.5rem 0 1rem 1.5rem;
}

li { margin-bottom: 0.3rem; }
li ul, li ol { margin-top: 0.3rem; margin-bottom: 0; }

/* === Cards (Index + Overview Pages) === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  transition: box-shadow 0.2s, border-color 0.2s;
  text-decoration: none;
  color: var(--text);
  display: block;
}

.card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  border-color: var(--accent);
  text-decoration: none;
}

.card h4 {
  margin-top: 0.4rem;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0;
}

.card .card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* === Code === */
code {
  background: var(--border-light);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: 'SF Mono', 'Menlo', monospace;
}

/* === Horizontal Rule === */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* === Back to Top === */
.back-to-top {
  display: inline-block;
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 0.95rem;
}

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }

  .sidebar-toggle { display: block; }

  .main-content {
    margin-left: 0;
    padding: 1.5rem;
  }

  .card-grid { grid-template-columns: 1fr; }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }

  table { font-size: 0.8rem; }
  th, td { padding: 0.4rem 0.5rem; }
}

/* === Flag/Bookmark === */
.flag-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-secondary);
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
  margin-left: auto;
  flex-shrink: 0;
}

.flag-btn:hover {
  color: var(--accent);
  background: var(--border-light);
}

.flag-btn.flagged {
  color: #d97706;
}

.flag-btn.article-flag {
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  display: inline-block;
}

.flag-btn.article-flag.flagged {
  background: #fffbeb;
  border-color: #d97706;
  color: #92400e;
}

.flag-filter-container {
  margin-bottom: 1rem;
}

.flag-filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.flag-filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.flag-filter-btn.active {
  background: #fffbeb;
  border-color: #d97706;
  color: #92400e;
}

/* === Scroll to Top === */
.scroll-to-top {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 200;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, color 0.15s, border-color 0.15s;
  line-height: 1;
}

.scroll-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.scroll-to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* === Print === */
@media print {
  .sidebar, .sidebar-toggle, .search-box, .flag-btn, .flag-filter-btn, .flag-filter-container { display: none; }
  .main-content { margin-left: 0; max-width: 100%; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
}
