/* ========================================
   CNC Calc Pro - Mobile-First Responsive
   Theme: Azul Glossy + Preto + Amarelo
   ======================================== */

:root {
    --blue-primary: #1976D2;
    --blue-glossy: #2196F3;
    --blue-light: #42A5F5;
    --blue-dark: #0D47A1;
    --blue-glow: rgba(33, 150, 243, 0.3);
    --blue-subtle: rgba(33, 150, 243, 0.08);
    --black-bg: #0a0e17;
    --black-card: #111827;
    --black-surface: #1a2235;
    --yellow-accent: #FFD200;
    --yellow-soft: rgba(255, 210, 0, 0.12);
    --text-primary: #e8edf5;
    --text-secondary: #8899b0;
    --text-muted: #556677;
    --green-success: #4CAF50;
    --red-error: #ef5350;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-blue: 0 4px 20px rgba(33, 150, 243, 0.2);
    --shadow-lift: 0 8px 32px rgba(0,0,0,0.5);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== RESET & BASE ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--black-bg);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ========== HEADER ========== */
.header {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.98) 0%, rgba(17, 24, 39, 0.92) 100%);
    border-bottom: 1px solid rgba(33, 150, 243, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.logo h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.highlight {
    color: var(--yellow-accent);
}

.tagline {
    font-size: 0.65rem;
    color: var(--text-secondary);
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

/* Mobile hamburger */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
}

.nav-toggle:hover {
    background: var(--blue-subtle);
    color: var(--blue-light);
}

.nav-toggle svg {
    display: block;
}

.nav-links {
    display: flex;
    gap: 4px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
    color: var(--blue-light);
    background: var(--blue-subtle);
}

/* ========== MAIN ========== */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 14px;
    text-align: center;
    color: var(--text-primary);
}

.section-desc {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.85rem;
    padding: 0 8px;
}

/* ========== MODE SELECTOR ========== */
.mode-section {
    margin-bottom: 24px;
}

.mode-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.mode-card {
    background: var(--black-card);
    border: 2px solid transparent;
    border-radius: var(--radius);
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    min-height: 44px; /* Touch target */
}

.mode-card svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.mode-card span {
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

.mode-card small {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.2;
}

.mode-card:hover {
    border-color: var(--blue-glossy);
    background: var(--black-surface);
    box-shadow: var(--shadow-blue);
}

.mode-card:active {
    transform: scale(0.97);
}

.mode-card.active {
    border-color: var(--blue-glossy);
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.15) 0%, rgba(33, 150, 243, 0.05) 100%);
    color: var(--blue-light);
    box-shadow: var(--shadow-blue);
}

.mode-card.active small {
    color: var(--blue-light);
    opacity: 0.7;
}

/* ========== CALCULATOR ========== */
.calc-section {
    margin-bottom: 40px;
}

