:root {
    --primary: #344164;
    --secondary: #F4DEC7;
    --accent: #F8C74E;
    --alert: #E93F3F;
    --muted: #5F6B53;
    --bg-light: #fafafa;
}

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

body {
    font-family: 'Fira Sans', sans-serif;
    background: linear-gradient(135deg, var(--bg-light) 0%, var(--secondary) 100%);
    color: var(--primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: var(--primary);
    color: white;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1em;
    font-weight: 300;
    opacity: 0.9;
}

.main-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
    margin-bottom: 40px;
}

.sidebar {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    height: fit-content;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.sidebar h2 {
    font-family: 'Playfair Display', serif;
    color: var(--primary);
    font-size: 1.4em;
    margin-bottom: 20px;
    font-weight: 600;
}

.reference-types {
    list-style: none;
}

.reference-types li {
    margin-bottom: 8px;
}

.reference-types button {
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    background: var(--bg-light);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Fira Sans', sans-serif;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--primary);
}

.reference-types button:hover {
    background: var(--secondary);
    border-color: var(--accent);
}

.reference-types button.active {
    background: var(--accent);
    color: var(--primary);
    font-weight: 600;
}

.hints-toggle {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid var(--secondary);
}

.toggle-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.toggle-switch input {
    width: 50px;
    height: 26px;
    position: relative;
    appearance: none;
    background: #ccc;
    border-radius: 13px;
    outline: none;
    cursor: pointer;
    transition: 0.3s;
}

.toggle-switch input:checked {
    background: var(--accent);
}

.toggle-switch input::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    background: white;
    transition: 0.3s;
}

.toggle-switch input:checked::before {
    left: 26px;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.form-section, .output-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.form-section h2, .output-section h2 {
    font-family: 'Playfair Display', serif;
    color: var(--primary);
    font-size: 1.6em;
    margin-bottom: 20px;
    font-weight: 600;
}

.form-grid {
    display: grid;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.required {
    color: var(--alert);
}

.hint {
    font-size: 0.85em;
    color: var(--muted);
    font-weight: 400;
    margin-top: 4px;
    font-style: italic;
}

.form-group input, .form-group select, .form-group textarea {
    padding: 12px;
    border: 2px solid var(--secondary);
    border-radius: 8px;
    font-family: 'Fira Sans', sans-serif;
    font-size: 1em;
    transition: border-color 0.3s;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group input.error {
    border-color: var(--alert);
}

.error-message {
    color: var(--alert);
    font-size: 0.85em;
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-family: 'Fira Sans', sans-serif;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--accent);
    color: var(--primary);
}

.btn-primary:hover {
    background: #e6b938;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-secondary {
    background: var(--muted);
    color: white;
}

.btn-secondary:hover {
    background: #4a5442;
}

.btn-danger {
    background: var(--alert);
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

.reference-list {
    margin-top: 20px;
}

.reference-item {
    background: var(--bg-light);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: start;
    border-left: 4px solid var(--accent);
}

.reference-text {
    flex: 1;
    font-size: 0.95em;
    line-height: 1.6;
}

.reference-actions {
    display: flex;
    gap: 8px;
    margin-left: 15px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85em;
    border-radius: 6px;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--muted);
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.output-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--secondary);
}

.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip-icon {
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: var(--primary);
}

.tooltip-text {
    visibility: hidden;
    width: 250px;
    background-color: var(--primary);
    color: white;
    text-align: left;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -125px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85em;
    font-weight: 400;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.info-banner {
    background: var(--secondary);
    border-left: 4px solid var(--accent);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9em;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    animation: slideUp 0.3s;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.modal-header h2 {
    font-family: 'Playfair Display', serif;
    color: var(--primary);
    font-size: 1.6em;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2em;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.modal-close:hover {
    background: var(--secondary);
    color: var(--primary);
}

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

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: relative;
        top: 0;
        max-height: none;
    }

    header h1 {
        font-size: 2em;
    }
}

@media (max-width: 768px) {
    .form-actions, .output-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .reference-item {
        flex-direction: column;
        gap: 12px;
    }

    .reference-actions {
        margin-left: 0;
        width: 100%;
    }

    .reference-actions .btn-small {
        flex: 1;
    }
}
