/* ==========================================================================
   DESIGN SYSTEM & VARIABLES (Modern Theme)
   ========================================================================== */
:root {
    /* UI Editor Themes */
    --ui-bg: #f8fafc;
    --ui-surface: #ffffff;
    --ui-border: #e2e8f0;
    --ui-text: #0f172a;
    --ui-text-muted: #64748b;
    --ui-dot-color: rgba(15, 23, 42, 0.09);
    --ui-glow-color: rgba(5, 150, 105, 0.09);

    /* Branding Colors */
    --primary: #059669;
    --primary-rgb: 5, 150, 105;
    /* Emerald 600 */
    --primary-hover: #047857;
    /* Emerald 700 */
    --primary-light: #ecfdf5;
    /* Emerald 50 */
    --primary-dark: #064e3b;
    /* Emerald 950 */

    /* Accent Colors */
    --accent-light: #a7f3d0;
    --accent-secondary: #f59e0b;
    --accent-secondary-rgb: 245, 158, 11;
    /* Emerald 200 — used across card themes */

    /* Card Specific Defaults */
    --card-shadow: 0 22px 45px -10px rgba(0, 0, 0, 0.13), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* UI Editor Dark Mode (optional, applied to body) */
[data-ui-theme="dark"] {
    --ui-bg: #0b0f17;
    --ui-surface: #161e2e;
    --ui-border: #243044;
    --ui-text: #f8fafc;
    --ui-text-muted: #94a3b8;
    --ui-dot-color: rgba(255, 255, 255, 0.12);
    --ui-glow-color: rgba(16, 185, 129, 0.15);
}

/* ==========================================================================
   RESET & SYSTEM STYLES
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Twemoji Apple Emojis sizing */
img.emoji {
    height: 1.15em;
    width: 1.15em;
    margin: 0 .05em 0 .1em;
    vertical-align: -0.125em;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--ui-bg);
    color: var(--ui-text);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(5, 150, 105, 0.2);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary);
}

/* ==========================================================================
   EDITOR APP LAYOUT
   ========================================================================== */
.app-container {
    display: grid;
    grid-template-columns: 360px 1fr auto;
    height: 100vh;
    overflow: hidden;
}

@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: 100vh;
    }
}

/* Sidebar Styling */
.sidebar {
    background-color: var(--ui-surface);
    border-right: 1px solid var(--ui-border);
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.02);
}

.brand-section {
    margin-bottom: 30px;
}

