:root {
    --bg-dark: #0a0514;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glow-color: #7b2cbf;
    --text-main: #ffffff;
    --text-muted: #a09eb0;

    /* PWA Padding Adjustments */
    --pwa-gap: 25px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* --- Glowing Orbs Background --- */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: drift 20s infinite alternate ease-in-out;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: #4cc9f0;
    top: -10%;
    left: -10%;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: #7209b7;
    bottom: -20%;
    right: -10%;
    animation-delay: -5s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: #f72585;
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 50px) scale(1.1);
    }
}

/* --- Layout --- */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: calc(24px + env(safe-area-inset-top, 0px)) 20px calc(40px + env(safe-area-inset-bottom, 0px));
    transition: max-width 0.3s ease;
}

/* Extra safety for iOS Home Screen app (standalone mode) */
@media screen and (max-width: 600px) and (display-mode: standalone) {
    .container {
        padding-top: calc(70px + env(safe-area-inset-top, 0px));
    }
}

.ios-pwa .container {
    padding-top: calc(var(--pwa-gap) + env(safe-area-inset-top, 0px)) !important;
}

@media (min-width: 1000px) {
    .container {
        max-width: 95%;
        padding-left: 40px;
        padding-right: 40px;
    }
}

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.full-width {
    width: 100%;
}

/* --- Glassmorphism Cards & Antigravity --- */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 18px 24px;
    margin-bottom: 0px;
    /* Managed by grid gap now */
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease, border-color 0.4s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden; /* Ensure countdown bar doesn't bleed out of rounded corners */
}

.variable-status-icon {
    position: absolute;
    right: 16px;
    bottom: 14px;
    left: auto;
    width: 12px;
    height: 12px;
    color: var(--text-muted);
    opacity: 0.2;
    pointer-events: none;
    z-index: 5;
    flex-shrink: 0;
    transition: opacity 0.3s ease, color 0.3s ease;
}

.variable-status-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Reserve a clear bottom strip so the icon never sits on title, tags, or actions */
.glass-card:has(.variable-status-icon) {
    padding-bottom: 42px;
}

.glass-card.expanded:has(.variable-status-icon) .card-body-footer {
    padding-right: 36px;
    margin-bottom: 6px;
}

.glass-card:hover .variable-status-icon {
    opacity: 1.0;
    color: #fdffff;
    /* transform: scale(1.5); */
}

.glass-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 45px rgba(123, 44, 191, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* --- Temporary Highlight for Copied Cards --- */
.glass-card.recently-copied {
    border: 4px solid #006400 !important;
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.15), rgba(0, 100, 0, 0.15));
    box-shadow: 0 0 20px rgba(0, 100, 0, 0.2);
}

.glass-card.recently-copied:hover {
    border: 4px solid #006400 !important;
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.25), rgba(0, 100, 0, 0.25));
    box-shadow: 0 15px 45px rgba(0, 100, 0, 0.35);
}

/* --- Login / Auth Section --- */
#auth-section {
    margin-top: 15vh;
    margin-left: auto;
    margin-right: auto;
    max-width: 480px;
    padding: 60px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#auth-section h2 {
    font-size: 2.2rem;
    background: linear-gradient(to right, #ffffff, #4cc9f0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

#auth-section p {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 25px;
}

#login-btn {
    padding: 16px 40px;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* --- Forms & Inputs --- */
input[type="text"],
textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s, height 0.1s ease;
    resize: none;
    overflow-y: hidden;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--glow-color);
    box-shadow: 0 0 15px rgba(123, 44, 191, 0.4);
}

/* Modal Groups */
.category-row {
    margin-bottom: 20px;
}

.modal-category-selection {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: center;
}

#modal-category-select {
    flex: 1;
    margin-bottom: 0;
    color-scheme: dark;
    background-color: #120c1c;
    color: #f5f5f7;
}

#modal-category-select option,
#modal-category-select optgroup {
    color-scheme: dark;
    background-color: #120c1c;
    color: #f5f5f7;
}

#modal-category-select option:checked,
#modal-category-select option:hover {
    background-color: #2a1848;
    color: #ffffff;
}

.plus-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
}

.error-msg {
    color: #f72585;
    /* Vibrant pink */
    font-size: 0.85rem;
    margin-bottom: 12px;
    margin-top: 4px;
    /* Added spacing */
    font-weight: 500;
    width: 100%;
    /* Force wrap inside flex-wrap container */
}

.error-msg.hidden {
    display: none;
}

.plus-btn:hover {
    background: var(--glass-bg);
    border-color: var(--glow-color);
    box-shadow: 0 0 15px rgba(123, 44, 191, 0.4);
}

/* --- Dynamic Additional Blocks (Modal) --- */
.add-block-actions {
    display: flex;
    flex-wrap: wrap;
    /* Ensure buttons wrap if needed */
    gap: 12px;
    margin: 10px 0 20px;
}

.dynamic-block-item {
    position: relative;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 12px;
    animation: fadeIn 0.3s forwards;
}

.dynamic-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.dynamic-block-header label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.remove-block-btn {
    background: transparent;
    border: none;
    color: #f72585;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.remove-block-btn:hover {
    opacity: 1;
}

