:root {
    --primary: #D63031;
    /* Crimson Red */
    --primary-hover: #b82829;
    --secondary: #FF7675;
    /* Light Red */
    --accent: #00CEC9;
    /* Cyan Accent */
    --bg: #1A0A0A;
    /* Very dark red/black */
    --surface: #2D1414;
    /* Dark reddish surface */
    --surface-hover: #3D1C1C;
    --text-primary: #F8FAFC;
    --text-secondary: #ffbaba;
    --border: rgba(214, 48, 49, 0.2);
    --border-focus: rgba(255, 118, 117, 0.6);
    --radius: 12px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(214, 48, 49, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 206, 201, 0.05) 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Glassmorphism Helpers */
.glass-panel {
    background: rgba(45, 20, 20, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 0 1rem;
}

.header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.accent-text {
    color: var(--accent);
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin-top: 0.25rem;
}

.unit-type-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.25rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.type-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition);
}

.type-btn:hover {
    color: var(--text-primary);
}

.type-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(214, 48, 49, 0.4);
}

/* Main Content Layout */
.main-content {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.output-area {
    width: 450px;
    position: sticky;
    top: 2rem;
}

/* Form Sections */
.section-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.section-header {
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid transparent;
}

.section-card.open .section-header {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

.section-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.toggle-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-card.open .toggle-icon {
    transform: rotate(180deg);
}

.section-body {
    padding: 1.25rem;
    display: none;
    flex-direction: column;
    gap: 1.25rem;
}

.section-card.open .section-body {
    display: flex;
}

.section-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.9;
}

.section-hint code {
    color: var(--accent);
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.row-group {
    flex-direction: row;
    gap: 1rem;
}

.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.7rem;
    cursor: help;
    color: var(--text-primary);
    font-style: normal;
}

.form-input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

.form-input:focus {
    border-color: var(--border-focus);
}

select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ffbaba' 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 1rem center;
    padding-right: 2.5rem;
    font-family: 'Inter', sans-serif;
}

/* Custom Directives */
.custom-directives-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.custom-row {
    display: flex;
    gap: 0.5rem;
    animation: slideIn 200ms ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

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

.cd-section {
    flex: 1;
}

.cd-key {
    flex: 1.5;
}

.cd-val {
    flex: 2;
}

/* Buttons */
.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-radius: 8px;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.remove-custom {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #EF4444;
}

.remove-custom:hover {
    background: rgba(239, 68, 68, 0.2);
}

.text-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
    text-align: left;
    align-self: flex-start;
}

.text-btn:hover {
    text-decoration: underline;
    text-shadow: 0 0 8px rgba(0, 206, 201, 0.4);
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(214, 48, 49, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(214, 48, 49, 0.4);
}

.sm-btn {
    padding: 0.5rem 1rem;
}

/* Output Area */
.output-panel {
    display: flex;
    flex-direction: column;
}

.output-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.output-title h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.output-badge {
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}

.output-actions {
    display: flex;
    gap: 0.5rem;
}

.output-body {
    padding: 0;
    background: #000;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.output-body pre {
    margin: 0;
    padding: 1.25rem;
    overflow-x: auto;
}

.output-body code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: #a6e22e;
    line-height: 1.5;
}

/* Quick instructions */
.quick-instructions {
    padding: 1.25rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.quick-instructions h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.quick-instructions pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow-x: auto;
}

.quick-instructions code {
    color: #A3BE8C;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Responsive */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }

    .output-area {
        width: 100%;
        position: static;
    }

    .row-group {
        flex-direction: column;
    }

    .custom-row {
        flex-direction: column;
    }

    .icon-btn.remove-custom {
        width: 100%;
    }
}