:root {
    --calc-primary: #6C63FF;
    --calc-primary-2: #8B7CFF;
    --calc-bg: #FAFAFD;
    --calc-bg-soft: #F8F7FF;
    --calc-card: #FFFFFF;
    --calc-border: #E7E4FF;
    --calc-text: #111827;
    --calc-muted: #667085;
    --calc-shadow: 0 18px 40px rgba(108, 99, 255, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #FFFFFF 0%, var(--calc-bg-soft) 100%);
    color: var(--calc-text);
    overflow-x: hidden;
}

body.tyfit-calculator-page {
    min-height: 100vh;
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
}

.calc-shell {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 14px 18px 0;
}

.calc-header {
    min-height: 48px;
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: 8px;
}

.calc-header h1 {
    margin: 0;
    color: var(--calc-text);
    font-size: 18px;
    line-height: 1.1;
    font-weight: 700;
    text-align: center;
}

.calc-icon-btn,
.calc-header-link {
    width: 42px;
    height: 42px;
    border: 1px solid rgba(108, 99, 255, 0.12);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--calc-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.calc-header-link {
    width: auto;
    padding: 0 10px;
    color: var(--calc-primary);
    font-size: 13px;
    font-weight: 700;
}

.calc-icon-btn svg,
.calc-header-link svg {
    width: 20px;
    height: 20px;
}

.calc-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    margin-top: 14px;
    margin-bottom: 18px;
}

.calc-hero h2 {
    margin: 0;
    color: var(--calc-text);
    font-size: 30px;
    line-height: 1.04;
    font-weight: 800;
    letter-spacing: 0;
}

.calc-hero p {
    margin: 9px 0 0;
    color: var(--calc-muted);
    font-size: 14px;
    line-height: 1.48;
    font-weight: 500;
}

.calc-hero-art {
    width: 74px;
    height: 74px;
    border-radius: 24px;
    background: linear-gradient(135deg, #F0EDFF, #FFFFFF);
    color: var(--calc-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--calc-shadow);
}

.calc-hero-art svg {
    width: 34px;
    height: 34px;
}

.calc-card {
    background: var(--calc-card);
    border: 1px solid var(--calc-border);
    border-radius: 15px;
    box-shadow: var(--calc-shadow);
}

.calc-input-card {
    overflow: hidden;
}

.calc-field-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    position: relative;
    align-items: center;
    gap: 10px 12px;
    min-height: 88px;
    padding: 15px 16px 0px;
}

.calc-field-row::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 0;
    height: 1px;
    background: #F0EEFF;
}

.calc-field-row:last-child::after {
    display: none;
}

.calc-icon-tile {
    width: 42px;
    height: 42px;
    border-radius: 16px;
    background: #F0EDFF;
    color: #5C52E8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.calc-field-row[data-field="activity"] .calc-icon-tile {
    background: #ECFDF3;
    color: #0F9D58;
}

.calc-field-row[data-field="gender"] .calc-icon-tile {
    background: #EAF2FF;
    color: #2563EB;
}

.calc-field-row[data-field="age"] .calc-icon-tile {
    background: #FFF5E8;
    color: #D97706;
}

.calc-field-row[data-field="weight"] .calc-icon-tile,
.calc-field-row[data-field="currentWeight"] .calc-icon-tile,
.calc-field-row[data-field="targetWeight"] .calc-icon-tile {
    background: #FEECEE;
    color: #DC2626;
}

.calc-field-row[data-field="height"] .calc-icon-tile {
    background: #E8FBFF;
    color: #0284C7;
}

.calc-field-row[data-field="bodyFat"] .calc-icon-tile {
    background: #F3EFFF;
    color: #7C3AED;
}

.calc-field-row[data-field="weeks"] .calc-icon-tile {
    background: #F5F3FF;
    color: #6D28D9;
}

.calc-field-row[data-field="tdee"] .calc-icon-tile {
    background: #FFF1EB;
    color: #EA580C;
}

.calc-icon-tile svg {
    width: 20px;
    height: 20px;
}

