/* ===== Labs Tool Pages — Shared Layout ===== */

:root {
    --tool-text-sub: rgba(255, 255, 255, 0.8);
}

html {
    background-color: var(--tool-bg) !important;
}

body {
    background: transparent !important;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Fixed Background Layer ===== */

.tool-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--tool-bg);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.tool-bg.loaded {
    opacity: 1;
}

.tool-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* ===== Header ===== */

.page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

.footer-area {
    margin-top: auto;
}

.tool-header {
    background: transparent !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    padding-top: calc(1.25rem + env(safe-area-inset-top));
    padding-left: max(2rem, env(safe-area-inset-left));
    padding-right: max(2rem, env(safe-area-inset-right));
}

.tool-header h1 {
    color: #FFFFFF !important;
    font-weight: 700;
    font-size: 1.1rem;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    white-space: nowrap;
}

.tool-back-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 9999px !important;
    color: rgba(255, 255, 255, 0.85) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    text-decoration: none;
    z-index: 2;
    padding: 0.45rem 1rem !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.25s;
}

.tool-back-btn .material-symbols-outlined {
    font-size: 0.95rem;
    font-variation-settings: 'wght' 600;
}

.tool-back-btn:hover {
    color: #FFFFFF !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    background: rgba(255, 255, 255, 0.1) !important;
}

.theme-toggle {
    display: none !important;
}

/* ===== Main Content ===== */

.tool-main {
    max-width: 42rem;
    text-align: center;
    position: relative;
    z-index: 1;
    padding-top: 5rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .tool-header {
        padding-top: calc(1rem + env(safe-area-inset-top));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* ===== Short viewports (iPhone landscape, etc.) ===== */
/* Triggered by height alone so it catches landscape iPhones (667~932px wide)
   which normal width-based mobile breakpoints miss. Uses higher-specificity
   selectors for mascot rules so tool-level .mascot-img overrides don't win. */
@media (max-height: 500px) {
    .tool-header {
        padding-top: calc(0.5rem + env(safe-area-inset-top));
    }

    .tool-main {
        padding-top: 3.25rem;
    }

    .footer-area .mascot-container {
        margin-top: 1rem;
    }

    .footer-area .mascot-img {
        max-width: 7rem;
    }

    .footer-area .note {
        margin-top: 0.75rem;
        font-size: 0.7rem;
    }
}
