/* =========================================================
   ChrysoKit, Mobile Pro (additive only, desktop untouched)
   v=20260509f
   Loaded LAST so it has priority over earlier mobile rules.
   Every rule is wrapped in a max-width media query, so any
   viewport >= 769px is bit-for-bit identical to before.
   ========================================================= */

/* =========================================================
   1. TOKENS for mobile (used inside media queries below)
   ========================================================= */
@media (max-width: 768px) {
  :root {
    --m-gap: 14px;
    --m-pad: 18px;
    --m-radius: 14px;
    --m-radius-lg: 18px;
    --m-tap: 44px;
    --m-shadow-card: 0 1px 2px rgba(60,42,24,0.05), 0 4px 12px rgba(60,42,24,0.05);
    --m-shadow-pop:  0 8px 28px rgba(60,42,24,0.12), 0 2px 8px rgba(60,42,24,0.06);
    --m-bg-soft: rgba(255, 255, 255, 0.55);
  }
  html[data-theme="dark"] {
    --m-bg-soft: rgba(255, 255, 255, 0.04);
    --m-shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.35);
    --m-shadow-pop:  0 8px 28px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.4);
  }
}

/* =========================================================
   2. GLOBAL: smoother scroll, safe-area, focus, selection
   ========================================================= */
@media (max-width: 768px) {
  html {
    -webkit-overflow-scrolling: touch;
    /* Defensive: ensure single-finger vertical pan is always allowed.
       Some restrictive ancestor or stale cached CSS could otherwise
       leave the page at touch-action: none. */
    touch-action: pan-y pinch-zoom;
  }
  body {
    text-rendering: optimizeSpeed;
    overscroll-behavior-y: none;
    /* CRITICAL: background-attachment: fixed is broken on mobile
       Safari/Chrome and disables single-finger scroll. The body in
       styles.css uses fixed for desktop atmosphere; we override here
       so phones can scroll normally. */
    background-attachment: scroll;
    /* Defensive touch-action: explicit pan-y so nothing inherited can
       block single-finger vertical scrolling. */
    touch-action: pan-y pinch-zoom;
  }
  /* Better text spacing on phones */
  p { line-height: 1.55; }
  /* Lock body when mobile menu is open (modern browsers via :has()) */
  body:has(.main-nav.open) {
    /* overflow and touch-action are handled by JS scroll-lock in script.js
       to prevent the page from jumping to top when nav opens while scrolled. */
    touch-action: none;
  }
  /* JS fallback (Safari < 16) - script.js toggles .nav-open */
  html.nav-open,
  body.nav-open {
    touch-action: none;
  }
}

/* =========================================================
   2b. STICKY HEADER FIX
   The sticky site-header in styles.css uses backdrop-filter,
   which combined with position: sticky is a documented cause
   of janky / blocked single-finger scrolling on iOS Safari and
   Chrome iOS. Drop the backdrop-filter on mobile and use a
   solid (slightly more opaque) background instead. The visual
   tradeoff is small; the scroll improvement is large.
   ========================================================= */
@media (max-width: 768px) {
  .site-header {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background-color: var(--page-bg) !important;
  }
  html[data-theme="dark"] .site-header {
    background-color: var(--page-bg) !important;
  }
}

/* =========================================================
   2c. iOS FORM-ZOOM PREVENTION
   iOS Safari auto-zooms when the user taps a form field whose
   font-size is below 16px. The zoom never reverses cleanly and
   it is jarring. Force a 16px floor on all form fields at the
   mobile breakpoint. Visual size of the inputs is preserved by
   the underlying tool CSS (padding, layout); only the font-size
   floor is enforced.
   ========================================================= */