.calc-field-label {
    display: block;
    min-width: 0;
}

.calc-field-label strong {
    color: var(--calc-text);
    font-size: 15px;
    font-weight: 500;
}

.calc-field-row input,
.calc-field-row select {
    width: 100%;
    max-width: none;
    min-height: 42px;
    border: none;
    border-radius: 12px;
    background: #ffffff;
    color: var(--calc-text);
    font: inherit;
    font-size: 12px !important;
    font-weight: 400;
    padding: 0 12px;
    outline: none;
    transition: none;
    grid-column: 1 / -1;
}

.calc-field-row select {
    appearance: none;
    padding-right: 28px;
}

.calc-field-row input:focus,
.calc-field-row select:focus {
    border: none;
    outline: none;
    box-shadow: none;
}

.calc-control {
    width: 100%;
    max-width: none;
    min-height: 42px;
    border: none;
    border-radius: 12px;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
    padding: 0 0 0 8px;
    grid-column: 1 / -1;
}

.calc-control input {
    max-width: none;
    min-height: 40px;
    border: none;
    border-radius: 0;
    background: transparent;
    font-size: 14px !important;
    box-shadow: none;
    padding: 0 2px 0 0;
}

.calc-control input:focus {
    border: none;
    box-shadow: none;
}

.calc-control:focus-within {
    border: none;
    outline: none;
    box-shadow: none;
}

.calc-control-unit {
    padding: 0 10px 0 8px;
    color: #6b7280;
    font-size: 12px;
    font-style: normal;
    font-weight: 600;
    white-space: nowrap;
}

.calc-error {
    grid-column: 1 / -1;
    display: none;
    margin-top: -4px;
    color: #E11D48;
    font-size: 11px;
    font-weight: 700;
}

.calc-field-row.is-invalid .calc-error {
    display: block;
}

.macro-input-row.is-invalid .calc-error {
    display: block;
}

.calc-helper-card p {
    margin: 0;
    color: var(--calc-text);
    font-size: 13px;
    font-weight: 700;
}

.calc-link-btn {
    border: 0;
    background: #F0EDFF;
    color: var(--calc-primary);
    border-radius: 999px;
    min-height: 34px;
    padding: 0 12px;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.calc-sticky-cta {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(250, 249, 255, 0), rgba(250, 249, 255, 0.96) 32%, rgba(250, 249, 255, 1));
}

.calc-primary-btn {
    width: min(100%, 724px);
    height: 56px;
    margin: 0 auto;
    border: 0;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--calc-primary), var(--calc-primary-2));
    color: #FFFFFF;
    font: inherit;
    font-size: 16px;
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    box-shadow: 0 16px 32px rgba(108, 99, 255, 0.24);
    cursor: pointer;
    text-decoration: none;
}

.calc-primary-btn svg {
    width: 18px;
    height: 18px;
}

.calc-ok-btn {
    width: min(50%, 724px);
    background:#0F9D58;
    height: 48px;
}