.dynamic-block-item textarea {
    margin-bottom: 0;
    font-size: 0.95rem;
    padding: 10px;
}

.dynamic-block-item textarea.code-textarea {
    font-family: monospace;
    color: #a8dadc;
    background: rgba(0, 0, 0, 0.3);
}

.block-title-input {
    margin-bottom: 8px;
    padding: 10px 12px;
    font-size: 0.9rem;
}

/* --- Responsive Visibility --- */
.mobile-only {
    display: none !important;
}

@media (max-width: 600px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: inline-flex !important;
    }
}

/* --- Buttons --- */
.glow-btn {
    background: linear-gradient(135deg, #7209b7, #3a0ca3);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(114, 9, 183, 0.5);
}

.glow-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 20px rgba(114, 9, 183, 0.8), 0 0 40px rgba(76, 201, 240, 0.4);
}

.glow-btn:disabled {
    opacity: 0.5 !important;
    filter: grayscale(1) !important;
    cursor: not-allowed !important;
    background: #444 !important;
    box-shadow: none !important;
    transform: none !important;
}

.outline-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.outline-btn:hover {
    color: white;
    border-color: white;
    background: rgba(255, 255, 255, 0.1);
}

/* --- Header Layout --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px;
    margin-bottom: 32px;
    /* Prevent touching on hover */
    flex-wrap: wrap;
    gap: 24px 32px;
    /* Row gap and column gap */
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--glow-color);
}

/* --- Displayed Prompts --- */
.category-with-color {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    /* Allow wrapping for error messages */
    gap: 10px;
    width: 100%;
}

#prompt-category {
    flex: 1;
    margin-bottom: 16px;
}

.color-controls {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.color-controls input[type="color"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 38px;
    height: 48px;
    background-color: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    flex-shrink: 0;
}

.color-controls input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-controls input[type="color"]::-webkit-color-swatch {
    border: none;
}

.prompt-tag {
    display: inline-block;
    background: rgba(76, 201, 240, 0.2);
    color: #4cc9f0;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 12px;
    border: 1px solid transparent;
}

.prompt-code-block {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    padding: 15px;
    border-radius: 8px;
    font-family: monospace;
    color: #a8dadc;
    margin-top: 10px;
    overflow-x: auto;
    position: relative;
    transition: border-color 0.3s;
}

.prompt-code-block:hover {
    border-color: var(--glow-color);
}

.code-content {
    white-space: pre;
    font-size: 0.9rem;
}

.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 5;
}

.prompt-code-block:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover,
.block-copy-btn:hover {
    background: var(--glow-color);
    color: white;
}

.code-copy-btn.copied,
.block-copy-btn.copied {
    background: #06d6a0;
    color: white;
    opacity: 1;
}

.expanded .code-copy-btn {
    opacity: 1;
}

.inline-copy-icon {
    width: 14px;
    height: 14px;
    display: block;
}


/* --- Custom Modern Slider --- */
.slider-group {
    margin-bottom: 20px;
}

.slider-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 12px;
    /* Thicker track */
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

input[type="range"]::-webkit-slider-thumb {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #4cc9f0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    margin-top: -5px;
    /* Center thumb */
    box-shadow: 0 0 10px rgba(76, 201, 240, 0.6);
}

/* --- Header Actions --- */
.header-actions {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.small-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
}

#export-btn:hover,
#import-trigger-btn:hover {
    border-color: #4cc9f0;
    color: #4cc9f0;
}

.burger-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
}

.burger-btn:hover {
    background: var(--glass-bg);
    border-color: var(--glow-color);
}

/* --- Mobile Menu Overlay --- */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 5, 20, 0.95);
    backdrop-filter: blur(20px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mobile-nav-content {
    width: 85%;
    max-width: 350px;
    padding: 30px;
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.mobile-nav-links .outline-btn {
    padding: 15px;
    font-size: 1.1rem;
    text-align: center;
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    /* Slightly increased blur for depth */
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    /* Ensure it covers everything including the header */
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

.modal-content {
    width: 95%;
    max-width: 900px;
    max-height: 95vh;
    overflow-y: auto;
    margin-bottom: 0;
    /* Reset margin from glass-card */
    transform: scale(0.9);
    animation: scaleUp 0.3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 0 50px 50px;
    padding-bottom: calc(50px + env(safe-area-inset-bottom, 0px));
}

.slim-modal {
    max-width: 550px !important;
    min-height: 450px;
}
    /* Search Highlighting */
mark.search-highlight {
    background: rgba(123, 44, 191, 0.4);
    color: #fff;
    border-radius: 2px;
    padding: 0 2px;
    font-weight: 600;
}

/* FAB Scroll to Top */
.fab-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--glow-color);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 1;
}

.fab-btn:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 8px 25px rgba(123, 44, 191, 0.5);
}

.fab-btn.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
}

/* Shortcut Legend */
.shortcut-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.shortcut-item kbd {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: white;
    min-width: 30px;
    text-align: center;
}

.shortcut-item span {
    flex: 1;
}

/* Help & Variable Explanations */
.help-section {
    margin-top: 25px;
    border-top: 1px solid var(--glass-border);
    padding-top: 20px;
}

