*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #F0EEFF;
    --sidebar-bg: #1E0A35;
    --sidebar-text: #E4DAFF;
    --sidebar-muted: #7B6A9E;
    --accent: #7C3AED;
    --accent-hover: #6D28D9;
    --accent-soft: #EDE9FE;
    --text: #1E1030;
    --text-muted: #7C6FA0;
    --border: #E2DAFF;
    --border-strong: #C4B5FD;
    --white: #FFFFFF;
    --output-bg: #FDFCFF;
    --line-height: 32px;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* ══════════════════════════════
   SIDEBAR
══════════════════════════════ */
.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 24px 14px 16px;
    gap: 12px;
    height: 100vh;
    overflow: hidden;
}

.sidebar-header h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 22px;
    letter-spacing: -0.4px;
    line-height: 1;
}

.jot   { color: var(--white); }
.notes { color: #A78BFA; }

.subtitle {
    font-size: 10px;
    color: var(--sidebar-muted);
    margin-top: 4px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
}

.new-note-btn {
    background: rgba(124,58,237,0.15);
    color: #C4B5FD;
    border: 1px solid rgba(124,58,237,0.28);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.new-note-btn:hover {
    background: rgba(124,58,237,0.28);
    color: #EDE9FE;
    border-color: rgba(124,58,237,0.45);
}

.cleans-counter {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    padding: 11px 13px;
    flex-shrink: 0;
}

.cleans-counter-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 7px;
}

.cleans-label {
    font-size: 10px;
    color: var(--sidebar-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cleans-number {
    font-size: 13px;
    font-weight: 700;
    color: var(--white);
}

.cleans-bar-bg {
    width: 100%;
    height: 3px;
    background: rgba(255,255,255,0.07);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 9px;
}

.cleans-bar-fill {
    height: 100%;
    background: #A78BFA;
    border-radius: 2px;
    transition: width 0.4s ease;
}

.styleupgrade-Btn {
    display: flex;
    gap: 5px;
}

.upgrade-btn {
    flex: 1;
    background: none;
    border: 1px solid rgba(167,139,250,0.2);
    color: #8875B0;
    border-radius: 6px;
    padding: 5px 6px;
    font-size: 10px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    text-align: center;
    white-space: nowrap;
}

.upgrade-btn:hover {
    background: rgba(124,58,237,0.2);
    color: #C4B5FD;
    border-color: rgba(167,139,250,0.4);
}

.notes-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.06) transparent;
}

.no-notes {
    font-size: 11px;
    color: var(--sidebar-muted);
    text-align: center;
    padding-top: 28px;
    line-height: 1.9;
}

.no-notes-icon {
    font-size: 20px;
    display: block;
    margin-bottom: 6px;
    opacity: 0.25;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 10px;
}

.footer-copy {
    font-size: 10px;
    color: rgba(255,255,255,0.18);
    font-weight: 500;
    line-height: 1.7;
}

.footer-copy a {
    color: rgba(167,139,250,0.5);
    text-decoration: none;
}

.footer-copy a:hover { color: #A78BFA; }

/* ══════════════════════════════
   NOTE ITEMS
══════════════════════════════ */
.note-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 9px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    gap: 8px;
    user-select: none;
    border: 1px solid transparent;
    margin-bottom: 2px;
}

.note-item:hover { background: rgba(255,255,255,0.05); }
.note-item:active { transform: scale(0.99); }

.note-item.active {
    background: rgba(124,58,237,0.2);
    border-color: rgba(167,139,250,0.3);
}

.note-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow: hidden;
}

.note-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--sidebar-muted);
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s, background 0.15s;
}

.note-item.active .note-dot {
    background: #A78BFA;
    opacity: 1;
    box-shadow: 0 0 5px rgba(167,139,250,0.5);
}

.note-item-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
    flex: 1;
}

