/* ========================================
   PT Design Dashboard - White Theme
   ======================================== */

/* ---------- Video Intro Overlay ---------- */
.intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.intro-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.intro-video {
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    filter: contrast(1.08) brightness(1.03) saturate(1.12);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: high-quality;
    backface-visibility: hidden;
    will-change: filter;
    transition: opacity 0.6s ease;
}



.intro-skip {
    position: absolute;
    bottom: 40px;
    right: 40px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 9999px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: 'Inter', system-ui, sans-serif;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    animation: skipFadeIn 0.5s ease-out 1.5s forwards;
}

.intro-skip:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    transform: translateX(2px);
}

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

/* Hidden utility for app shell */
.app-shell.hidden {
    display: none;
}

@media (max-width: 768px) {
    .intro-skip {
        bottom: 24px;
        right: 24px;
        padding: 8px 18px;
        font-size: 0.8rem;
    }
}

/* ---------- Design Tokens ---------- */
:root {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8F9FC;
    --bg-card: #FFFFFF;
    --bg-hover: #F1F3F9;
    --bg-input: #F4F6FA;
    --bg-input-focus: #FFFFFF;

    --text-primary: #1A1D2E;
    --text-secondary: #6B7280;
    --text-tertiary: #9CA3AF;
    --text-accent: #4F46E5;

    --border-light: #E5E7EB;
    --border-medium: #D1D5DB;
    --border-focus: #4F46E5;

    --accent-primary: #4F46E5;
    --accent-primary-light: #EEF2FF;
    --accent-primary-hover: #4338CA;
    --accent-success: #059669;
    --accent-success-light: #ECFDF5;
    --accent-warning: #D97706;
    --accent-warning-light: #FFFBEB;
    --accent-info: #0284C7;
    --accent-info-light: #F0F9FF;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.1);
    --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
    --shadow-card-hover: 0 8px 30px rgba(79, 70, 229, 0.12), 0 4px 12px rgba(0,0,0,0.06);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 10px;
    --radius-full: 9999px;

    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ---------- App Shell ---------- */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Tool-Active Mode: single-screen, no page scroll ── */
body.tool-active {
    overflow: hidden;
    height: 100vh;
}

body.tool-active .app-footer {
    display: none;
}

body.tool-active .app-shell {
    height: 100vh;
    overflow: hidden;
}

body.tool-active .main-content {
    flex: 1;
    overflow: hidden;
    padding: 12px 32px;
}

body.tool-active .tool-header {
    margin-bottom: 8px;
    padding-bottom: 6px;
}

body.tool-active .tool-header-icon {
    width: 32px;
    height: 32px;
}

body.tool-active .tool-header-info h2 {
    font-size: 1.1rem;
}

body.tool-active .tool-header-info p {
    font-size: 0.75rem;
}

body.tool-active .calc-card {
    padding: 12px 16px;
}

body.tool-active .calc-card-title {
    margin-bottom: 8px;
    font-size: 0.8rem;
}

body.tool-active .st-split {
    gap: 10px;
}

body.tool-active .segment-control {
    margin-bottom: 8px;
    padding: 4px;
}

body.tool-active .segment-btn {
    padding: 5px 16px;
    font-size: 0.82rem;
}

/* Compact tables */
body.tool-active .st-table td,
body.tool-active .st-table th {
    padding: 3px 6px;
    font-size: 0.78rem;
}

body.tool-active .st-table th {
    font-size: 0.65rem;
}

body.tool-active .st-section-header td {
    padding: 5px 6px 3px;
    font-size: 0.68rem;
}

body.tool-active .st-computed-val,
body.tool-active .st-out-val {
    font-size: 0.82rem;
}

body.tool-active .st-out-val.st-highlight {
    font-size: 0.85rem;
}

body.tool-active .st-formula {
    font-size: 0.65rem;
}

/* Compact diagram */
body.tool-active .st-diagram-compact {
    height: 220px;
}

/* Compact note/status cards */
body.tool-active .calc-total-card {
    padding: 10px 16px;
}

body.tool-active .calc-total-value {
    font-size: 1.6rem !important;
    margin: 2px 0;
}

body.tool-active .calc-total-unit {
    font-size: 0.78rem;
}

body.tool-active .calc-result-row {
    padding: 3px 0;
}

body.tool-active .calc-result-value {
    font-size: 1.1rem;
}

/* ── Extra compact for 24" monitors (viewport ≤ 1100px height) ── */
@media (max-height: 1100px) {
    body.tool-active .main-content {
        padding: 8px 24px;
    }

    body.tool-active .tool-header {
        margin-bottom: 4px;
        padding-bottom: 4px;
    }

    body.tool-active .tool-header-icon {
        width: 28px;
        height: 28px;
    }

    body.tool-active .tool-header-info h2 {
        font-size: 1rem;
    }

    body.tool-active .tool-header-info p {
        display: none;
    }

    body.tool-active .calc-card {
        padding: 8px 12px;
    }

    body.tool-active .calc-card-title {
        margin-bottom: 6px;
        font-size: 0.75rem;
    }

    body.tool-active .st-split {
        gap: 8px;
    }

    body.tool-active .segment-control {
        margin-bottom: 6px;
        padding: 3px;
    }

    body.tool-active .segment-btn {
        padding: 4px 12px;
        font-size: 0.78rem;
    }

    body.tool-active .st-table td,
    body.tool-active .st-table th {
        padding: 2px 5px;
        font-size: 0.74rem;
    }

    body.tool-active .st-table th {
        font-size: 0.62rem;
    }

    body.tool-active .st-section-header td {
        padding: 4px 5px 2px;
        font-size: 0.64rem;
    }

    body.tool-active .st-computed-val,
    body.tool-active .st-out-val {
        font-size: 0.78rem;
    }

    body.tool-active .st-formula {
        font-size: 0.6rem;
    }

    body.tool-active .st-diagram-compact {
        height: 180px;
    }

    body.tool-active .calc-total-card {
        padding: 6px 12px;
    }

    body.tool-active .calc-total-value {
        font-size: 1.3rem !important;
        margin: 0;
    }

    body.tool-active .calc-total-unit {
        font-size: 0.7rem;
    }

    body.tool-active .calc-result-row {
        padding: 2px 0;
    }

    body.tool-active .calc-result-value {
        font-size: 0.95rem;
    }

    body.tool-active .calc-field label {
        font-size: 0.62rem;
    }

    body.tool-active .calc-field input,
    body.tool-active .calc-field select {
        padding: 3px 5px;
        font-size: 0.8rem;
    }

    body.tool-active .st-input-table input[type="number"],
    body.tool-active .st-input-table select {
        padding: 2px 4px;
        font-size: 0.78rem;
    }

    body.tool-active .top-nav {
        padding: 6px 24px;
    }
}


/* ---------- Top Navigation ---------- */
.top-nav {
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--border-light);
    padding: 0 32px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.nav-brand {
    display: flex;
    align-items: center;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.nav-brand:hover {
    transform: scale(1.02);
}

.nav-brand-logo {
    height: 50px;
    width: auto;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(10, 37, 64, 0.08));
}

.nav-back {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-normal);
    font-family: inherit;
}