.help-section h4 {
    margin-bottom: 12px;
    color: var(--glow-color);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.help-description {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.5;
}

.variable-type {
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 3px solid #4cc9f0;
}

.variable-type strong {
    color: #4cc9f0;
    display: block;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.variable-type p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.variable-example {
    display: block;
    font-family: monospace;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #a8dadc;
    border: 1px solid rgba(168, 218, 220, 0.2);
}

/* Variable Placeholder improvement */
.prompt-input:empty::before {
    content: attr(data-placeholder);
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
}
    scrollbar-width: thin;
    scrollbar-color: var(--glow-color) rgba(255, 255, 255, 0.05);
}

.ios-pwa .modal-content {
    padding-top: calc(var(--pwa-gap) - 20px + env(safe-area-inset-top, 0px)) !important;
}

.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--glow-color);
    border-radius: 10px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 10, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    margin-left: -50px;
    margin-right: -50px;
    padding: calc(30px + env(safe-area-inset-top, 0px)) 50px 20px;
    border-bottom: 1px solid var(--glass-border);
}

/* Specific help/shortcut modal styling */
#shortcut-modal .shortcut-list {
    padding-top: 10px;
}

.close-btn {
    background: rgba(247, 37, 133, 0.1);
    border: 1px solid rgba(247, 37, 133, 0.4);
    color: #f72585;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
    line-height: 1;
}

.close-btn:hover {
    background: #f72585;
    color: white;
    border-color: #f72585;
    box-shadow: 0 0 15px rgba(247, 37, 133, 0.4);
}

/* --- Copy Button Specifics --- */
.card-header-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
    transition: margin-bottom 0.3s ease;
}

.expanded .card-header-main {
    margin-bottom: 0px;
}

.glass-card h3 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    flex: 1;
    word-break: break-word;
    /* Ensure titles wrap on mobile */
    overflow-wrap: break-word;
}

.prompt-body {
    flex: 1;
}

.card-tag-row {
    margin-top: 15px;
    display: flex;
    justify-content: flex-start;
}
.card-header-actions {
    display: grid;
    grid-template-columns: repeat(2, 36px);
    grid-auto-rows: 36px;
    gap: 8px;
    justify-content: end;
    align-items: center;
    flex-shrink: 0;
    margin-left: 16px;
    transition: all 0.3s ease;
}

/* Ensure Expand and Pin have stable grid positions */
.pin-btn {
    grid-column: 1;
    grid-row: 1;
}

.expand-btn {
    grid-column: 2;
    grid-row: 1;
}

/* Caret Rotation */
.caret-icon {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.expanded .caret-icon {
    transform: rotate(180deg);
}



.copy-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
}

.copy-btn.copied {
    background: #4cc9f0;
    color: #0a0514;
    border-color: #4cc9f0;
    font-weight: 600;
}

/* --- Countdown Bar for Delayed Reordering --- */
.countdown-bar-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    z-index: 20;
    overflow: hidden;
}

.countdown-bar {
    height: 100%;
    width: 100%;
    background: var(--glow-color);
    transform-origin: left;
    animation: countdown-shrink linear forwards;
}

@keyframes countdown-shrink {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}


@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes scaleUp {
    to {
        transform: scale(1);
    }
}

/* --- Card Actions --- */
.card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.edit-btn, .duplicate-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.edit-btn:hover, .duplicate-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.duplicate-btn:hover {
    color: #4cc9f0;
    border-color: #4cc9f0;
}

.edit-btn, .duplicate-btn {
    display: none !important;
}

.expanded .edit-btn, .expanded .duplicate-btn {
    display: flex !important;
}


.action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.edit-btn:hover {
    background: rgba(30, 144, 255, 0.2) !important;
    color: white !important;
    border-color: #1e90ff !important;
}

.action-btn {
    width: 100%;
    justify-content: center;
    white-space: nowrap;
}

.expand-btn, .copy-btn, .pin-btn, .edit-btn, .visit-btn, .history-btn, .duplicate-btn, .archive-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important; /* Override any min-width */
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px !important;
    flex-shrink: 0;
}

.copy-icon-svg, .edit-icon-svg, .shortcut-icon-svg, .archive-icon-svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.shortcut-icon-svg {
    width: 15px;
    height: 15px;
}

.copy-btn.copied {
    background: #06d6a0 !important;
    color: #0a0514 !important;
    border-color: #06d6a0 !important;
    box-shadow: 0 0 15px rgba(6, 214, 160, 0.4) !important;
}