.note-item-title {
    font-size: 12px;
    color: rgba(228,218,255,0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 400;
}

.note-item.active .note-item-title {
    color: #EDE9FE;
    font-weight: 600;
}

.note-item-time {
    font-size: 10px;
    color: var(--sidebar-muted);
    opacity: 0.55;
    white-space: nowrap;
}

.note-item.active .note-item-time {
    opacity: 0.85;
    color: #9B82C4;
}

.note-delete-btn {
    background: none;
    border: none;
    color: transparent;
    cursor: pointer;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.1s, background 0.1s;
    font-size: 10px;
}

.note-item:hover .note-delete-btn { color: var(--sidebar-muted); }
.note-delete-btn:hover { color: #ff8080 !important; background: rgba(255,80,80,0.12); }

/* ══════════════════════════════
   MAIN CONTENT
══════════════════════════════ */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-width: 0;
}

.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 52px;
    gap: 0;
    overflow-y: auto;
    min-width: 0;
    background: var(--bg);
}

/* ── Title bar ── */
.editor-top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    height: var(--line-height);
    margin-top: 44px;
    margin-bottom: var(--line-height);
}

.title-input {
    flex: 1;
    border: 1px solid transparent;
    border-radius: 8px;
    background: rgba(124,58,237,0.05);
    font-family: 'DM Serif Display', serif;
    font-size: 24px;
    color: var(--text);
    resize: none;
    outline: none;
    line-height: 1.3;
    height: auto;
    padding: 6px 12px;
    letter-spacing: -0.4px;
    transition: background 0.2s, border-color 0.2s;
}

.title-input:focus {
    background: rgba(124,58,237,0.08);
    border-color: rgba(196,181,253,0.5);
}

.title-input:hover {
    background: rgba(124,58,237,0.07);
}

.title-input::placeholder {
    color: #C4B5FD;
}
.word-count {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
    opacity: 0.6;
    letter-spacing: 0.03em;
}

/* ── Note body ── */
.note-body {
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    min-height: 700px;
    flex: 1;
}

.note-body.shrunk {
    flex: 0 0 200px;
    min-height: 200px;
    border-radius: 8px;
    outline: 1px solid rgba(124,58,237,0.15);
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='24'%3E%3Crect width='120' height='24' rx='12' fill='%237C3AED'/%3E%3Ctext x='60' y='16' font-family='DM Sans,sans-serif' font-size='11' fill='white' text-anchor='middle'%3EClick to expand%3C/text%3E%3C/svg%3E") 60 12, pointer;
    overflow: hidden;
}

.note-body.shrunk:hover { outline-color: var(--accent); }

body.modal-open { overflow: visible; }

/* ── Textarea ── */
.note-textarea {
    width: 100%;
    flex: 1;
    min-height: 660px;
    border: none;
    background-image:
        linear-gradient(to right, transparent 63px, rgba(124,58,237,0.08) 63px, rgba(124,58,237,0.08) 64px, transparent 64px),
        repeating-linear-gradient(
            to bottom,
            transparent,
            transparent 31px,
            rgba(124,58,237,0.065) 31px,
            rgba(124,58,237,0.065) 32px
        );
    background-attachment: local;
    background-color: transparent;
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    line-height: var(--line-height);
    color: var(--text);
    resize: none;
    outline: none;
    padding: 0;
    padding-left: 80px;
}

.note-textarea::placeholder {
    color: #C4B5FD;
}

.note-textarea.shrunk {
    min-height: 100px;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='24'%3E%3Crect width='120' height='24' rx='12' fill='%237C3AED'/%3E%3Ctext x='60' y='16' font-family='DM Sans,sans-serif' font-size='11' fill='white' text-anchor='middle'%3EClick to expand%3C/text%3E%3C/svg%3E") 60 12, pointer;
}

/* ── Loading bar ── */
.loading-bar-container {
    width: 100%;
    height: 2px;
    background: rgba(196,181,253,0.2);
    border-radius: 2px;
    overflow: hidden;
    display: none;
    flex-shrink: 0;
    margin: 4px 0;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), #A78BFA);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ── Output section ── */
.output-section {
    display: none;
    background: transparent;
    border: none !important;
    border-radius: 0;
    overflow: hidden;
    flex-shrink: 0;
    margin: 24px 0;
    box-shadow: none;
}
.output-section.expanded {
    flex-shrink: 1;
    flex: 2;
    overflow-y: auto;
    min-height: 600px;
}