.nav-back:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

.nav-back.visible {
    display: flex;
}

.nav-back svg {
    width: 16px;
    height: 16px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* iOS bounce */
    font-family: inherit;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: #007AFF; /* iOS Blue */
    color: #FFFFFF;
}

.btn-primary:hover {
    background: #0062CC;
    box-shadow: 0 4px 10px rgba(0, 122, 255, 0.3);
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    padding: 40px 32px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* ---------- Dashboard View ---------- */
.view {
    display: none;
    animation: viewFadeIn 0.4s var(--transition-smooth) forwards;
}

.view.active {
    display: block;
}

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

/* Dashboard Background */
body.on-dashboard {
    overflow: hidden;
}

body.on-dashboard .main-content {
    max-width: 100%;
    padding: 0;
}

#dashboardView {
    display: none;
    position: relative;
    height: calc(100vh - 68px);
    padding: 48px 48px;
    overflow: hidden;
}

#dashboardView.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#dashboardView::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url('../img/dashboard_bg.png') center center / cover no-repeat;
    z-index: -2;
}

#dashboardView::after {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(15, 23, 42, 0.75) 0%,
        rgba(30, 41, 59, 0.65) 40%,
        rgba(30, 41, 59, 0.80) 100%
    );
    z-index: -1;
}

/* Dashboard Header */
.dashboard-header {
    text-align: center;
    margin-bottom: 48px;
}

.dashboard-title {
    font-size: 2rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dashboard-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 400;
}

/* ---------- Tool Cards Grid ---------- */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1200px;
}

.tool-card {
    background: #ffffff;
    border: none;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: var(--transition-normal);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--card-accent, var(--accent-primary)), var(--card-accent-end, #7C3AED));
    opacity: 0;
    transition: var(--transition-normal);
    z-index: 2;
}