@media (max-width: 768px) {
  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="url"],
  input[type="tel"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="datetime-local"],
  input[type="month"],
  input[type="week"],
  input[type="time"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* =========================================================
   3. HEADER: sleeker, safe-area-aware, sharper hamburger
   ========================================================= */
@media (max-width: 768px) {
  .site-header {
    padding-top: env(safe-area-inset-top, 0px);
    /* backdrop-filter intentionally removed on mobile - see section 2b */
  }
  .header-inner {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }

  /* Hamburger: cleaner, centered, larger tap target */
  .nav-toggle {
    width: 44px;
    height: 44px;
    padding: 0;
    gap: 5px;
    align-items: center;
    border-radius: 10px;
    transition: background var(--t-fast);
  }
  .nav-toggle:active { background: var(--secondary-bg); }
  .nav-toggle span {
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
  }
  .nav-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Header icon buttons get visible chip styling */
  .header-actions .icon-btn {
    border-radius: 10px;
    background: transparent;
  }
  .header-actions .icon-btn:active {
    background: var(--secondary-bg);
    transform: scale(0.96);
  }
}

/* ---------- Mobile nav: drawer with backdrop ----------
   Note: .main-nav lives inside .site-header which has backdrop-filter,
   so position:fixed gets a non-viewport containing block in some browsers.
   We therefore keep position:absolute (matches original) and put the
   scrim on body::before via :has() so it always covers the viewport. */
@media (max-width: 768px) {
  .main-nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--page-bg);
    border-bottom: 1px solid var(--border-warm);
    padding: 12px 14px max(18px, env(safe-area-inset-bottom));
    box-shadow: 0 14px 28px rgba(60,42,24,0.14);
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 49;
    /* Slide+fade in */
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms var(--ease), transform 220ms var(--ease);
  }
  .main-nav.open {
    display: flex;
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  /* Backdrop scrim - body pseudo so it always covers the viewport */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(20, 16, 10, 0.42);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms var(--ease);
    z-index: 40;
  }
  body:has(.main-nav.open)::before,
  body.nav-open::before {
    opacity: 1;
    pointer-events: auto;
  }
  /* Nav links: editorial spacing, separators, chevron */
  .main-nav a {
    position: relative;
    display: flex;
    align-items: center;
    padding: 14px 18px;
    margin: 0 0 6px;
    width: 100%;
    box-sizing: border-box;
    border-radius: 12px;
    font-size: 1.02rem;
    font-weight: 500;
    color: var(--text);
    border: 1px solid var(--border-warm);
    background: var(--white);
    box-shadow: var(--m-shadow-card);
    transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  }
  .main-nav a::before {
    content: "";
    width: 6px;
    height: 6px;
    margin-right: 12px;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0.55;
    flex-shrink: 0;
  }
  .main-nav a:active {
    transform: scale(0.985);
    background: var(--secondary-bg);
    border-color: var(--primary);
  }
  .main-nav a:last-of-type { margin-bottom: 4px; }
  .main-nav a::after { display: none; }
  .main-nav .btn {
    margin: 10px 14px 4px;
    width: calc(100% - 28px);
    min-height: 48px;
  }
  /* Stagger entrance when menu opens */
  .main-nav.open a {
    animation: m-rise 320ms var(--ease) both;
  }
  .main-nav.open a:nth-child(1) { animation-delay: 20ms; }
  .main-nav.open a:nth-child(2) { animation-delay: 50ms; }
  .main-nav.open a:nth-child(3) { animation-delay: 80ms; }
  .main-nav.open a:nth-child(4) { animation-delay: 110ms; }
  .main-nav.open a:nth-child(5) { animation-delay: 140ms; }
  .main-nav.open a:nth-child(6) { animation-delay: 170ms; }
}
@keyframes m-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .main-nav.open a { animation: none !important; }
}

/* =========================================================
   4. HERO: refined typography & spacing on phones
   ========================================================= */
