/* app.css — consolidated global stylesheet (DESIGN.md Apple Design System).
 * Extracted from views/layout.php. Organization:
 *   1. Tokens   (:root custom properties)
 *   *   2. Base      (reset, body, links, focus, utilities)
 *   3. Components (global nav, tiles, buttons, footer, banners, keyframes)
 * Page-specific styles remain in their view files; view <style> blocks load
 * after this sheet, preserving the original cascade.
 */
        :root {
            --primary: #0066cc; --primary-focus: #0071e3; --ink: #1d1d1f;
            --ink-muted-80: #333; --ink-muted-48: #7a7a7a; --body-muted: #ccc;
            --hairline: #e0e0e0; --canvas: #fff; --canvas-parchment: #f5f5f7;
            --surface-black: #000; --on-dark: #fff; --focus-ring: #0071e3;
            --font-display: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
            --font-text: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
            --page-max: min(1280px, 92vw);
        }
        * { box-sizing: border-box; margin: 0; padding: 0; }
        body { font-family: var(--font-text); font-size: 17px; line-height: 1.47; color: var(--ink); background: var(--canvas); }
        a { color: var(--primary); text-decoration: none; }
        a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
            outline: 3px solid var(--focus-ring); outline-offset: 2px;
        }
        .skip-link {
            position: absolute; left: 12px; top: -100px; z-index: 200;
            padding: 10px 16px; background: var(--primary); color: #fff; border-radius: 8px; font-size: 14px; font-weight: 600;
        }
        .skip-link:focus { top: 12px; outline: 3px solid #fff; outline-offset: 2px; }
        .global-nav {
            background: var(--surface-black); color: var(--on-dark); height: 44px;
            display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
            position: sticky; top: 0; z-index: 100;
        }
        .global-nav a { color: var(--on-dark); font-size: 12px; }
        .global-nav .logo { font-size: 17px; font-weight: 600; }
        .global-nav .nav-links { display: flex; gap: 20px; list-style: none; align-items: center; flex-wrap: wrap; }
        .global-nav .nav-links > li > a,
        .global-nav .nav-drop summary {
            position: relative;
            display: inline-block;
            padding-bottom: 3px;
        }
        .global-nav .nav-links > li > a::after,
        .global-nav .nav-drop summary::after {
            content: '';
            position: absolute;
            left: 0; right: 100%; bottom: 0;
            height: 1px;
            background: var(--on-dark);
        }
        .global-nav .nav-links a:hover { color: var(--body-muted); }
        .global-nav .nav-links > li > a:hover::after,
        .global-nav .nav-links > li > a:focus-visible::after,
        .global-nav .nav-drop summary:hover::after,
        .global-nav .nav-drop summary:focus-visible::after,
        .global-nav .nav-links > li > a[aria-current="page"]::after,
        .global-nav .nav-drop summary[aria-current="page"]::after {
            right: 0;
        }
        .global-nav .nav-drop details { position: relative; }
        .global-nav .nav-drop summary {
            list-style: none; cursor: pointer; color: var(--on-dark); font-size: 12px;
        }
        .global-nav .nav-drop summary::-webkit-details-marker { display: none; }
        .global-nav .nav-drop ul {
            position: absolute; top: 100%; left: 0; min-width: 160px; margin: 6px 0 0;
            padding: 8px 0; list-style: none; background: #1d1d1f; border-radius: 10px;
        }
        .global-nav .nav-drop ul a { display: block; padding: 8px 14px; font-size: 13px; }
        main { min-height: calc(100vh - 44px - 200px); }
        .tile { padding: 80px 24px; text-align: center; }
        .tile-light { background: var(--canvas); }
        .tile-parchment { background: var(--canvas-parchment); }
        .tile-dark { background: var(--surface-black); color: var(--on-dark); }
        .tile-dark a { color: #2997ff; }
        .tile h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(28px, 5.5vw, 56px); letter-spacing: -0.028em; margin-bottom: 12px; }
        .tile .lead { font-size: clamp(20px, 2.5vw, 28px); margin-bottom: 24px; opacity: 0.9; }
        .btn {
            display: inline-block; font-size: 17px; padding: 11px 22px; border-radius: 9999px;
            border: none; cursor: pointer; text-decoration: none;
        }
        .btn-primary { background: var(--primary); color: #fff; }
        .btn-secondary { background: transparent; color: var(--primary); }
        .btn-ghost {
            background: rgba(0,102,204,.08); color: var(--primary); font-weight: 600;
        }
        .btn + .btn { margin-left: 12px; }
        .card, .tool-card, .name-row {
            display: block; color: inherit; text-decoration: none;
        }
        .flash {
            max-width: 720px; margin: 12px auto 0; padding: 10px 16px;
            border-radius: 10px; background: var(--canvas-parchment);
        }
        .visually-hidden {
            position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
            overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
        }
        .empty-state {
            text-align: center; max-width: 420px; margin: 0 auto; padding: 36px 20px;
            background: var(--canvas-parchment); border: 1px solid var(--hairline); border-radius: 16px;
        }
        .empty-state-heading { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
        .empty-state-lead { font-size: 14px; color: var(--ink-muted-48); margin: 0 0 20px; }
        .empty-state-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 0; }
        .page-wide,
        .page-shell,
        .with-sidebar,
        .tool-shell {
            max-width: var(--page-max);
            width: 100%;
            margin-left: auto;
            margin-right: auto;
            padding-left: clamp(16px, 3vw, 32px);
            padding-right: clamp(16px, 3vw, 32px);
        }
        .page-shell { padding-top: 28px; padding-bottom: 56px; }
        .with-sidebar {
            display: grid;
            grid-template-columns: minmax(0, 1fr) 280px;
            gap: 28px;
            padding-top: 0;
            padding-bottom: 48px;
            align-items: start;
        }
        .with-sidebar-aside { position: sticky; top: 56px; }
        @media (max-width: 900px) {
            .with-sidebar { grid-template-columns: 1fr; }
            .with-sidebar-aside { position: static; order: -1; }
        }
        @media (max-width: 734px) {
            :root { --page-max: 100%; }
            .page-wide, .page-shell, .with-sidebar, .tool-shell {
                padding-left: 16px;
                padding-right: 16px;
            }
        }
        .form-stack { display: grid; gap: 16px; max-width: 480px; margin: 0 auto; text-align: left; }
        .form-field { display: grid; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink); }
        .form-field input,
        .form-field select,
        .form-field textarea {
            height: 44px; padding: 0 16px; border: 1px solid var(--hairline); border-radius: 12px;
            font: inherit; font-size: 17px; color: var(--ink); background: var(--canvas); width: 100%;
        }
        .form-field textarea { height: auto; min-height: 120px; padding: 12px 16px; resize: vertical; }
        .form-field input:focus,
        .form-field select:focus,
        .form-field textarea:focus {
            border-color: var(--primary-focus);
            box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2);
            outline: none;
        }
        .alert-err {
            padding: 12px 16px; border-radius: 12px; background: #fdecea; color: #b71c1c; margin-bottom: 8px;
        }
        .alert-ok {
            padding: 12px 16px; border-radius: 12px; background: #e8f5e9; color: #1b5e20; margin-bottom: 8px;
        }
        .meta { font-size: 13px; color: var(--ink-muted-48); }
        .site-sidebar { padding: 0 2px; }
        .sb-cta {
            background: var(--primary); color: #fff; border-radius: 14px;
            padding: 16px 14px; margin-bottom: 18px;
        }
        .sb-cta-title { font-size: 16px; font-weight: 700; margin: 0 0 6px; color: #fff; }
        .sb-cta-lead { font-size: 13px; opacity: 0.92; margin: 0 0 12px; line-height: 1.35; }
        .sb-cta-btn {
            display: block; text-align: center; background: #fff; color: var(--primary);
            font-weight: 600; padding: 10px 14px; border-radius: 10px; text-decoration: none; font-size: 14px;
        }
        .sb-block { margin-bottom: 18px; }
        .sb-heading {
            font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
            color: var(--ink-muted-48); margin: 0 0 8px; font-weight: 700;
        }
        .sb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
        .sb-name {
            display: flex; align-items: center; gap: 8px; padding: 8px 10px;
            border-radius: 10px; color: inherit; text-decoration: none;
            background: var(--canvas-parchment); border: 1px solid transparent;
            min-height: 44px;
        }
        .sb-name:hover { border-color: var(--hairline); }
        .sb-rank {
            width: 22px; height: 22px; border-radius: 6px; background: var(--canvas);
            display: flex; align-items: center; justify-content: center;
            font-size: 11px; font-weight: 700; color: var(--ink-muted-48); flex-shrink: 0;
        }
        .sb-name-body { min-width: 0; }
        .sb-name-title { display: block; font-weight: 600; font-size: 14px; line-height: 1.25; }
        .sb-name-meta {
            display: block; font-size: 11px; color: var(--ink-muted-48);
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3;
        }
        .sb-more { margin: 8px 0 0; font-size: 12px; }
        .sb-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 13px; }
        .site-footer {
            width: 100%;
            background: var(--canvas-parchment);
            color: var(--ink-muted-48);
            padding: 48px 0 28px;
            font-size: 13px;
            margin-top: 0;
        }
        .site-footer a { color: var(--ink-muted-48); }
        .site-footer a:hover { color: var(--ink); }
        .site-footer-inner {
            width: 100%;
            max-width: none;
            padding: 0 32px;
        }
        .site-footer-grid {
            display: grid;
            grid-template-columns: minmax(200px, 1.4fr) repeat(5, minmax(120px, 1fr));
            gap: 32px 24px;
            align-items: start;
            margin-bottom: 40px;
        }
        .site-footer-logo {
            display: inline-block;
            font-size: 18px; font-weight: 700;
            color: var(--ink) !important;
            margin-bottom: 12px;
        }
        .site-footer-blurb {
            max-width: 280px;
            line-height: 1.5;
            color: var(--ink-muted-48);
            font-size: 13px;
        }
        .site-footer-heading {
            font-size: 11px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.12em;
            color: var(--ink-muted-80);
            margin-bottom: 14px;
        }
        .site-footer-list {
            list-style: none;
            display: grid;
            gap: 10px;
        }
        .site-footer-list a {
            display: inline-block;
            font-size: 13px;
            font-weight: 500;
        }
        .site-footer-bottom {
            border-top: 1px solid var(--hairline);
            padding-top: 20px;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
        }
        .site-footer-copy {
            font-size: 11px;
            letter-spacing: 0.04em;
            color: var(--ink-muted-48);
        }
        .site-footer-note {
            font-size: 11px;
            color: var(--ink-muted-48);
            max-width: 420px;
        }
        @media (max-width: 1100px) {
            .site-footer-grid {
                grid-template-columns: repeat(3, minmax(140px, 1fr));
            }
            .site-footer-brand { grid-column: 1 / -1; }
        }
        @media (max-width: 734px) {
            .global-nav { padding: 0 12px; }
            .global-nav .nav-links { gap: 12px; font-size: 11px; }
            .tile { padding: 48px 16px; }
            .site-footer { padding: 36px 0 24px; }
            .site-footer-inner { padding: 0 16px; }
            .site-footer-grid {
                grid-template-columns: 1fr 1fr;
                gap: 28px 16px;
            }
            .site-footer-brand { grid-column: 1 / -1; }
            .site-footer-bottom { flex-direction: column; align-items: flex-start; }
        }
        @media (max-width: 420px) {
            .site-footer-grid { grid-template-columns: 1fr; }
        }
        @media (prefers-reduced-motion: no-preference) {
            main { animation: fade-in 220ms ease-out; }
            .btn, .card, .tool-card, .name-row, .sb-name {
                transition: transform 180ms ease, background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
            }
            .btn:hover, .card:hover, .tool-card:hover, .name-row:hover {
                transform: translateY(-3px);
            }
            .btn:active, .card:active, .tool-card:active, .name-row:active {
                transform: translateY(0);
            }
            .btn-primary.cta-pulse {
                animation: cta-glow 1.2s ease-out 1;
            }
            .flash {
                animation: fade-in 180ms ease-out;
            }
            .global-nav .nav-links > li > a::after,
            .global-nav .nav-drop summary::after {
                transition: right 160ms ease;
            }
            .global-nav .nav-drop details[open] ul {
                animation: nav-drop-in 140ms ease-out;
            }
            .stagger > :nth-child(-n+6) { animation: fade-in 280ms ease-out both; }
            .stagger > :nth-child(1) { animation-delay: 0ms; }
            .stagger > :nth-child(2) { animation-delay: 40ms; }
            .stagger > :nth-child(3) { animation-delay: 80ms; }
            .stagger > :nth-child(4) { animation-delay: 120ms; }
            .stagger > :nth-child(5) { animation-delay: 160ms; }
            .stagger > :nth-child(6) { animation-delay: 200ms; }
        }
        @media (prefers-reduced-motion: reduce) {
            *, *::before, *::after {
                animation: none !important;
                transition: none !important;
            }
        }
        @keyframes fade-in {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        @keyframes cta-glow {
            0% { box-shadow: 0 0 0 0 rgba(0, 102, 204, 0.45); }
            100% { box-shadow: 0 0 0 14px rgba(0, 102, 204, 0); }
        }
        @keyframes nav-drop-in {
            from { opacity: 0; transform: translateY(-4px); }
            to { opacity: 1; transform: translateY(0); }
        }