/* ============================================
   Web Font Subsetter — Styles
   Neon Lime palette with glassmorphism
   ============================================ */

:root {
    --primary: #A3CB38;
    --primary-light: #C4E538;
    --accent: #6C5CE7;
    --accent-light: #8B7FF0;
    --bg: #0F1A0A;
    --bg-elevated: #162010;
    --bg-card: rgba(22, 32, 16, 0.7);
    --surface: #1E2E14;
    --surface-hover: #283D1B;
    --text: #F1F5F9;
    --text-secondary: #A5C48F;
    --text-muted: #6B8A56;
    --border: rgba(163, 203, 56, 0.1);
    --border-hover: rgba(163, 203, 56, 0.3);
    --success: #22C55E;
    --danger: #EF4444;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --transition: 0.25s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="light"] {
    --bg: #F6FBF0;
    --bg-elevated: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.8);
    --surface: #E6F0DA;
    --surface-hover: #D4E6C2;
    --text: #1A2E0F;
    --text-secondary: #4A6637;
    --text-muted: #7D9A6A;
    --border: rgba(0, 0, 0, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: border-color var(--transition);
}

.glass-card:hover {
    border-color: var(--border-hover);
}

/* --- Header --- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 26, 10, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

[data-theme="light"] .header {
    background: rgba(246, 251, 240, 0.85);
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #0F1A0A;
    box-shadow: 0 2px 8px rgba(163, 203, 56, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(163, 203, 56, 0.5);
    transform: translateY(-1px);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.btn-secondary:hover {
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.5);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
}

.btn-ghost:hover {
    background: var(--surface);
    color: var(--text);
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.375rem 0.75rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1.5rem;
}

/* --- Main --- */
.main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* --- Dropzone --- */
.dropzone {
    border: 2px dashed var(--border);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: rgba(163, 203, 56, 0.05);
}

.dropzone.dragover {
    transform: scale(1.01);
}

.dropzone-icon {
    color: var(--primary);
    margin-bottom: 1rem;
    opacity: 0.6;
}

.dropzone-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.dropzone-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- Font Info --- */
.font-info {
    padding: 1.25rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.info-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-light);
}

/* --- Controls Grid --- */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.presets-panel,
.range-panel {
    padding: 1.5rem;
}

.presets-panel h3,
.range-panel h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.preset-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.preset-btn {
    padding: 0.375rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 99px;
    background: var(--surface);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.preset-btn.active {
    background: var(--primary);
    color: #0F1A0A;
    border-color: var(--primary);
    font-weight: 600;
}

.preset-btn:hover:not(.active) {
    border-color: var(--primary);
    color: var(--text);
}

.custom-section {
    margin-bottom: 1rem;
}

.custom-section h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.custom-section textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    resize: vertical;
    transition: border-color var(--transition);
}

.custom-section textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(163, 203, 56, 0.15);
}

.selection-stats {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

.selection-stats .divider {
    margin: 0 0.5rem;
    opacity: 0.4;
}

/* --- Range Editor --- */
.range-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.range-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.range-item code {
    font-family: 'SF Mono', monospace;
    color: var(--primary-light);
    flex: 1;
}

.range-item .range-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex: 1;
}

.range-item button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    transition: color var(--transition);
}

.range-item button:hover {
    color: var(--danger);
}

.range-add {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-input {
    width: 90px;
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: monospace;
    font-size: 0.85rem;
}

.range-input:focus {
    outline: none;
    border-color: var(--primary);
}

.range-add span {
    color: var(--text-muted);
}

/* --- Preview --- */
.preview-panel {
    padding: 1.5rem;
}

.preview-controls {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.preview-input {
    flex: 1;
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
}

.preview-input:focus {
    outline: none;
    border-color: var(--primary);
}

.preview-controls select {
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
}

.preview-output {
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
    min-height: 80px;
    word-wrap: break-word;
    line-height: 1.6;
}

.preview-output p {
    color: var(--text-muted);
    text-align: center;
}

/* --- Size Comparison --- */
.size-comparison {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.size-bar-container {
    flex: 1;
}

.size-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.size-bar-row:last-child {
    margin-bottom: 0;
}

.size-bar-label {
    width: 70px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.size-bar {
    flex: 1;
    height: 24px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
}

.size-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.size-bar-fill.original {
    background: linear-gradient(90deg, var(--text-muted), var(--text-secondary));
}

.size-bar-fill.subset {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.size-bar-value {
    width: 80px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
}

.savings-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(163, 203, 56, 0.15), rgba(196, 229, 56, 0.1));
    border: 2px solid var(--primary);
}

.savings-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-light);
    line-height: 1;
}

.savings-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.25rem;
}

/* --- Download --- */
.download-panel {
    padding: 1.5rem;
}

.download-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.download-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}

.download-option:hover {
    border-color: var(--primary);
}

.download-option input[type="radio"] {
    accent-color: var(--primary);
}

.tag {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    background: rgba(163, 203, 56, 0.15);
    color: var(--primary);
    border-radius: 99px;
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
}

.toast {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    color: var(--text);
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    max-width: 360px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--primary);
}

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 2rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

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

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* --- Responsive --- */
@media (max-width: 800px) {
    .controls-grid {
        grid-template-columns: 1fr;
    }

    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .size-comparison {
        flex-direction: column;
    }

    .savings-badge {
        width: 80px;
        height: 80px;
    }
}

@media (max-width: 480px) {
    .header-inner {
        padding: 0.625rem 1rem;
    }

    .main {
        padding: 1.25rem 1rem;
    }

    .logo h1 {
        font-size: 1rem;
    }

    .download-options {
        flex-direction: column;
    }

    .preview-controls {
        flex-direction: column;
    }
}