.logo {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.05em;
    color: var(--ui-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-beta {
    background-color: var(--primary-light);
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 6px;
    text-transform: uppercase;
}

.brand-desc {
    font-size: 13px;
    color: var(--ui-text-muted);
    margin-top: 6px;
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel-title {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ui-text-muted);
    margin-bottom: 5px;
}

/* Premium Buttons */
.btn {
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    padding: 14px 20px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-telegram {
    background-color: #0088cc;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(0, 136, 204, 0.35);
}

.btn-telegram:hover {
    background-color: #0077b5;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 136, 204, 0.45);
}

.btn-telegram:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--ui-bg);
    color: var(--ui-text);
    border: 1px solid var(--ui-border);
}

.btn-secondary:hover {
    background-color: var(--ui-border);
    transform: translateY(-1px);
}

/* File Input Wrapper */
.file-upload {
    position: relative;
    width: 100%;
}

.file-upload input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Details & Info */
.info-box {
    background-color: var(--ui-bg);
    border: 1px solid var(--ui-border);
    border-radius: 16px;
    padding: 16px;
    font-size: 13px;
    color: var(--ui-text-muted);
}

.info-box ul {
    list-style-type: none;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-box li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-box li::before {
    content: "•";
    color: var(--primary);
    font-weight: bold;
}

/* Theme Switcher */
.theme-switch {
    display: flex;
    gap: 8px;
    background-color: var(--ui-bg);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--ui-border);
}

.theme-opt {
    flex: 1;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.theme-opt.active {
    background-color: var(--ui-surface);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    color: var(--primary);
}

/* Preset Selector Dropdown */
.preset-select-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--ui-border);
    background-color: var(--ui-surface);
    color: var(--ui-text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' 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 16px center;
    background-size: 16px;
    padding-right: 40px;
}

[data-ui-theme="dark"] .preset-select-input {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' 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");
}

.preset-select-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.footer-credits {
    font-size: 11px;
    color: var(--ui-text-muted);
    text-align: center;
    margin-top: 20px;
}

.footer-credits a {
    color: var(--primary);
    text-decoration: none;
    font-weight: bold;
}

/* Preview Area */
.preview-workspace {
    padding: 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    height: 100%;
    position: relative;
    background-color: var(--ui-bg);
    background-image: 
        radial-gradient(ellipse 80% 50% at 50% -10%, var(--ui-glow-color) 0%, transparent 80%),
        radial-gradient(var(--ui-dot-color) 1.5px, transparent 1.5px);
    background-size: 100% 100%, 28px 28px;
    background-position: 0 0, 0 0;
    background-attachment: local, local;
}

.preview-header {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.7);
    /* backdrop-filter removed for clean html2canvas render */
    padding: 12px 20px;
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

[data-ui-theme="dark"] .preview-header {
    background: rgba(22, 30, 46, 0.75);
    border-color: rgba(36, 48, 68, 0.8);
}

.preview-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.preview-count {
    background-color: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 99px;
}

.cards-feed {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 50px;
    width: 100%;
}

/* ==========================================================================
   CARD CONTAINER & RESIZING WRAPPER
   ========================================================================== */
.card-preview-container {
    width: 100%;
    max-width: 540px;
    /* 50% of 1080px by default */
    aspect-ratio: 1080 / 1350;
    position: relative;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    background-color: transparent;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

.card-preview-container:hover {
    transform: translateY(-3px);
    box-shadow: 0 32px 65px -12px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(5, 150, 105, 0.25);
}

.card-preview-container.card-overflow-warning {
    border: 2px solid #ef4444;
}

/* The actual 1:1 Instagram Card (1080x1350) */
.card {
    width: 1080px;
    height: 1350px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: top left;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 75px 85px 135px 85px;
    overflow: hidden;
    box-sizing: border-box;
}

/* ==========================================================================
   CARD DECORATIVE PATTERNS (Glassmorphism & Gradients)
   ========================================================================== */
.card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0.15;
    background-size: 40px 40px;
    /* Dotted background using linear gradients instead for better html2canvas support, or just solid dots */
    background-image: radial-gradient(circle, var(--ui-text-muted) 1px, transparent 1px);
}



/* Theme Layouts */
.card.theme-emerald {
    background-color: #064e3b;
    color: #ffffff;
}

.card.theme-emerald::before {
    opacity: 0.22;
    background-image: 
        radial-gradient(circle at 85% 12%, rgba(52, 211, 153, 0.45) 0%, transparent 55%),
        radial-gradient(circle at 10% 88%, rgba(16, 185, 129, 0.3) 0%, transparent 50%),
        radial-gradient(circle, #ffffff 1px, transparent 1px);
    background-size: auto, auto, 40px 40px;
}

.card.theme-dark {
    background-color: #18181b;
    color: #ffffff;
}

.card.theme-dark::before {
    opacity: 0.25;
    background-image: 
        radial-gradient(circle at 85% 12%, rgba(5, 150, 105, 0.25) 0%, transparent 55%),
        radial-gradient(circle at 12% 88%, rgba(16, 185, 129, 0.2) 0%, transparent 50%),
        radial-gradient(circle, #ffffff 1px, transparent 1px);
    background-size: auto, auto, 40px 40px;
}

.card.theme-light {
    background-color: #ffffff;
    color: #0f172a;
}

.card.theme-light::before {
    opacity: 0.35;
    background-image: 
        radial-gradient(circle at 85% 12%, rgba(16, 185, 129, 0.12) 0%, transparent 55%),
        radial-gradient(circle at 10% 88%, rgba(226, 232, 240, 0.8) 0%, transparent 50%),
        radial-gradient(circle, #64748b 1px, transparent 1px);
    background-size: auto, auto, 40px 40px;
}

/* ==========================================================================
   CARD INNER COMPONENTS
   ========================================================================== */
.card-header,
.card-body,
.card-footer {
    position: relative;
    z-index: 2;
}

/* Header Elements & Social Proof */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-shrink: 0;
}

.card-author-block {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 72%;
}

.author-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.theme-light .author-avatar {
    border: 2px solid rgba(15, 23, 42, 0.12);
}

.theme-emerald .author-avatar,
.theme-dark .author-avatar {
    border: 2px solid rgba(255, 255, 255, 0.25);
}

.author-monogram {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 800;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.theme-emerald .author-monogram {
    background: linear-gradient(135deg, var(--accent-light), #10b981);
    color: #064e3b;
}

.theme-dark .author-monogram {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
}

.theme-light .author-monogram {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #ffffff;
}

.author-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: visible;
}

.author-name {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.author-handle-row {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: visible;
}

.author-handle {
    font-size: 22px;
    font-weight: 600;
    opacity: 0.7;
    line-height: 1.4;
    padding: 2px 4px;
    white-space: nowrap;
    overflow: visible;
    display: inline-block;
}

.author-verified-icon {
    display: none !important;
}

.card-badge {
    font-size: 22px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 6px 16px;
    border-radius: 99px;
    display: inline-flex;
    align-items: center;
}

.theme-emerald .card-badge {
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--accent-light);
}

.theme-dark .card-badge {
    background-color: rgba(5, 150, 105, 0.18);
    color: #34d399;
}

.theme-light .card-badge {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.card-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 30px;
    font-weight: 900;
    letter-spacing: -0.04em;
}

.card-logo .dot {
    font-weight: 900;
}

.theme-emerald .card-logo .dot,
.theme-dark .card-logo .dot {
    color: var(--accent-light);
}

.theme-light .card-logo .dot {
    color: var(--primary);
}

/* Footer Elements */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0;
    /* Absolute positioning to make it ironclad at the bottom */
    position: absolute;
    bottom: 50px;
    left: 85px;
    right: 85px;
    width: auto;
    z-index: 10;
}

.theme-light .card-footer {
    /* No border */
}

.card-footer-text {
    font-size: 24px;
    font-weight: 600;
    opacity: 0.7;
    letter-spacing: -0.01em;
    flex: 1;
    text-align: left;
}

/* Pagination Dots */
.card-dots {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.card-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: currentColor;
    opacity: 0.25;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-dot.active {
    width: 36px;
    height: 14px;
    border-radius: 99px;
    opacity: 1 !important;
    background-color: var(--primary) !important;
    box-shadow: 0 0 16px var(--primary), 0 0 32px rgba(var(--primary-rgb, 5, 150, 105), 0.6);
    transform: none !important;
}

.card-number {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 0.05em;
    opacity: 0.65;
    flex: 1;
    text-align: right;
}

.theme-emerald .card-number,
.theme-dark .card-number {
    color: var(--accent-light);
}

.theme-light .card-number {
    color: var(--primary);
}

.card-cta {
    font-size: 24px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
}

.theme-emerald .card-cta,
.theme-dark .card-cta {
    color: var(--accent-light);
}

.theme-light .card-cta {
    color: var(--primary);
}

/* ==========================================================================
   TEMPLATE VARIATIONS
   ========================================================================== */

/* 1. COVER TEMPLATE */
.template-cover {
    justify-content: space-between;
}

.cover-content {
    margin: auto 0;
    display: flex;
    flex-direction: column;
    gap: 30px;
    z-index: 2;
    overflow: hidden;
    max-height: 1040px;
    min-height: 0;
}

.cover-title {
    font-size: 110px;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.theme-light .cover-title {
    color: var(--primary-dark);
}

.cover-desc {
    font-size: 55px;
    line-height: 1.4;
    opacity: 0.85;
    max-width: 900px;
}

/* 2. CONTENT TEMPLATE (Default) */
.template-content {
    justify-content: space-between;
}

.content-area {
    margin-top: auto;
    margin-bottom: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 35px;
    z-index: 2;
    overflow: hidden;
    max-height: 1040px;
    min-height: 0;
}

.content-title {
    font-size: 88px;
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.theme-light .content-title {
    color: var(--primary-dark);
}

.content-body-box {
    font-size: 58px;
    line-height: 1.45;
    opacity: 0.95;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow: hidden;
}

/* Glassmorphic card around content points */
.content-glass-card {
    display: flex;
    align-items: flex-start;
    gap: 28px;
    border-radius: 28px;
    padding: 32px 36px;
    /* backdrop-filter removed for clean html2canvas render */
    box-sizing: border-box;
    width: 100%;
}

.theme-dark .content-glass-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.theme-emerald .content-glass-card {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: none;
}

.theme-light .content-glass-card {
    background: rgba(248, 250, 252, 0.85);
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: none;
}

.card-point-index {
    font-size: 28px;
    font-weight: 900;
    line-height: 1;
    padding: 8px 14px;
    border-radius: 12px;
    flex-shrink: 0;
    margin-top: 4px;
    letter-spacing: 0.02em;
}

.theme-dark .card-point-index {
    background: rgba(5, 150, 105, 0.2);
    color: #10b981;
    border: 1px solid rgba(52, 211, 153, 0.35);
}

.theme-emerald .card-point-index {
    background: rgba(167, 243, 208, 0.2);
    color: var(--accent-light);
    border: 1px solid rgba(167, 243, 208, 0.35);
}

.theme-light .card-point-index {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.content-glass-card.single {
    gap: 0;
    padding: 38px 44px;
}

.content-paragraph {
    margin: 0;
    flex: 1;
}

/* Special formatting inside card text (lists, numbers, bolding, highlights) */
.card strong,
.card b {
    font-weight: 800;
    color: var(--primary-dark); /* Dark Emerald Green default */
}

.card.theme-light strong,
.card.theme-light b {
    color: var(--primary-dark); /* Dark Emerald Green on light */
}

.card.theme-emerald strong,
.card.theme-emerald b {
    color: var(--accent-light); /* Light mint green on emerald */
}

.card.theme-dark strong,
.card.theme-dark b {
    color: #34d399; /* Bright Emerald Green on dark */
}

/* Except titles which keep their natural title color */
.cover-title strong, .cover-title b,
.content-title strong, .content-title b,
.outro-title strong, .outro-title b,
.word-term strong, .word-term b,
.word-translation strong, .word-translation b {
    color: inherit;
}

.card em,
.card i {
    font-style: italic;
}

.card a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
}

.card.theme-dark a,
.card.theme-emerald a {
    color: #10b981;
}

/* Notebook Accents & Highlighting */
.card mark {
    background-color: rgba(5, 150, 105, 0.16);
    color: inherit;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: inherit; /* Preserves exact weight (bold/regular/extra-bold) of parent text */
    display: inline;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.card.theme-light mark {
    background-color: rgba(5, 150, 105, 0.14);
    color: var(--primary-dark);
}

.card.theme-dark mark,
.card.theme-emerald mark {
    background-color: rgba(167, 243, 208, 0.35);
    color: #ffffff;
    font-weight: 700;
}

.cover-title mark, .content-title mark, .outro-title mark {
    font-weight: inherit;
    padding: 2px 10px;
    border-radius: 8px;
}

.card del, .card s {
    text-decoration: line-through;
    text-decoration-color: var(--primary);
    text-decoration-thickness: 4px;
    opacity: 0.8;
}

.card.theme-dark del, .card.theme-dark s,
.card.theme-emerald del, .card.theme-emerald s {
    text-decoration-color: var(--accent-light);
}

.content-body-box ul {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3em;
    margin: 0.3em 0;
}

.content-body-box ul li {
    position: relative;
    padding-left: 1.5em;
}

.content-body-box ul li::before {
    content: "—";
    position: absolute;
    left: 0;
    top: 0;
    font-size: 1em;
    color: var(--primary);
}

.theme-emerald .content-body-box ul li::before,
.theme-dark .content-body-box ul li::before {
    color: var(--accent-light);
}

blockquote.callout {
    border-left: 0.12em solid var(--primary);
    background-color: rgba(128, 128, 128, 0.05);
    padding: 0.4em 0.6em;
    border-radius: 0 16px 16px 0;
    margin: 0.3em 0;
    font-style: italic;
    opacity: 0.95;
}

.theme-emerald blockquote.callout {
    border-left-color: var(--accent-light);
}

.theme-dark blockquote.callout {
    border-left-color: var(--primary);
    background-color: rgba(5, 150, 105, 0.08);
}


/* 3. WORD TEMPLATE (Word Concept Flashcard) */
.template-word {
    justify-content: space-between;
}

.word-area {
    margin-top: auto;
    margin-bottom: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 35px;
    z-index: 2;
    overflow: hidden;
    max-height: 1040px;
    min-height: 0;
}

/* The primary word display container */
.word-container {
    background-color: var(--primary-dark);
    border: none;
    border-radius: 30px;
    padding: 40px 50px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: none;
}

.theme-emerald .word-container {
    background-color: rgba(255, 255, 255, 0.06);
    box-shadow: none;
}

.theme-dark .word-container {
    background-color: #1a1a1a;
    box-shadow: none;
}

.word-header-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 20px;
}

.word-term {
    font-size: 85px;
    font-weight: 900;
    letter-spacing: -0.04em;
    line-height: 1;
    color: #ffffff;
    flex: 1 1 auto;
    word-break: break-word;
}

.theme-light .word-term {
    color: #ffffff;
    /* keep term bright on green box */
}

.word-transcription {
    font-family: monospace;
    font-size: 38px;
    opacity: 0.9;
    color: var(--accent-light);
    flex: 0 0 auto;
    min-width: 360px;
    text-align: right;
    white-space: nowrap;
}

.word-divider {
    height: 2px;
    background-color: rgba(255, 255, 255, 0.15);
    width: 100%;
}

.theme-emerald .word-divider {
    background-color: rgba(167, 243, 208, 0.2);
}

.word-translation {
    font-size: 75px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #ffffff;
}

.word-tag {
    font-size: 32px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-light);
    opacity: 0.9;
}

.word-description {
    font-size: 48px;
    line-height: 1.45;
    opacity: 0.95;
    padding: 0 10px;
}

/* Example section inside word template */
.word-example-box {
    background-color: rgba(5, 150, 105, 0.05);
    border-left: 6px solid var(--primary);
    border-radius: 0 20px 20px 0;
    padding: 25px 30px;
    margin-top: 10px;
}

.theme-emerald .word-example-box {
    background-color: rgba(255, 255, 255, 0.04);
    border-left-color: var(--accent-light);
}

.theme-dark .word-example-box {
    background-color: rgba(5, 150, 105, 0.1);
    border-left-color: var(--primary);
}

.word-example {
    font-size: 50px;
    font-weight: 800;
    line-height: 1.35;
    letter-spacing: -0.02em;
    margin-bottom: 15px;
}

.word-example-translation {
    font-size: 42px;
    font-style: italic;
    opacity: 0.8;
    line-height: 1.35;
}

/* 4. QUOTE TEMPLATE */
.template-quote {
    justify-content: space-between;
}

.quote-area {
    margin-top: auto;
    margin-bottom: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 35px;
    z-index: 2;
    position: relative;
    overflow: hidden;
    max-height: 1040px;
    min-height: 0;
}

/* Giant quotation mark */
.quote-icon {
    display: none;
}

.quote-text {
    font-size: 75px;
    font-weight: 900;
    line-height: 1.32;
    letter-spacing: -0.02em;
    position: relative;
    padding-left: 30px;
    border-left: 6px solid var(--primary);
}

.theme-emerald .quote-text,
.theme-dark .quote-text,
.card.theme-emerald .quote-text,
.card.theme-dark .quote-text {
    color: #ffffff;
    border-left-color: var(--primary);
}

.theme-light .quote-text,
.card.theme-light .quote-text {
    color: var(--primary-dark);
    border-left-color: var(--primary);
}

.quote-author {
    font-size: 30px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.7;
    margin-top: 0px;
    padding-left: 30px;
}

.theme-light .quote-author {
    color: var(--primary);
}

.quote-translation-box {
    background-color: rgba(128, 128, 128, 0.08);
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 20px;
    padding: 30px;
    margin-top: 20px;
}

.theme-light .quote-translation-box {
    background-color: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.quote-translation-title {
    font-size: 28px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 15px;
    opacity: 0.6;
}

.quote-translation-text {
    font-size: 46px;
    line-height: 1.45;
    font-style: italic;
    opacity: 0.9;
}

/* 5. OUTRO TEMPLATE */
.template-outro {
    align-items: flex-start;
    justify-content: space-between;
    text-align: left;
}

.outro-content {
    margin: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 35px;
    z-index: 2;
    width: 100%;
    padding-bottom: 120px; /* Shifts content slightly higher for visual balance */
    overflow: hidden;
    max-height: 1040px;
    min-height: 0;
    text-align: left;
}

.outro-logo-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
    margin-top: 55px; /* Keeps logo at top: 140px from card top (85px padding + 55px margin) */
}

.outro-icon-frame {
    width: 130px;
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.outro-brandname {
    font-size: 78px;
    font-weight: 900;
    letter-spacing: -0.05em;
}

.theme-light .outro-brandname {
    color: #0b1528;
}

.theme-emerald .outro-brandname {
    color: #ffffff;
}

.theme-dark .outro-brandname {
    color: #ffffff;
}

.outro-title {
    font-size: 90px;
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -0.03em;
    max-width: 900px;
    text-align: left;
}

.theme-light .outro-title {
    color: var(--primary-dark);
}

.outro-body {
    font-size: 44px;
    line-height: 1.4;
    opacity: 0.9;
    max-width: 900px;
    text-align: left;
}

.outro-paragraph {
    margin-top: 0;
    margin-bottom: 25px;
    text-align: left;
}

/* CTA and Badges */
.outro-cta-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 0;
}

/* Domain Highlight */
.highlight-domain {
    display: inline-block;
    padding: 0 15px;
    background-color: var(--primary-light);
    border-radius: 16px;
    color: var(--primary-dark);
}

.theme-dark .highlight-domain,
.theme-emerald .highlight-domain {
    background-color: rgba(5, 150, 105, 0.25);
    color: var(--accent-light);
}

.outro-badge-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 28px;
    border-radius: 99px;
    font-size: 26px;
    font-weight: 700;
    line-height: 1.35;
    max-width: 860px;
    cursor: pointer;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.outro-btn-text {
    flex: 1;
    text-align: left;
    letter-spacing: -0.01em;
}

.outro-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    line-height: 1;
}

.outro-btn-icon svg {
    display: block;
}

.card.theme-dark .outro-badge-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    border: none;
    box-shadow: 0 12px 35px rgba(16, 185, 129, 0.35);
}

.card.theme-dark .outro-btn-icon {
    background-color: rgba(0, 0, 0, 0.25);
    color: #ffffff;
}

.card.theme-emerald .outro-badge-btn {
    background-color: #ffffff;
    color: #064e3b;
    border: none;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.card.theme-emerald .outro-btn-icon {
    background-color: #ecfdf5;
    color: #064e3b;
}

.card.theme-light .outro-badge-btn {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
    border: none;
    box-shadow: 0 14px 35px rgba(5, 150, 105, 0.35);
}

.card.theme-light .outro-btn-icon {
    background-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.outro-socials-row {
    display: flex;
    gap: 25px;
    font-size: 24px;
    opacity: 0.8;
}

/* ==========================================================================
   JSON SLIDE-OUT EDITOR DRAWER
   ========================================================================== */
.editor-drawer {
    width: 0;
    overflow: hidden;
    height: 100vh;
    background-color: var(--ui-surface);
    border-left: none;
    box-shadow: none;
    z-index: 1000;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-left-color 0.4s ease, box-shadow 0.4s ease;
    display: flex;
    flex-direction: column;
}

.editor-drawer.open {
    width: 550px;
    border-left: 1px solid var(--ui-border);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.06);
}

.drawer-header {
    padding: 24px;
    border-bottom: 1px solid var(--ui-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-header h3 {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--ui-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--ui-text-muted);
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.drawer-close-btn:hover {
    color: var(--ui-text);
}

.drawer-body {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

/* Format Toolbar above Textarea */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 12px;
    background-color: var(--ui-bg);
    border: 1px solid var(--ui-border);
    border-radius: 12px;
}

.toolbar-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--ui-text-muted);
    margin-right: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.fmt-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    border-radius: 8px;
    border: 1px solid var(--ui-border);
    background-color: var(--ui-surface);
    color: var(--ui-text);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
}

.fmt-btn:hover {
    background-color: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
    transform: translateY(-1px);
}

.fmt-btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    transform: translateY(-1px);
}

.fmt-btn:active {
    transform: translateY(0);
}

.fmt-btn i {
    font-size: 13px;
}

.fmt-btn-mark:hover {
    background-color: #fef08a;
    border-color: #eab308;
    color: #854d0e;
}

.drawer-body textarea {
    flex: 1;
    width: 100%;
    font-family: 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--ui-border);
    background-color: var(--ui-bg);
    color: var(--ui-text);
    resize: none;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    tab-size: 2;
}

.drawer-body textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.editor-error-msg {
    color: #ef4444;
    font-size: 13px;
    font-weight: 600;
    min-height: 20px;
    padding: 8px 12px;
    border-radius: 8px;
    background-color: rgba(239, 68, 68, 0.08);
    display: none; /* Shown dynamically */
}

.drawer-footer {
    padding: 24px;
    border-top: 1px solid var(--ui-border);
    display: flex;
    gap: 16px;
}

@media (max-width: 900px) {
    .editor-drawer {
        position: fixed;
        top: 0;
        right: -100%;
        width: 100%;
        height: 100vh;
        border-left: none;
        box-shadow: none;
        transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .editor-drawer.open {
        right: 0;
        width: 100%;
        box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
    }
}

/* ==========================================================================
   MOBILE & RESPONSIVE DESIGN SYSTEM
   ========================================================================== */

/* Mobile Top Header (Hidden on Desktop) */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background-color: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--ui-border);
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
    z-index: 500;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

[data-ui-theme="dark"] .mobile-header {
    background-color: rgba(15, 23, 42, 0.88);
    border-bottom-color: var(--ui-border);
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 18px;
    color: var(--ui-text);
}

.mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--ui-border);
    background-color: var(--ui-surface);
    color: var(--ui-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.mobile-icon-btn:active {
    background-color: var(--ui-border);
    transform: scale(0.95);
}

/* Sidebar Backdrop for Mobile Overlay */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 800;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background-color: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--ui-border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 500;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

[data-ui-theme="dark"] .mobile-bottom-nav {
    background-color: rgba(15, 23, 42, 0.92);
    border-top-color: var(--ui-border);
}

.mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    height: 100%;
    border: none;
    background: transparent;
    color: var(--ui-text-muted);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.2s, transform 0.15s;
    user-select: none;
}

.mobile-nav-btn i {
    font-size: 18px;
}

.mobile-nav-btn.active, .mobile-nav-btn:active {
    color: var(--primary);
}

.mobile-nav-btn:active {
    transform: scale(0.92);
}

.mobile-hint {
    display: none;
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
    margin-left: 6px;
}

/* Mobile Responsive Breakpoints */
@media (max-width: 850px) {
    .mobile-header {
        display: flex;
    }

    .mobile-bottom-nav {
        display: flex;
    }

    .mobile-hint {
        display: inline-block;
    }

    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        height: 100vh;
        height: 100dvh;
        padding-top: 56px;
        padding-bottom: 64px;
    }

    /* Transform Sidebar into Mobile Left Drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: -320px;
        bottom: 0;
        width: 300px;
        height: 100vh;
        height: 100dvh;
        z-index: 900;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
        transition: left 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        padding: 24px 20px;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Workspace adjustments on mobile */
    .preview-workspace {
        padding: 20px 12px 30px 12px;
        gap: 20px;
    }

    .preview-header {
        padding: 0 4px;
    }

    .preview-title {
        font-size: 15px;
    }

    /* Card Preview container scaled for phone screen width */
    .card-preview-container {
        max-width: calc(100vw - 24px);
        margin: 0 auto;
        border-radius: 16px;
    }

    /* Fullscreen/Sheet Drawer for Mobile JSON Editor */
    .editor-drawer {
        position: fixed;
        top: 0;
        right: -100%;
        left: auto;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        z-index: 1000;
        border-left: none;
        box-shadow: none;
        transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        border-radius: 0;
    }

    .editor-drawer.open {
        right: 0;
        width: 100%;
    }

    .drawer-drag-handle {
        width: 36px;
        height: 5px;
        background-color: var(--ui-border);
        border-radius: 99px;
        margin: 8px auto 0 auto;
    }

    .drawer-header {
        padding: 16px 20px;
    }

    .drawer-body {
        padding: 16px;
        gap: 10px;
    }

    .editor-toolbar {
        overflow-x: auto;
        white-space: nowrap;
        padding: 6px;
        -webkit-overflow-scrolling: touch;
    }

    .fmt-btn span {
        display: inline;
    }

    .drawer-footer {
        padding: 16px;
        gap: 10px;
        background-color: var(--ui-surface);
    }
}