.calc-panel {
    background: var(--black-card);
    border: 1px solid rgba(33, 150, 243, 0.12);
    border-radius: var(--radius);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tool-visual {
    display: none; /* Hidden on mobile by default */
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.tool-visual svg {
    filter: drop-shadow(0 4px 12px rgba(33, 150, 243, 0.3));
}

/* ========== INPUTS ========== */
.calc-inputs {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.calc-title {
    font-size: 1.1rem;
    color: var(--blue-light);
    font-weight: 700;
}

.calc-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: -6px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--transition);
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-group label svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.input-group input[type="number"] {
    background: var(--black-surface);
    border: 2px solid rgba(33, 150, 243, 0.12);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    width: 100%;
    min-height: 48px; /* Minimum touch target */
    -webkit-appearance: none;
    appearance: none;
}

.input-group input[type="number"]:focus {
    outline: none;
    border-color: var(--blue-glossy);
    box-shadow: 0 0 0 3px var(--blue-glow);
    background: rgba(26, 34, 53, 0.9);
}

.input-group input[type="number"]::placeholder {
    color: var(--text-muted);
}

/* State classes */
.input-group.is-result label {
    color: var(--yellow-accent);
    font-weight: 600;
}

.input-group.is-result input {
    border-color: rgba(255, 210, 0, 0.4);
    background: var(--yellow-soft);
    color: var(--yellow-accent);
    font-weight: 700;
    cursor: not-allowed;
}

.input-group.is-required label {
    color: var(--blue-light);
}

.input-group.is-required input {
    border-color: rgba(33, 150, 243, 0.3);
}

.input-group.is-optional {
    opacity: 0.45;
    transition: opacity var(--transition);
}

.input-group.is-optional:focus-within {
    opacity: 1;
}

.input-group.is-hidden {
    display: none;
}

/* Flute Selector */
.flute-selector {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.flute-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    border: 2px solid rgba(33, 150, 243, 0.12);
    background: var(--black-surface);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    -webkit-appearance: none;
    min-height: 48px;
}

.flute-btn:hover,
.flute-btn:active {
    border-color: var(--blue-glossy);
    color: var(--blue-light);
}

.flute-btn.active {
    border-color: var(--blue-glossy);
    background: rgba(33, 150, 243, 0.2);
    color: var(--blue-light);
}

.flute-custom {
    width: 80px !important;
    min-height: 48px;
    text-align: center;
}

/* Helper Button */
.helper-btn {
    background: var(--blue-subtle);
    border: 1px dashed rgba(33, 150, 243, 0.3);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--blue-light);
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    align-self: flex-start;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.helper-btn:hover,
.helper-btn:active {
    background: rgba(33, 150, 243, 0.15);
    border-color: var(--blue-glossy);
}

/* Calculate Button */
.calc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--blue-primary) 0%, var(--blue-glossy) 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 6px;
    font-family: inherit;
    min-height: 52px;
    -webkit-appearance: none;
    box-shadow: 0 4px 16px rgba(33, 150, 243, 0.3);
}

.calc-btn:hover {
    box-shadow: 0 6px 24px rgba(33, 150, 243, 0.5);
    filter: brightness(1.05);
}

.calc-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

/* ========== RESULTS ========== */
.results-panel {
    background: var(--black-surface);
    border: 1px solid rgba(33, 150, 243, 0.12);
    border-radius: var(--radius);
    padding: 20px 16px;
}

.results-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
    margin-bottom: 14px;
    color: var(--green-success);
}

.results-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-item {
    background: var(--black-card);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    border-left: 3px solid var(--blue-glossy);
}

.result-item.is-main {
    border-left-color: var(--yellow-accent);
    background: linear-gradient(135deg, rgba(255, 210, 0, 0.06) 0%, var(--black-card) 100%);
    border-left-width: 4px;
}

.result-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.result-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.result-item.is-main .result-value {
    color: var(--yellow-accent);
    font-size: 1.6rem;
}

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

/* Formulas */
.formula-section {
    margin-top: 14px;
}

.formula-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 6px 0;
    font-family: inherit;
    transition: var(--transition);
    min-height: 44px;
    display: flex;
    align-items: center;
}

.formula-toggle:hover {
    color: var(--blue-light);
}

.formula-content {
    margin-top: 8px;
    padding: 12px;
    background: var(--black-card);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.8;
    font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ========== MATERIALS TABLE ========== */
.materials-section {
    margin-bottom: 40px;
}

.table-filters {
    display: flex;
    gap: 6px;
    justify-content: flex-start;
    margin-bottom: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.table-filters::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    padding: 10px 16px;
    border-radius: 24px;
    border: 1px solid rgba(33, 150, 243, 0.15);
    background: var(--black-card);
    color: var(--text-secondary);
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
    min-height: 44px;
    flex-shrink: 0;
}

.filter-btn:hover,
.filter-btn:active {
    border-color: var(--blue-glossy);
    color: var(--blue-light);
}

.filter-btn.active {
    background: var(--blue-glossy);
    color: white;
    border-color: var(--blue-glossy);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    border: 1px solid rgba(33, 150, 243, 0.1);
    /* Scroll hint gradient */
    background:
        linear-gradient(to right, var(--black-card) 30%, transparent),
        linear-gradient(to left, var(--black-card) 30%, transparent);
    background-size: 40px 100%;
    background-position: left, right;
    background-repeat: no-repeat;
}

.materials-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    min-width: 600px;
}

