/*
 * IndexGram — Modern Sleek Theme
 * Clean flat design: white card surfaces, dark slate background,
 * indigo-to-violet accent, rounded corners, refined shadows.
 */

/* ── CSS Custom Properties ─────────────────────────────────────────────────── */
:root {
  --desktop-bg:        #0F172A;   /* Deep slate page background */
  --window-bg:         #F8FAFC;   /* Near-white card surface */
  --titlebar-bg:       #6366F1;   /* Indigo */
  --titlebar-bg-end:   #8B5CF6;   /* Violet */
  --titlebar-text:     #FFFFFF;
  --titlebar-inactive: #A5B4FC;
  --text-color:        #1E293B;
  --link-color:        #4F46E5;
  --link-hover:        #7C3AED;
  --accent-color:      #6366F1;
  --content-bg:        #FFFFFF;
  --footer-bg:         #1E293B;
  --footer-text:       #CBD5E1;
  --border-light:      #E2E8F0;
  --border-mid:        #CBD5E1;
  --border-dark:       #94A3B8;
  --button-bg:         #6366F1;
  --input-border:      #CBD5E1;
  --code-bg:           #F1F5F9;
  --table-header-bg:   #6366F1;
  --table-header-text: #FFFFFF;
  --table-row-alt:     #F8FAFC;
  --tag-bg:            #6366F1;
  --tag-text:          #FFFFFF;
  --sidebar-bg:        #F8FAFC;
  --flash-success-bg:  #DCFCE7;
  --flash-error-bg:    #FEE2E2;
  --flash-info-bg:     #EDE9FE;
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* ── Global link-as-button ─────────────────────────────────────────────────── */
a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 14px;
  background: var(--button-bg);
  border: none;
  border-radius: 6px;
  color: #FFFFFF;
  text-decoration: none;
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  box-shadow: 0 1px 3px rgba(99,102,241,0.25), 0 1px 2px rgba(0,0,0,0.1);
}
a:hover {
  background: var(--link-hover);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
  transform: translateY(-1px);
}
a:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(99,102,241,0.2);
}

/* Markdown / document body links — readable inline text */
.markdown-body a,
.markdown-body a:hover {
  display: inline;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  color: var(--link-color);
  font-weight: inherit;
  text-decoration: underline;
  transform: none;
  letter-spacing: normal;
}
.markdown-body a:hover { color: var(--link-hover); text-decoration: underline; }

html { height: 100%; }

body {
  margin: 0;
  padding: 0;
  background-color: var(--desktop-bg);
  color: var(--text-color);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Desktop wrapper ───────────────────────────────────────────────────────── */
#desktop {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Taskbar / Nav ─────────────────────────────────────────────────────────── */
#taskbar {
  background: #FFFFFF;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: stretch;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,0.08);
}

#taskbar-logo {
  background: linear-gradient(135deg, var(--titlebar-bg) 0%, var(--titlebar-bg-end) 100%);
  color: var(--titlebar-text);
  padding: 0 20px;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  letter-spacing: -0.02em;
}

#taskbar-logo .site-logo { max-height: 30px; }
#taskbar-logo .site-title-nav { font-size: 15px; font-weight: 700; }

#taskbar-links {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  flex: 1;
}

#taskbar-links a {
  display: flex;
  align-items: center;
  padding: 0 16px;
  text-decoration: none;
  color: #475569;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  white-space: nowrap;
  letter-spacing: 0;
  transition: color 0.15s, background 0.15s;
  border-bottom: 2px solid transparent;
}
#taskbar-links a:hover {
  background: #F8FAFC;
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
  transform: none;
  box-shadow: none;
}
#taskbar-links a:active { transform: none; }
#taskbar-links a.rss-link { color: #B45309; font-weight: 600; }
#taskbar-links a.rss-link:hover { color: #92400E; background: #FEF3C7; border-bottom-color: #B45309; }

/* ── Main Window ───────────────────────────────────────────────────────────── */
#main-window {
  flex: 1;
  padding: 20px 16px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ── Card / Window ─────────────────────────────────────────────────────────── */
.window {
  background: var(--window-bg);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  overflow: hidden;
}

.win-titlebar {
  background: linear-gradient(135deg, var(--titlebar-bg) 0%, var(--titlebar-bg-end) 100%);
  color: var(--titlebar-text);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  letter-spacing: 0.01em;
}