@media (max-width: 768px) {
  .hero {
    padding: 36px 0 28px;
    text-align: center;
  }
  .hero .eyebrow {
    font-size: 0.7rem;
    padding: 5px 12px;
    letter-spacing: 0.02em;
    margin-bottom: 16px;
  }
  .hero h1 {
    font-size: clamp(1.75rem, 7.4vw, 2.4rem);
    line-height: 1.12;
    letter-spacing: -0.025em;
    margin-bottom: 14px;
    max-width: 22ch;
    margin-left: auto;
    margin-right: auto;
    text-wrap: balance;
  }
  .hero .subhead {
    font-size: 0.97rem;
    line-height: 1.55;
    max-width: 36ch;
    margin: 0 auto 24px;
    color: var(--text-muted);
    padding: 0 4px;
    text-wrap: pretty;
  }
  .search-wrap {
    max-width: 100%;
    margin: 0 auto;
  }
  .search-wrap input {
    padding: 14px 48px 14px 48px;
    border-radius: 14px;
    box-shadow: var(--m-shadow-card);
    font-size: 16px;
  }
  .search-wrap input:focus {
    box-shadow: var(--shadow-focus), var(--m-shadow-card);
  }
  .search-wrap .search-icon { left: 16px; }
  .search-wrap .search-clear {
    right: 8px;
    width: 36px;
    height: 36px;
  }
}
@media (max-width: 380px) {
  .hero h1 { font-size: 1.65rem; }
  .hero { padding: 28px 0 20px; }
}

/* =========================================================
   5. SECTION & SECTION-HEADER on mobile
   ========================================================= */
@media (max-width: 768px) {
  .section { padding: 28px 0; }
  .section-header {
    text-align: left;
    margin-bottom: 18px;
    padding: 0 2px;
  }
  .section-header h2 {
    font-size: 1.45rem;
    margin-bottom: 6px;
    letter-spacing: -0.018em;
  }
  .section-header p {
    font-size: 0.92rem;
    line-height: 1.5;
    text-align: left;
  }
}

/* =========================================================
   6. FILTER BAR on mobile: clean two-row grid layout
   Row 1: scrollable category chips with edge fade (full width)
   Row 2: Top10 | Favorites | View toggle
   ========================================================= */
@media (max-width: 768px) {
  .filter-bar {
    /* Reset to a 3-column grid */
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    grid-auto-rows: auto;
    column-gap: 8px;
    row-gap: 10px;
    align-items: center;
    justify-content: stretch;
    padding: 12px;
    border-radius: 14px;
    box-shadow: var(--m-shadow-card);
    margin-bottom: 18px;
    flex-wrap: nowrap;
    position: relative; /* anchor for scroll hint */
  }
  /* Row 1: chips span all 3 columns */
  .filter-bar > .filter-chips {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    flex: none;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    gap: 6px;
    padding: 2px 22px 2px 6px;
    margin: 0 -10px;
    width: auto;
    max-width: none;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Soft right-edge fade so users see a partial chip "peeking" - strong scroll cue */
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 30px), rgba(0,0,0,0.25) 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 30px), rgba(0,0,0,0.25) 100%);
  }
  .filter-chips::-webkit-scrollbar { display: none; }
  .filter-chip {
    flex: 0 0 auto;
    padding: 9px 14px;
    font-size: 0.86rem;
    font-weight: 500;
    min-height: 38px;
    border-radius: 999px;
    scroll-snap-align: start;
    -webkit-tap-highlight-color: transparent;
  }
  .filter-chip.active {
    box-shadow: 0 2px 8px rgba(212,163,115,0.30);
  }
  /* Row 2: action buttons + view toggle */
  .filter-bar > #topFilter {
    grid-column: 1;
    grid-row: 2;
  }
  .filter-bar > #favFilter {
    grid-column: 2;
    grid-row: 2;
  }
  .filter-bar > .view-toggle {
    grid-column: 3;
    grid-row: 2;
    background: var(--page-bg);
    padding: 3px;
    border-radius: 10px;
    align-self: stretch;
    display: inline-flex;
    align-items: center;
  }
  .filter-bar > #topFilter,
  .filter-bar > #favFilter {
    width: 100%;
    justify-content: center;
    padding: 10px 12px;
    min-height: 42px;
    font-size: 0.86rem;
    border-radius: 10px;
    margin: 0;
  }
  .filter-bar > .view-toggle .view-btn {
    width: 36px;
    height: 36px;
  }
}

/* =========================================================
   7. STATS BAR on mobile: cleaner inline
   ========================================================= */
