/* Styles for /library (moved out of the page so browsers can cache them) */
        :root { --color-danger: #ef4444; }
                * { margin: 0; padding: 0; box-sizing: border-box; }
        [hidden] { display: none !important; }
        body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background: var(--color-light); color: var(--color-text); line-height: 1.6; }
        a { color: var(--color-link); }

        header { background: var(--color-white); box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 100; }
        nav { display: flex; justify-content: space-between; align-items: center; padding: 1rem 2rem; max-width: 1200px; margin: 0 auto; gap: 1rem; }
        .logo { display: flex; align-items: center; gap: 0.5rem; font-size: 1.5rem; font-weight: 700; color: var(--color-primary); text-decoration: none; }
        .nav-right { display: flex; gap: 0.6rem; align-items: center; }

        .btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; height: 40px; padding: 0 1.1rem; border: none; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; font-size: 0.95rem; text-decoration: none; white-space: nowrap; }
        .btn:disabled { opacity: 0.6; cursor: not-allowed; }
        .btn-primary { background: var(--color-primary); color: #fff; }
        .btn-primary:hover:not(:disabled) { background: var(--color-accent); }
        .btn-secondary { background: var(--color-light); color: var(--color-text); box-shadow: inset 0 0 0 1px var(--color-border); }
        .btn-secondary:hover { background: var(--color-tint); }
        .btn-danger { background: #c81e1e; color: #fff; }
        .btn-sm { height: 32px; padding: 0 0.75rem; font-size: 0.85rem; }

        .page-hero { background: linear-gradient(135deg, #134a38 0%, #1a654c 55%, #1f6a50 100%); color: #fff; padding: 3rem 2rem 4.5rem; text-align: center; }
        .page-hero h1 { font-size: 2.25rem; font-weight: 800; margin-bottom: 0.4rem; }
        .page-hero p { font-size: 1.1rem; max-width: 640px; margin: 0 auto; }

        .container { max-width: 1150px; margin: -2.5rem auto 3rem; padding: 0 2rem; position: relative; }
        .card { background: var(--color-white); border-radius: 14px; box-shadow: var(--shadow-sm); }
        /* Filters sit on the page itself: no second box around the search field */
        .card.toolbar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; padding: 0; margin-bottom: 1.5rem; background: none; border: none; box-shadow: none; }
        .toolbar .search { height: 44px; background: var(--color-white); box-shadow: var(--shadow-sm); }
        .sort-tabs { display: flex; gap: 0.25rem; background: var(--color-white); border: 1px solid var(--color-border); border-radius: 999px; padding: 0.2rem; }
        .sort-tab { border: none; background: none; font: inherit; font-weight: 600; font-size: 0.9rem; color: var(--color-gray); padding: 0.4rem 0.9rem; border-radius: 999px; cursor: pointer; }
        .sort-tab.active { background: var(--color-primary); color: #fff; }
        .input, .select, .textarea { font: inherit; font-size: 0.95rem; color: var(--color-text); background: var(--color-white); border: 1px solid var(--color-border); border-radius: 8px; padding: 0 0.75rem; height: 40px; width: 100%; }
        .textarea { height: auto; padding: 0.6rem 0.75rem; resize: vertical; }
        .toolbar .search { flex: 1 1 200px; }

        .section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-gray); margin: 0 0 0.6rem 0.25rem; font-weight: 700; }
        .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
        .deck { display: flex; flex-direction: column; cursor: pointer; transition: box-shadow 0.2s ease; text-decoration: none; color: inherit; position: relative; }
        .grid:has(> .deck) { isolation: isolate; }
        .deck::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--color-white); border: 1px solid var(--color-border); transform: translate(5px, 5px) rotate(1.2deg); pointer-events: none; }
        .deck:hover::before { transform: translate(7px, 7px) rotate(2deg); }
        @media (prefers-reduced-motion: no-preference) { .deck::before { transition: transform 0.2s ease; } }
        .deck .stripe { border-radius: 14px 14px 0 0; }
        .deck:hover { box-shadow: var(--shadow-md); }
        .deck .stripe { height: 6px; }
        .deck .body { padding: 1rem 1.1rem; flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }
        .deck h3 { font-size: 1.05rem; color: var(--color-heading); line-height: 1.35; overflow-wrap: anywhere; }
        .deck .desc { font-size: 0.88rem; color: var(--color-gray); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
        .deck .meta { font-size: 0.8rem; color: var(--color-gray); margin-top: auto; padding-top: 0.4rem; display: flex; gap: 0.7rem; flex-wrap: wrap; }
        .flags { display: flex; gap: 0.3rem; flex-wrap: wrap; }

        .badge { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; line-height: 1; padding: 0.24rem 0.45rem; border-radius: 4px; white-space: nowrap; }
        .save-btn.saved { color: var(--color-link); }
        .save-btn.saved .lbl { font-weight: 700; }
        .b-official { color: #121a16; background: #f2b134; }
        .b-reviewed { color: #fff; background: #1d4ed8; }
        .b-pro { color: #fff; background: var(--color-dark); }
        .b-pending { color: #92400e; background: rgba(245, 158, 11, 0.2); }
        .b-rejected { color: #b91c1c; background: rgba(239, 68, 68, 0.14); }
        .b-approved { color: #047857; background: rgba(16, 185, 129, 0.14); }
        @media (prefers-color-scheme: dark) { .b-approved { color: #6ee7b7; } }
        @media (prefers-color-scheme: dark) { .b-pro { background: #1a654c; } }

        .detail-head { padding: 1.5rem; margin-bottom: 1rem; }
        .detail-head h2 { font-size: 1.5rem; color: var(--color-heading); margin: 0.4rem 0; }
        .detail-head .meta { color: var(--color-gray); font-size: 0.9rem; }
        .detail-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
        .staff-box { margin-top: 1rem; padding: 0.9rem 1rem; border-radius: 10px; background: var(--color-light); display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; font-size: 0.9rem; }
        .card-list { display: flex; flex-direction: column; gap: 0.6rem; }
        .sub-heading { font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-gray); margin: 0.6rem 0 0; }
        .sub-heading:first-child { margin-top: 0; }
        .fc { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }
        .fc > div { padding: 0.9rem 1.1rem; font-size: 0.93rem; overflow-wrap: anywhere; white-space: pre-wrap; }
        .fc-img { display: block; max-width: 100%; max-height: 180px; border-radius: 8px; margin-top: 0.5rem; background: #fff; }
        .fc .front { font-weight: 600; color: var(--color-heading); border-right: 1px solid var(--color-border); }
        .fc .label { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-gray); font-weight: 700; margin-bottom: 0.2rem; white-space: normal; }
        .notice { padding: 0.85rem 1rem; border-radius: 10px; background: var(--color-tint); font-size: 0.92rem; margin-bottom: 1rem; }
        .notice.warn { background: rgba(245, 158, 11, 0.12); }
        .empty { text-align: center; padding: 2.5rem 1rem; color: var(--color-gray); }
        .empty .icon { font-size: 2.4rem; }

        .modal { position: fixed; inset: 0; background: rgba(29, 27, 22, 0.55); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 1000; }
        .modal-content { background: var(--color-white); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.5rem; }
        .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
        .modal-header h2 { font-size: 1.2rem; color: var(--color-heading); }
        .modal-close { background: none; border: none; font-size: 1.6rem; color: var(--color-gray); cursor: pointer; width: 36px; height: 36px; border-radius: 8px; }
        .form-grid { display: flex; flex-direction: column; gap: 0.9rem; }
        .field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; color: var(--color-heading); }
        .field .hint { font-size: 0.8rem; color: var(--color-gray); margin-top: 0.3rem; }
        .modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; flex-wrap: wrap; }
        .gate { text-align: center; padding: 3rem 2rem; }
        .gate .icon { font-size: 3rem; }
        .gate h2 { margin: 0.5rem 0; }
        .gate p { color: var(--color-gray); margin-bottom: 1.25rem; }
        .toasts { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 0.5rem; z-index: 2000; width: max-content; max-width: calc(100vw - 2rem); }
        .toast { background: var(--color-dark); color: #fff; padding: 0.75rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; font-size: 0.92rem; }
        .toast.error { background: #b91c1c; }

        @media (max-width: 600px) {
            nav { padding: 0.75rem 1rem; }
            .logo { font-size: 1.25rem; }
            .logo svg { width: 32px; height: 32px; }
            .hide-sm { display: none; }
            .page-hero { padding: 2.25rem 1.25rem 3.75rem; }
            .page-hero h1 { font-size: 1.75rem; }
            .container { padding: 0 0.75rem; }
            .fc { grid-template-columns: 1fr; }
            .fc .front { border-right: none; border-bottom: 1px solid var(--color-border); }
        }

        /* Palette pass: sentence-case section headings, teal review badge, drawn icons */
        .section-title { font-size: 1.05rem; text-transform: none; letter-spacing: -0.01em; color: var(--color-heading); margin: 0.4rem 0 0.75rem; font-weight: 750; }
        .badge .ic { width: 12px; height: 12px; margin-right: 0.2rem; vertical-align: -1px; }
        .b-reviewed { color: var(--pr-brand-ink, #1a654c); background: var(--color-tint); }
        .b-official { color: var(--pr-on-accent, #121a16); background: var(--pr-accent, #f2b134); }
        .deck .meta span { display: inline-flex; align-items: center; gap: 0.3rem; }
        .deck .meta .ic { color: var(--color-link); }
        .deck h3 .lock { display: inline-flex; vertical-align: -1px; margin-right: 0.3rem; color: var(--color-gray); }
        .notice.warn { display: flex; align-items: center; gap: 0.5rem; }
        @media (prefers-color-scheme: dark) { .b-reviewed { color: #a7dfc4; background: rgba(124, 201, 165, 0.14); } }
    