/* Touch Floating Formatting Bar for Mobile Devices */
@media (max-width: 600px) {
    .card-floating-toolbar {
        max-width: calc(100vw - 20px);
        overflow-x: auto;
        padding: 6px 10px;
        border-radius: 18px;
        -webkit-overflow-scrolling: touch;
    }

    .card-fmt-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

/* ==========================================================================
   INLINE EDITABLE CARDS & FLOATING TOOLBAR
   ========================================================================== */

.inline-editable {
    outline: none;
    border-radius: 6px;
    transition: outline 0.15s ease, background-color 0.15s ease;
    cursor: text;
}

.inline-editable:hover {
    outline: 2px dashed rgba(5, 150, 105, 0.45);
    background-color: rgba(5, 150, 105, 0.04);
}

.inline-editable:focus {
    outline: 3px solid var(--primary) !important;
    background-color: rgba(5, 150, 105, 0.08) !important;
}

/* Floating Inline Selection Formatting Bubble */
.card-floating-toolbar {
    position: fixed;
    z-index: 10000;
    display: none;
    align-items: center;
    gap: 4px;
    background-color: #0f172a;
    border: 1px solid #334155;
    padding: 6px 8px;
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    transform: translate(-50%, -100%) translateY(-10px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    user-select: none;
}

.card-floating-toolbar.visible {
    display: flex;
    animation: popIn 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
    from { opacity: 0; transform: translate(-50%, -100%) translateY(-4px) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, -100%) translateY(-10px) scale(1); }
}

.card-fmt-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #f8fafc;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.card-fmt-btn:hover {
    background-color: #334155;
    color: #10b981;
    transform: scale(1.08);
}