.modal-footer-actions {
    display: flex;
    gap: 12px;
    width: calc(100% + 80px);
    /* Compensate for modal padding */
    margin-top: 24px;
    position: sticky;
    bottom: calc(-30px - env(safe-area-inset-bottom, 0px));
    /* Match safe area inset */
    z-index: 100;
    background: rgba(10, 5, 20, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin-left: -40px;
    margin-right: -40px;
    padding: 20px 40px calc(20px + env(safe-area-inset-bottom, 0px));
    margin-bottom: calc(-30px - env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--glass-border);
}

.modal-footer-actions .glow-btn {
    flex: 1;
}

.danger-btn {
    background: linear-gradient(135deg, #f72585, #b5179e) !important;
    box-shadow: 0 0 15px rgba(247, 37, 133, 0.4) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.danger-btn:hover {
    box-shadow: 0 0 25px rgba(247, 37, 133, 0.7) !important;
    transform: translateY(-2px);
}

/* --- Danger Modal Theme --- */
.danger-border {
    border: 1px solid rgba(247, 37, 133, 0.4);
    box-shadow: 0 8px 32px 0 rgba(247, 37, 133, 0.2);
}

.danger-btn {
    background: linear-gradient(135deg, #f72585, #b5179e);
    box-shadow: 0 0 15px rgba(247, 37, 133, 0.4);
}

.danger-btn:hover {
    box-shadow: 0 0 25px rgba(247, 37, 133, 0.7);
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    gap: 24px;
    padding: 20px 30px;
    margin-bottom: 32px;
    align-items: center;
    flex-wrap: wrap;
    flex-direction: column;
    /* Use column to support row grouping */
}

.filter-row {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.filter-row:nth-child(2) {
    margin-top: 12px;
    /* Added padding/margin above filters and sort */
}

.sort-group {
    flex-shrink: 0;
}

.glass-select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
    min-width: 180px;
}

.glass-select:focus {
    border-color: var(--glow-color);
    box-shadow: 0 0 15px rgba(123, 44, 191, 0.4);
}

.glass-select option {
    background-color: #0f0a1f;
    color: white;
    padding: 10px;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.category-pills {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.category-pill {
    background: var(--pill-bg, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--glass-border);
    color: var(--pill-text, var(--text-muted));
    padding: 8px 18px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    opacity: 0.7;
}

.category-pill:hover {
    background: var(--pill-bg, rgba(255, 255, 255, 0.1));
    color: var(--pill-text, white);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    opacity: 1;
}

.category-pill.active {
    background: var(--pill-bg, var(--glow-color));
    color: var(--pill-text, white);
    border-color: var(--pill-bg, var(--glow-color));
    box-shadow: 0 0 20px var(--pill-bg, rgba(123, 44, 191, 0.4));
    transform: translateY(-1px);
    opacity: 1;
}

.prompt-count-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.3px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    width: 100%;
    /* Forced to its own line in the flex container */
    text-align: center;
    margin-top: 10px;
}

.search-group {
    flex: 2;
}

.filter-group {
    flex: 1;
}

.filter-bar input,
.filter-bar select {
    margin-bottom: 0;
    /* Reset from general input styles */
}

select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 14px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    transition: all 0.3s;
}

select:focus {
    outline: none;
    border-color: var(--glow-color);
    box-shadow: 0 0 15px rgba(123, 44, 191, 0.4);
}

@media (max-width: 600px) {
    .filter-bar {
        flex-direction: column;
        gap: 12px;
        padding: 20px;
    }

    .search-group,
    .filter-group {
        width: 100%;
    }
}

/* --- Inline Prompt Inputs (Fill-in-the-Blanks) --- */
.prompt-input {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-bottom: 2px solid var(--glow-color);
    color: #4cc9f0;
    /* Match prompt-tag color for highlights */
    font-family: inherit;
    font-size: 0.95rem;
    padding: 2px 8px;
    margin: 0 4px;
    border-radius: 4px 4px 0 0;
    min-width: 60px;
    max-width: 100%;
    box-sizing: border-box;
    transition: all 0.3s ease;
    display: inline-block;
    vertical-align: baseline;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}

.prompt-input:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.5;
    pointer-events: none;
}

.prompt-input:focus {
    outline: none;
    background: rgba(123, 44, 191, 0.15);
    border-bottom-color: #4cc9f0;
    box-shadow: 0 4px 10px rgba(76, 201, 240, 0.2);
}

.prompt-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.5;
}

/* --- Variable Suggestions Dropdown --- */
.prompt-variable-wrapper {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
    margin: 0 4px;
}

.prompt-variable-wrapper .prompt-input {
    margin: 0;
    border-radius: 4px 0 0 0;
}

.suggestions-toggle {
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 2px solid var(--glow-color);
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 0 8px;
    margin: 0;
    border-radius: 0 4px 0 0;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.suggestions-toggle:hover {
    background: rgba(123, 44, 191, 0.2);
    color: #4cc9f0;
}

.suggestions-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: rgba(15, 10, 25, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    min-width: 150px;
    max-width: 300px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    padding: 4px;
    text-align: left;
}

.suggestions-menu.hidden {
    display: none !important;
}

.suggestion-item {
    padding: 8px 12px;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: inherit;
}

.suggestion-item:hover {
    background: rgba(123, 44, 191, 0.4);
    color: #ffffff;
}

/* Top-of-card mirrors for inline variables */
.variable-mirror-bar {
    position: sticky;
    top: 0;
    z-index: 6;
    margin: 4px 0 16px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(14, 10, 24, 0.94);
    border: 1px solid rgba(196, 181, 253, 0.28);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.variable-mirror-heading {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #c4b5fd;
    margin-bottom: 10px;
}

.variable-mirror-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}

.variable-mirror-row + .variable-mirror-row {
    margin-top: 12px;
}

.variable-mirror-label {
    width: 100%;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-main);
    word-break: break-word;
}

.variable-mirror-field,
.variable-mirror-row > .variable-mirror-input {
    width: 100%;
    min-width: 0;
}

.variable-mirror-field .prompt-variable-wrapper {
    display: flex;
    width: 100%;
    margin: 0;
}

.variable-mirror-input {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-bottom: 2px solid var(--glow-color);
    color: #4cc9f0;
    font-family: inherit;
    font-size: 0.95rem;
    padding: 6px 8px;
    border-radius: 4px 4px 0 0;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}

.variable-mirror-field .variable-mirror-input {
    flex: 1;
    width: auto;
    border-radius: 4px 0 0 0;
}

.variable-mirror-input:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.5;
    pointer-events: none;
}

.variable-mirror-input:focus {
    outline: none;
    background: rgba(123, 44, 191, 0.15);
    border-bottom-color: #4cc9f0;
    box-shadow: 0 4px 10px rgba(76, 201, 240, 0.2);
}

/* --- QoL Features --- */
.counters {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: -10px;
    margin-bottom: 15px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#clear-search-btn {
    position: absolute;
    right: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-muted);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

#clear-search-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* --- Pinning Styles --- */

.pin-btn,
.edit-btn {
    display: none !important; /* Hidden by default */
    background: transparent !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-muted) !important;
}