@media (max-width: 540px) {
  .stats-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.82rem;
    padding: 0 4px;
  }
  .stats-bar > span:last-child {
    font-size: 0.74rem !important;
    color: var(--text-subtle);
  }
}

/* =========================================================
   8. CATEGORY HEADERS: tighter, cleaner on phones
   ========================================================= */
@media (max-width: 768px) {
  .tool-categories { gap: 36px; }
  .category-section { scroll-margin-top: calc(var(--header-h) + 12px); }
  .category-header {
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom-color: var(--border-warm);
  }
  .category-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }
  .category-icon svg { width: 20px; height: 20px; }
  .category-title {
    font-size: 1.18rem;
    line-height: 1.2;
  }
  .category-desc {
    font-size: 0.83rem;
    margin-top: 3px;
    line-height: 1.4;
  }
  .category-count {
    font-size: 0.66rem;
    padding: 3px 9px;
    align-self: flex-start;
  }
}

/* =========================================================
   9. TOOL CARDS on mobile: refined feel + touch feedback
   - Two compact columns on >= 480px
   - Single column on < 480px (with refined density)
   ========================================================= */
@media (max-width: 768px) {
  .tool-grid {
    gap: 12px;
  }
  /* Touch press feedback on cards */
  .tool-card {
    border-radius: 14px;
    box-shadow: var(--m-shadow-card);
    transition: transform 120ms var(--ease), box-shadow 200ms var(--ease), border-color 200ms var(--ease);
  }
  .tool-card:active {
    transform: scale(0.985);
    box-shadow: var(--shadow-xs);
  }
  /* Hover effects neutralised on touch */
  .tool-card:hover { transform: none; box-shadow: var(--m-shadow-card); border-color: var(--border-warm); }
  .tool-card:hover .icon-wrap { transform: none; background: var(--secondary-bg); color: var(--primary-darker); }
  .tool-card::before { display: none; }

  /* Make the entire card feel tappable: full-card link area */
  .tool-card .btn {
    width: 100%;
    justify-content: center;
    min-height: 42px;
    margin-top: 4px;
  }
  /* Bigger, always-visible favorite button */
  .tool-card .fav-btn {
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .tool-card .fav-btn svg { width: 18px; height: 18px; }
}

/* Two-column compact grid for typical phones */
@media (max-width: 768px) and (min-width: 480px) {
  .tool-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .tool-card {
    padding: 16px 16px 18px;
    gap: 10px;
  }
  .tool-card .icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }
  .tool-card .icon-wrap svg { width: 19px; height: 19px; }
  .tool-card h3 {
    font-size: 1rem;
    line-height: 1.25;
  }
  .tool-card p {
    font-size: 0.84rem;
    line-height: 1.45;
    /* Clamp to 3 lines so cards stay even-height */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .tool-card .btn {
    font-size: 0.85rem;
    min-height: 38px;
    padding: 9px 12px;
  }
}

/* Single column on tiny phones - pleasant density, not sparse */
@media (max-width: 479px) {
  .tool-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .tool-card {
    padding: 16px 16px 18px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }
  .tool-card .icon-wrap {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 11px;
  }
  .tool-card .icon-wrap svg { width: 20px; height: 20px; }
  .tool-card h3 {
    font-size: 1.02rem;
    flex: 1 1 0;
    min-width: 0;
  }
  .tool-card p {
    font-size: 0.86rem;
    line-height: 1.45;
    flex-basis: 100%;
    margin-top: -4px;
    color: var(--text-muted);
  }
  .tool-card .btn {
    flex-basis: 100%;
    justify-content: center;
    margin-top: 2px;
    min-height: 40px;
    font-size: 0.88rem;
  }
}

/* List view on mobile: clean rows */
@media (max-width: 768px) {
  .tool-grid.view-list {
    gap: 8px;
  }
  .tool-grid.view-list .tool-card {
    padding: 14px 16px;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
  }
  .tool-grid.view-list .tool-card .icon-wrap {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }
  .tool-grid.view-list .tool-card h3 {
    flex: 0 0 auto;
    font-size: 0.98rem;
    margin: 0;
    flex-basis: 100%;
    line-height: 1.3;
  }
  .tool-grid.view-list .tool-card p {
    flex-basis: 100%;
    margin-top: -4px;
    font-size: 0.84rem;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .tool-grid.view-list .tool-card .btn {
    flex: 0 0 auto;
    font-size: 0.82rem;
    padding: 8px 14px;
    min-height: 36px;
    margin-left: auto;
    width: auto;
    flex-basis: auto;
  }
  .tool-grid.view-list .tool-card .fav-btn {
    position: relative;
    top: auto;
    right: auto;
  }
}

/* =========================================================
   10. NO-RESULTS state on mobile
   ========================================================= */
@media (max-width: 540px) {
  .no-results {
    padding: 36px 18px;
    border-radius: 14px;
    font-size: 0.92rem;
  }
}

/* =========================================================
   11. TOOL PAGE: refined header & content
   ========================================================= */
@media (max-width: 768px) {
  .tool-page {
    padding: 16px 0 56px;
  }
  .breadcrumb {
    font-size: 0.78rem;
    margin-bottom: 14px;
    padding: 6px 12px;
    background: var(--white);
    border: 1px solid var(--border-warm);
    border-radius: 999px;
    display: inline-flex;
    align-self: flex-start;
    box-shadow: var(--shadow-xs);
  }
  .tool-header {
    margin-bottom: 22px;
    padding: 0 2px;
  }
  .tool-header .tool-icon {
    width: 52px;
    height: 52px;
    margin-bottom: 14px;
    border-radius: 13px;
    box-shadow: var(--m-shadow-card);
  }
  .tool-header .tool-icon svg { width: 25px; height: 25px; }
  .tool-header h1 {
    font-size: 1.55rem;
    line-height: 1.18;
    margin-bottom: 8px;
    letter-spacing: -0.022em;
    text-wrap: balance;
  }
  .tool-header p {
    font-size: 0.94rem;
    line-height: 1.55;
    color: var(--text-muted);
    text-wrap: pretty;
  }
  .tool-card-lg {
    padding: 18px 16px;
    border-radius: 14px;
    box-shadow: var(--m-shadow-card);
  }
  .how-to {
    padding: 18px 18px 20px;
    border-radius: 14px;
    margin-top: 26px;
  }
  .how-to h2 { font-size: 1.08rem; margin-bottom: 10px; }
  .how-to ol, .how-to ul { padding-left: 20px; }
  .how-to li { margin-bottom: 6px; line-height: 1.5; font-size: 0.92rem; }
}

/* =========================================================
   12. FORMS: comfortable tap targets, premium input feel
   ========================================================= */
@media (max-width: 768px) {
  .field {
    margin-bottom: 14px;
    gap: 6px;
  }
  .field label {
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0;
  }
  .field input,
  .field textarea,
  .field select,
  .text-input {
    padding: 13px 14px;
    border-radius: 11px;
    background: var(--white);
    border: 1.5px solid var(--border-warm);
    transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  }
  .field input:focus,
  .field textarea:focus,
  .field select:focus,
  .text-input:focus {
    border-color: var(--primary);
    background: var(--white);
  }
  .field textarea {
    min-height: 160px;
    line-height: 1.5;
  }
  .field .helper { font-size: 0.78rem; }

  .row, .row-3 { gap: 12px; }
}

/* =========================================================
   13. BUTTONS: 44px min, premium press
   ========================================================= */
@media (max-width: 768px) {
  .btn {
    min-height: 44px;
    padding: 12px 18px;
    font-size: 0.94rem;
    border-radius: 11px;
    -webkit-tap-highlight-color: transparent;
    transition: transform 100ms var(--ease), box-shadow var(--t), background var(--t), color var(--t);
  }
  .btn:active { transform: scale(0.97); }
  .btn-lg {
    min-height: 50px;
    padding: 14px 22px;
    font-size: 1rem;
    border-radius: 12px;
  }
  .btn-icon {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    border-radius: 11px;
  }
  .btn-icon svg { width: 20px; height: 20px; }

  .button-row { gap: 8px; }
  .button-row .btn { flex: 1 1 auto; min-width: 0; }
}
@media (max-width: 480px) {
  .button-row { flex-direction: column; }
  .button-row .btn { width: 100%; flex: 0 0 auto; }
}

/* =========================================================
   14. OUTPUT BOXES, RESULT, STATS GRID polish
   ========================================================= */
@media (max-width: 540px) {
  .output-box {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px;
    border-radius: 12px;
    font-size: 0.92rem;
  }
  .output-box .val {
    word-break: break-all;
    line-height: 1.45;
    font-size: 0.95rem;
  }
  .output-box .btn { width: 100%; min-height: 42px; }
}
@media (max-width: 480px) {
  .result {
    padding: 18px 16px;
    border-radius: 13px;
    box-shadow: var(--m-shadow-card);
  }
  .result-big { font-size: 1.5rem; line-height: 1.15; }
  .result-sub { font-size: 0.86rem; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 16px;
  }
  .stat-card {
    padding: 12px 10px;
    border-radius: 11px;
    box-shadow: var(--m-shadow-card);
  }
  .stat-card .stat-value { font-size: 1.3rem; }
  .stat-card .stat-label { font-size: 0.7rem; letter-spacing: 0.04em; }
}

/* =========================================================
   15. ARTICLE pages (about, privacy, terms): tighter rhythm
   ========================================================= */
@media (max-width: 768px) {
  .article {
    padding: 24px 16px 36px;
  }
  .article h1 {
    margin-bottom: 14px;
    font-size: 1.7rem;
    line-height: 1.18;
    letter-spacing: -0.022em;
  }
  .article h2 {
    margin-top: 22px;
    font-size: 1.18rem;
    margin-bottom: 10px;
  }
  .article p,
  .article li {
    font-size: 0.96rem;
    line-height: 1.62;
  }
  .article ul, .article ol {
    padding-left: 22px;
  }
}

/* =========================================================
   16. FOOTER: refined column layout on phones
   ========================================================= */
@media (max-width: 600px) {
  .site-footer {
    padding: 22px 0 max(22px, env(safe-area-inset-bottom));
  }
  .footer-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    font-size: 0.82rem;
  }
  .footer-nav {
    gap: 12px 18px;
    justify-content: center;
    flex-wrap: wrap;
  }
  .footer-nav a {
    padding: 6px 4px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }
}

/* =========================================================
   17. BACK-TO-TOP & TOAST: safe-area-aware
   ========================================================= */
@media (max-width: 768px) {
  .back-to-top {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 16px));
    width: 46px;
    height: 46px;
    border-radius: 14px;
    box-shadow: var(--m-shadow-pop);
  }
  .toast {
    bottom: max(76px, calc(env(safe-area-inset-bottom, 0px) + 76px));
    left: 16px;
    right: 16px;
    border-radius: 12px;
    font-size: 0.92rem;
    box-shadow: var(--m-shadow-pop);
  }
}