.materials-table th {
    background: var(--black-surface);
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--blue-light);
    white-space: nowrap;
    border-bottom: 2px solid rgba(33, 150, 243, 0.15);
    position: sticky;
    top: 0;
    z-index: 1;
}

.materials-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    color: var(--text-primary);
    white-space: nowrap;
}

.materials-table tr:nth-child(even) {
    background: rgba(255,255,255,0.015);
}

.materials-table tr:hover {
    background: var(--blue-subtle);
}

.materials-table .use-btn {
    background: rgba(33, 150, 243, 0.12);
    border: 1px solid rgba(33, 150, 243, 0.4);
    border-radius: 8px;
    padding: 8px 16px;
    color: var(--blue-light);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    min-height: 36px;
    font-weight: 600;
    white-space: nowrap;
}

.materials-table .use-btn:hover,
.materials-table .use-btn:active {
    background: var(--blue-glossy);
    color: white;
}

/* ========== HELP ========== */
.help-section {
    margin-bottom: 40px;
}

.help-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.help-card {
    background: var(--black-card);
    border: 1px solid rgba(33, 150, 243, 0.08);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.help-step {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-glossy));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: white;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.help-card h4 {
    font-size: 0.95rem;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.help-card p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.formulas-reference {
    background: var(--black-card);
    border: 1px solid rgba(33, 150, 243, 0.08);
    border-radius: var(--radius);
    padding: 20px;
}

.formulas-reference h3 {
    font-size: 1.05rem;
    margin-bottom: 14px;
    color: var(--blue-light);
}

.formula-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.formula-item {
    background: var(--black-surface);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
    overflow-x: auto;
}

.formula-item strong {
    color: var(--yellow-accent);
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 0;
}

.modal-content {
    background: var(--black-card);
    border: 1px solid rgba(33, 150, 243, 0.15);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px 16px;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    max-height: 80dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: var(--black-surface);
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
    background: rgba(33, 150, 243, 0.1);
}

.modal-content h3 {
    font-size: 1.15rem;
    margin-bottom: 6px;
}

.modal-content > p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.modal-materials {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-mat-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--black-surface);
    border: 1px solid rgba(33, 150, 243, 0.08);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    font-size: 0.88rem;
    min-height: 48px;
    gap: 8px;
    text-align: left;
}

.modal-mat-btn:hover,
.modal-mat-btn:active {
    border-color: var(--blue-glossy);
    background: var(--blue-subtle);
}

.modal-mat-btn .mat-range {
    font-size: 0.75rem;
    color: var(--blue-light);
    text-align: right;
    flex-shrink: 0;
}

/* ========== FLOATING ADS ========== */
.floating-ad {
    position: fixed;
    z-index: 500;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-lift);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    animation: floatIn 0.5s ease-out;
    max-width: calc(100vw - 32px);
}

.floating-ad:hover {
    transform: scale(1.02);
    box-shadow: 0 12px 48px rgba(0,0,0,0.6);
}

@keyframes floatIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.floating-ad .ad-content {
    display: flex;
    flex-direction: column;
    background: var(--black-card);
    border: 1px solid rgba(33, 150, 243, 0.15);
    border-radius: var(--radius);
    overflow: hidden;
    max-width: 280px;
}

.floating-ad .ad-image {
    width: 100%;
    height: auto;
    display: block;
}

.floating-ad .ad-text {
    padding: 12px 14px;
}

.floating-ad .ad-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    line-height: 1.3;
}

.floating-ad .ad-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.floating-ad .ad-cta {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 14px;
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-glossy));
    color: white;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(33, 150, 243, 0.3);
}

