/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --color-bg: #f6f7fb;
  --color-bg-alt: #ececf3;
  --color-surface: #ffffff;
  --color-text: #131a2b;
  --color-text-muted: #4e5872;
  --color-border: #d9dce6;
  --color-accent: #8f620d;
  --color-accent-ink: #fffaf0;

  --badge-windows: #2563ab;
  --badge-macos: #5b6472;
  --badge-linux: #8a5a12;
  --badge-android: #2f8f4e;
  --badge-ios: #5a5fc4;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --max-width: 1120px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --shadow-md: 0 8px 24px rgba(19, 26, 43, 0.08);
}

[data-theme="dark"] {
  --color-bg: #0b0f1a;
  --color-bg-alt: #121826;
  --color-surface: #131a2b;
  --color-text: #e7e9f2;
  --color-text-muted: #97a0bc;
  --color-border: #232c42;
  --color-accent: #e3ac4c;
  --color-accent-ink: #1a1305;
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);

  --badge-windows: #60a5fa;
  --badge-macos: #a2abbd;
  --badge-linux: #d49e4a;
  --badge-android: #6ed194;
  --badge-ios: #9aa0eb;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Reset & base
   ========================================================================== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; }
h1, h2, h3 { line-height: 1.2; font-weight: 700; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.9rem, 1.5rem + 1.6vw, 2.5rem); letter-spacing: -0.01em; }
h2 { font-size: 1.4rem; margin-top: 2.2em; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 1.25rem; }
.muted { color: var(--color-text-muted); }
.small { font-size: 0.8125rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.section { padding: 2.75rem 1.25rem; }
.lede { font-size: 1.05rem; color: var(--color-text-muted); max-width: 62ch; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--color-accent); color: var(--color-accent-ink);
  padding: 0.6rem 1rem; border-radius: 0 0 var(--radius-sm) 0; font-weight: 600;
}
.skip-link:focus { left: 0; top: 0; }

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky; top: 0; z-index: 50;
}
.site-header-inner {
  display: flex; align-items: center; gap: 1.5rem;
  height: 64px;
}
.brand {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 700; font-size: 1.05rem; text-decoration: none;
  white-space: nowrap;
}
.brand-mark { width: 22px; height: 22px; flex: none; }
.main-nav {
  display: flex; gap: 1.5rem; margin-left: 0.5rem; flex: 1;
}
.main-nav a {
  text-decoration: none; color: var(--color-text-muted);
  font-size: 0.92rem; font-weight: 500;
}
.main-nav a:hover { color: var(--color-text); }
.header-actions { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-md);
  border: none; background: transparent; color: var(--color-text);
  cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--color-bg-alt); }
.icon-btn svg { width: 19px; height: 19px; }
#theme-toggle .theme-icon-moon { display: none; }
[data-theme="dark"] #theme-toggle .theme-icon-sun { display: none; }
[data-theme="dark"] #theme-toggle .theme-icon-moon { display: inline-flex; }
.nav-toggle { display: none; }

.mobile-nav {
  display: flex; flex-direction: column; padding: 0.5rem 1.25rem 1.25rem;
  border-top: 1px solid var(--color-border);
}
.mobile-nav[hidden] { display: none; }
.mobile-nav a {
  padding: 0.65rem 0; text-decoration: none; color: var(--color-text);
  border-bottom: 1px solid var(--color-border); font-weight: 500;
}
.mobile-nav-divider { height: 0.5rem; }

@media (max-width: 860px) {
  .main-nav { display: none; }
  .nav-toggle { display: inline-flex; }
}
@media (min-width: 861px) {
  .mobile-nav { display: none !important; }
}

/* ==========================================================================
   Hero
   ========================================================================== */
.hero { padding: 3.5rem 1.25rem 3rem; }
.hero-grid {
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 3rem; align-items: center;
}
.hero-grid > * { min-width: 0; }
.hero-copy .lede { margin-bottom: 1.5rem; }
.hero-search {
  display: flex; gap: 0.5rem; max-width: 480px;
}
.hero-search input {
  flex: 1; min-width: 0; padding: 0.75rem 1rem; border-radius: var(--radius-md);
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text); font-size: 1rem;
}
.hero-search button, .search-form button, .hero-search + button {
  padding: 0.75rem 1.25rem; border-radius: var(--radius-md); border: none;
  background: var(--color-accent); color: var(--color-accent-ink);
  font-weight: 600; cursor: pointer;
}
.hero-search button:hover { filter: brightness(1.08); }

.example-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 1.5rem;
  box-shadow: var(--shadow-md);
}
.example-q { margin: 0 0 0.15rem; font-weight: 600; }
.example-title { margin: 0 0 1rem; color: var(--color-text-muted); font-size: 0.9rem; }
.example-path-row {
  display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem;
}
.example-path-row code {
  font-family: var(--font-mono); font-size: 0.82rem;
  background: var(--color-bg-alt); padding: 0.3rem 0.55rem; border-radius: 4px;
  overflow-wrap: anywhere;
}
.example-cta {
  display: inline-block; margin-top: 0.5rem; font-weight: 600; font-size: 0.9rem;
  color: var(--color-accent);
}