.card-fmt-btn-mark:hover {
    background-color: #fef08a;
    color: #854d0e;
}

.card-fmt-btn:active {
    transform: scale(0.96);
}

/* ==========================================================================
   CUSTOM MODALS & TELEGRAM SETTINGS STYLES
   ========================================================================== */
.custom-modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalFadeIn 0.2s ease forwards;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.custom-modal-card {
    background-color: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalScaleUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes modalScaleUp {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.custom-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--ui-border);
}

.modal-title-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-title-box h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: var(--ui-text);
}

.modal-subtitle {
    font-size: 12px;
    color: var(--ui-text-muted);
}

.tg-icon-badge {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2AABEE 0%, #229ED9 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(34, 158, 217, 0.35);
}

.custom-modal-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tg-info-box {
    background-color: rgba(0, 136, 204, 0.08);
    border: 1px solid rgba(0, 136, 204, 0.2);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: var(--ui-text);
}

.form-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field-group label {
    font-size: 13px;
    color: var(--ui-text);
}

.modal-text-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--ui-border);
    background-color: var(--ui-bg);
    color: var(--ui-text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-text-input:focus {
    border-color: #0088cc;
    box-shadow: 0 0 0 3px rgba(0, 136, 204, 0.15);
}

.field-hint {
    font-size: 11px;
    color: var(--ui-text-muted);
    line-height: 1.3;
}

.field-hint a {
    color: #0088cc;
    text-decoration: underline;
}

.tg-test-status {
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 12px;
    display: none;
}

.tg-test-status.success {
    display: block;
    background-color: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.tg-test-status.error {
    display: block;
    background-color: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.custom-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--ui-border);
    display: flex;
    gap: 12px;
    background-color: rgba(0, 0, 0, 0.02);
}

/* Export Options Grid */
.export-options-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.export-opt-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid var(--ui-border);
    background-color: var(--ui-surface);
    color: var(--ui-text);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    width: 100%;
}

