:root { --primary: #E60005; --bg: #cbd5e1; --card-bg: #ffffff; --text: #1e293b; --accent: #E60005; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: var(--bg); padding: 20px; display: flex; justify-content: center; color: var(--text); }

.card { background: var(--card-bg); padding: 30px; border-radius: 20px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); width: 100%; max-width: 960px; box-sizing: border-box; display: flex; flex-direction: column; }

/* Tool header: logo + tool icon/title side by side, same sizes as the Blend Calculator / Pattern Generator */
.tool-header { display: flex; align-items: center; gap: 16px; padding-bottom: 14px; margin-bottom: 20px; border-bottom: 1px solid #e2e8f0; }
.brand-logo { max-width: 160px; max-height: 40px; width: auto; height: auto; display: block; }
.tool-identity { display: flex; align-items: center; gap: 10px; padding-left: 16px; border-left: 1px solid #e2e8f0; min-width: 0; }
.tool-icon { width: 36px; height: 36px; object-fit: contain; flex-shrink: 0; }
.tool-icon-placeholder { display: inline-flex; align-items: center; justify-content: center; border: 1px dashed #cbd5e1; border-radius: 8px; color: #94a3b8; font-size: 1.2rem; box-sizing: border-box; }
.tool-title { font-size: 0.95rem; color: var(--primary); text-transform: uppercase; margin: 0; font-weight: bold; }
#back-btn { margin-left: auto; font-size: 0.65rem; font-weight: 700; color: #64748b; text-decoration: none; text-transform: uppercase; letter-spacing: 0.05em; padding: 5px 11px; border: 1px solid #e2e8f0; border-radius: 20px; transition: color 0.2s, border-color 0.2s; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
#back-btn i { font-size: 0.85rem; }
#back-btn:hover { color: var(--primary); border-color: var(--primary); }

/* Tabs System */
.tabs { display: flex; gap: 10px; margin: 0 auto 20px; width: 100%; max-width: 500px; box-sizing: border-box; background: #f1f5f9; padding: 5px; border-radius: 12px; }
.tab-btn { flex: 1; padding: 12px; border: none; background: transparent; border-radius: 8px; font-weight: 700; font-size: 0.85rem; color: #64748b; cursor: pointer; transition: all 0.2s; text-transform: uppercase; letter-spacing: 0.5px; }
.tab-btn.active { background: var(--card-bg); color: var(--primary); box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.tab-pane { display: none; flex-direction: column; }
.tab-pane.active { display: flex; animation: fadeIn 0.3s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Two-column calculator layout: inputs left, results + lenses right */
.calc-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; align-items: start; }
.calc-col { display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 860px) {
    .calc-layout { grid-template-columns: 1fr; gap: 0; }
    .calc-col:last-child .section-label:first-child { margin-top: 20px; }
}

.section-label { font-size: 0.7rem; font-weight: 800; color: #94a3b8; margin: 20px 0 10px 0; text-transform: uppercase; letter-spacing: 1.5px; display: flex; align-items: center; }
.section-label::after { content: ""; flex: 1; height: 1px; background: #e2e8f0; margin-left: 10px; }
.section-label:first-child { margin-top: 0; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 10px; }
label { display: flex; align-items: center; gap: 4px; min-height: 22px; font-size: 0.75rem; font-weight: 700; margin-bottom: 5px; color: #64748b; text-transform: uppercase; cursor: pointer; }
.unit-tag { text-transform: none; color: #94a3b8; }

input, select { width: 100%; padding: 12px; border: 2px solid #f1f5f9; border-radius: 10px; font-size: 1rem; box-sizing: border-box; background: #f8fafc; transition: all 0.2s; font-weight: 600; color: #0f172a; }
input:focus, select:focus { border-color: var(--primary); outline: none; background: #fff; }
input[readonly] { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; cursor: not-allowed; }
input.locked { border-color: rgba(230, 0, 5, 0.35); background: rgba(230, 0, 5, 0.04); color: #0f172a; }

/* Lock toggle next to Image Width / Throw Ratio / Throw Distance */
.lock-btn { margin-left: auto; background: none; border: 1px solid #e2e8f0; border-radius: 6px; width: 24px; height: 22px; padding: 0; display: inline-flex; align-items: center; justify-content: center; color: #94a3b8; cursor: pointer; font-size: 0.85rem; transition: all 0.2s; }
.lock-btn:hover { color: var(--primary); border-color: var(--primary); }
.lock-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.hint { font-size: 0.75rem; color: #64748b; margin: 0 0 6px 0; line-height: 1.4; }
.hint i { color: var(--primary); }

.results { background: #f8fafc; border: 2px solid #f1f5f9; padding: 4px 18px; border-radius: 12px; color: var(--text); }
.res-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.9rem; color: #64748b; padding: 12px 0; border-bottom: 1px solid #e2e8f0; }
.res-line:last-of-type { border-bottom: none; }
.res-line.highlight-row { color: var(--text); font-weight: 700; }
.val { color: #0f172a; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.imp { background: rgba(230, 0, 5, 0.08); color: var(--primary); font-size: 0.85rem; font-weight: 800; padding: 5px 12px; border-radius: 20px; white-space: nowrap; }

.btn-print { margin-top: 20px; width: 100%; padding: 16px; border-radius: 12px; border: none; background: var(--primary); color: white; font-weight: 800; cursor: pointer; text-transform: uppercase; letter-spacing: 1px; transition: background 0.2s; box-shadow: 0 4px 15px rgba(230, 0, 5, 0.3); }
.btn-print:hover { background: #b90004; }

/* Diagram Styles */
.diagram-container { background: #f8fafc; border-radius: 15px; padding: 20px; border: 2px solid #e2e8f0; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 400px; }
.diagram-container svg { width: 100%; height: auto; max-width: 400px; }
.diagram-note { font-size: 0.8rem; color: #64748b; text-align: center; margin-top: 15px; line-height: 1.5; }

/* Suggested Lenses */
.lens-list { display: flex; flex-direction: column; gap: 4px; }
.lens-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 12px; border: 1px solid #e2e8f0; border-radius: 8px; text-decoration: none; color: var(--text); background: #f8fafc; transition: border-color 0.2s; }
.lens-item:hover { border-color: var(--primary); }
.lens-item.recommended { border-color: var(--primary); background: rgba(230, 0, 5, 0.04); }
.lens-name { font-weight: 700; font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lens-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; vertical-align: middle; }
.lens-meta { display: flex; align-items: center; gap: 8px; font-size: 0.72rem; color: #94a3b8; flex-shrink: 0; }
.lens-meta i { color: var(--primary); font-size: 1rem; }
.lens-note { font-size: 0.8rem; color: #64748b; margin: 0 0 6px 0; }
.lens-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.lens-more { background: none; border: none; padding: 0; font-size: 0.8rem; font-weight: 700; color: #64748b; cursor: pointer; }
.lens-more:hover { color: var(--primary); }

/* Fixed back tab */
.fixed-back-button { position: fixed; bottom: 20px; right: 0; z-index: 1000; width: 60px; height: 50px; background-color: var(--primary); clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 25% 50%); display: flex; align-items: center; justify-content: flex-end; padding-right: 20px; text-decoration: none; transition: all 0.2s ease; }
.fixed-back-button:hover { background-color: #d40000; transform: translateX(5px); }
.fixed-back-button img { width: 24px; height: 24px; object-fit: contain; }
@media (max-width: 768px) {
    .fixed-back-button { bottom: 10px; width: 60px; height: 45px; }
}

/* Mobile */
@media (max-width: 560px) {
    body { margin: 0; padding: 12px 12px 70px; } /* bottom room so the back tab doesn't cover the download button */
    .card { padding: 20px 16px; border-radius: 16px; }
    .tool-header { flex-wrap: wrap; gap: 12px; }
    .brand-logo { max-width: 130px; }
    .tool-identity { order: 3; flex-basis: 100%; padding-left: 0; border-left: none; }
    .tabs { gap: 5px; }
    .tab-btn { padding: 10px 6px; font-size: 0.75rem; letter-spacing: 0; }
    .grid { gap: 10px; }
    input, select { padding: 10px; }
    .results { padding: 2px 14px; }
    .res-line { font-size: 0.85rem; }
    .diagram-container { min-height: 0; padding: 15px; }
}
@media (max-width: 360px) {
    .grid { grid-template-columns: 1fr; }
}