/* =========================================================
   18. COOKIE CONSENT: cleaner stacked panel
   On phones <= 480px, stack buttons vertically (matches
   styles.css @768px) so labels never get squeezed.
   On tablets 481-600px, allow side-by-side with min sizes.
   IMPORTANT: .ck-consent__body MUST NOT have flex-grow inside
   a column-flex panel; otherwise it expands to fill the panel
   and pushes the buttons off-screen on small phones.
   ========================================================= */
@media (max-width: 600px) {
  #ck-consent {
    left: 10px;
    right: 10px;
    bottom: max(10px, calc(env(safe-area-inset-bottom, 0px) + 10px));
  }
  .ck-consent__panel {
    padding: 16px;
    gap: 12px;
    border-radius: 14px;
    flex-direction: column;
    align-items: stretch;
    box-shadow: var(--m-shadow-pop);
    /* Hard ceiling so the panel can never push the action row out
       of the visible viewport. Inner overflow-y handles long copy. */
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }
  .ck-consent__body {
    /* Size to content, do NOT grow (otherwise it pushes buttons off-screen) */
    flex: 0 0 auto;
    font-size: 0.88rem;
    line-height: 1.5;
    /* Inner scroll for overly long copy, so buttons remain visible below */
    max-height: 50vh;
    max-height: 50dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .ck-consent__actions {
    width: 100%;
    gap: 8px;
    /* Pin actions to bottom of the column so they never get hidden */
    flex: 0 0 auto;
    margin-top: auto;
  }
  .ck-consent__btn {
    min-height: 44px;
    padding: 12px 14px;
    font-size: 0.9rem;
    border-radius: 10px;
  }
}
/* Phones <= 480px: stack buttons vertically; primary first */
@media (max-width: 480px) {
  .ck-consent__actions {
    flex-direction: column;
    flex-wrap: nowrap;
  }
  .ck-consent__btn {
    width: 100%;
    flex: 0 0 auto;
    order: 2;
  }
  .ck-consent__btn--primary { order: 1; }
}
/* Tablets 481-600px: side-by-side, equal width */
@media (min-width: 481px) and (max-width: 600px) {
  .ck-consent__actions {
    flex-direction: row;
    flex-wrap: nowrap;
  }
  .ck-consent__btn {
    flex: 1 1 0;
    width: auto;
  }
}