.export-opt-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.export-opt-tg:hover {
    border-color: #0088cc;
    background-color: rgba(0, 136, 204, 0.05);
}

.export-opt-share:hover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.export-opt-zip:hover {
    border-color: #f59e0b;
    background-color: rgba(245, 158, 11, 0.05);
}

.export-opt-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.export-opt-tg .export-opt-icon {
    background: linear-gradient(135deg, #2AABEE 0%, #229ED9 100%);
    color: #ffffff;
}

.export-opt-share .export-opt-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
}

.export-opt-zip .export-opt-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
}

.export-opt-info {
    flex: 1;
}

.export-opt-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 2px;
}

.export-opt-desc {
    font-size: 12px;
    color: var(--ui-text-muted);
    line-height: 1.35;
}

.export-opt-arrow {
    font-size: 14px;
    color: var(--ui-text-muted);
    transition: transform 0.2s ease;
}

.export-opt-card:hover .export-opt-arrow {
    transform: translateX(4px);
    color: var(--ui-text);
}

/* ==========================================================================
   DESIGN STUDIO & CUSTOMIZATION SYSTEM (FONTS, BACKGROUNDS, COUNTERS)
   ========================================================================== */

/* Typography Classes */
.card.font-inter { font-family: 'Inter', sans-serif; }
.card.font-montserrat { font-family: 'Montserrat', sans-serif; }
.card.font-playfair { font-family: 'Playfair Display', Georgia, serif; }
.card.font-oswald { font-family: 'Oswald', sans-serif; }
.card.font-unbounded { font-family: 'Unbounded', sans-serif; }
.card.font-manrope { font-family: 'Manrope', sans-serif; }
.card.font-bebas { font-family: 'Bebas Neue', sans-serif; letter-spacing: 0.04em; }
.card.font-golos { font-family: 'Golos Text', sans-serif; }
.card.font-cormorant { font-family: 'Cormorant Garamond', Georgia, serif; }