.pin-btn.active {
    background: rgba(255, 215, 0, 0.1) !important;
    border-color: #ffd700 !important;
}

.pin-btn:hover {
    background: rgba(255, 215, 0, 0.1) !important;
    border-color: #ffd700 !important;
    color: #ffd700 !important;
}

.expanded .pin-btn,
.expanded .edit-btn {
    display: flex !important; /* Show when expanded */
}

.pin-icon-svg {
    width: 20px;
    height: 20px;
    fill: #ffffff;
    /* Black when not pinned per request */
    transition: all 0.3s ease;
}

.pin-btn:hover .pin-icon-svg {
    fill: var(--glow-color);
    transform: rotate(-15deg) scale(1.1);
}

.pin-btn.active .pin-icon-svg {
    fill: #ffd700;
    /* Yellow when pinned */
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.8));
    /* Yellow glow */
    transform: rotate(-45deg);
}

.pinned-card {
    border: 4px solid #fb00ff !important;
    box-shadow: 0 8px 32px 0 rgba(255, 215, 0, 0.15) !important;
}

.pinned-card:hover {
    box-shadow: 0 15px 45px rgba(255, 215, 0, 0.25) !important;
}

.newly-added-card {
    border: 4px solid #ffd700 !important;
    box-shadow: 0 8px 32px 0 rgba(255, 215, 0, 0.2) !important;
}

.newly-added-card:hover {
    box-shadow: 0 15px 45px rgba(255, 215, 0, 0.35) !important;
}

/* --- Dual State Combinations --- */

/* Pinned + Recently Copied */
.pinned-card.recently-copied {
    border: 4px solid #fb00ff !important;
    box-shadow: inset 0 0 0 4px #006400, 0 8px 32px 0 rgba(0, 100, 0, 0.2) !important;
}
.pinned-card.recently-copied:hover {
    box-shadow: inset 0 0 0 4px #006400, 0 15px 45px rgba(0, 100, 0, 0.3) !important;
}

/* Pinned + Newly Added */
.pinned-card.newly-added-card {
    border: 4px solid #fb00ff !important;
    box-shadow: inset 0 0 0 4px #ffd700, 0 8px 32px 0 rgba(255, 215, 0, 0.2) !important;
}
.pinned-card.newly-added-card:hover {
    box-shadow: inset 0 0 0 4px #ffd700, 0 15px 45px rgba(255, 215, 0, 0.35) !important;
}

/* Recently Copied + Newly Added */
.newly-added-card.recently-copied {
    border: 4px solid #006400 !important;
    box-shadow: inset 0 0 0 4px #ffd700, 0 8px 32px 0 rgba(0, 100, 0, 0.2) !important;
}
.newly-added-card.recently-copied:hover {
    box-shadow: inset 0 0 0 4px #ffd700, 0 15px 45px rgba(0, 100, 0, 0.3) !important;
}

/* --- Triple State Combination --- */

/* Pinned + Recently Copied + Newly Added */
.pinned-card.recently-copied.newly-added-card {
    border: 4px solid #fb00ff !important;
    box-shadow: inset 0 0 0 4px #006400, inset 0 0 0 8px #ffd700, 0 8px 32px 0 rgba(0, 100, 0, 0.2) !important;
}
.pinned-card.recently-copied.newly-added-card:hover {
    box-shadow: inset 0 0 0 4px #006400, inset 0 0 0 8px #ffd700, 0 15px 45px rgba(0, 100, 0, 0.3) !important;
}

/* --- Archival Styles --- */
.archived-card {
    border: 2px solid #8FBC8F !important;
}

.archived-card h3,
.archived-card .card-tag-container,
.archived-card .prompt-body,
.archived-card .variable-status-icon {
    opacity: 0.3 !important;
    transition: opacity 0.3s ease;
}

.archived-card:hover h3,
.archived-card:hover .card-tag-container,
.archived-card:hover .card-time-meta,
.archived-card:hover .prompt-body,
.archived-card:hover .variable-status-icon {
    opacity: 0.8 !important;
}