.tool-card:hover {
    transform: translateY(-6px);
    background: #ffffff;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    border-color: transparent;
}

.tool-card:hover::before {
    opacity: 1;
}

.tool-card:active {
    transform: translateY(-2px);
}

/* ── Card Thumbnail ── */
.tool-card-thumb {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.tool-card-img {
    width: 85%;
    height: 85%;
    object-fit: contain;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.tool-card:hover .tool-card-img {
    transform: scale(1.06);
}

/* ── Card Footer (Name + Arrow) ── */
.tool-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
}

.tool-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.tool-arrow {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: #F2F2F7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 2px 5px rgba(0,0,0,0.04);
    flex-shrink: 0;
}

.tool-card:hover .tool-arrow {
    background: var(--accent-primary);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

/* ── Hover Overlay (Description) ── */
.tool-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 16px 20px;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    border-top: 1px solid var(--border-light);
    z-index: 1;
}

.tool-card:hover .tool-card-overlay {
    transform: translateY(0);
}

.tool-card-overlay-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ---------- Tool View ---------- */
.tool-view {
    display: none;
    animation: toolSlideIn 0.45s var(--transition-smooth) forwards;
}

.tool-view.active {
    display: block;
}

@keyframes toolSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-light);
}

.tool-header-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.tool-header-info h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.tool-header-info p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.tool-header-info {
    flex: 1;
}

.btn-export-pdf {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent-primary);
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-export-pdf:hover {
    background: #4338CA;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-export-pdf:active {
    transform: translateY(0);
}

.btn-export-pdf svg {
    flex-shrink: 0;
}

/* ---------- PT Calculator (White Theme) ---------- */
.calc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.calc-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: var(--shadow-card);
    transition: var(--transition-normal);
}

.calc-card:hover {
    box-shadow: var(--shadow-md);
}

.calc-card.full-width {
    grid-column: 1 / -1;
}

.calc-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 20px;
}

.calc-card-title svg {
    width: 20px;
    height: 20px;
}

.calc-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.calc-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.calc-field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.calc-field input,
.calc-field select {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 1rem;
    font-weight: 700;
    color: #1e40af;
    transition: var(--transition-fast);
    outline: none;
    font-family: inherit;
    width: 100%;
}

.calc-field input:focus {
    border-color: var(--border-focus);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.calc-output {
    border-top: 1px solid var(--border-light);
    margin-top: 20px;
    padding-top: 16px;
}

.calc-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.calc-result-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.calc-result-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--accent-primary);
}

.calc-result-unit {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-left: 4px;
}

/* Total card */
.calc-total-card {
    background: linear-gradient(135deg, #EEF2FF, #F5F3FF);
    border: 1px solid rgba(79, 70, 229, 0.12);
    text-align: center;
}

.calc-total-value {
    font-size: 3rem;
    font-weight: 900;
    color: var(--accent-primary);
    margin: 8px 0;
    letter-spacing: -0.03em;
}

.calc-total-unit {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-tertiary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1rem;
    font-weight: 500;
}

/* ---------- Footer ---------- */
.app-footer {
    text-align: center;
    padding: 24px 32px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-primary);
}

.footer-text {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    font-weight: 400;
}

/* ---------- Animations ---------- */
.tool-card {
    opacity: 0;
    animation: cardFadeIn 0.5s ease-out forwards;
}

.tool-card:nth-child(1) { animation-delay: 0.05s; }
.tool-card:nth-child(2) { animation-delay: 0.1s; }
.tool-card:nth-child(3) { animation-delay: 0.15s; }
.tool-card:nth-child(4) { animation-delay: 0.2s; }
.tool-card:nth-child(5) { animation-delay: 0.25s; }
.tool-card:nth-child(6) { animation-delay: 0.3s; }

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

.calc-card {
    opacity: 0;
    animation: calcCardIn 0.5s ease-out forwards;
}

.calc-card:nth-child(1) { animation-delay: 0.05s; }
.calc-card:nth-child(2) { animation-delay: 0.1s; }
.calc-card:nth-child(3) { animation-delay: 0.15s; }
.calc-card:nth-child(4) { animation-delay: 0.2s; }

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

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .top-nav {
        padding: 0 16px;
    }

    .main-content {
        padding: 24px 16px;
    }

    .dashboard-title {
        font-size: 1.5rem;
    }

    .tools-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

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

    .tool-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

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

    .calc-total-value {
        font-size: 2.2rem;
    }

    .nav-back span {
        display: none;
    }
}