.win-body { padding: 16px; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.button, button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--button-bg);
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  color: #FFFFFF;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  box-shadow: 0 1px 3px rgba(99,102,241,0.3);
  letter-spacing: 0.01em;
}
.button:hover, button.button:hover {
  background: var(--link-hover);
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
  transform: translateY(-1px);
  color: #FFFFFF;
}
.button:active, button.button:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(99,102,241,0.2);
}
.button.btn-sm { padding: 4px 10px; font-size: 12px; }
.full-width { display: block; width: 100%; text-align: center; margin-bottom: 8px; }

/* ── Flash messages ────────────────────────────────────────────────────────── */
.flash {
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid transparent;
}
.flash-success {
  background: var(--flash-success-bg);
  border-color: #86EFAC;
  color: #166534;
  border-left: 4px solid #16A34A;
}
.flash-error {
  background: var(--flash-error-bg);
  border-color: #FCA5A5;
  color: #991B1B;
  border-left: 4px solid #DC2626;
}
.flash-info {
  background: var(--flash-info-bg);
  border-color: #C4B5FD;
  color: #4C1D95;
  border-left: 4px solid #7C3AED;
}

/* ── Breadcrumb ────────────────────────────────────────────────────────────── */
.breadcrumb {
  font-size: 12px;
  margin-bottom: 12px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  color: #94A3B8;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}
.breadcrumb a {
  font-size: 12px;
  padding: 2px 6px;
  color: #94A3B8;
  background: transparent;
  border: none;
  border-radius: 4px;
  box-shadow: none;
  font-weight: 400;
}
.breadcrumb a:hover {
  background: rgba(255,255,255,0.1);
  color: #FFFFFF;
  transform: none;
  box-shadow: none;
}

/* ── Hero ──────────────────────────────────────────────────────────────────── */
.page-hero {
  background: linear-gradient(135deg, var(--titlebar-bg) 0%, var(--titlebar-bg-end) 100%) !important;
  margin-bottom: 20px;
  padding: 28px 24px !important;
  border-radius: 12px;
}
.hero-inner { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.hero-logo  { max-height: 60px; }
.hero-sitename { font-size: 26px; font-weight: 800; color: #FFFFFF; letter-spacing: -0.03em; }
.hero-desc  { margin: 0; color: rgba(255,255,255,0.8); font-size: 14px; }

/* ── Section headers ───────────────────────────────────────────────────────── */
.section-titlebar {
  background: transparent;
  color: var(--text-color);
  padding: 0 0 10px 0;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--border-light);
}
.section-titlebar h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-color);
  letter-spacing: -0.02em;
}