/* =========================================================
   19. DISABLE hover lift on touch devices
   ========================================================= */
@media (hover: none) {
  .tool-card:hover { transform: none; box-shadow: var(--m-shadow-card); border-color: var(--border-warm); }
  .tool-card:hover .icon-wrap { transform: none; background: var(--secondary-bg); color: var(--primary-darker); }
  .btn-primary:hover { transform: none; }
  .featured-card:hover, .post-card:hover { transform: none; }
  .stat-card:hover { transform: none; }
  .filter-chip:hover { border-color: var(--border-warm); color: var(--text-muted); }
  .filter-chip.active:hover { border-color: var(--primary); color: var(--white); }
}

/* =========================================================
   20. SUPER-NARROW phones (<= 360px): density tweaks
   ========================================================= */
@media (max-width: 360px) {
  .container { padding: 0 14px; }
  .header-inner { padding-left: 14px; padding-right: 14px; }
  .hero h1 { font-size: 1.55rem; }
  .tool-header h1 { font-size: 1.35rem; }
  .filter-bar { padding: 10px; column-gap: 6px; }
  .filter-bar > #topFilter,
  .filter-bar > #favFilter {
    font-size: 0.78rem;
    padding: 9px 8px;
    gap: 4px;
  }
  .filter-bar > #topFilter svg,
  .filter-bar > #favFilter svg {
    width: 13px; height: 13px;
  }
  .filter-bar > .view-toggle .view-btn {
    width: 32px; height: 32px;
  }
}