.output-section.shrunk {
    flex: 0 0 180px;
    min-height: 180px;
    overflow: hidden;
    opacity: 0.65;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='24'%3E%3Crect width='120' height='24' rx='12' fill='%237C3AED'/%3E%3Ctext x='60' y='16' font-family='DM Sans,sans-serif' font-size='11' fill='white' text-anchor='middle'%3EClick to expand%3C/text%3E%3C/svg%3E") 60 12, pointer;
}

.output-section.shrunk:hover {
    opacity: 1;
    border-left-color: var(--accent) !important;
    transition: opacity 0.15s, border-color 0.15s;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 10px 0;
    background: transparent;
    border-bottom: none;
    flex-shrink: 0;
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
}

.output-label {
    font-family: 'DM Serif Display', serif;
    font-size: 20px;
    color: var(--accent);
    opacity: 0.7;
    letter-spacing: 0.01em;
}

.output-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.out-btn {
    background: transparent;
    border: 1px solid rgba(196,181,253,0.4);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 4px 11px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.out-btn:hover {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

.output-content {
    padding: 0 0 24px 0;
    overflow-x: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.output-content > * { box-sizing: border-box !important; }

.output-content > div {
    box-shadow: 0 2px 20px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
    border-radius: 10px;
    width: 100%;
    max-width: 850px;
}

/* ── Action bar ── */
.action-bar {
    position: sticky;
    bottom: 0;
    background: rgba(240,238,255,0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 9px 52px;
    margin: 0 -52px;
    z-index: 9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-top: 1px solid rgba(196,181,253,0.35);
}

.action-right {
    display: flex;
    gap: 7px;
    align-items: center;
}

.mic-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 7px 13px;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.mic-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.adv-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 7px;
    padding: 7px 13px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.adv-btn:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--border-strong);
}

.clean-btn {
    background: var(--accent);
    color: var(--white);
    border: none;
    border-radius: 7px;
    padding: 8px 18px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(124,58,237,0.28);
}

.clean-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 14px rgba(124,58,237,0.4);
}

.clean-btn:active { transform: scale(0.98); }
.clean-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Spinner inside clean button */
.btn-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
    flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Export dropdown */
.export-wrapper { position: relative; display: inline-block; }

.export-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(124,58,237,0.12), 0 2px 6px rgba(0,0,0,0.05);
    min-width: 168px;
    z-index: 100;
}

.export-dropdown.open { display: block; }

.export-option {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 15px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    font-family: 'DM Sans', sans-serif;
    text-align: left;
    transition: background 0.12s;
}

.export-option:hover { background: var(--accent-soft); color: var(--accent); }

/* ── Unsaved banner ── */
.unsaved-banner {
    position: fixed;
    bottom: 64px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #1E1030;
    color: #E4DAFF;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    z-index: 998;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    white-space: nowrap;
}

.unsaved-banner.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.unsaved-save-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: background 0.15s;
}

.unsaved-save-btn:hover { background: var(--accent-hover); }

.unsaved-dismiss-btn {
    background: none;
    border: none;
    color: rgba(228,218,255,0.4);
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}

.unsaved-dismiss-btn:hover { color: rgba(228,218,255,0.8); }


.action-save-btn {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--accent);
    border-radius: 7px;
    padding: 7px 13px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.action-save-btn:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}
/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #1E1030;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.22);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ══════════════════════════════
   RESPONSIVE
══════════════════════════════ */
@media (max-width: 1200px) {
    .sidebar { width: 200px; }
    .editor-area { padding: 0 32px; }
    .action-bar { margin: 0 -32px; padding: 9px 32px; }
}

@media (max-width: 900px) {
    .sidebar { width: 160px; }
    .editor-area { padding: 0 20px; }
    .title-input { font-size: 20px; }
    .action-bar { margin: 0 -20px; padding: 9px 20px; }
}

body.modal-open { overflow: visible; }
.output-content [contenteditable]:empty { display: none; }

/* ══════════════════════════════
   JN OUTPUT
══════════════════════════════ */
.jn-output {
    font-family: Calibri, sans-serif;
    font-size: 15.5px;
    line-height: 1.85;
    color: #1a1a1a;
    width: 100%;
    max-width: 660px;
    margin: 0 auto;
    padding: 36px 44px;
    background: #ffffff;
    border-radius: 10px;
}