.card.font-playfair .cover-title,
.card.font-playfair .content-title,
.card.font-playfair .word-term,
.card.font-cormorant .cover-title,
.card.font-cormorant .content-title,
.card.font-cormorant .word-term {
    font-weight: 800;
    font-style: italic;
    letter-spacing: -0.02em;
}

.card.font-montserrat .cover-title,
.card.font-montserrat .content-title,
.card.font-manrope .cover-title,
.card.font-manrope .content-title {
    font-weight: 900;
    letter-spacing: -0.03em;
}

.card.font-oswald .cover-title,
.card.font-oswald .content-title,
.card.font-bebas .cover-title,
.card.font-bebas .content-title {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.card.font-unbounded .cover-title,
.card.font-unbounded .content-title {
    font-weight: 800;
    letter-spacing: -0.04em;
}

/* Background Texture Classes (Dynamically tinted via var(--primary)) */
.card.bg-solid.theme-dark { background-color: #121214; }
.card.bg-solid.theme-dark::before { display: none !important; }
.card.bg-solid.theme-emerald { background-color: #064e3b; }
.card.bg-solid.theme-emerald::before { display: none !important; }
.card.bg-solid.theme-light { background-color: #f8fafc; }
.card.bg-solid.theme-light::before { display: none !important; }

/* 1. Ambient Glow */
.card.bg-ambient::before {
    opacity: 0.35;
    background-image: 
        radial-gradient(circle at 85% 12%, rgba(var(--primary-rgb, 5, 150, 105), 0.35) 0%, transparent 60%),
        radial-gradient(circle at 15% 88%, rgba(var(--primary-rgb, 5, 150, 105), 0.25) 0%, transparent 55%);
    background-size: 100% 100%, 100% 100%;
}

/* 2. Dot Grid */
.card.bg-dots::before {
    opacity: 0.3;
    background-image: 
        radial-gradient(circle at 85% 12%, rgba(var(--primary-rgb, 5, 150, 105), 0.32) 0%, transparent 55%),
        radial-gradient(circle, rgba(255, 255, 255, 0.22) 1.5px, transparent 1.5px);
    background-size: auto, 38px 38px;
}
.theme-light .card.bg-dots::before {
    background-image: 
        radial-gradient(circle at 85% 12%, rgba(var(--primary-rgb, 5, 150, 105), 0.20) 0%, transparent 55%),
        radial-gradient(circle, rgba(0, 0, 0, 0.15) 1.5px, transparent 1.5px);
    background-size: auto, 38px 38px;
}

/* 3. Cyber Mesh */
.card.bg-mesh::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: var(--mesh-opacity, 0.60);
    background-image: 
        radial-gradient(circle at 12% 15%, var(--mesh-c1, rgba(var(--primary-rgb, 5, 150, 105), 0.55)) 0px, transparent 55%),
        radial-gradient(circle at 88% 15%, var(--mesh-c2, rgba(var(--accent-secondary-rgb, 245, 158, 11), 0.50)) 0px, transparent 55%),
        radial-gradient(circle at 85% 85%, var(--mesh-c3, rgba(6, 182, 212, 0.50)) 0px, transparent 55%),
        radial-gradient(circle at 15% 85%, var(--mesh-c2, rgba(var(--accent-secondary-rgb, 245, 158, 11), 0.50)) 0px, transparent 50%);
    background-size: 100% 100%;
    pointer-events: none;
}

/* 4. Line Matrix (Grid) */
.card.bg-grid::before {
    opacity: 0.25;
    background-image: 
        linear-gradient(to right, rgba(var(--primary-rgb, 5, 150, 105), 0.18) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(var(--primary-rgb, 5, 150, 105), 0.18) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* 5. Soft Aura */
.card.bg-aura::before {
    opacity: 0.42;
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(var(--primary-rgb, 5, 150, 105), 0.32) 0%, transparent 65%);
    background-size: 100% 100%;
}

/* 6. Clean Glass */
.card.bg-glass::before {
    opacity: 0.32;
    background-image: 
        linear-gradient(135deg, rgba(var(--primary-rgb, 5, 150, 105), 0.26) 0%, transparent 50%),
        linear-gradient(315deg, rgba(var(--primary-rgb, 5, 150, 105), 0.18) 0%, transparent 50%);
    background-size: 100% 100%;
}

/* Counter Variations */
.card-progress-bar-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 10;
}
.theme-light .card-progress-bar-container {
    background: rgba(15, 23, 42, 0.08);
}
.card-progress-bar-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}
.theme-emerald .card-progress-bar-fill {
    background: var(--accent-light);
}

.card-pill-counter {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 6px 18px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    margin-left: auto;
}
.theme-light .card-pill-counter {
    background: rgba(15, 23, 42, 0.05);
    border-color: rgba(15, 23, 42, 0.1);
}

/* Design Studio Modal Dialog UI */
.design-studio-dialog {
    max-width: 580px;
    width: 94vw;
    background: var(--ui-surface);
    border-radius: 24px;
    padding: 24px;
    border: 1px solid var(--ui-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
}

.design-studio-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 68vh;
    overflow-y: auto;
    padding-right: 4px;
}

.studio-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.studio-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ui-text-muted);
}