.floating-ad .ad-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: rgba(0,0,0,0.7);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 2;
}

.floating-ad .ad-close:hover {
    background: rgba(0,0,0,0.95);
}

.floating-ad .ad-label {
    position: absolute;
    top: 6px;
    left: 8px;
    background: rgba(0,0,0,0.6);
    color: var(--text-muted);
    font-size: 0.55rem;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========== FOOTER ========== */
.footer {
    background: var(--black-card);
    border-top: 1px solid rgba(33, 150, 243, 0.08);
    padding: 20px 16px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.footer-small {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ========== SCROLLBAR (desktop) ========== */
@media (pointer: fine) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    ::-webkit-scrollbar-track {
        background: var(--black-bg);
    }
    ::-webkit-scrollbar-thumb {
        background: var(--black-surface);
        border-radius: 4px;
    }
    ::-webkit-scrollbar-thumb:hover {
        background: rgba(33, 150, 243, 0.3);
    }
}

/* Number input arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.5;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   Mobile-first: styles above are for mobile
   ============================================ */

/* ---------- Small phones (< 360px) ---------- */
@media (max-width: 360px) {
    .mode-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .mode-card svg {
        width: 24px;
        height: 24px;
    }
    .mode-card span {
        font-size: 0.72rem;
    }
    .logo h1 {
        font-size: 1.05rem;
    }
    .floating-ad .ad-content {
        max-width: 200px;
    }
    .btn-seja-pro {
        font-size: 0.75rem;
        padding: 6px 10px;
        gap: 4px;
    }
    .quiz-option {
        padding: 6px 12px;
        font-size: 0.78rem;
    }
}

/* ---------- Tablets (>= 600px) ---------- */
@media (min-width: 600px) {
    .main-container {
        padding: 24px;
    }

    .section-title {
        font-size: 1.3rem;
    }

    .mode-cards {
        grid-template-columns: repeat(6, 1fr);
        gap: 10px;
    }

    .mode-card {
        padding: 16px 10px;
    }

    .mode-card svg {
        width: 32px;
        height: 32px;
    }

    .mode-card span {
        font-size: 0.85rem;
    }

    .calc-panel {
        padding: 24px;
    }

    .help-cards {
        grid-template-columns: repeat(3, 1fr);
    }

    .help-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .formula-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    /* Modal centered on tablet+ */
    .modal-overlay {
        align-items: center;
        padding: 24px;
    }

    .modal-content {
        border-radius: var(--radius);
        padding: 32px;
        max-height: 75vh;
    }
}

/* ---------- Desktop (>= 900px) ---------- */
@media (min-width: 900px) {
    .header-content {
        padding: 12px 32px;
    }

    .logo-icon {
        width: 40px;
        height: 40px;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .main-container {
        padding: 32px;
    }

    .section-title {
        font-size: 1.4rem;
        margin-bottom: 18px;
    }

    .mode-card {
        padding: 18px 12px;
        gap: 6px;
    }

    .mode-card:hover {
        transform: translateY(-3px);
    }

    .mode-card svg {
        width: 36px;
        height: 36px;
    }

    .mode-card span {
        font-size: 0.95rem;
    }

    .mode-card small {
        font-size: 0.7rem;
    }

    /* 3-column layout for calculator */
    .calc-panel {
        display: grid;
        grid-template-columns: auto 1fr 280px;
        gap: 28px;
        padding: 32px;
        align-items: start;
    }

    .tool-visual {
        display: flex;
        padding-top: 40px;
    }

    /* Sticky results on desktop */
    .results-panel {
        position: sticky;
        top: 80px;
        min-width: 260px;
    }

    .formula-list {
        grid-template-columns: repeat(3, 1fr);
    }

    .floating-ad .ad-content {
        max-width: 300px;
    }
}

/* ---------- Large desktop (>= 1200px) ---------- */
@media (min-width: 1200px) {
    .calc-panel {
        grid-template-columns: auto 1fr 320px;
        gap: 36px;
        padding: 36px;
    }

    .result-item.is-main .result-value {
        font-size: 1.8rem;
    }

    .formula-list {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
}

/* ========== MOBILE NAV ========== */
@media (max-width: 599px) {
    .nav-toggle {
        display: block;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--black-card);
        border-bottom: 1px solid rgba(33, 150, 243, 0.15);
        flex-direction: column;
        padding: 8px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-link {
        padding: 14px 16px;
        font-size: 0.95rem;
        border-radius: var(--radius-sm);
    }
}

/* ========== TOUCH ENHANCEMENTS ========== */
@media (pointer: coarse) {
    .mode-card:active,
    .calc-btn:active,
    .filter-btn:active,
    .helper-btn:active,
    .flute-btn:active,
    .use-btn:active {
        transform: scale(0.97);
    }

    /* Larger touch targets */
    .input-group input[type="number"] {
        padding: 16px;
        font-size: 1.05rem;
    }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    html {
        scroll-behavior: auto;
    }
}

/* ========== LANDSCAPE PHONE ========== */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        position: relative;
    }
    .mode-cards {
        grid-template-columns: repeat(6, 1fr);
    }
    .mode-card svg {
        width: 24px;
        height: 24px;
    }
    .mode-card small {
        display: none;
    }
}

/* ========================================
   PREMIUM SYSTEM STYLES
   Auth, AI Chat, Limits
   ======================================== */

/* --- Header Auth Area --- */
.header-auth {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.btn-login {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--blue-glossy);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.btn-login:hover {
    background: var(--blue-light);
    box-shadow: var(--shadow-blue);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
}
.user-name {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
}
.premium-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, var(--yellow-accent), #FFA000);
    color: #000;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.btn-logout {
    background: none;
    border: 1px solid var(--text-muted);
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: var(--transition);
}
.btn-logout:hover {
    border-color: var(--red-error);
    color: var(--red-error);
}

/* --- Calc Limit Bar --- */
.calc-limit-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--black-card);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 6px 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    position: sticky;
    top: 60px;
    z-index: 99;
}
.limit-progress-track {
    flex: 1;
    max-width: 200px;
    height: 4px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
    overflow: hidden;
}
.limit-progress-fill {
    height: 100%;
    background: var(--blue-glossy);
    border-radius: 2px;
    transition: width 0.4s ease;
}
.limit-progress-fill.low {
    background: #FF9800;
}
.limit-progress-fill.empty {
    background: var(--red-error);
}