/* ── Topics grid ───────────────────────────────────────────────────────────── */
.topics-section  { margin-bottom: 24px; }
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.topic-card {
  background: var(--window-bg);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  padding: 0;
  overflow: hidden;
}
.topic-card:hover {
  box-shadow: 0 8px 24px rgba(99,102,241,0.18);
  transform: translateY(-2px);
  background: var(--window-bg);
  color: inherit;
  border-color: #C4B5FD;
}
.topic-card-body { padding: 12px; flex: 1; }
.topic-card-name {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-color);
  margin: 2px 0 6px;
  letter-spacing: 0.01em;
}
.topic-thumb { width: calc(100% + 24px); margin: -12px -12px 8px; height: 120px; object-fit: cover; display: block; }
.topic-icon  { font-size: 28px; display: block; margin-bottom: 6px; }
.topic-desc  { font-size: 12px; margin: 0 0 8px; color: var(--text-color); line-height: 1.5; opacity: 0.75; }
.topic-count { font-size: 11px; font-weight: 600; color: var(--accent-color); }
.topic-rss   { float: right; font-size: 11px; }
.topic-rss a {
  color: #B45309;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
}
.topic-rss a:hover { color: #92400E; background: transparent; transform: none; box-shadow: none; }

/* ── Document table ────────────────────────────────────────────────────────── */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 6px;
}
.doc-table th {
  background: linear-gradient(135deg, var(--titlebar-bg) 0%, var(--titlebar-bg-end) 100%);
  color: var(--table-header-text);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 12px;
}
.doc-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-light); }
.doc-table tr:nth-child(even) td { background: #F8FAFC; }
.doc-table tr:hover td { background: #EDE9FE; }
.doc-table a { color: var(--link-color); }

/* ── Document layout ───────────────────────────────────────────────────────── */
.doc-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.doc-window  { flex: 3; min-width: 0; }
.doc-sidebar { flex: 1; min-width: 200px; max-width: 260px; }

.doc-og-image {
  width: 100%;
  height: auto;
  display: block;
  margin-bottom: 16px;
  border-radius: 8px;
}
.topic-feature-image {
  width: calc(100% + 28px);
  margin: -14px -14px 16px;
  display: block;
  height: auto;
}

.win-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Links inside titlebars/section headers — white text on dark background */
.win-titlebar a, .topic-card-title a, .section-titlebar a {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 5px;
  color: var(--titlebar-text);
  box-shadow: none;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.15s;
}
.win-titlebar a:hover, .topic-card-title a:hover, .section-titlebar a:hover {
  background: rgba(255,255,255,0.3);
  color: var(--titlebar-text);
  transform: none;
  box-shadow: none;
}

/* ── Markdown body ─────────────────────────────────────────────────────────── */
.markdown-body {
  background: var(--content-bg);
  color: var(--text-color);
  padding: 20px;
  font-size: 15px;
  line-height: 1.75;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  color: var(--text-color);
  margin: 1.4em 0 0.5em;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.markdown-body h1 {
  font-size: 1.8em;
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 8px;
}
.markdown-body h2 {
  font-size: 1.4em;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 4px;
}
.markdown-body h3 { font-size: 1.15em; }

.markdown-body p { margin: 0.8em 0; }
.markdown-body strong { font-weight: 700; }
.markdown-body em     { font-style: italic; }
.markdown-body del    { text-decoration: line-through; color: #94A3B8; }

.markdown-body img.md-img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 14px 0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent-color);
  margin: 14px 0;
  padding: 8px 18px;
  background: #F5F3FF;
  font-style: italic;
  color: #4C1D95;
  border-radius: 0 6px 6px 0;
}

.markdown-body code {
  background: var(--code-bg);
  padding: 2px 6px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', Courier, monospace;
  font-size: 0.87em;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  color: #7C3AED;
}

.markdown-body pre {
  background: #0F172A;
  color: #E2E8F0;
  padding: 16px 20px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', Courier, monospace;
  font-size: 0.87em;
  border-radius: 8px;
  margin: 14px 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  border-radius: 0;
}

.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 14px 0;
  font-size: 0.93em;
  border-radius: 8px;
  overflow: hidden;
}
.markdown-body table th {
  background: linear-gradient(135deg, var(--titlebar-bg) 0%, var(--titlebar-bg-end) 100%);
  color: var(--table-header-text);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.03em;
}
.markdown-body table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}
.markdown-body table tr:nth-child(even) td { background: #F8FAFC; }
.markdown-body table tr:last-child td { border-bottom: none; }

.markdown-body ul,
.markdown-body ol { margin: 0.6em 0; padding-left: 1.8em; }
.markdown-body li  { margin: 0.3em 0; }

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

/* ── PDF embeds ────────────────────────────────────────────────────────────── */
.pdf-embed {
  margin: 16px 0;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--window-bg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  overflow: hidden;
}
.pdf-embed-bar {
  background: linear-gradient(135deg, var(--titlebar-bg) 0%, var(--titlebar-bg-end) 100%);
  color: var(--titlebar-text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  gap: 8px;
  flex-wrap: wrap;
}
.pdf-embed-label {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.pdf-embed-controls {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}
.pdf-size-btn {
  background: rgba(255,255,255,0.15);
  color: var(--titlebar-text);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.pdf-size-btn:hover { background: rgba(255,255,255,0.3); }
.pdf-dl-btn {
  color: var(--titlebar-text);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  padding: 2px 8px;
}
.pdf-dl-btn:hover { background: rgba(255,255,255,0.25); }
.pdf-frame { display: block; width: 100%; border: none; background: #FFFFFF; }
.pdf-frame-page { aspect-ratio: 8.5 / 11; min-height: 480px; max-height: 90vh; }
.pdf-frame-tall { height: 1200px; max-height: none; aspect-ratio: unset; }
.pdf-frame-full {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh; max-height: 100vh;
  z-index: 9900; aspect-ratio: unset;
}
.pdf-fullscreen-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9899; cursor: pointer;
}
.pdf-fallback { padding: 20px; text-align: center; font-size: 14px; }
.markdown-body a.pdf-link { color: var(--link-color); font-weight: 600; }
.markdown-body a.pdf-link::after {
  content: " [PDF]";
  font-size: 0.8em;
  font-weight: 400;
  color: #94A3B8;
}

/* ── Video embeds ──────────────────────────────────────────────────────────── */
.video-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  margin: 16px 0;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.video-embed iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.tiktok-embed { padding-top: 0; }

/* ── Audio embed ───────────────────────────────────────────────────────────── */
.audio-embed {
  margin: 12px 0;
  padding: 12px 16px;
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  border-radius: 8px;
}
.audio-embed audio { width: 100%; }

/* ── Tags ──────────────────────────────────────────────────────────────────── */
.tag-badge {
  display: inline-flex;
  align-items: center;
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  margin: 2px 2px 2px 0;
  text-decoration: none;
  border: none;
  border-radius: 20px;
  box-shadow: none;
  transition: filter 0.15s, transform 0.1s;
  letter-spacing: 0.02em;
}
.tag-badge:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  color: var(--tag-text);
  background: var(--tag-bg);
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.tag-badge.active { outline: 2px solid #FFFFFF; outline-offset: 1px; }
a.tag-badge:active { transform: translateY(0); }
.tag-filter { margin: 10px 0; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tag-filter strong { font-size: 12px; margin-right: 4px; color: #64748B; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar-section { margin-bottom: 12px; }
.doc-meta-list { margin: 0; }
.doc-meta-list dt { font-weight: 600; font-size: 11px; color: var(--text-color); margin-top: 8px; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.65; }
.doc-meta-list dd { margin: 2px 0 4px 0; font-size: 13px; color: var(--text-color); }

/* ── Revisions ─────────────────────────────────────────────────────────────── */
.revisions-window { margin-top: 16px; }

/* ── Topic description ─────────────────────────────────────────────────────── */
.topic-description {
  padding: 10px 14px;
  background: #F5F3FF;
  border: 1px solid #DDD6FE;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  color: #4C1D95;
}
.topic-meta { font-size: 11px; color: var(--text-color); margin-bottom: 8px; letter-spacing: 0.01em; opacity: 0.7; }
.topic-window .win-body { padding: 14px; overflow: hidden; }

/* ── RSS badge ─────────────────────────────────────────────────────────────── */
.rss-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  background: #B45309;
  color: #FFF !important;
  padding: 3px 10px;
  text-decoration: none;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: background 0.15s;
}
.rss-badge:hover {
  background: #92400E !important;
  color: #FFF !important;
  transform: none;
}

/* ── Forms (public) ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: #374151; }
.input-full {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--input-border);
  border-radius: 7px;
  background: #FFFFFF;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-color);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-full:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.form-actions { margin-top: 14px; }

/* ── Login window ──────────────────────────────────────────────────────────── */
.login-window .win-body { padding: 28px; }

/* ── Footer ────────────────────────────────────────────────────────────────── */
#site-footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  border-top: none;
  margin-top: auto;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px;
  font-size: 12px;
}
.footer-inner p { margin: 3px 0; color: #94A3B8; }
.footer-links a {
  color: #94A3B8;
  background: transparent;
  border: none;
  border-radius: 4px;
  box-shadow: none;
  margin: 0 4px;
  font-size: 12px;
  font-weight: 400;
  padding: 1px 4px;
}
.footer-links a:hover {
  color: #FFFFFF;
  background: rgba(255,255,255,0.08);
  transform: none;
  box-shadow: none;
}

/* ── Recent / Document sections ────────────────────────────────────────────── */
.recent-section { margin-bottom: 24px; }

/* ── Document cards grid ────────────────────────────────────────────────────── */
.doc-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.doc-card {
  background: var(--window-bg);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  transition: box-shadow 0.2s, transform 0.2s;
  overflow: hidden;
}
.doc-card:hover {
  box-shadow: 0 8px 24px rgba(99,102,241,0.15);
  transform: translateY(-2px);
}

.doc-card-body {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.doc-card-name {
  display: block;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
  margin: 0 0 6px;
}
.doc-card-name a {
  display: block;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  color: var(--link-color);
  text-decoration: none;
  font-weight: 600;
  transform: none;
  letter-spacing: normal;
}
.doc-card-name a:hover {
  background: transparent;
  color: var(--link-color);
  text-decoration: underline;
  transform: none;
  box-shadow: none;
}

.doc-card-thumb {
  width: calc(100% + 24px);
  margin: -12px -12px 8px;
  height: 140px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}

.doc-card-desc {
  font-size: 12px;
  margin: 0 0 10px;
  color: var(--text-color);
  opacity: 0.75;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-card-meta {
  margin-top: auto;
  clear: both;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.doc-card-tags { display: flex; flex-wrap: wrap; gap: 3px; }

.doc-card-topic { font-size: 11px; color: var(--text-color); opacity: 0.75; }
.doc-card-topic a {
  color: var(--link-color);
  font-weight: 600;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  font-size: 11px;
  text-decoration: none;
  border-radius: 0;
}
.doc-card-topic a:hover {
  text-decoration: underline;
  background: transparent;
  transform: none;
  box-shadow: none;
}

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  color: #64748B;
  font-style: italic;
  padding: 16px 20px;
  background: #F8FAFC;
  border: 1px dashed var(--border-mid);
  border-radius: 8px;
  text-align: center;
}

/* ── Scrollbars (Chromium) ─────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 8px; height: 8px; }
::-webkit-scrollbar-track  { background: #F1F5F9; border-radius: 4px; }
::-webkit-scrollbar-thumb  { background: #CBD5E1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.button, button.button, .btn, a.button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hamburger {
  display: none;
  background: linear-gradient(135deg, var(--titlebar-bg) 0%, var(--titlebar-bg-end) 100%);
  border: none;
  color: var(--titlebar-text);
  font-size: 20px;
  padding: 4px 16px;
  cursor: pointer;
  align-self: stretch;
  align-items: center;
  flex-shrink: 0;
  border-radius: 0;
}
.hamburger:active { background: rgba(0,0,0,0.2); }

.admin-nav-toggle {
  display: none;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 4px;
  color: var(--titlebar-text);
  font-size: 18px;
  padding: 2px 10px;
  cursor: pointer;
  margin-right: 8px;
}

@media (max-width: 900px) {
  .doc-sidebar { min-width: 170px; max-width: 210px; }
  .topics-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .doc-cards   { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 700px) {
  .hamburger { display: flex; }
  #taskbar { position: relative; flex-wrap: wrap; }
  #taskbar-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: #FFFFFF;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    z-index: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    max-height: 70vh;
    overflow-y: auto;
  }
  #taskbar-links.nav-open { display: flex; }
  #taskbar-links a {
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    border-bottom-color: var(--border-light) !important;
    padding: 12px 16px;
    font-size: 14px;
  }
  .doc-layout { flex-direction: column; }
  .doc-sidebar { max-width: 100%; width: 100%; min-width: 0; }
  .topics-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .doc-cards   { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .win-body { padding: 12px; }
  .topic-feature-image { width: calc(100% + 24px); margin: -12px -12px 16px; }
  #main-window { padding: 12px 10px; }
  .markdown-body { padding: 12px; font-size: 14px; }
  .markdown-body table { display: block; overflow-x: auto; }
  .doc-table { display: block; overflow-x: auto; }
  .win-titlebar { flex-wrap: wrap; gap: 6px; }
  .win-actions { flex-wrap: wrap; }
  .login-window { margin: 16px auto; }
  .login-window .win-body { padding: 20px; }
  .footer-links { word-break: break-word; }
  .pdf-embed-bar { flex-direction: column; align-items: flex-start; gap: 4px; }
  .pdf-embed-controls { width: 100%; flex-wrap: wrap; }
  .form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .hero-sitename { font-size: 20px; }
  .breadcrumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .doc-table th:nth-child(3), .doc-table td:nth-child(3) { display: none; }
}

@media (max-width: 400px) {
  .topics-grid { grid-template-columns: 1fr 1fr; }
  .doc-cards   { grid-template-columns: 1fr; }
  body { font-size: 13px; }
  .markdown-body { font-size: 13px; }
  .doc-table th:nth-child(4), .doc-table td:nth-child(4) { display: none; }
}

@media (max-width: 800px) {
  #admin-shell { flex-direction: column; }
  .admin-nav-toggle { display: inline-block; }
  #admin-nav { width: 100%; border-right: none; border-bottom: 1px solid var(--border-light); display: none; }
  #admin-nav.nav-open { display: block; }
  #admin-nav ul li a { padding: 10px 14px; }
  #admin-main { padding: 10px; }
  .admin-table { display: block; overflow-x: auto; }
  .editor-layout { flex-direction: column; }
}


/* ── Palette overrides (from Settings → Colour Palette) ── */
:root {
  --desktop-bg: #1a0a2e;
  --window-bg: #c8c4d0;
  --titlebar-bg: #cdab8f;
  --titlebar-bg-end: #ffbe6f;
  --titlebar-text: #ffffff;
  --text-color: #000000;
  --link-color: #4a007a;
  --accent-color: #ff7800;
  --content-bg: #ffffff;
  --footer-bg: #9888b0;
}

/* ── Readability fixes (always applied, override theme CSS) ── */
.hero-desc { color: var(--titlebar-text) !important; opacity: 0.9; }
.win-titlebar a, .section-titlebar a { color: var(--titlebar-text) !important; }
.win-titlebar a:hover, .section-titlebar a:hover { color: var(--titlebar-text) !important; }