@media (max-width: 780px) {
  .hero-grid { grid-template-columns: 1fr; gap: 2rem; }
}

/* ==========================================================================
   Badges
   ========================================================================== */
.badges { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.badge {
  display: inline-flex; align-items: center;
  padding: 0.22rem 0.6rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.badge-os { --bc: var(--color-accent); color: var(--bc); background: rgba(0,0,0,0.06); }
@supports (background: color-mix(in srgb, red 50%, transparent)) {
  .badge-os { background: color-mix(in srgb, var(--bc) 18%, transparent); }
}
.badge-windows { --bc: var(--badge-windows); }
.badge-macos   { --bc: var(--badge-macos); }
.badge-linux   { --bc: var(--badge-linux); }
.badge-android { --bc: var(--badge-android); }
.badge-ios     { --bc: var(--badge-ios); }

/* ==========================================================================
   Section headings / grids
   ========================================================================== */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.section-head h2 { margin-top: 0; }
.section-head a { text-decoration: none; font-weight: 600; color: var(--color-accent); }

.category-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.category-card {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: 1.25rem; background: var(--color-surface);
}
.category-card:hover { border-color: var(--color-accent); }
.category-card h3 { margin-bottom: 0.35rem; }
.category-card p { margin: 0; font-size: 0.9rem; }

.os-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.os-chip {
  --bc: var(--color-accent);
  display: inline-flex; align-items: center;
  padding: 0.5rem 1rem; border-radius: 999px;
  text-decoration: none; font-weight: 600; font-size: 0.9rem;
  color: var(--bc); background: rgba(0,0,0,0.06); border: 1px solid var(--color-border);
}
@supports (background: color-mix(in srgb, red 50%, transparent)) {
  .os-chip {
    background: color-mix(in srgb, var(--bc) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--bc) 30%, transparent);
  }
}
.os-chip.badge-windows { --bc: var(--badge-windows); }
.os-chip.badge-macos   { --bc: var(--badge-macos); }
.os-chip.badge-linux   { --bc: var(--badge-linux); }
.os-chip.badge-android { --bc: var(--badge-android); }
.os-chip.badge-ios     { --bc: var(--badge-ios); }

/* ==========================================================================
   Post list (directory-style rows)
   ========================================================================== */
.post-list { list-style: none; margin: 1rem 0 0; padding: 0; border-top: 1px solid var(--color-border); }
.post-row { border-bottom: 1px solid var(--color-border); }
.post-row a {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem 0.25rem; text-decoration: none; color: inherit;
}
.post-row a:hover { background: var(--color-bg-alt); }
.post-row-main { display: flex; flex-direction: column; min-width: 0; }
.post-row-app { font-size: 0.78rem; font-weight: 600; color: var(--color-accent); }
.post-row-title { font-weight: 500; }
.empty-state { padding: 1.5rem 0; }

/* ==========================================================================
   Pagination
   ========================================================================== */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 0.35rem;
  margin: 2rem 0 0; flex-wrap: wrap;
}
.page-step {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.45rem 0.7rem; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--color-text); font-size: 0.88rem; font-weight: 500;
}
.page-step svg { width: 16px; height: 16px; }
.page-step:hover { background: var(--color-bg-alt); }
.page-step.is-disabled { color: var(--color-text-muted); opacity: 0.4; }
.page-numbers { display: flex; gap: 0.15rem; }
.page-numbers a, .page-numbers .current, .page-numbers .ellipsis {
  min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); text-decoration: none; color: var(--color-text); font-size: 0.88rem;
}
.page-numbers a:hover { background: var(--color-bg-alt); }
.page-numbers .current { background: var(--color-accent); color: var(--color-accent-ink); font-weight: 700; }

/* ==========================================================================
   Breadcrumbs
   ========================================================================== */
.breadcrumbs { margin: 1.25rem 0 1rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; padding: 0; }
.breadcrumbs li { font-size: 0.85rem; color: var(--color-text-muted); }
.breadcrumbs a { text-decoration: none; color: var(--color-text-muted); }
.breadcrumbs a:hover { color: var(--color-text); text-decoration: underline; }
.breadcrumbs li[aria-current] { color: var(--color-text); font-weight: 600; }
.breadcrumbs .sep { color: var(--color-border); }

/* ==========================================================================
   Post page
   ========================================================================== */
.post-page { padding: 0.5rem 1.25rem 3rem; }
.post-header { max-width: 68ch; margin-bottom: 1.5rem; }
.post-header .badges { margin-bottom: 0.75rem; }
.post-header h1 { margin-bottom: 0.5rem; }
.post-intro { max-width: 68ch; }
.post-intro p { color: var(--color-text); }

