<style nonce="{{ csp_nonce }}">

/* === settings.html === */
.settings-header {
            margin-bottom: 24px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .settings-header h1 {
            font-size: 24px;
            font-weight: 700;
        }
        .settings-layout {
            display: grid;
            grid-template-columns: 200px 1fr;
            gap: 24px;
        }
        .settings-sidebar {
            position: sticky;
            top: 20px;
            align-self: start;
        }
        .settings-sidebar a {
            display: block;
            padding: 8px 16px;
            color: #666;
            text-decoration: none;
            font-size: 14px;
            border-radius: 6px;
            margin-bottom: 2px;
            transition: background 0.15s, color 0.15s;
        }
        .settings-sidebar a:hover {
            background: #e9ecef;
            color: #333;
        }
        .settings-sidebar a.active {
            background: var(--accent-dim);
            color: var(--accent);
            font-weight: 600;
        }
        .settings-content { min-width: 0; }

        /* Card/form/button/toggle styles now in _shared.css.html — gold standard */

        /* ─── Page-specific badges ─── */
        .badge { display: inline-block; padding: 2px 8px; background: #e9ecef; border-radius: 12px; font-size: 12px; }
        .badge-free { background: #e9ecef; color: #333; }
        .badge-starter { background: var(--accent-dim); color: var(--accent); }
        .badge-pro { background: #fef3c7; color: #92400e; }
        .badge-ai { background: #f3e8ff; color: #6b21a8; font-weight: 600; }

        .verified-badge {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 2px 8px;
            background: #dcfce7;
            color: #166534;
            border-radius: 12px;
            font-size: 11px;
            font-weight: 600;
            margin-left: 8px;
        }
        .unverified-badge {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 2px 8px;
            background: #fef3c7;
            color: #92400e;
            border-radius: 12px;
            font-size: 11px;
            font-weight: 600;
            margin-left: 8px;
        }

        /* MOBILE */
        @media (max-width: 640px) {
            .container { padding: 8px; }
            .settings-layout {
                grid-template-columns: 1fr;
            }
            .settings-sidebar {
                position: static;
                display: flex;
                overflow-x: auto;
                gap: 4px;
                padding-bottom: 8px;
                border-bottom: 1px solid #e5e7eb;
            }
            .settings-sidebar a {
                white-space: nowrap;
                padding: 6px 12px;
                margin-bottom: 0;
            }
        }

/* === user_settings_api_keys.html === */
/* Page-level layout (no universal reset — _shared.css.html handles that) */
    .api-keys-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 16px;
    }
    .api-keys-header h2 {
        font-size: 18px;
        margin-bottom: 0;
    }
    .perm-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 24px;
        margin: 12px 0;
    }
    .perm-item {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 14px;
    }
    .perm-item input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }
    .perm-item label {
        cursor: pointer;
    }
    .new-key-display {
        background: #f0f9ff;
        border: 1px solid #93c5fd;
        padding: 16px;
        border-radius: 6px;
        margin-bottom: 16px;
    }
    .new-key-display code {
        font-size: 15px;
        word-break: break-all;
        display: block;
        margin: 8px 0;
        background: white;
        padding: 8px 12px;
        border-radius: 4px;
        border: 1px solid #cbd5e1;
    }
    .new-key-display .copy-btn {
        display: inline-block;
        margin-top: 8px;
        padding: 6px 12px;
        background: var(--accent);
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        font-size: 13px;
        font-family: var(--font);
    }
    .new-key-display .copy-btn:hover {
        background: var(--accent-bright);
    }
    .new-key-display .warning {
        color: #d97706;
        font-size: 12px;
        margin-top: 8px;
    }
    .perm-label {
        font-weight: 600;
        font-size: 14px;
        margin-top: 12px;
        display: block;
    }
    .form-actions {
        display: flex;
        gap: 12px;
        margin-top: 16px;
    }

    .api-keys-table {
        border-collapse: separate;
        border-spacing: 0;
        table-layout: fixed;
        width: 100%;
    }
    .api-keys-table th,
    .api-keys-table td {
        padding: 10px 12px;
        overflow: hidden;
    }
    .api-keys-table th {
        font-weight: 600;
        color: var(--text-muted);
        font-size: 13px;
        border-bottom: 2px solid var(--border);
        background: var(--bg-elevated);
        text-align: left;
        vertical-align: middle;
        white-space: nowrap;
    }
    .api-keys-table td {
        border-bottom: 1px solid var(--border);
        font-size: 14px;
        text-align: left;
        vertical-align: middle;
    }
    /* Column widths */
    .api-keys-table th:nth-child(1),
    .api-keys-table td:nth-child(1) { width: 18%; }
    .api-keys-table th:nth-child(2),
    .api-keys-table td:nth-child(2) { width: 16%; }
    .api-keys-table th:nth-child(3),
    .api-keys-table td:nth-child(3) { width: 20%; }
    .api-keys-table th:nth-child(4),
    .api-keys-table td:nth-child(4) { width: 15%; }
    .api-keys-table th:nth-child(5),
    .api-keys-table td:nth-child(5) { width: 14%; }
    .api-keys-table th:nth-child(6),
    .api-keys-table td:nth-child(6) { width: 17%; }

    .api-keys-table .token {
        display: inline-block;
        font-family: var(--mono);
        background: var(--bg-elevated);
        padding: 2px 6px;
        border-radius: 3px;
        font-size: 12px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        box-sizing: border-box;
    }

    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .back-link {
        display: inline-block;
        margin-bottom: 16px;
        color: var(--accent);
        text-decoration: none;
        font-size: 14px;
    }
    .back-link:hover { text-decoration: underline; }

    .empty {
        text-align: center;
        padding: 40px;
        color: var(--text-muted);
    }

    @media (max-width: 640px) {
        .api-keys-table { display: block; }
        .api-keys-table thead,
        .api-keys-table tbody,
        .api-keys-table tr,
        .api-keys-table th,
        .api-keys-table td { display: block; }
        .api-keys-table thead tr { display: none; }
        .api-keys-table tr {
            padding: 12px 0;
            border-bottom: 2px solid var(--border);
        }
        .api-keys-table td {
            text-align: right;
            padding: 6px 12px;
            border: none;
            position: relative;
            padding-left: 50%;
            white-space: normal;
            overflow: visible;
            text-overflow: clip;
        }
        .api-keys-table td:before {
            content: attr(data-label);
            position: absolute;
            left: 12px;
            font-weight: 600;
            color: var(--text-muted);
            text-align: left;
        }
        .api-keys-table td:nth-child(n) { width: 100%; }
        .api-keys-table td:last-child {
            justify-content: flex-end;
            margin-top: 8px;
            padding-top: 8px;
            border-top: 1px solid var(--border);
        }
        .api-keys-table td:last-child::before { display: none; }
    }
</style>
