/* =========================================================
   CATPPUCCIN LATTE — Light mode (CSS default)
   ========================================================= */
:root {
  color-scheme: light dark;
  --bg: #eff1f5;        /* Latte Base */
  --bg2: #e6e9ef;       /* Latte Mantle */
  --text: #4c4f69;      /* Latte Text */
  --title: #1e1e2e;     /* Dark heading */
  --brand: #9ca0b0;     /* Latte Surface 1 */
  --border: rgba(76, 79, 105, 0.15);

  --font: "Inter", sans-serif;
  --weight-light: 300;
  --weight-medium: 400;
  --weight-bold: 600;

  --space-xs: 0.4rem;
  --space-sm: 0.8rem;
  --space-md: 1.2rem;
  --space-lg: 2rem;
  --space-xl: 3rem;

  --max-width: 48rem;
  --line-height: 1.5;
  --line-height-relaxed: 1.6;
  --line-height-loose: 1.7;

  --back-button-offset: 8rem;

  --scale-xs: 0.8rem;
  --scale-sm: 0.933rem;
  --scale-base: 1rem;
  --scale-lg: 1.2rem;
  --scale-meta: 0.875rem;
}

/* =========================================================
   CATPPUCCIN MOCHA — OS-level dark preference (no JS needed)
   ========================================================= */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #181825;        /* Mantle */
    --bg2: #1e1e2e;       /* Base */
    --text: #cdd6f4;      /* Text */
    --title: #ffffff;     /* White */
    --brand: #45475a;     /* Surface 1 */
    --border: rgba(205, 214, 244, 0.15);
  }
}

/* =========================================================
   Explicit overrides — set by JS when user chooses a theme
   ========================================================= */
[data-theme="dark"] {
  --bg: #181825;        /* Mantle */
  --bg2: #1e1e2e;       /* Base */
  --text: #cdd6f4;      /* Text */
  --title: #ffffff;     /* White */
  --brand: #45475a;     /* Surface 1 */
  --border: rgba(205, 214, 244, 0.15);
}

[data-theme="light"] {
  --bg: #eff1f5;        /* Latte Base */
  --bg2: #e6e9ef;       /* Latte Mantle */
  --text: #4c4f69;      /* Latte Text */
  --title: #1e1e2e;     /* Dark heading */
  --brand: #9ca0b0;     /* Latte Surface 1 */
  --border: rgba(76, 79, 105, 0.15);
}

/* =========================================================
   THEME TRANSITION
   Applied by JS only during user-initiated toggle clicks.
   Scoped to the elements that actually change — html/body for
   background and text color, icon paths for fill.
   Nothing else needs its own transition since colors propagate
   via CSS variables instantly.
   ========================================================= */
html.theme-transition,
html.theme-transition body {
  transition: background-color 0.3s ease, color 0.3s ease;
}
html.theme-transition .icon-left,
html.theme-transition .icon-right {
  transition: fill 0.3s ease;
}

/* =========================================================
   RESET & BASE
   ========================================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  font-family: var(--font);
  font-weight: var(--weight-medium);
  line-height: var(--line-height);
  color: var(--text);
  background: var(--bg);
  font-size: var(--scale-base);
}

/* =========================================================
   LAYOUT
   ========================================================= */
.container {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: var(--space-xl);
}

.container > div {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-xl) var(--space-xl);
}

/* =========================================================
   NAV
   ========================================================= */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
}

.nav-left a {
  position: relative;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--title);
}

.nav-left a:hover {
  color: var(--title);
}

.nav-initials {
  font-family: "JetBrains Mono", monospace;
  font-weight: var(--weight-bold);
  color: transparent;
  -webkit-text-stroke: 1px var(--title);
  letter-spacing: 0.04em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  position: relative;
}

.nav-initials::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% - 0.1em);
  transform: translateY(-50%);
  height: 0.16em; /* ~10% of S height (1.6rem) */
  background: var(--bg);
  pointer-events: none;
}