@media (max-width: 480px) {
    .calc-inputs {
        grid-template-columns: 1fr;
    }
}

/* ---------- Segment Control (Toggle) ---------- */
.segment-control {
    display: inline-flex;
    background: var(--bg-input);
    padding: 6px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-light);
    margin-bottom: 24px;
}

.segment-btn {
    padding: 8px 20px;
    border: none;
    background: transparent;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-normal);
    font-family: inherit;
}

.segment-btn.active {
    background: var(--bg-primary);
    color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.segment-btn:hover:not(.active) {
    color: var(--text-primary);
}

/* ---------- Strut & Tie Split Layout ---------- */
.st-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: stretch;
}

.st-left,
.st-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.st-left > :last-child,
.st-right > :last-child {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Compact cards for fitting on one screen */
.st-split .calc-card {
    padding: 18px 20px;
    border-radius: var(--radius-lg);
}

.st-split .calc-card-title {
    margin-bottom: 12px;
    font-size: 0.88rem;
}

.st-split .calc-inputs {
    gap: 10px;
}

.st-split .calc-field label {
    font-size: 0.68rem;
    margin-bottom: 2px;
}

.st-split .calc-field input,
.st-split .calc-field select {
    padding: 7px 10px;
    font-size: 0.88rem;
    border-radius: var(--radius-sm);
}

.st-split .calc-output {
    margin-top: 12px;
    padding-top: 10px;
}

.st-split .calc-result-row {
    padding: 5px 0;
}

.st-split .calc-result-value {
    font-size: 1.15rem;
}

.st-split .calc-total-card {
    padding: 16px 20px;
}

.st-split .calc-total-value {
    font-size: 2rem;
    margin: 4px 0;
}

.st-split .calc-total-unit {
    font-size: 1.2rem;
}

/* Diagram compact */
.st-diagram-compact {
    height: 260px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* Input section title inline */
.st-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.st-section-label svg {
    width: 14px;
    height: 14px;
}

/* Compact input grid: more columns */
.st-compact-inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.st-compact-inputs .calc-field label {
    font-size: 0.65rem;
}

.st-compact-inputs .calc-field input,
.st-compact-inputs .calc-field select {
    padding: 6px 8px;
    font-size: 0.85rem;
}

/* ── Spreadsheet-style tables ── */
.st-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.st-table td, .st-table th {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.st-table th {
    background: var(--bg-card);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--accent-primary);
}

/* Section header rows */
.st-table .st-section-header td {
    font-weight: 800;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-primary);
    background: rgba(79, 70, 229, 0.05);
    border-bottom: 2px solid var(--accent-primary);
    padding: 8px 8px 4px;
}

/* Input table */
.st-input-table input[type="number"],
.st-input-table select {
    width: 100%;
    padding: 4px 6px;
    font-size: 0.85rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: #fff;
    font-weight: 700;
    text-align: right;
    color: #1e40af;
    font-family: inherit;
    cursor: pointer;
}

.st-input-table select {
    text-align: left;
    appearance: auto;
}

.st-input-table input[type="number"]:focus,
.st-input-table select:focus {
    border-color: var(--accent-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

/* ── Global form element unification ── */
#toolBody select,
#toolBody input[type="number"],
#toolBody input[type="text"] {
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e40af;
    padding: 4px 6px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: #fff;
}

#toolBody select {
    cursor: pointer;
}

#toolBody select:focus,
#toolBody input[type="number"]:focus,
#toolBody input[type="text"]:focus {
    border-color: var(--accent-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

/* Computed rows (Deff, θ, F factored in input) */
.st-computed-row {
    background: #fefce8;
}

.st-computed-val {
    font-weight: 800;
    color: #b45309;
    text-align: right;
    font-size: 0.88rem;
    white-space: nowrap;
}

/* Formula column */
.st-formula {
    font-size: 0.7rem;
    color: #6b7280;
    font-style: italic;
    white-space: nowrap;
}

.st-formula.st-note {
    font-style: normal;
    color: #9ca3af;
}

/* Output table */
.st-output-table .st-section-header td {
    border-bottom: 2px solid currentColor;
}

.st-out-val {
    font-weight: 800;
    text-align: right;
    font-size: 0.88rem;
    color: var(--text-primary);
}

.st-highlight-row {
    background: #eff6ff;
}

.st-out-val.st-highlight {
    color: var(--accent-primary);
    font-size: 0.92rem;
}

/* Responsive: stack on narrow */
@media (max-width: 1024px) {
    .st-split {
        grid-template-columns: 1fr;
    }
}