/* =========================================================
   21. AD ZONES: graceful on small viewports
   ========================================================= */
@media (max-width: 768px) {
  .ad-zone {
    margin: 22px auto;
  }
  .ad-zone__label {
    font-size: 0.62rem;
  }
  .ad-zone--leaderboard .ad-zone__inner {
    min-height: 70px;
    max-width: 100%;
    border-radius: 10px;
  }
  .ad-zone--rectangle .ad-zone__inner {
    max-width: 100%;
    border-radius: 10px;
  }
}

/* =========================================================
   22. BLOG: refined mobile reading experience
   Pre-existing bug: .blog-layout's `padding: 2rem 0 3rem`
   wipes out .container's horizontal padding on mobile.
   Restore it here for both blog-main and post pages.
   ========================================================= */
@media (max-width: 768px) {
  .blog-layout {
    padding: 1rem 20px 2rem !important;
  }
  .post-article,
  .blog-content {
    min-width: 0;
    word-wrap: break-word;
  }
  .post-article img,
  .post-article pre,
  .post-article table {
    max-width: 100%;
  }
}
@media (max-width: 480px) {
  .blog-layout {
    padding: 0.8rem 16px 1.6rem !important;
  }
}
@media (max-width: 600px) {
  .blog-hero { padding: 4px 0 1.4rem; }
  .blog-hero-title {
    font-size: 1.7rem;
    line-height: 1.18;
    letter-spacing: -0.022em;
  }
  .blog-hero-sub {
    font-size: 0.96rem;
    line-height: 1.55;
  }
  .post-card {
    border-radius: 12px;
  }
  .post-card-cover {
    height: 86px;
  }
  .post-card-icon {
    width: 30px;
    height: 30px;
  }
  .post-card-body {
    padding: 1rem 1rem 1.05rem;
  }
  .post-card-title {
    font-size: 1rem;
    line-height: 1.3;
  }
  .post-card-excerpt {
    font-size: 0.84rem;
    line-height: 1.5;
  }
  .featured-card {
    border-radius: 14px;
  }
  .featured-body {
    padding: 1.2rem 1.1rem;
    gap: 0.65rem;
  }
  .featured-title {
    font-size: 1.28rem;
    line-height: 1.22;
  }
  .featured-excerpt {
    font-size: 0.92rem;
    line-height: 1.5;
  }
}