.platform-list { display: flex; flex-direction: column; gap: 0.85rem; margin: 1rem 0 2rem; max-width: 68ch; }
.platform-card {
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: 1rem 1.1rem; background: var(--color-surface);
}
.platform-head { margin-bottom: 0.6rem; }
.path-row { display: flex; align-items: stretch; gap: 0.5rem; }
.path {
  flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 0.88rem;
  background: var(--color-bg-alt); border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem; overflow-x: auto; white-space: pre;
}
.copy-btn {
  flex: none; width: 40px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.copy-btn:hover { border-color: var(--color-accent); }
.copy-btn svg { width: 17px; height: 17px; }
.copy-btn .check-icon { display: none; color: var(--color-accent); }
.copy-btn.copied .copy-icon { display: none; }
.copy-btn.copied .check-icon { display: inline-flex; }
.platform-notes { margin: 0.65rem 0 0; font-size: 0.92rem; color: var(--color-text-muted); }

.faq { max-width: 68ch; }
.faq-item {
  border-bottom: 1px solid var(--color-border); padding: 0.9rem 0;
}
.faq-item summary {
  cursor: pointer; font-weight: 600; list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: "+ "; color: var(--color-accent); font-weight: 700; }
.faq-item[open] summary::before { content: "\2212 "; }
.faq-item p { margin: 0.6rem 0 0; color: var(--color-text-muted); }

.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.75rem 0 1rem; }
.tag {
  text-decoration: none; font-size: 0.82rem; color: var(--color-text-muted);
  border: 1px solid var(--color-border); border-radius: 999px; padding: 0.3rem 0.7rem;
}
.tag:hover { border-color: var(--color-accent); color: var(--color-text); }
.report-line { margin-top: 1.5rem; }
.related { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--color-border); max-width: 68ch; }

/* ==========================================================================
   Search page
   ========================================================================== */
.search-form { max-width: 560px; }
.noscript-notice {
  max-width: 560px; background: var(--color-bg-alt); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 0.9rem 1.1rem; font-size: 0.9rem; margin-bottom: 1.25rem;
}
.search-form input {
  width: 100%; padding: 0.85rem 1rem; border-radius: var(--radius-md);
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text); font-size: 1.05rem;
}
.search-suggestions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.9rem 0; }
.search-suggestions a {
  text-decoration: none; font-size: 0.85rem; color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: 999px; padding: 0.3rem 0.75rem;
}
.search-suggestions a:hover { border-color: var(--color-accent); }
#search-status { margin: 1.25rem 0 0; }

.not-found .search-form { display: flex; gap: 0.5rem; max-width: 480px; }
.not-found .search-form input { flex: 1; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer { border-top: 1px solid var(--color-border); margin-top: 3rem; padding-top: 2.5rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 2.5rem; flex-wrap: wrap; padding-bottom: 2rem; }
.footer-brand-col { max-width: 320px; }
.footer-brand-col .brand { margin-bottom: 0.5rem; }
.footer-cols { display: flex; gap: 2.5rem; flex-wrap: wrap; }
.footer-cols h3 { font-size: 0.8rem; text-transform: none; color: var(--color-text-muted); margin-bottom: 0.6rem; }
.footer-cols a { display: block; text-decoration: none; color: var(--color-text); padding: 0.2rem 0; font-size: 0.92rem; }
.footer-cols a:hover { color: var(--color-accent); }
.site-footer > .wrap:last-child { border-top: 1px solid var(--color-border); padding-top: 1.25rem; padding-bottom: 1.5rem; }

@media (max-width: 640px) {
  .site-header-inner { height: 58px; }
  .hero { padding-top: 2rem; }
  h2 { margin-top: 1.8em; }
}

@media (max-width: 360px) {
  .site-header-inner { gap: 0.5rem; }
  .header-actions { gap: 0.1rem; }
  .icon-btn { width: 34px; height: 34px; }
  .brand { font-size: 0.95rem; gap: 0.35rem; }
  .brand-mark { width: 19px; height: 19px; }
}

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
  :root, [data-theme="dark"] {
    --color-bg: #ffffff; --color-bg-alt: #f4f4f4; --color-surface: #ffffff;
    --color-text: #000000; --color-text-muted: #333333; --color-border: #999999;
    --color-accent: #000000; --color-accent-ink: #ffffff;
  }
  .site-header, .site-footer, .skip-link, .breadcrumbs, .pagination,
  .copy-btn, .report-line, .search-form, .search-suggestions, #search-status,
  .hero-search, .header-actions, .example-cta { display: none !important; }
  body { font-size: 12pt; }
  a { color: #000; text-decoration: none; }
  a[href^="/posts/"]::after { content: " (" attr(href) ")"; font-size: 0.75em; color: #555; }
  .path { border: 1px solid #999; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge { border: 1px solid #999; background: none !important; color: #000 !important; }
  .platform-card { border: 1px solid #999; break-inside: avoid; }
  h1, h2 { break-after: avoid; }
}