.studio-badge {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 6px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}

.font-grid, .bg-grid, .counter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
    gap: 8px;
}

.font-card, .bg-card, .counter-card {
    padding: 12px 8px;
    border-radius: 14px;
    border: 2px solid var(--ui-border);
    background: var(--ui-bg);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.font-card:hover, .bg-card:hover, .counter-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.font-card.active, .bg-card.active, .counter-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}

[data-ui-theme="dark"] .font-card.active,
[data-ui-theme="dark"] .bg-card.active,
[data-ui-theme="dark"] .counter-card.active {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: #10b981;
}

.font-preview-name {
    font-size: 15px;
    font-weight: 800;
}

.font-preview-sub {
    font-size: 10px;
    opacity: 0.7;
}

.bg-preview-box {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    margin-bottom: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}

.bg-preview-ambient {
    background: radial-gradient(circle at 80% 20%, #10b981 0%, #18181b 80%);
}

.bg-preview-dots {
    background-color: #18181b;
    background-image: radial-gradient(#10b981 1.5px, transparent 1.5px);
    background-size: 8px 8px;
}

.bg-preview-solid {
    background: #18181b;
}

.bg-preview-mesh {
    background: linear-gradient(135deg, #10b981, #064e3b, #34d399);
}

.counter-preview-val {
    font-size: 16px;
    font-weight: 900;
    color: var(--primary);
}

.accent-palette {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.accent-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 3px solid transparent;
}

.accent-swatch:hover {
    transform: scale(1.15);
}

.accent-swatch.active {
    border-color: var(--ui-surface);
    box-shadow: 0 0 0 3px var(--primary);
    transform: scale(1.15);
}

/* Quote Customization Styles (Editorial, Modern Line, Glass Callout, Speech Bubble) */
.card.quote-style-editorial .quote-text {
    border-left: none !important;
    padding-left: 50px !important;
    font-style: italic;
    position: relative;
}
.card.quote-style-editorial .quote-text::before {
    content: '“';
    position: absolute;
    left: 0;
    top: -20px;
    font-size: 110px;
    font-family: Georgia, serif;
    color: var(--accent-secondary, #f59e0b);
    line-height: 1;
    opacity: 0.9;
}
.card.quote-style-editorial .quote-author {
    color: var(--accent-secondary, #f59e0b) !important;
    padding-left: 50px !important;
}

.card.quote-style-modern_line .quote-text {
    border-left: 10px solid var(--accent-secondary, #f59e0b) !important;
    padding-left: 35px !important;
    box-shadow: -10px 0 25px -5px rgba(var(--accent-secondary-rgb, 245, 158, 11), 0.4);
}
.card.quote-style-modern_line .quote-author {
    color: var(--accent-secondary, #f59e0b) !important;
    padding-left: 35px !important;
}

.card.quote-style-glass_card .quote-area {
    background: rgba(var(--accent-secondary-rgb, 245, 158, 11), 0.12);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(var(--accent-secondary-rgb, 245, 158, 11), 0.35);
    border-radius: 30px;
    padding: 50px 40px !important;
    box-shadow: 0 20px 50px -10px rgba(var(--accent-secondary-rgb, 245, 158, 11), 0.3);
}
.card.quote-style-glass_card .quote-text {
    border-left: none !important;
    padding-left: 0 !important;
}
.card.quote-style-glass_card .quote-author {
    padding-left: 0 !important;
    color: var(--accent-secondary, #f59e0b) !important;
}

.card.quote-style-speech .quote-area {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 30px;
    padding: 50px 40px !important;
    border-left: 8px solid var(--accent-secondary, #f59e0b);
    position: relative;
}
.card.quote-style-speech .quote-text {
    border-left: none !important;
    padding-left: 0 !important;
}
.card.quote-style-speech .quote-author {
    padding-left: 0 !important;
    color: var(--accent-secondary, #f59e0b) !important;
}

/* Dual Font Pairing */
.card .cover-title,
.card .content-title,
.card .word-term {
    font-family: var(--font-title, inherit);
}
.card .cover-subtitle,
.card .content-box,
.card .content-body,
.card .quote-text,
.card .point-text {
    font-family: var(--font-body, inherit);
}

/* Enhanced Modern Smooth Fonts */
.card.font-plus_jakarta, .font-plus_jakarta {
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
}
.card.font-onest, .font-onest {
    font-family: 'Onest', 'Inter', -apple-system, sans-serif;
}
.card.font-rubik, .font-rubik {
    font-family: 'Rubik', -apple-system, sans-serif;
}