/* Blog post body */
@media (max-width: 600px) {
  .post-article p,
  .post-article li {
    font-size: 1rem;
    line-height: 1.7;
  }
  .post-article h2 {
    font-size: 1.3rem;
    margin-top: 1.6rem;
    line-height: 1.25;
  }
  .post-article h3 {
    font-size: 1.1rem;
    margin-top: 1.4rem;
  }
  .post-article pre {
    border-radius: 10px;
    font-size: 0.84rem;
  }
  .post-article blockquote {
    padding-left: 1rem;
    font-size: 0.96rem;
  }
}

/* =========================================================
   23. PRINT
   ========================================================= */
@media print {
  .site-header, .site-footer, .back-to-top, #ck-consent,
  .filter-bar, .stats-bar, .nav-toggle, .header-actions,
  .scroll-hint {
    display: none !important;
  }
  body { background: #fff !important; color: #000 !important; }
}

/* =========================================================
   24. SCROLL HINT PILL - UX cue for horizontally scrolling
   areas (category chips, etc). Injected by mobile-pro.js
   only when overflow exists. Auto-dismisses on first
   interaction or after 7s.
   ========================================================= */
@media (max-width: 768px) {
  .scroll-hint {
    position: absolute;
    top: 14px;
    right: 10px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0 11px 0 12px;
    background: linear-gradient(135deg, var(--primary, #d4a373), var(--primary-darker, #b8865b));
    color: #fff;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
    border-radius: 999px;
    box-shadow:
      0 0 0 3px var(--white, #fff),
      0 6px 16px rgba(212,163,115,0.50),
      0 2px 4px rgba(60,42,24,0.18);
    pointer-events: none;
    z-index: 5;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    will-change: transform, opacity;
    animation:
      sh-pop 380ms cubic-bezier(0.34, 1.56, 0.64, 1) both,
      sh-pulse 1.5s ease-in-out 600ms infinite;
  }
  html[data-theme="dark"] .scroll-hint {
    box-shadow:
      0 0 0 3px var(--secondary-bg, #1f1c19),
      0 6px 16px rgba(0,0,0,0.55),
      0 2px 4px rgba(0,0,0,0.4);
  }
  .scroll-hint__text { display: inline-block; }
  .scroll-hint__icon {
    display: block;
    flex-shrink: 0;
  }
  .scroll-hint--gone {
    opacity: 0 !important;
    transform: translateX(12px) scale(0.94) !important;
    transition: opacity 380ms ease, transform 380ms ease;
    animation: none !important;
  }
}
@keyframes sh-pop {
  from { opacity: 0; transform: translateX(22px) scale(0.82); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes sh-pulse {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-5px); }
}
@media (prefers-reduced-motion: reduce) {
  .scroll-hint { animation: sh-pop 200ms ease both !important; }
}

/* Super-narrow phones: shrink the hint a touch */
@media (max-width: 380px) {
  .scroll-hint {
    height: 32px;
    padding: 0 10px;
    font-size: 0.66rem;
    gap: 4px;
  }
}