.archive-btn {
    display: none !important;
    background: transparent !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-muted) !important;
}

.expanded .archive-btn {
    display: flex !important;
}

.archive-btn:hover {
    background: rgba(143, 188, 143, 0.1) !important;
    border-color: #8FBC8F !important;
    color: #8FBC8F !important;
}

.archive-btn.archived {
    background: rgba(143, 188, 143, 0.2) !important;
    border-color: #8FBC8F !important;
    color: #8FBC8F !important;
}

/* --- Metadata Section --- */
.modal-metadata {
    margin: 15px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-metadata p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
    display: flex;
    justify-content: space-between;
}

.modal-metadata p span {
    color: #4cc9f0;
    font-weight: 600;
}

/* --- Import Stats Modal --- */
.import-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.stat-line {
    font-size: 1.05rem;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
}

.stat-icon {
    width: 20px;
    height: 20px;
    fill: #4cc9f0;
}

.stat-line span {
    color: #4cc9f0;
    /* Electric blue for counts */
    font-size: 1.2rem;
    font-weight: 600;
}

/* --- Slim Modal Utility --- */
.slim-modal {
    max-width: 450px !important;
}

/* --- Reorder List --- */
.reorder-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 50vh;
    overflow-y: auto;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
}

.reorder-item {
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    transition: background 0.2s;
    user-select: none;
}

.reorder-item:last-child {
    border-bottom: none;
}

.reorder-item:active {
    cursor: grabbing;
}

.reorder-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.reorder-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 15px;
}

.drag-handle {
    color: var(--text-muted);
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* SortableJS Ghost Classes */
.sortable-ghost {
    opacity: 0.3;
    background: var(--glow-color) !important;
}

.sortable-chosen {
    background: rgba(255, 255, 255, 0.1);
}

.sortable-drag {
    background: var(--glass-bg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glow-color);
    border-radius: 12px;
}

/* --- Collapsible Prompt Body --- */
.prompt-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1), opacity 0.3s ease, margin-top 0.3s ease;
    margin-top: 0;
}

.expanded .prompt-body {
    max-height: 5000px;
    /* Large enough to fit content */
    opacity: 1;
    transition: max-height 0.4s cubic-bezier(1, 0, 1, 0), opacity 0.4s ease, margin-top 0.4s ease;
    margin-top: 4px;
    overflow-y: auto;
    /* Fallback for very long content */
}

/* Custom scrollbar for prompt-body when height is constrained */
.prompt-body::-webkit-scrollbar {
    width: 4px;
}

.prompt-body::-webkit-scrollbar-track {
    background: transparent;
}

.prompt-body::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.card-body-footer {
    display: none;
    /* Only show when expanded */
    margin-top: 20px;
    justify-content: flex-end;
    border-top: 1px dashed var(--glass-border);
    padding-top: 12px;
}

.expanded .card-body-footer {
    display: flex;
}

.collapse-btn-bottom {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.collapse-btn-bottom:hover {
    background: var(--glass-bg);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

/* --- Additional Blocks in Card --- */
.additional-block {
    margin-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 15px;
}

.additional-block:first-of-type {
    margin-top: 20px;
    border-top: 1px dashed var(--glass-border);
}

/* --- Expand Button & Caret --- */
.expand-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
}

.expand-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    color: white;
}

.caret-icon {
    width: 14px;
    height: 14px;
    fill: currentColor;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.expanded .caret-icon {
    transform: rotate(180deg);
}

/* --- Things to Remember (Card View) --- */
.prompt-remember-note {
    margin-top: 15px;
    padding: 15px;
    border-radius: 12px;
    background: rgba(255, 215, 0, 0.03);
    /* Subtle gold glass */
    border: 1px dashed rgba(255, 215, 0, 0.2);
}

.remember-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: rgba(255, 215, 0, 0.82);
    margin-bottom: 6px;
    letter-spacing: 1.5px;
}

.extra-block-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 8px;
    min-height: 28px;
}

.extra-block-label {
    display: block;
    font-family: Inter, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #c4b5fd;
    margin-bottom: 8px;
    white-space: normal !important;
}

.extra-block-toolbar .extra-block-label {
    margin-bottom: 0;
    margin-right: auto;
}

.code-block-label {
    padding-right: 36px;
}

.block-copy-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: all 0.2s ease;
}

.remember-content {
    font-size: 0.9rem;
    font-style: italic;
    color: var(--text-muted);
    line-height: 1.5;
    white-space: pre-wrap;
    /* Preserve line breaks */
}

.prompt-text-display,
.remember-content,
.extra-block-content,
.code-content {
    white-space: pre-wrap !important;
    word-break: break-word;
}

.prompt-code-block {
    white-space: normal;
}

.extra-block-content {
    line-height: 1.5;
    color: var(--text-muted);
}

/* --- Slim Mobile View --- */
@media (max-width: 480px) {
    .glass-card {
        padding: 24px 20px;
    }

    .card-header-main {
        margin-bottom: 12px;
    }

    .card-tag-row {
        margin-top: 8px;
    }

    .prompt-tag {
        margin-bottom: 8px;
    }
}