.jn-output h1 {
    font-family: Calibri, sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    border-bottom: 2px solid #222;
    margin-top: 0;
    margin-bottom: 20px;
    letter-spacing: -0.3px;
}

.jn-output h2 {
    font-family: Calibri, sans-serif;
    font-size: 19px;
    font-weight: 600;
    color: #222;
    margin-top: 28px;
    margin-bottom: 10px;
    letter-spacing: -0.2px;
}

.jn-output h3 {
    font-family: Calibri, sans-serif;
    font-size: 17px;
    font-weight: 600;
    color: #444;
    text-decoration: underline;
    margin-top: 18px;
    margin-bottom: 6px;
}

.jn-output p {
    font-family: Calibri, sans-serif;
    font-size: 15.5px;
    line-height: 1.85;
    color: #1a1a1a;
    margin-bottom: 10px;
}

.jn-output ul, .jn-output ol {
    font-family: Calibri, sans-serif;
    font-size: 15.5px;
    line-height: 1.85;
    padding-left: 22px;
    margin-bottom: 12px;
    color: #1a1a1a;
}

.jn-output li { font-family: Calibri, sans-serif; font-size: 15.5px; line-height: 1.85; color: #1a1a1a; }

.jn-output .jn-pill { background: #f0f0f0; border-radius: 4px; padding: 2px 6px; font-size: 15.5px; font-weight: 600; font-family: Calibri, sans-serif; }

.jn-output .jn-callout { font-family: Calibri, sans-serif; font-size: 15.5px; padding: 12px 16px; margin: 16px 0; }
.jn-output .jn-callout-exam      { background: #fff5f5; border-left: 4px solid #e53e3e; }
.jn-output .jn-callout-def       { background: #ebf8ff; border-left: 4px solid #3182ce; }
.jn-output .jn-callout-important { background: #fffff0; border-left: 4px solid #d69e2e; }
.jn-output .jn-divider { border-top: 1px solid #eee; margin: 20px 0; }

.jn-output table { width: 100%; border-collapse: collapse; font-size: 15.5px; font-family: Calibri, sans-serif; margin-bottom: 12px; border: 1.5px solid #c4b5fd; }
.jn-output table td, .jn-output table th { border: 1px solid #e0e0e0; padding: 10px 14px; font-size: 15.5px; font-family: Calibri, sans-serif; color: #1a1a1a; }
.jn-output table th { background: #f0ecff; color: #3B1F6B; font-weight: 700; border-bottom: 2px solid #c4b5fd; }
.jn-output table tr:nth-child(even) td { background: #faf9ff; }
.jn-output table tr:nth-child(odd) td  { background: #ffffff; }
.jn-output table tr:hover td           { background: #f0ecff; transition: background 0.12s; }
.jn-output table tr:not(:has(th)) td:first-child { font-weight: 600; }

.jn-output .jn-indent { margin-left: 24px; border-left: 2px solid #eee; padding-left: 12px; }
.jn-output .jn-continuation { padding-left: 16px; color: #444; }
.jn-output .jn-quote { font-size: 15.5px; font-style: italic; color: #444; border-left: 3px solid #222; padding: 8px 16px; margin: 16px 0; }
.jn-output .jn-date    { float: right; font-size: 15.5px; color: #999; }
.jn-output .jn-speaker { font-variant: small-caps; color: #444; font-weight: 600; }
.jn-output mark.jn-highlight { background: #fef08a; color: #1a1a1a; border-radius: 2px; padding: 0 2px; }

/* ══════════════════════════════
   MODAL
══════════════════════════════ */

.pref-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(12,4,24,0.6);
    backdrop-filter: blur(6px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.pref-overlay.open { display: flex; }

.pref-modal {
    background: #fff;
    border-radius: 16px;
    padding: 22px 26px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 24px 64px rgba(124,58,237,0.22);
    max-height: 90vh;
    overflow-y: auto;
}

.pref-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.pref-title {
    font-family: 'DM Serif Display', serif;
    font-size: 19px;
    color: var(--text);
}

.pref-close {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 7px;
    border-radius: 6px;
    transition: background 0.15s;
    line-height: 1;
}

.pref-close:hover { background: var(--accent-soft); color: var(--accent); }

.pref-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 14px;
    line-height: 1.5;
}

.pref-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.pref-delete-btn:hover { color: #ef4444; }

.pref-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.pref-radio-group {
    display: flex;
    gap: 5px;
    margin-bottom: 12px;
}

.pref-radio-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: 7px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--white);
    transition: border-color 0.15s, background 0.15s;
    flex: 1;
}

.pref-radio-option:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}


.pref-enhance-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 9px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--white);
    transition: border-color 0.15s, background 0.15s;
    width: 100%;
    margin-bottom: 4px;
}

.pref-enhance-label:hover {
    border-color: var(--border-strong);
    background: var(--output-bg);
}

.pref-enhance-label:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.pref-enhance-label input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.pref-enhance-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: rgba(124, 58, 237, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.pref-enhance-label:has(input:checked) .pref-enhance-icon {
    background: rgba(124, 58, 237, 0.15);
}

.pref-enhance-text { flex: 1; }

.pref-enhance-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.pref-enhance-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
    line-height: 1.4;
}

.pref-enhance-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 100px;
    padding: 2px 8px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.pref-enhance-label:has(input:checked) .pref-enhance-badge {
    opacity: 1;
}

.pref-radio-option input[type="radio"] { display: none; }

.pref-radio-option .pref-toggle-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.pref-toggles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 4px;
}

.pref-toggle-compact {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 9px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    color: var(--text);
    transition: background 0.12s;
}

.pref-toggle-compact:hover { background: var(--bg); }

.pref-toggle-compact input[type="checkbox"] {
    width: 13px;
    height: 13px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.pref-toggle-group {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 9px 11px;
    margin-bottom: 4px;
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pref-group-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.pref-clean-btn {
    width: 100%;
    padding: 11px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 9px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
    margin-top: 6px;
    box-shadow: 0 2px 8px rgba(124,58,237,0.28);
}

.pref-clean-btn:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(124,58,237,0.38); }
.pref-clean-btn:active { transform: scale(0.98); }

.pref-divider { height: 1px; background: var(--border); margin: 14px 0 10px; }

.pref-premium-tag {
    background: linear-gradient(135deg, #7C3AED, #9D4EDD);
    color: white;
    border-radius: 100px;
    padding: 2px 7px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.pref-personal { display: flex; flex-direction: column; gap: 4px; margin-bottom: 7px; min-height: 18px; }

.pref-personal-empty {
    font-size: 12px;
    color: var(--text-muted);
    padding: 3px 2px;
}

.pref-add-btn {
    background: none;
    border: 1px dashed var(--border-strong);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    margin-bottom: 8px;
}

.pref-add-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.pref-create-form {
    display: none;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 10px;
    background: var(--bg);
    border-radius: 9px;
    padding: 12px;
}

.pref-create-form.open { display: flex; }

.pref-input {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    color: var(--text);
    background: var(--white);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.pref-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,0.07); }

textarea.pref-input { resize: vertical; min-height: 64px; line-height: 1.5; }

.pref-create-actions { display: flex; gap: 7px; }

.pref-save-option-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 7px;
    padding: 6px 14px;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.pref-save-option-btn:hover { background: var(--accent-hover); }

.pref-cancel-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 7px;
    padding: 6px 14px;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: border-color 0.15s;
}

.pref-cancel-btn:hover { border-color: var(--text-muted); }

.pref-toggle-info { display: flex; flex-direction: column; gap: 2px; }

.pref-toggle-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.pref-toggle-desc {
    font-size: 11px;
    color: var(--text-muted);
}
.credits-display {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.credits-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.credits-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.credits-count {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.credits-count.credits--warning { color: #f97316; }
.credits-count.credits--over    { color: #ef4444; }

.credits-bar-bg {
    width: 100%;
    height: 4px;
    background: rgba(124,58,237,0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.credits-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease, background 0.3s;
}

.credits-sub {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}