.nav-initial-s {
  font-size: 1.6rem; /* 80% of 2rem */
}

.nav-initial-m {
  font-size: 2rem;
}

.nav-right {
  display: flex;
  align-items: center;
}

/* =========================================================
   TYPOGRAPHY
   All headings same size as body — hierarchy via weight/color
   ========================================================= */
h1, h2, h3, h4, h5, h6 {
  font-size: var(--scale-base);
  font-family: var(--font);
  color: var(--title);
  margin-bottom: var(--space-xs);
  line-height: var(--line-height);
}

p {
  font-size: var(--scale-base);
  margin-bottom: var(--space-lg);
  color: var(--text);
  line-height: var(--line-height-loose);
  font-weight: var(--weight-medium);
}

strong {
  font-weight: var(--weight-bold);
}

em {
  font-style: italic;
}

/* =========================================================
   LINKS
   ========================================================= */
a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

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

/* =========================================================
   LANDING PAGE
   ========================================================= */
.site-title {
  color: var(--title);
}

.small-link {
  font-size: var(--scale-xs);
  opacity: 0.7;
}

.small-link a {
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.small-link a:hover {
  opacity: 1;
}

/* =========================================================
   CARD GRID — hfactor-style
   No visible state at rest. bg2 tint on hover.
   Bottom border always visible. Blue (#89b4fa) tint on hover.
   ========================================================= */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.card {
  border-bottom: 1px solid var(--border);
  padding: var(--space-sm);
  background-color: transparent;
  transition: background-color 0.3s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}

.card:hover {
  background-color: rgba(137, 180, 250, 0.22);
  border-bottom-color: var(--border);
}

.card h4 {
  margin-bottom: 0;
  color: var(--title);
  font-weight: var(--weight-bold);
}

.card p {
  font-size: var(--scale-sm);
  margin-bottom: 0;
  color: var(--text);
  line-height: var(--line-height);
  margin-top: var(--space-xs);
}

@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
  .card {
    padding: var(--space-md) 0;
  }
}

/* =========================================================
   BUTTON
   ========================================================= */
.btn {
  padding: 0.6rem 1.2rem;
  color: var(--bg);
  background: var(--title);
  transition: background 0.2s;
  text-decoration: none;
  font-size: var(--scale-base);
  text-align: center;
  display: inline-block;
  margin-right: var(--space-sm);
  border: none;
  font-weight: var(--weight-medium);
  letter-spacing: 0.025em;
}

.btn:hover {
  background: var(--text);
  color: var(--bg);
}

/* =========================================================
   NOTES & FEED
   ========================================================= */
.note-list-sec {
  margin-top: var(--space-xl);
}

.note-list-sec h3 {
  margin-top: 0;
}

.note-list {
  list-style: none;
}

.note-list li {
  border-bottom: 1px solid var(--border);
  padding: var(--space-xs) 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.note-list > li:first-child {
  border-top: 1px solid var(--border);
}

.note-title {
  font-size: var(--scale-base);
  font-weight: var(--weight-medium);
  color: var(--title);
}

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

.note-title a:hover {
  color: var(--text);
}

.links-section {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.links-section h6 {
  color: var(--title);
  font-size: var(--scale-base);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-sm);
}

.links-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  list-style: none;
  margin-bottom: 0;
  padding-left: 0;
  padding-top: var(--space-lg);
}

.links-grid li {
  border-bottom: 1px solid var(--border);
  padding: var(--space-sm) var(--space-xs);
  background-color: var(--bg);
  transition: all 0.3s ease;
}

.links-grid li:hover {
  background-color: rgba(137, 180, 250, 0.22);
}

.links-grid a {
  color: var(--text);
  text-decoration: none;
  font-size: var(--scale-base);
  line-height: 1.5;
  display: block;
  width: 100%;
  height: 100%;
}

.links-grid a:hover {
  color: var(--text);
}

