/* --- Reaction Scheme --- */
#reaction-scheme {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 1.5em auto;
    max-width: 700px;
}

/* --- Substrate Panel --- */
#substrate-panel {
    width: 250px;
    flex-shrink: 0;
    text-align: center;
}

#substrate-svg {
    width: 250px;
    height: 200px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: white;
    overflow: hidden;
}

#substrate-svg svg {
    width: 100%;
    height: 100%;
}


/* --- Arrow Panel --- */
#arrow-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 0.3em;
    min-width: 130px;
}

#arrow-reagent {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    text-align: center;
    margin-bottom: 2px;
    line-height: 1.3;
}

.reaction-arrow {
    font-size: 2.5rem;
    color: #555;
    line-height: 1;
    user-select: none;
}

#arrow-reagent {
    cursor: help;
}

#arrow-conditions {
    font-size: 0.78rem;
    color: #888;
    text-align: center;
    line-height: 1.4;
    margin-top: 2px;
}

/* --- Reagent structure tooltip --- */
#reagent-tooltip {
    position: fixed;
    transform: translateX(-50%);
    width: 200px;
    height: 150px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 6px;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

#reagent-tooltip.visible {
    opacity: 1;
}

#reagent-tooltip svg {
    width: 100%;
    height: 100%;
}

/* --- Product Panel --- */
#product-panel {
    width: 250px;
    height: 200px;
    border: 2px dashed #ddd;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #fafafa;
    transition: border-color 0.3s, background-color 0.3s, border-style 0.3s;
    overflow: hidden;
}

#product-panel.revealed {
    border-style: solid;
    border-color: #2a9d8f;
    background: white;
}

#product-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.product-question {
    font-size: 3rem;
    font-weight: 700;
    color: #ccc;
    user-select: none;
}

#product-svg {
    width: 100%;
    flex: 1;
    min-height: 0;
}

#product-svg svg {
    width: 100%;
    height: 100%;
}

#product-name {
    font-size: 0.75rem;
    color: #999;
    padding: 2px 8px 4px;
    text-align: center;
    height: 1.6em;
    line-height: 1.6;
    overflow: hidden;
    flex-shrink: 0;
}

/* --- Multiple products (SN1 + E1) --- */
#product-svg {
    overflow-y: auto;
}

.product-item {
    text-align: center;
    padding: 2px 0;
}

.product-item + .product-item {
    border-top: 1px dashed #ddd;
}

.product-item-svg {
    height: 75px;
}

.product-item-svg svg {
    width: 100%;
    height: 100%;
}

.product-item-label {
    font-size: 0.65rem;
    color: #999;
    line-height: 1;
}

/* --- Choices --- */
#guess-controls {
    max-width: 560px;
    margin: 0 auto;
    text-align: center;
}

.choice-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 1em;
}

.choice-btn {
    min-width: 72px;
    padding: 10px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    font-size: 1rem;
    font-weight: 600;
    color: #444;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.choice-btn:hover {
    border-color: #999;
    background: #fafafa;
}

.choice-btn.selected {
    border-color: #6153cc;
    background: #f0eeff;
    color: #6153cc;
}

.choice-btn.correct {
    border-color: #2a9d8f;
    background: #e8f8f5;
    color: #2a9d8f;
}

.choice-btn.wrong {
    border-color: #c0392b;
    background: #fdf2f2;
    color: #c0392b;
}

.choice-btn.missed {
    border-color: #2a9d8f;
    background: white;
    color: #2a9d8f;
    border-style: dashed;
}

.choice-btn:disabled {
    cursor: default;
    opacity: 0.85;
}

.choice-nr {
    min-width: 110px;
}

/* --- Controls --- */
#secondary-controls {
    display: flex;
    gap: 0.5em;
    justify-content: center;
}

#check-btn {
    background-color: #2a9d8f;
    min-width: 120px;
}

#check-btn:disabled {
    background-color: #bbb;
    cursor: default;
}

#skip-next-btn {
    background-color: #bbc8ca;
    min-width: 100px;
}

#skip-next-btn.next-ready {
    background-color: #333;
}

/* --- Reveal / Share row --- */
#reveal-share-row {
    display: flex;
    justify-content: center;
    gap: 1.5em;
    margin: 0.5em 0;
}

#reveal-link, #share-link {
    font-size: 0.85rem;
    color: #999;
}

#share-link {
    text-decoration: none;
}

#share-link:hover {
    color: #666;
}

/* --- Feedback --- */
#feedback-message {
    min-height: 28px;
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0.5em 0 0.3em;
    text-align: center;
}

#explanation {
    max-width: 560px;
    margin: 0 auto;
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
    text-align: left;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

#explanation.visible {
    max-height: 500px;
}

.explain-item {
    margin: 0.3em 0;
    padding: 0.5em 0.8em;
    border-left: 3px solid #2a9d8f;
    background: #f8fffe;
    border-radius: 0 4px 4px 0;
}

.explain-factors {
    margin: 0.4em 0 0;
    padding: 0;
    list-style: none;
}

.explain-factors li {
    padding: 0.2em 0;
    font-size: 0.82rem;
    color: #666;
}

.explain-factors li::before {
    content: "\2022";
    color: #2a9d8f;
    margin-right: 0.4em;
}

/* --- Responsive --- */
@media (max-width: 700px) {
    #reaction-scheme {
        flex-direction: column;
        gap: 0.5em;
    }
    #arrow-panel {
        flex-direction: row;
        gap: 0.8em;
    }
    .reaction-arrow {
        transform: rotate(90deg);
        font-size: 2rem;
    }
    #product-panel {
        width: 250px;
        height: 200px;
    }
    .product-question {
        font-size: 2rem;
    }
}

@media (max-width: 500px) {
    #substrate-svg {
        width: 100%;
        max-width: 250px;
        margin: 0 auto;
    }
    .choice-btn {
        min-width: 60px;
        padding: 8px 12px;
        font-size: 0.9rem;
    }
}