/* --- Auth Modal --- */
.modal-auth {
    max-width: 400px;
    width: 90%;
}
.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(255,255,255,0.08);
}
.auth-tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}
.auth-tab-btn.active {
    color: var(--blue-glossy);
    border-bottom-color: var(--blue-glossy);
}
.auth-tab-content {
    display: none;
}
.auth-tab-content.active {
    display: block;
}
.auth-field {
    margin-bottom: 14px;
}
.auth-field label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 4px;
}
.auth-field input {
    width: 100%;
    padding: 10px 14px;
    background: var(--black-bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    box-sizing: border-box;
}
.auth-field input:focus {
    border-color: var(--blue-glossy);
    box-shadow: 0 0 0 3px var(--blue-glow);
}
.auth-error {
    color: var(--red-error);
    font-size: 0.8rem;
    min-height: 20px;
    margin-bottom: 8px;
}
.auth-submit {
    width: 100%;
    padding: 12px;
    background: var(--blue-glossy);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}
.auth-submit:hover {
    background: var(--blue-light);
    box-shadow: var(--shadow-blue);
}
.auth-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.auth-note {
    margin-top: 14px;
    padding: 10px;
    background: var(--yellow-soft);
    border-radius: var(--radius-sm);
    color: var(--yellow-accent);
    font-size: 0.78rem;
    text-align: center;
    line-height: 1.4;
}

/* --- Limit Modal --- */
.modal-limit {
    max-width: 400px;
    width: 90%;
    text-align: center;
}
.limit-icon {
    margin-bottom: 12px;
}
.modal-limit h3 {
    color: #FF9800;
    font-size: 1.2rem;
    margin-bottom: 8px;
}
.modal-limit p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 20px;
}
.limit-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.btn-hotmart {
    display: block;
    padding: 12px;
    background: linear-gradient(135deg, var(--yellow-accent), #FFA000);
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
}
.btn-hotmart:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(255, 210, 0, 0.3);
}