@media (max-width: 520px) {
  .links-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   FOOTER
   ========================================================= */
.footer {
  margin-top: calc(var(--space-xl) * 2);
  margin-bottom: var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer h6 {
  color: var(--title);
  font-size: var(--scale-xs);
  font-weight: var(--weight-medium);
  margin-bottom: 0;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.footer-left a {
  position: relative;
  display: inline-flex;
  align-items: center;
  opacity: 0.5;
  text-decoration: none;
  color: var(--text);
  transition: opacity 0.15s ease;
}

.footer-left a:hover {
  opacity: 1;
}

.footer-right a {
  position: relative;
  font-size: var(--scale-sm);
  opacity: 0.5;
  text-decoration: none;
  color: var(--text);
  transition: opacity 0.15s ease;
}

.footer-right a:hover {
  opacity: 1;
}

/* =========================================================
   THEME TOGGLE (nav-right)
   ========================================================= */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--title);
  cursor: pointer;
  padding: 0;
  margin: 0;
}

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

.theme-toggle svg {
  display: block;
  width: 17.5px;
  height: 17.5px;
}

/* Half-and-half theme toggle icon */

/* Light mode (default) */
.icon-left  { fill: #4c4f69; } /* Latte Text */
.icon-right { fill: #ccd0da; } /* Latte Surface 0 */

/* Dark mode via OS preference (no data-theme attribute) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .icon-left  { fill: #cdd6f4; } /* Mocha Text */
  :root:not([data-theme]) .icon-right { fill: #45475a; } /* Mocha Surface 1 */
}

/* Dark mode via explicit user choice */
[data-theme="dark"] .icon-left  { fill: #cdd6f4; } /* Mocha Text */
[data-theme="dark"] .icon-right { fill: #45475a; } /* Mocha Surface 1 */

/* Light mode via explicit user choice */
[data-theme="light"] .icon-left  { fill: #4c4f69; } /* Latte Text */
[data-theme="light"] .icon-right { fill: #ccd0da; } /* Latte Surface 0 */

/* =========================================================
   MARKDOWN
   ========================================================= */
blockquote {
  border-left: 4px solid var(--text);
  padding: var(--space-md);
  margin: var(--space-lg) 0;
  font-style: italic;
  color: var(--text);
  line-height: var(--line-height-relaxed);
  background: var(--bg2);
}

code {
  background: var(--bg2);
  padding: 0.125rem 0.25rem;
  font-size: 0.875em;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  color: var(--text);
}

pre {
  background: var(--bg2);
  padding: var(--space-md);
  overflow-x: auto;
  margin: var(--space-lg) 0;
  border: 1px solid var(--border);
}

pre code {
  background: none;
  padding: 0;
  font-size: var(--scale-meta);
  line-height: var(--line-height);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: calc(var(--space-xl) / 2) 0;
}

ul, ol {
  margin-bottom: var(--space-md);
  padding-left: var(--space-lg);
}

li {
  margin-bottom: var(--space-xs);
  line-height: var(--line-height-relaxed);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-lg) 0;
  font-size: var(--scale-meta);
}

th, td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: var(--weight-bold);
  color: var(--title);
  background: var(--bg2);
}

td {
  background: var(--bg);
  color: var(--text);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: var(--space-md) 0;
}

/* =========================================================
   SEARCH
   ========================================================= */
.search-container {
  margin-bottom: var(--space-lg);
  position: relative;
}

.search-input {
  width: 100%;
  padding: var(--space-sm);
  border: 1px solid var(--border);
  font-size: var(--scale-base);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

.search-input:focus {
  outline: none;
  border-color: var(--text);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 999;
  display: none;
}

.search-active .search-results {
  display: block;
  border: 1px solid var(--border);
  border-top: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.search-results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-results-list-item {
  margin: 0;
}

.search-result {
  display: block;
  padding: var(--space-xs);
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s ease;
  border-bottom: 1px solid var(--border);
  line-height: var(--line-height);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover {
  background: var(--bg2);
  color: var(--text);
}

.search-result-title {
  color: var(--title);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-sm);
  font-size: var(--scale-base);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.search-result-doc {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.search-result-doc-title {
  font-weight: var(--weight-bold);
  color: var(--title);
}

.search-result-previews {
  margin-top: var(--space-xs);
}

.search-result-preview {
  color: var(--text);
  font-size: var(--scale-base);
  line-height: var(--line-height);
  margin-bottom: var(--space-xs);
  opacity: 0.8;
}

.search-result-highlight {
  background: var(--text);
  color: var(--bg);
  padding: 0 2px;
  font-weight: var(--weight-bold);
}

.search-no-result {
  color: var(--text);
  font-style: italic;
  padding: var(--space-md);
  text-align: center;
}

/* =========================================================
   NOTES FEED
   ========================================================= */
.feed-container {
  margin-top: var(--space-sm);
}

.notelist-feed {
  border-bottom: 1px solid var(--border);
  padding: var(--space-sm) 0;
}

.notelist-feed a {
  text-decoration: none;
  color: inherit;
}

.notelist-feed a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* Kill the global p margin inside feed items */
.notelist-feed p {
  margin-bottom: 0;
  color: var(--title);
}

.list-feed {
  border-bottom: 1px solid var(--border);
  padding: var(--space-sm) 0;
}

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

.list-feed a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* =========================================================
   BACKLINKS
   ========================================================= */
.hide {
  display: none;
}

.show {
  display: block;
}

/* =========================================================
   UI TOOLTIPS (nav & footer icons)
   Uses ::before to avoid conflict with external-link ::after arrows.
   data-tooltip="Label" on any element shows a centered tip above it.
   ========================================================= */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: var(--scale-xs);
  font-weight: var(--weight-medium);
  line-height: var(--line-height);
  color: var(--text);
  background-color: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 100;
}

[data-tooltip]:hover::before {
  opacity: 1;
  visibility: visible;
}



/* =========================================================
   WIKI LINKS & TOOLTIPS
   ========================================================= */
.tooltip {
  position: relative;
  display: inline;
}

.tooltip .right {
  width: 300px;
  padding: 0.5rem 0.75rem;
  font-size: var(--scale-xs);
  line-height: 1.3;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 150%;
  z-index: 1;
  background-color: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s;
  text-align: left;
}

.tooltip:hover .right {
  opacity: 1;
  visibility: visible;
}

.tooltip .right .tooltip-excerpt {
  color: var(--text);
  line-height: 1.3;
  font-size: var(--scale-xs);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.stale-link {
  color: var(--text) !important;
  opacity: 0.6;
  cursor: not-allowed;
}

.wiki-link {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

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

.link-preview,
.wiki-link-preview {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: var(--space-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-width: 320px;
  font-size: var(--scale-base);
  line-height: var(--line-height);
  position: absolute;
  z-index: 1000;
  color: var(--text);
  pointer-events: none;
}

.link-preview .preview-content strong,
.wiki-link-preview .preview-content strong {
  color: var(--title);
  display: block;
  margin-bottom: var(--space-xs);
}

.link-preview .preview-content p,
.wiki-link-preview .preview-content p {
  color: var(--text);
  margin: 0;
  opacity: 0.8;
  font-size: var(--scale-meta);
  line-height: var(--line-height);
}

/* =========================================================
   EXTERNAL LINK INDICATOR
   Light mode: dark stroke. Dark mode: light stroke.
   Suppressed on nav, footer, search, feeds, and card <a> wrappers.
   On card grid, arrow appears on h4:after instead (next to title).
   ========================================================= */

/* Light mode arrow — dark stroke */
a[href^="http://"]:after,
a[href^="https://"]:after {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 0.25em;
  vertical-align: text-top;
  background-image: url('data:image/svg+xml;utf8,%3Csvg%20width%3D%2210%22%20height%3D%2210%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%2019L19%205M5%205h14v14%22%20stroke%3D%22%234c4f69%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.7;
}

/* Dark mode arrow — light stroke (OS preference) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) a[href^="http://"]:after,
  :root:not([data-theme]) a[href^="https://"]:after {
    background-image: url('data:image/svg+xml;utf8,%3Csvg%20width%3D%2210%22%20height%3D%2210%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%2019L19%205M5%205h14v14%22%20stroke%3D%22%23cdd6f4%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
  }
}

/* Dark mode arrow — light stroke (explicit choice) */
[data-theme="dark"] a[href^="http://"]:after,
[data-theme="dark"] a[href^="https://"]:after {
  background-image: url('data:image/svg+xml;utf8,%3Csvg%20width%3D%2210%22%20height%3D%2210%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%2019L19%205M5%205h14v14%22%20stroke%3D%22%23cdd6f4%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
}

/* Suppress external-link arrow on nav, footer, search, feeds */
.nav-left a:after,
.footer a:after,
.search-result:after,
.search-results a:after,
.stale-link:after,
.notelist-feed a:after,
.list-feed a:after,
.toc-list a:after {
  display: none !important;
}

/* Suppress on card <a> wrapper — arrow lands after <p> otherwise */
.card-grid a[href^="http://"]:after,
.card-grid a[href^="https://"]:after {
  display: none;
}

/* Place arrow on h4:after for external cards — appears next to the title */
.card-grid a[href^="http://"] h4:after,
.card-grid a[href^="https://"] h4:after {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 0.25em;
  vertical-align: text-top;
  background-image: url('data:image/svg+xml;utf8,%3Csvg%20width%3D%2210%22%20height%3D%2210%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%2019L19%205M5%205h14v14%22%20stroke%3D%22%234c4f69%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.7;
}

/* Card grid dark arrow — OS preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .card-grid a[href^="http://"] h4:after,
  :root:not([data-theme]) .card-grid a[href^="https://"] h4:after {
    background-image: url('data:image/svg+xml;utf8,%3Csvg%20width%3D%2210%22%20height%3D%2210%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%2019L19%205M5%205h14v14%22%20stroke%3D%22%23cdd6f4%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
  }
}

/* Card grid dark arrow — explicit choice */
[data-theme="dark"] .card-grid a[href^="http://"] h4:after,
[data-theme="dark"] .card-grid a[href^="https://"] h4:after {
  background-image: url('data:image/svg+xml;utf8,%3Csvg%20width%3D%2210%22%20height%3D%2210%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%2019L19%205M5%205h14v14%22%20stroke%3D%22%23cdd6f4%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
}

/* =========================================================
   BACK BUTTON
   Inline below nav on mobile; fixed to left margin on desktop.
   ========================================================= */
.back-button-container {
  margin-bottom: var(--space-md);
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--text);
  text-decoration: none;
  font-size: var(--scale-sm);
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.back-button:hover {
  opacity: 1;
  color: var(--text);
  text-decoration: none;
}

.post-meta {
  font-size: var(--scale-meta);
  font-weight: var(--weight-light);
  color: var(--text);
  opacity: 0.5;
  margin-top: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.post-excerpt {
  font-size: var(--scale-meta);
  font-weight: var(--weight-light);
  color: var(--text);
  opacity: 0.7;
  margin-top: 0;
  margin-bottom: var(--space-lg);
  line-height: var(--line-height-relaxed);
}

@media (min-width: 768px) {
  .back-button-container {
    position: fixed;
    left: var(--back-button-offset);
    top: var(--back-button-offset);
    margin-bottom: 0;
    z-index: 100;
  }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
  .container {
    padding-top: var(--space-md);
    margin-top: var(--space-lg);
  }

  .container > div {
    padding: 0 var(--space-md) var(--space-sm);
  }

  .nav {
    margin-bottom: var(--space-sm);
  }
}

@media (max-width: 520px) {
  .container {
    padding-top: var(--space-sm);
  }

  .container > div {
    padding: 0 var(--space-md);
  }

  .btn {
    display: block;
    margin-bottom: var(--space-sm);
  }
}