.tyfit-calc-modal-actions {
    position: sticky;
    bottom: -24px;
    z-index: 2;
    margin: 18px -22px -24px;
    padding: 14px 22px 18px;
    background: linear-gradient(180deg, rgba(250, 249, 255, 0), rgba(250, 249, 255, 0.96) 28%, #FAF9FF 100%);
}

.calc-secondary-btn {
    min-height: 48px;
    border: 1px solid var(--calc-border);
    border-radius: 16px;
    background: #FFFFFF;
    color: var(--calc-primary);
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.calc-toast {
    position: fixed;
    left: 50%;
    bottom: calc(88px + env(safe-area-inset-bottom));
    z-index: 60;
    transform: translate(-50%, 16px);
    opacity: 0;
    pointer-events: none;
    min-width: min(320px, calc(100vw - 36px));
    padding: 12px 14px;
    border-radius: 999px;
    background: #111827;
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.calc-toast.is-show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.calc-sheet[hidden] {
    display: none !important;
}

.calc-sheet {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.calc-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    backdrop-filter: blur(6px);
}

.calc-sheet-panel {
    position: relative;
    z-index: 1;
    width: min(100%, 760px);
    max-height: 85vh;
    overflow: auto;
    border-radius: 28px 28px 0 0;
    background: #FFFFFF;
    box-shadow: 0 -20px 48px rgba(17, 24, 39, 0.2);
    padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
}

.calc-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.calc-sheet-head h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
}

.calc-result-ring {
    width: 184px;
    height: 184px;
    margin: 8px auto 18px;
    border-radius: 50%;
    background:
        radial-gradient(circle at center, #FFFFFF 0 56%, transparent 57%),
        conic-gradient(var(--calc-primary) 0 78%, #EEEAFE 78% 100%);
    display: grid;
    place-items: center;
    box-shadow: 0 18px 38px rgba(108, 99, 255, 0.16);
}

.calc-result-ring div {
    text-align: center;
}

.calc-result-ring strong {
    display: block;
    color: var(--calc-primary);
    font-size: 38px;
    line-height: 1;
    font-weight: 800;
}

.calc-result-ring span {
    display: block;
    margin-top: 5px;
    color: var(--calc-muted);
    font-size: 13px;
    font-weight: 700;
}

.calc-result-hero {
    display: grid;
    place-items: center;
    margin: 6px auto 14px;
}

.calc-result-hero img {
    width: min(200px, 58vw);
    height: auto;
    display: block;
}

.calc-result-subtitle {
    margin: -8px auto 16px;
    max-width: 310px;
    color: var(--calc-muted);
    font-size: 13px;
    line-height: 1.45;
    text-align: center;
}

.calc-result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.calc-result-grid--single {
    grid-template-columns: 1fr;
}

.calc-result-card {
    padding: 14px;
    border: 1px solid var(--calc-border);
    border-radius: 18px;
    background: #FFFFFF;
    text-align: center;
}

.calc-result-card span {
    color: var(--calc-text);
    font-size: 14px;
    font-weight: 500;
}

.calc-result-card strong {
    display: block;
    margin-top: 6px;
    color: var(--calc-text);
    font-size: 24px;
    font-weight: 800;
}

.calc-result-card .calc-result-unit {
    margin-top: 4px;
    color: var(--calc-muted);
    font-size: 12px;
    font-weight: 400;
}

.calc-action-grid {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.macro-ring-card {
    display: grid;
    place-items: center;
    margin-bottom: 16px;
    padding: 18px;
}

.macro-ring {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(#E9EAF2 0 100%);
    transition: background 0.25s ease;
}

.macro-ring-center {
    width: 132px;
    height: 132px;
    border-radius: 50%;
    background: #FFFFFF;
    display: grid;
    place-items: center;
    text-align: center;
    box-shadow: inset 0 0 0 1px #F0EEFF;
}

.macro-ring-center strong {
    display: block;
    color: var(--calc-text);
    font-size: 34px;
    line-height: 1;
    font-weight: 800;
}

.macro-ring-center span {
    color: var(--calc-muted);
    font-size: 12px;
    font-weight: 700;
}

.macro-input-row {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.macro-input-row label {
    color: var(--calc-muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.macro-input-row input {
    min-height: 52px;
    border: 1px solid var(--calc-border);
    border-radius: 18px;
    background: #FFFFFF;
    color: var(--calc-text);
    font: inherit;
    font-size: 18px;
    font-weight: 800;
    padding: 0 14px;
}

.calc-inline-link {
    justify-self: start;
    color: var(--calc-primary);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

.diet-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0;
}

.diet-option {
    min-height: 72px;
    border: 1px solid var(--calc-border);
    border-radius: 18px;
    background: #FFFFFF;
    color: var(--calc-text);
    text-align: left;
    padding: 12px;
    cursor: pointer;
}

.diet-option.is-active {
    border-color: rgba(108, 99, 255, 0.55);
    background: #F7F5FF;
    box-shadow: 0 10px 24px rgba(108, 99, 255, 0.1);
}

.diet-option strong {
    display: block;
    font-size: 13px;
    font-weight: 800;
}

.diet-option span {
    display: block;
    margin-top: 4px;
    color: var(--calc-muted);
    font-size: 11px;
    font-weight: 700;
}

.custom-ratio-grid,
.macro-card-grid {
    display: grid;
    gap: 10px;
}

.custom-ratio-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 14px;
}

.custom-ratio-grid label {
    display: grid;
    gap: 6px;
    color: var(--calc-muted);
    font-size: 11px;
    font-weight: 800;
}

.custom-ratio-grid input {
    min-height: 44px;
    border: 1px solid var(--calc-border);
    border-radius: 14px;
    padding: 0 10px;
    font: inherit;
    font-weight: 800;
}

.macro-card {
    padding: 14px;
    border: 1px solid var(--calc-border);
    border-radius: 20px;
    background: #FFFFFF;
}

.macro-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.macro-card strong {
    color: var(--calc-text);
    font-size: 22px;
    font-weight: 800;
}

.macro-card span {
    color: var(--calc-muted);
    font-size: 12px;
    font-weight: 700;
}

.macro-progress {
    height: 8px;
    margin-top: 10px;
    border-radius: 999px;
    background: #F0F2F7;
    overflow: hidden;
}

.macro-progress i {
    display: block;
    height: 100%;
    border-radius: inherit;
}

.goal-visual {
    width: 84px;
    height: 84px;
}

.goal-pill {
    width: fit-content;
    max-width: 100%;
    padding: 8px 12px;
    border-radius: 999px;
    background: #F0EDFF;
    color: var(--calc-primary);
    font-size: 12px;
    font-weight: 800;
}

.safety-meter {
    margin-top: 14px;
}

.safety-track {
    position: relative;
    height: 12px;
    border-radius: 999px;
    background: linear-gradient(90deg, #22C55E 0 25%, #A3E635 25% 50%, #F59E0B 50% 75%, #EF4444 75% 100%);
}

.safety-pointer {
    position: absolute;
    top: 50%;
    width: 18px;
    height: 18px;
    border: 3px solid #FFFFFF;
    border-radius: 50%;
    background: var(--calc-text);
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 10px rgba(17, 24, 39, 0.25);
}

.safety-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 7px;
    color: var(--calc-muted);
    font-size: 10px;
    font-weight: 700;
}

.goal-timeline {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.goal-timeline span {
    min-height: 66px;
    padding: 10px;
    border: 1px dashed #D9D5FF;
    border-radius: 16px;
    color: var(--calc-muted);
    font-size: 11px;
    font-weight: 700;
}

.goal-timeline strong {
    display: block;
    color: var(--calc-text);
    font-size: 16px;
    margin-bottom: 4px;
}

.calc-warning {
    margin-top: 12px;
    padding: 12px;
    border-radius: 16px;
    background: #FFF7ED;
    color: #9A3412;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
}

@media (min-width: 768px) {
    body.tyfit-calculator-page {
        padding-bottom: 112px;
    }

    .calc-shell {
        padding-top: 24px;
    }

    .calc-hero h2 {
        font-size: 40px;
    }

    .calc-sticky-cta {
        padding-inline: 22px;
    }

    .macro-card-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 420px) {
    .tyfit-calc-modal-actions {
        bottom: calc(-24px - env(safe-area-inset-bottom));
        margin: 18px -16px calc(-24px - env(safe-area-inset-bottom));
        padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
    }

    .calc-shell {
        padding-inline: 14px;
    }

    .calc-hero h2 {
        font-size: 27px;
    }

    .calc-field-row {
        grid-template-columns: 40px minmax(0, 1fr);
        gap: 9px;
        padding-inline: 12px;
    }

    .calc-icon-tile {
        width: 38px;
        height: 38px;
        border-radius: 14px;
    }

    .calc-field-label strong {
        font-size: 15px;
    }

    .diet-grid {
        grid-template-columns: 1fr;
    }
}