/* --- AI Chat Panel --- */
.ai-chat-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 140px);
    background: var(--black-card);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lift);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.ai-chat-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.9rem;
}
.ai-chat-actions {
    display: flex;
    gap: 4px;
}
.ai-chat-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}
.ai-chat-actions button:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ai-msg {
    display: flex;
}
.ai-msg.user {
    justify-content: flex-end;
}
.ai-msg.assistant {
    justify-content: flex-start;
}
.ai-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.5;
    word-wrap: break-word;
}
.ai-msg.user .ai-bubble {
    background: var(--blue-glossy);
    color: white;
    border-bottom-right-radius: 4px;
}
.ai-msg.assistant .ai-bubble {
    background: var(--black-surface);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.typing-dots span {
    animation: blink 1.4s infinite;
    font-size: 1.5rem;
    line-height: 1;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
    0%, 20% { opacity: 0.2; }
    50% { opacity: 1; }
    80%, 100% { opacity: 0.2; }
}
.ai-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.ai-input-area input {
    flex: 1;
    padding: 10px 14px;
    background: var(--black-bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition);
}
.ai-input-area input:focus {
    border-color: var(--blue-glossy);
}
.ai-send-btn {
    background: var(--blue-glossy);
    border: none;
    color: white;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: var(--transition);
}
.ai-send-btn:hover {
    background: var(--blue-light);
}

/* --- AI Float Button --- */
.ai-float-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--blue-glossy), var(--blue-dark));
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    /* display is controlled by JS - starts as display:none in HTML */
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(33, 150, 243, 0.4);
    z-index: 999;
    transition: var(--transition);
}
.ai-float-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(33, 150, 243, 0.5);
}

/* --- Premium body class hides ads and Seja PRO --- */
body.is-premium #floating-ads-container {
    display: none !important;
}
body.is-premium .btn-seja-pro {
    display: none !important;
}
body:not(.is-premium) .ai-float-btn {
    display: none !important;
}
body:not(.is-premium) .ai-chat-panel {
    display: none !important;
}