/* --- Mode Toggle Switch (3-state) --- */
.mode-switch-3 {
    position: relative;
    display: flex;
    align-items: center;
    width: 260px;
    height: 38px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 3px;
    cursor: pointer;
    border: 1px solid var(--glass-border);
}

.mode-control {
    display: none;
}

.mode-options {
    display: flex;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.mode-option {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: color 0.3s ease;
    cursor: pointer;
    z-index: 2;
}

.mode-glider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(33.33% - 4px);
    height: calc(100% - 6px);
    background: linear-gradient(135deg, #7b2cbf, #9d4edd);
    border-radius: 18px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.4s;
    z-index: 1;
    box-shadow: 0 4px 12px rgba(123, 44, 191, 0.3);
}

/* Handle Glider Position */
#mode-prompt:checked ~ .mode-options .mode-glider {
    transform: translateX(0);
    background: linear-gradient(135deg, #7b2cbf, #9d4edd);
}

#mode-command:checked ~ .mode-options .mode-glider {
    transform: translateX(calc(100% + 2px));
    background: linear-gradient(135deg, #4361ee, #4cc9f0);
    box-shadow: 0 4px 12px rgba(76, 201, 240, 0.3);
}

#mode-link:checked ~ .mode-options .mode-glider {
    transform: translateX(calc(200% + 4px));
    background: linear-gradient(135deg, #06d6a0, #118ab2);
    box-shadow: 0 4px 12px rgba(6, 214, 160, 0.3);
}

/* Label Colors */
#mode-prompt:checked ~ .mode-options label[for="mode-prompt"],
#mode-command:checked ~ .mode-options label[for="mode-command"],
#mode-link:checked ~ .mode-options label[for="mode-link"] {
    color: white;
}

/* --- Mode-Specific Overrides --- */
.command-mode-active #main-content-group,
.command-mode-active #add-text-block-btn,
.command-mode-active #add-negative-prompt-btn {
    display: none !important;
}

.link-mode-active #prompt-code-container,
.link-mode-active .add-block-actions,
.link-mode-active .counters {
    display: none !important;
}

.visit-btn {
    background: rgba(6, 214, 160, 0.1) !important;
    border: 1px solid rgba(6, 214, 160, 0.4) !important;
    color: #06d6a0 !important;
}

.visit-btn:hover {
    background: #06d6a0 !important;
    color: #0a0514 !important;
    border-color: #06d6a0 !important;
    box-shadow: 0 0 15px rgba(6, 214, 160, 0.4) !important;
}

/* Responsive adjustment for header */
@media (max-width: 850px) {
    .app-header {
        flex-direction: column;
        gap: 20px;
        padding: 24px;
    }

    .mode-toggle-container {
        margin: 0;
        width: 100%;
    }

    .mode-switch-3 {
        width: 100%;
    }
}

/* Category Color Modal Specifics */
.category-colors-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 15px;
}

.color-picker-row {
    display: flex;
    gap: 20px;
}

.color-picker-row .form-group {
    flex: 1;
}

#category-color-select {
    width: 100%;
}

/* --- Prompts Feed Grid Layout --- */
#prompts-feed {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

@media (max-width: 800px) {
    #prompts-feed {
        grid-template-columns: 1fr;
    }

    .glass-card {
        margin-bottom: 20px;
        /* Fallback for older browsers or simple stacks */
    }
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #ffbe0b;
    /* Vibrant Yellow */
    color: #0d0d0d;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(255, 190, 11, 0.4);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-icon {
    font-size: 1.1rem;
}

.search-svg-icon {
    width: 20px;
    height: 20px;
    fill: white;
    transition: transform 0.3s ease;
}

.search-toggle:hover .search-svg-icon {
    transform: scale(1.1);
}

