* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

/* Back-to-calculator link */
.back-link {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 600px;
    margin: 20px auto 0;
    padding: 0 0 8px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: #dc2626;
    text-decoration: none;
    transition: color 0.2s ease, gap 0.2s ease;
}

.back-link::before {
    content: '←';
    font-size: 20px;
    transition: transform 0.2s ease;
}

.back-link:hover {
    color: #b91c1c;
    gap: 10px;
}

.back-link:hover::before {
    transform: translateX(-3px);
}

main{
    margin: 250px 0;
}

main#calculator {
    max-width: 600px;
    margin: 40px auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 40px;
}

main#calculator h1 {
    color: #dc2626;
    margin-bottom: 20px;
    font-size: 28px;
    font-weight: 600;
}

/* main#calculator h1::before {
    content: '🧱 ';
} */
.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

.inputs {
    margin-bottom: 30px;
}

.inputs label {
    display: block;
    margin-top: 18px;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

.inputs label:first-of-type {
    margin-top: 0;
}

.inputs input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.input-unit {
    position: relative;
}

.input-unit.meters input {
    padding-right: 35px;
}

.input-unit.millimeters input {
    padding-right: 35px;
}

.input-unit::after {
    content: attr(data-unit);
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-weight: 500;
    pointer-events: none;
    line-height: 1;
}

.input-unit.meters input:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.inputs input:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
}

.calculator-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}
.calculator-header h1 {
    color: #dc2626;
    font-size: 28px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}
.calculator-header .product-img {
    width: 80px;
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 6px;
}

button {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#calculate {
    background-color: #dc2626;
    color: white;
}

#calculate:hover {
    background-color: #b91c1c;
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3);
}

#calculate:active {
    transform: translateY(1px);
}

#finalize {
    background-color: #059669;
    color: white;
}

#finalize:hover {
    background-color: #047857;
    box-shadow: 0 4px 8px rgba(5, 150, 105, 0.3);
}

#finalize:active {
    transform: translateY(1px);
}

.hidden {
    display: none !important;
}

.result-section {
    background-color: #fef2f2;
    border-left: 4px solid #dc2626;
    padding: 20px;
    border-radius: 4px;
}

.result-section h2 {
    color: #333;
    font-size: 16px;
    margin-bottom: 10px;
    font-weight: 500;
}

#answer {
    color: #dc2626;
    font-size: 28px;
    font-weight: 700;
}

#cement-answer,
#cement-answer-1,
#cement-answer-2 {
    color: #dc2626;
    font-size: 28px;
    font-weight: 700;
}

.info-text {
    color: #666;
    font-size: 13px;
    margin-top: 15px;
    line-height: 1.6;
}

hr {
    margin: 25px 0;
    border: none;
    border-top: 2px solid #e5e7eb;
}

.cement {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.cement h2 {
    color: #1f2937;
    font-size: 15px;
    margin-top: 20px;
    margin-bottom: 12px;
    font-weight: 600;
    line-height: 1.4;
}

.cement h2:first-child {
    margin-top: 0;
    color: #333;
    font-size: 16px;
    font-weight: 700;
}

.cement>div[id] {
    padding: 16px;
    background-color: #fff7f7;
    border-radius: 4px;
    margin-top: 8px;
    border: 1px solid #ffe4e4;
}

/* Tooltip styles */
.cement h2 {
    cursor: default;
}

.cement h2:hover {
    color: #dc2626;
}

.tooltip {
    display: none;
    position: fixed;
    background-color: #000;
    color: black;
    padding: 12px 14px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    font-weight: normal;
    line-height: 1.6;
    min-width: 220px;
    max-width: 300px;
    pointer-events: none;
    border: 1px solid #444;
}

.tooltip p {
    margin: 0 0 8px 0;
    font-weight: 600;
}

.tooltip li {
    margin-left: 16px;
    margin-top: 4px;
}

.tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 10px;
    border: 6px solid transparent;
    border-bottom-color: #000;
}

.tooltip.above::before {
    top: 100%;
    bottom: auto;
    border-bottom-color: transparent;
    border-top-color: #000;
}

/* Input mode toggle (segmented control) */
.input-mode-toggle {
    display: flex;
    background: #f3f4f6;
    border-radius: 6px;
    padding: 4px;
    gap: 4px;
    margin-bottom: 20px;
}

.mode-btn {
    flex: 1;
    padding: 9px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: #6b7280;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.mode-btn.active {
    background: #dc2626;
    color: #fff;
    box-shadow: 0 1px 4px rgba(220, 38, 38, 0.35);
}

.mode-btn:not(.active):hover {
    background: #e5e7eb;
    color: #374151;
}