/* --- Mobile adjustments for premium --- */
@media (max-width: 599px) {
    .header-auth {
        gap: 4px;
    }
    .btn-login {
        padding: 6px 10px;
        font-size: 0.78rem;
    }
    .btn-login svg {
        width: 14px;
        height: 14px;
    }
    .user-name {
        font-size: 0.78rem;
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .calc-limit-bar {
        padding: 5px 12px;
        font-size: 0.7rem;
        top: 56px;
    }
    .ai-chat-panel {
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    .ai-float-btn {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }
    .modal-auth, .modal-limit {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* ========== SEJA PRO BUTTON ========== */
.btn-seja-pro {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #FFD200, #FFA000);
    color: #1a1a1a;
    font-weight: 700;
    font-size: 0.85rem;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: var(--transition);
    box-shadow: 0 2px 12px rgba(255, 210, 0, 0.3);
    animation: sejaProPulse 2.5s ease-in-out infinite;
}

.btn-seja-pro:hover {
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 4px 20px rgba(255, 210, 0, 0.5);
}

@keyframes sejaProPulse {
    0%, 100% { box-shadow: 0 2px 12px rgba(255, 210, 0, 0.3); }
    50% { box-shadow: 0 2px 20px rgba(255, 210, 0, 0.55); }
}

/* ========== EMAIL VERIFICATION ========== */
.verify-container {
    text-align: center;
    padding: 8px 0;
}
.verify-icon {
    margin-bottom: 12px;
}
.verify-title {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.verify-desc {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
    margin-bottom: 24px;
}
.verify-desc strong {
    color: var(--blue-light);
}
.verify-code-boxes {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}
.verify-code-input {
    width: 46px;
    height: 54px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--yellow-accent);
    background: var(--black-surface);
    border: 2px solid rgba(33, 150, 243, 0.2);
    border-radius: 10px;
    outline: none;
    caret-color: var(--blue-glossy);
    transition: var(--transition);
    font-family: 'Courier New', monospace;
}
.verify-code-input:focus {
    border-color: var(--blue-glossy);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}
.verify-resend {
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.verify-resend-btn {
    background: none;
    border: none;
    color: var(--blue-light);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    text-decoration: underline;
    padding: 0;
}
.verify-resend-btn:hover {
    color: var(--blue-glossy);
}
.verify-resend-btn:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    text-decoration: none;
}
.verify-back-btn {
    margin-top: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
}
.verify-back-btn:hover {
    color: var(--text-primary);
}

/* ========== AI QUESTIONNAIRE ========== */
.quiz-question {
    color: var(--text-primary);
    font-size: 0.92rem;
    line-height: 1.5;
    margin-bottom: 10px;
}

.quiz-question strong {
    color: var(--yellow-accent);
}

.quiz-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.quiz-option {
    display: inline-block;
    padding: 8px 16px;
    background: var(--black-surface);
    color: var(--text-primary);
    border: 1.5px solid rgba(33, 150, 243, 0.25);
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.quiz-option:hover {
    background: rgba(33, 150, 243, 0.15);
    border-color: var(--blue-glossy);
    transform: translateY(-1px);
}

.quiz-option.selected {
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-glossy));
    color: #fff;
    border-color: var(--blue-glossy);
    box-shadow: 0 2px 12px rgba(33, 150, 243, 0.35);
    pointer-events: none;
}

.quiz-options .quiz-option:not(.selected) {
    opacity: 1;
    transition: opacity 0.3s;
}

.quiz-option.selected ~ .quiz-option:not(.selected),
.quiz-options:has(.selected) .quiz-option:not(.selected) {
    opacity: 0.4;
    pointer-events: none;
}

/* ========== VALUE ALERTS (AI Recommendations) ========== */
.value-warning {
    border-color: var(--red-error) !important;
    box-shadow: 0 0 0 2px rgba(239, 83, 80, 0.25), 0 0 16px rgba(239, 83, 80, 0.15) !important;
    animation: warningPulse 1.5s ease-in-out infinite;
}

@keyframes warningPulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(239, 83, 80, 0.25), 0 0 16px rgba(239, 83, 80, 0.15); }
    50% { box-shadow: 0 0 0 3px rgba(239, 83, 80, 0.35), 0 0 24px rgba(239, 83, 80, 0.25); }
}

.value-alert {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    padding: 4px 10px;
    background: rgba(239, 83, 80, 0.1);
    border: 1px solid rgba(239, 83, 80, 0.25);
    border-radius: 6px;
    color: var(--red-error);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    animation: alertSlideIn 0.3s ease-out;
}

@keyframes alertSlideIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== REGENERATE BUTTON ========== */
.ai-regen-area {
    display: flex;
    justify-content: center;
    padding: 10px 0;
}

.btn-regen {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: transparent;
    color: var(--blue-light);
    border: 1.5px solid rgba(33, 150, 243, 0.3);
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-regen:hover {
    background: rgba(33, 150, 243, 0.1);
    border-color: var(--blue-glossy);
    transform: translateY(-1px);
}

.btn-regen:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ========== RESPONSIVE - 600px+ ========== */
@media (min-width: 600px) {
    .header-content {
        gap: 12px;
    }
    .btn-seja-pro {
        font-size: 0.88rem;
        padding: 8px 18px;
    }
}