/* --- Slim Mobile Compact Layout --- */
@media (max-width: 600px) {
    .container {
        padding-top: 0 !important;
    }

    .app-header {
        padding: 20px 12px;
        gap: 20px;
        margin-bottom: 24px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .user-info {
        display: none !important;
    }

    .header-actions {
        gap: 12px;
        width: 100%;
        justify-content: center;
    }

    .mode-toggle-container {
        margin: 0;
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .mode-switch-3 {
        width: 100%;
        max-width: 320px;
        height: 48px;
        /* Larger for mobile thumbs */
    }

    .mode-option {
        font-size: 0.9rem !important;
    }

    .mode-glider {
        height: calc(100% - 6px);
    }

    .filter-bar {
        padding: 8px 12px;
        gap: 10px;
        border-radius: 16px;
        margin-bottom: 16px;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .filter-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        gap: 10px;
    }

    .search-group {
        position: relative;
        display: flex;
        align-items: center;
        flex: 1;
    }

    .prompt-count-text {
        margin: 0 !important;
        font-size: clamp(0.65rem, 2.5vw, 0.8rem);
        color: var(--text-muted);
        text-align: right;
        flex-shrink: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-left: 8px !important;
    }

    .filter-group {
        flex: 1;
        min-width: 0;
        /* Allows text truncation if absolutely needed, but flex: 1 gives it priority */
        display: flex;
        justify-content: flex-start;
    }

    .sort-group {
        flex: 0 0 auto;
        display: flex;
        justify-content: flex-end;
    }

    /* Search Toggle Logic */
    .mobile-hidden {
        display: none !important;
    }

    .search-group.active .search-wrapper {
        display: flex !important;
        position: absolute;
        top: -4px;
        left: -4px;
        width: calc(100vw - 40px);
        /* Fill most of the width */
        z-index: 1000;
        background: #0f0a1f;
        border: 1px solid var(--glow-color);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
        padding: 4px;
        border-radius: 12px;
        animation: slideInLeft 0.2s ease-out;
    }

    @keyframes slideInLeft {
        from {
            transform: translateX(-10px);
            opacity: 0;
        }

        to {
            transform: translateX(0);
            opacity: 1;
        }
    }

    .search-group.active .search-toggle {
        opacity: 0;
        pointer-events: none;
    }

    #mobile-category-select {
        width: 100%;
        max-width: none;
        text-overflow: ellipsis;
        /* Fallback but aim for full width */
    }

    .glass-select {
        min-width: 0;
        width: 100%;
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    .search-toggle {
        width: 36px;
        height: 36px;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        background: linear-gradient(135deg, #7209b7, #3a0ca3);
        border: 1px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 4px 15px rgba(114, 9, 183, 0.4);
        border-radius: 10px;
    }

    .search-toggle:active {
        transform: scale(0.95);
        background: linear-gradient(135deg, #3a0ca3, #7209b7);
    }
}

/* --- History Modal & Items --- */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 8px;
}

.history-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    transition: all 0.3s ease;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
}

.history-item-info {
    flex: 1;
    min-width: 0;
}

.history-item-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: block;
}

.history-item-preview {
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: pre-wrap;
    word-break: break-word;
    display: block;
    line-height: 1.4;
}

.history-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.history-restore-btn {
    background: rgba(123, 44, 191, 0.2);
    border: 1px solid var(--glow-color);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-restore-btn:hover {
    background: var(--glow-color);
    box-shadow: 0 0 10px rgba(123, 44, 191, 0.4);
}

.history-delete-btn {
    background: rgba(247, 37, 133, 0.1);
    border: 1px solid rgba(247, 37, 133, 0.4);
    color: #f72585;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-delete-btn:hover {
    background: #f72585;
    color: white;
}

.history-btn {
    display: none !important;
}

.expanded .history-btn {
    display: flex !important;
}

.history-icon-svg {
    width: 18px;
    height: 18px;
}

/* --- Feed Section Headers --- */
.feed-section-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 40px 0 20px;
    padding: 0 10px;
    grid-column: 1 / -1;
}

.feed-section-header:first-of-type {
    margin-top: 10px;
}

.header-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--glass-border), transparent);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    white-space: nowrap;
}

.section-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.header-text {
    background: linear-gradient(to right, #ffffff, var(--text-muted));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-title-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.card-tag-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    min-width: 0;
}

.card-tag-container .prompt-tag {
    font-size: 0.75rem;
    padding: 3px 10px;
    margin-bottom: 0;
}

.card-time-meta {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 6px;
    font-size: 0.68rem;
    line-height: 1.2;
    color: var(--text-muted);
    letter-spacing: 0.01em;
    min-width: 0;
}

.time-meta-item {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
}

.time-meta-label {
    opacity: 0.7;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.62rem;
    letter-spacing: 0.04em;
}

.time-meta-value {
    color: rgba(255, 255, 255, 0.55);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.time-meta-sep {
    opacity: 0.35;
    user-select: none;
}

/* --- Slim Mobile Optimization --- */
@media (max-width: 480px) {
    #prompts-feed {
        gap: 12px;
    }

    .glass-card {
        padding: 16px 20px !important;
        margin-bottom: 12px !important;
    }

    .glass-card:has(.variable-status-icon) {
        padding-bottom: 38px !important;
    }

    .variable-status-icon {
        right: 14px;
        bottom: 12px;
    }

    .glass-card h3 {
        font-size: 1.2rem;
    }

    .feed-section-header {
        margin: 24px 0 12px;
    }

    .card-header-main {
        gap: 10px;
        margin-bottom: 8px;
    }

    .card-title-wrapper {
        gap: 4px;
    }

    .card-tag-container .prompt-tag {
        font-size: 0.7rem;
        padding: 2px 8px;
    }

    .card-time-meta {
        font-size: 0.62rem;
        width: 100%;
    }

    .time-meta-label {
        font-size: 0.58rem;
    }

    .card-header-actions {
        margin-left: 8px;
    }
}

/* --- Border Legend --- */
.border-legend {
    margin-top: 32px;
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.legend-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
}

.legend-items {
    display: flex;
    gap: 24px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-main);
}

.legend-color-box {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
}

.legend-color-box.pin-color {
    background-color: #fb00ff;
    box-shadow: 0 0 8px rgba(251, 0, 255, 0.4);
}

.legend-color-box.copied-color {
    background-color: #006400;
    box-shadow: 0 0 8px rgba(0, 100, 0, 0.4);
}

.legend-color-box.added-color {
    background-color: #ffd700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

@media (max-width: 600px) {
    .border-legend {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .legend-items {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}