/* Permanent Apple theme: global tokens, shared overrides and section flow.
   Related rules retain their original cascade order. */

/* ---- apple-theme ---- */
/* Permanent shared Apple theme. Loaded after shared and page styles.
   Page-specific Apple rules live alongside their page's base styles. */
body.apple-theme {
    --ap-bg: #fbfbfd;
    --ap-text: #1d1d1f;
    --ap-sub: #6e6e73;
    --ap-blue: #0071e3;
    --ap-red: #ff3b30;
    --ap-glass: rgba(255, 255, 255, 0.72);
    --ap-line: rgba(0, 0, 0, 0.08);
    --ap-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Helvetica Neue", Arial, sans-serif;
    --ap-ease: cubic-bezier(0.28, 0.11, 0.32, 1);
    color: var(--ap-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ---- Background: clean, no notebook lines / fabric / stickers ---- */
body.apple-theme,
body.apple-theme.plain-home-bg,
body.apple-theme.experience-live {
    background-color: var(--ap-bg) !important;
    background-image: none !important;
}
body.apple-theme::after {
    content: "";
    position: fixed;
    z-index: 54;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(18, 22, 27, 0.13), transparent min(8vw, 105px)) left / 50% 100% no-repeat,
        linear-gradient(270deg, rgba(18, 22, 27, 0.13), transparent min(8vw, 105px)) right / 50% 100% no-repeat,
        linear-gradient(180deg, rgba(18, 22, 27, 0.11), transparent min(9vh, 90px)) top / 100% 50% no-repeat,
        linear-gradient(0deg, rgba(18, 22, 27, 0.14), transparent min(10vh, 100px)) bottom / 100% 50% no-repeat,
        radial-gradient(circle at 0 0, rgba(18, 22, 27, 0.2), transparent min(31vw, 280px)),
        radial-gradient(circle at 100% 0, rgba(18, 22, 27, 0.2), transparent min(31vw, 280px)),
        radial-gradient(circle at 0 100%, rgba(18, 22, 27, 0.18), transparent min(31vw, 280px)),
        radial-gradient(circle at 100% 100%, rgba(18, 22, 27, 0.18), transparent min(31vw, 280px));
    box-shadow:
        inset 22px 0 34px -29px rgba(18, 22, 27, 0.3),
        inset -22px 0 34px -29px rgba(18, 22, 27, 0.3),
        inset 0 18px 30px -27px rgba(18, 22, 27, 0.18),
        inset 0 -24px 38px -31px rgba(18, 22, 27, 0.25);
    opacity: 0;
    transition: opacity 400ms ease;
    pointer-events: none;
}
body.apple-theme:is(.experience-live, .plain-home-bg)::after { opacity: 1; }
body.apple-theme.page-panel-open::after { opacity: 0; }
@media (max-width: 700px) {
    body.apple-theme::after {
        background:
            linear-gradient(90deg, rgba(18, 22, 27, 0.12), transparent 34px) left / 50% 100% no-repeat,
            linear-gradient(270deg, rgba(18, 22, 27, 0.12), transparent 34px) right / 50% 100% no-repeat,
            linear-gradient(180deg, rgba(18, 22, 27, 0.1), transparent 38px) top / 100% 50% no-repeat,
            linear-gradient(0deg, rgba(18, 22, 27, 0.12), transparent 42px) bottom / 100% 50% no-repeat,
            radial-gradient(circle at 0 0, rgba(18, 22, 27, 0.17), transparent 190px),
            radial-gradient(circle at 100% 0, rgba(18, 22, 27, 0.17), transparent 190px),
            radial-gradient(circle at 0 100%, rgba(18, 22, 27, 0.15), transparent 190px),
            radial-gradient(circle at 100% 100%, rgba(18, 22, 27, 0.15), transparent 190px);
    }}
@media (max-width: 700px) {
    body.apple-theme .portfolio-title { display: none !important; }
    body.apple-theme .face-counter-name { display: block; }}

/* ---- Typography: one family everywhere (handwritten / display fonts replaced) ---- */
/* Page containers keep the fonts they inherited before becoming sections. */
body.apple-theme :is(div, main, span, a, p, h1, h2, h3, h4, h5, h6, button, li, label, section, nav, input, textarea, text, tspan):where(:not(.about-wireframe, .model-bento-page)) {
    font-family: var(--ap-font) !important;
}

/* ---- Top-left label + bottom-left title block ---- */
body.apple-theme .ui-top-left {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ap-text);
    text-shadow: none;
}
body.apple-theme .ui-top-left::before {
    content: "";
    flex: 0 0 7px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ap-blue);
}
body.apple-theme .portfolio-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--ap-text);
}
body.apple-theme .portfolio-desc {
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: 0;
    color: rgba(5, 5, 5, 0.72);
}
body.apple-theme #nav-guide,
body.apple-theme #nav-guide.visible {
    right: auto;
    left: 50%;
    opacity: 1;
    transform: translateX(-50%);
}
body.apple-theme #face-counter {
    position: absolute;
    top: 50%;
    right: clamp(24px, 4vw, 64px);
    z-index: 55;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    color: #050505;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", Inter, system-ui, sans-serif !important;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    transform: translateY(-50%);
}
body.apple-theme .face-counter-name {
    max-width: 18ch;
    overflow: hidden;
    font-size: 0.66rem;
    font-weight: 650;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}
body.apple-theme .face-counter-numbers {
    display: flex;
    align-items: baseline;
    gap: 5px;
}
body.apple-theme .face-counter-current {
    font-size: clamp(1.15rem, 1.8vw, 1.55rem);
    font-weight: 650;
}
body.apple-theme .face-counter-total {
    color: rgba(5, 5, 5, 0.46);
    font-size: 0.72rem;
    font-weight: 500;
}
@media (min-width: 701px) {
    body.apple-theme .face-counter-name { font-size: 0.9rem; }
    body.apple-theme .face-counter-current { font-size: clamp(1.55rem, 2.3vw, 1.95rem); }
    body.apple-theme .face-counter-total { font-size: 0.85rem; }}
body.apple-theme #cube-drag-coach {
    position: absolute;
    z-index: 58;
    top: 50%;
    left: 50%;
    width: clamp(150px, 17vw, 230px);
    height: 104px;
    opacity: 0;
    transform: translate(-50%, 72px) scale(0.96);
    transition: opacity 360ms ease, transform 520ms cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}
body.apple-theme #cube-drag-coach.is-visible {
    opacity: 1;
    transform: translate(-50%, 72px) scale(1);
}
body.apple-theme .cube-drag-coach-vertical {
    --vertical-drag-distance: 40px;
    position: absolute;
    top: -139px;
    left: -26px;
    width: 2px;
    height: 130px;
    border-radius: 999px;
    background: linear-gradient(180deg, transparent, rgba(20, 22, 25, 0.28) 22%, rgba(20, 22, 25, 0.28) 78%, transparent);
}
body.apple-theme .cube-drag-coach-vertical::before,
body.apple-theme .cube-drag-coach-vertical::after {
    position: absolute;
    left: 50%;
    color: rgba(20, 22, 25, 0.68);
    font-size: 20px;
    font-weight: 650;
    line-height: 1;
    text-shadow: 0 1px 0 rgba(255,255,255,.8);
    transform: translateX(-50%);
}
body.apple-theme .cube-drag-coach-vertical::before { content: ">>>"; top: -20px; transform: translateX(-50%) rotate(-90deg); }
body.apple-theme .cube-drag-coach-vertical::after { content: ">>>"; bottom: -20px; transform: translateX(-50%) rotate(90deg); }
body.apple-theme .cube-drag-coach-track {
    position: absolute;
    top: 35px;
    left: 50%;
    width: 100%;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, rgba(20, 22, 25, 0.28) 22%, rgba(20, 22, 25, 0.28) 78%, transparent);
    transform: translateX(-50%);
}
body.apple-theme .cube-drag-coach-track::before,
body.apple-theme .cube-drag-coach-track::after {
    position: absolute;
    top: 50%;
    color: rgba(20, 22, 25, 0.68);
    font-size: 18px;
    font-weight: 650;
    line-height: 1;
    letter-spacing: 3px;
    text-shadow: 0 1px 0 rgba(255,255,255,.8);
    transform: translateY(-54%);
}
body.apple-theme .cube-drag-coach-track::before { content: "<<<"; left: 4px; }
body.apple-theme .cube-drag-coach-track::after { content: ">>>"; right: 1px; }
body.apple-theme .cube-drag-coach-hand {
    position: absolute;
    top: 11px;
    left: 50%;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 50%;
    color: #1d1d1f;
    background: rgba(255, 255, 255, 0.48);
    box-shadow: inset 1px 1px 1px rgba(255,255,255,.9), 0 10px 24px -14px rgba(18,22,27,.55);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    backdrop-filter: blur(10px) saturate(140%);
    animation: cubeDragCoach 1.6s ease-in-out infinite;
}
body.apple-theme .cube-drag-coach-hand-vertical {
    top: 50%;
    animation-name: cubeDragCoachVertical;
}
body.apple-theme .cube-drag-coach-label {
    position: absolute;
    top: 74px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 9px;
    border: 1px solid rgba(35, 42, 50, 0.2);
    border-radius: 4px;
    background: rgba(246, 248, 250, 0.9);
    box-shadow: 0 3px 10px rgba(25, 30, 36, 0.14);
    font: 650 0.76rem/1 'Inter', sans-serif;
    letter-spacing: 0;
    text-transform: uppercase;
    white-space: nowrap;
    color: #171b20;
}
body.apple-theme .cube-drag-coach-hand svg { width: 23px; height: 23px; stroke-width: 1.7; }
body.apple-theme.drag-coach-complete #nav-guide { opacity: 0.72; }
@keyframes cubeDragCoach {
    0%, 100% { transform: translateX(-50%) translateX(-54px) rotate(-7deg); }
    50% { transform: translateX(-50%) translateX(54px) rotate(7deg); }
}
@keyframes cubeDragCoachVertical {
    0%, 100% { transform: translate(-50%, -50%) translateY(calc(-1 * var(--vertical-drag-distance))) rotate(-7deg); }
    50% { transform: translate(-50%, -50%) translateY(var(--vertical-drag-distance)) rotate(7deg); }
}
@media (max-width: 700px) {
    body.apple-theme #cube-drag-coach {
        width: min(170px, 46vw);
        transform: translate(-50%, 52px) scale(0.96);
    }
    body.apple-theme .cube-drag-coach-vertical { --vertical-drag-distance: 32px; top: -116px; left: -17px; height: 110px; }
    body.apple-theme #cube-drag-coach.is-visible { transform: translate(-50%, 52px) scale(1); }}
@media (prefers-reduced-motion: reduce) {
    body.apple-theme .cube-drag-coach-hand { animation: none; transform: translateX(-50%); }
    body.apple-theme .cube-drag-coach-hand-vertical { transform: translate(-50%, -50%); }}
body.apple-theme #cube-face-coach {
    position: absolute;
    z-index: 59;
    top: 50%;
    left: 50%;
    width: 72px;
    height: 72px;
    opacity: 0;
    transform: translate(54px, -50%) scale(0.82);
    transition: opacity 320ms ease, transform 480ms cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}
body.apple-theme #cube-face-coach.is-visible {
    opacity: 1;
    transform: translate(54px, -50%) scale(1);
}
body.apple-theme .cube-face-coach-target {
    position: absolute;
    inset: 8px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 50%;
    color: #1d1d1f;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: inset 1px 1px 1px rgba(255,255,255,.92), 0 12px 28px -14px rgba(18,22,27,.62);
    -webkit-backdrop-filter: blur(10px) saturate(145%);
    backdrop-filter: blur(10px) saturate(145%);
    animation: cubeFaceCoachPress 1.25s ease-in-out infinite;
}
body.apple-theme .cube-face-coach-target::before,
body.apple-theme .cube-face-coach-target::after {
    content: "";
    position: absolute;
    inset: -1px;
    border: 1px solid rgba(29, 29, 31, 0.34);
    border-radius: 50%;
    animation: cubeFaceCoachRing 1.6s ease-out infinite;
}
body.apple-theme .cube-face-coach-target::after { animation-delay: 0.8s; }
body.apple-theme .cube-face-coach-target svg { width: 24px; height: 24px; stroke-width: 1.8; }
@keyframes cubeFaceCoachPress {
    0%, 100% { transform: scale(1); }
    45% { transform: scale(0.88); }
    62% { transform: scale(1.04); }
}
@keyframes cubeFaceCoachRing {
    0% { opacity: 0.62; transform: scale(0.8); }
    100% { opacity: 0; transform: scale(1.65); }
}
@media (max-width: 700px) {
    body.apple-theme #cube-face-coach { transform: translate(34px, -50%) scale(0.82); }
    body.apple-theme #cube-face-coach.is-visible { transform: translate(34px, -50%) scale(1); }}
@media (prefers-reduced-motion: reduce) {
    body.apple-theme .cube-face-coach-target,
body.apple-theme .cube-face-coach-target::before,
body.apple-theme .cube-face-coach-target::after { animation: none; }}
body.apple-theme .cube-widget-cluster {
    position: absolute;
    z-index: 55;
    inset: 0;
    pointer-events: none;
}
body.apple-theme .cube-widget {
    position: absolute;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.38);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.2), transparent 42%),
        rgba(38, 43, 51, 0.78);
    box-shadow:
        inset 1px 1px 1px rgba(255, 255, 255, 0.48),
        inset -1px -1px 1px rgba(255, 255, 255, 0.1),
        0 4px 7px -4px rgba(18, 22, 27, 0.36),
        0 18px 38px -20px rgba(18, 22, 27, 0.44);
    -webkit-backdrop-filter: blur(24px) saturate(145%) brightness(1.06);
    backdrop-filter: blur(24px) saturate(145%) brightness(1.06);
    color: rgba(255, 255, 255, 0.96);
    transition: opacity 260ms ease, transform 360ms cubic-bezier(0.16, 1, 0.3, 1);
}
body.apple-theme .cube-widget-profile {
    top: calc(var(--home-panel-top, 24px) + 58px);
    left: clamp(24px, 4vw, 64px);
    display: flex;
    align-items: center;
    gap: 11px;
    width: 230px;
    min-height: 72px;
    padding: 10px 12px;
    border-radius: 22px;
}
body.apple-theme .cube-widget-profile img {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 14px;
    object-fit: cover;
}
body.apple-theme .cube-widget-copy {
    display: grid;
    gap: 5px;
    min-width: 0;
}
body.apple-theme .cube-widget-copy strong {
    font-size: 0.82rem;
    font-weight: 650;
    letter-spacing: 0;
}
body.apple-theme .cube-widget-copy > span {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255, 255, 255, 0.94);
    font-size: 0.74rem;
    font-weight: 550;
    line-height: 1.2;
}
body.apple-theme .cube-widget-copy > span > i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #62d27c;
    box-shadow: 0 0 8px rgba(98, 210, 124, 0.72);
}
body.apple-theme .cube-widget-reel {
    top: 50%;
    left: clamp(24px, 4vw, 64px);
    width: 202px;
    aspect-ratio: 16 / 10;
    border-radius: 24px;
    transform: translateY(-50%);
}
body.apple-theme .cube-widget-reel video,
body.apple-theme .cube-widget-reel-shade {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
body.apple-theme .cube-widget-reel video {
    object-fit: cover;
    opacity: 0;
    transition: opacity 560ms ease;
}
body.apple-theme .cube-widget-reel video.is-active { opacity: 1; }
body.apple-theme .cube-widget-reel-shade {
    background: linear-gradient(180deg, rgba(10, 12, 16, 0.04), rgba(10, 12, 16, 0.78));
}
body.apple-theme .cube-widget-reel-label {
    position: absolute;
    z-index: 2;
    right: 14px;
    bottom: 12px;
    left: 14px;
    display: grid;
    gap: 3px;
}
body.apple-theme .cube-widget-reel-label small {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.66rem;
    font-weight: 650;
}
body.apple-theme .cube-widget-reel-label small::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #69b6ff;
}
body.apple-theme .cube-widget-reel-label strong {
    font-size: 0.9rem;
    font-weight: 620;
}
body.apple-theme .cube-widget-play {
    position: absolute;
    z-index: 3;
    top: 13px;
    right: 13px;
    width: 16px;
    height: 16px;
    padding: 7px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 50%;
    background: rgba(20, 23, 28, 0.3);
    backdrop-filter: blur(8px);
}
body.apple-theme .cube-widget-focus {
    top: calc(var(--home-panel-top, 24px) + 58px);
    right: clamp(24px, 4vw, 64px);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 174px;
    min-height: 112px;
    border-radius: 24px;
}
body.apple-theme .cube-widget-focus > span {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 5px;
    min-width: 0;
    padding: 10px;
}
body.apple-theme .cube-widget-focus > span:nth-child(even) { border-left: 1px solid rgba(255, 255, 255, 0.14); }
body.apple-theme .cube-widget-focus > span:nth-child(n + 3) { border-top: 1px solid rgba(255, 255, 255, 0.14); }
body.apple-theme .cube-widget-focus svg {
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.86);
    stroke-width: 1.65;
}
body.apple-theme .cube-widget-focus small {
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.7rem;
    font-weight: 550;
}
body.apple-theme .cube-widget-focus > span:first-child svg { color: #8bc9ff; }
body.apple-theme.page-panel-open .cube-widget-cluster {
    opacity: 0;
    transform: translateY(6px);
}
@media (max-width: 1200px) {
    body.apple-theme :is(.cube-widget-reel, .cube-widget-focus) { display: none; }}
@media (max-width: 900px) {
    body.apple-theme .cube-widget-profile {
        width: min(218px, 31vw);
    }
    body.apple-theme .cube-widget-copy > span { font-size: 0.68rem; }}
body.apple-theme .engagement-widget {
    position: absolute;
    z-index: 55;
    right: clamp(28px, 3vw, 52px);
    bottom: clamp(32px, 4vh, 48px);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 300px;
    min-height: 58px;
    overflow: hidden;
    border: 1px solid rgba(32, 37, 43, 0.48);
    border-radius: 18px;
    background: rgba(239, 241, 243, 0.48);
    box-shadow: inset 1px 1px 1px rgba(255, 255, 255, 0.9),
        inset -1px -1px 1px rgba(255, 255, 255, 0.65),
        0 4px 12px rgba(28, 33, 40, 0.16);
    -webkit-backdrop-filter: blur(10px) saturate(125%);
    backdrop-filter: blur(10px) saturate(125%);
    pointer-events: none;
}
body.apple-theme .engagement-stat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    padding: 10px 8px;
    color: #1d1d1f;
}
body.apple-theme .engagement-stat + .engagement-stat {
    border-left: 1px solid rgba(32, 37, 43, 0.16);
}
body.apple-theme .engagement-stat svg {
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
    stroke-width: 1.7;
}
body.apple-theme .engagement-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}
body.apple-theme .engagement-copy strong {
    font-size: 0.9rem;
    line-height: 1;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}
body.apple-theme .engagement-copy > span {
    font-size: 0.6rem;
    line-height: 1;
    color: #50545a;
}
body.apple-theme.page-panel-open .engagement-widget { opacity: 0; }
@media (min-width: 701px) and (max-width: 1229px) {
    body.apple-theme .engagement-widget {
        right: clamp(32px, 4vw, 64px);
        bottom: calc(100dvh - var(--home-panel-bottom, calc(100dvh - 24px)) + 18px);
    }}
@media (max-width: 700px) {
    body.apple-theme .engagement-widget {
        right: auto;
        bottom: max(115px, calc(env(safe-area-inset-bottom) + 111px));
        left: 50%;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-template-rows: 1fr;
        width: min(230px, 58vw);
        min-height: 48px;
        border-radius: 999px;
        transform: translateX(-50%);
    }
    body.apple-theme .engagement-stat {
        flex-direction: column;
        gap: 2px;
        padding: 4px 2px;
    }
    body.apple-theme .engagement-stat + .engagement-stat {
        border-top: 0;
        border-left: 1px solid rgba(32, 37, 43, 0.16);
    }
    body.apple-theme .engagement-stat svg { width: 14px; height: 14px; }
    body.apple-theme .engagement-copy { justify-items: center; }
    body.apple-theme .engagement-copy strong { font-size: 0.7rem; }
    body.apple-theme .engagement-copy > span { font-size: 0.5rem; }}
@media (max-width: 500px) {
    body.apple-theme .engagement-widget {
        bottom: calc(var(--home-glass-bottom) + 29px);
    }}
@media (max-width: 380px) {
    body.apple-theme .engagement-widget { width: min(190px, 54vw); }}
body.apple-theme #swipe-progress {
    --swipe-progress: 0;
    position: absolute;
    top: calc(var(--home-panel-top, 84px) + 20px);
    left: 50%;
    bottom: auto;
    z-index: 56;
    display: block;
    width: clamp(240px, 26vw, 380px);
    height: 3px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(5, 5, 5, 0.13);
    opacity: 0;
    transform: translateX(-50%);
    transition: opacity 180ms ease;
    pointer-events: none;
}
body.apple-theme #swipe-progress.active { opacity: 1; }
body.apple-theme #swipe-progress span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: #050505;
    transform: scaleX(var(--swipe-progress));
    transform-origin: left center;
}
body.apple-theme #swipe-progress.holding span {
    transform: scaleX(var(--hold-progress));
    transform-origin: center center;
}
body.apple-theme #swipe-progress.hold-released { opacity: 0; }
@media (max-width: 700px) {
    body.apple-theme .ui-top-left { display: none; }
    body.apple-theme #face-counter {
        top: max(16px, calc(env(safe-area-inset-top) + 8px));
        right: 16px;
        transform: none;
    }
    body.apple-theme .face-counter-current { font-size: clamp(1.22rem, 4.6vw, 1.48rem); }
    body.apple-theme .face-counter-total { font-size: clamp(0.72rem, 2.6vw, 0.84rem); }
    body.apple-theme #swipe-progress {
        --swipe-progress: 0;
        position: absolute;
        top: auto;
        right: auto;
        bottom: max(100px, calc(env(safe-area-inset-bottom) + 96px));
        left: 50%;
        z-index: 56;
        display: block;
        width: min(230px, 58vw);
        height: 3px;
        overflow: hidden;
        border-radius: 999px;
        background: rgba(77, 83, 90, 0.48);
        box-shadow: 0 1px 2px rgba(255, 255, 255, 0.72), 0 2px 5px rgba(28, 32, 38, 0.16);
        opacity: 0.78;
        transform: translateX(-50%);
        transition: opacity 180ms ease;
        pointer-events: none;
    }
    body.apple-theme #swipe-progress.active { opacity: 1; }
    body.apple-theme #swipe-progress span {
        display: block;
        width: 100%;
        height: 100%;
        border-radius: inherit;
        background: #17191c;
        transform: scaleX(var(--swipe-progress));
        transform-origin: left center;
    }}

@media (max-width: 380px) {
    body.apple-theme #swipe-progress {
        left: 50%;
        width: min(190px, 54vw);
    }}

@media (max-width: 480px) {
    body.apple-theme #face-counter { right: 12px; }}

/* ---- Nav: frosted-glass pills ---- */
body.apple-theme .nav-link {
    color: var(--ap-sub);
    font-weight: 500;
    letter-spacing: 0;
    background: var(--ap-glass);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid var(--ap-line);
    border-radius: 980px;
    transition: background 0.3s var(--ap-ease), color 0.3s var(--ap-ease), transform 0.3s var(--ap-ease);
}
body.apple-theme .nav-link::after { display: none !important; }
body.apple-theme .nav-link:hover,
body.apple-theme .nav-link[data-face="HOME"]:hover {
    color: var(--ap-text);
    background: rgba(255, 255, 255, 0.95);
    transform: scale(1.04);
}
body.apple-theme .nav-link.active,
body.apple-theme .nav-link[data-face="HOME"].active {
    color: #fff;
    background: var(--ap-text);
    border-color: transparent;
    transform: none;
}
@media (min-width: 701px) {
    body.apple-theme .nav-link { font-size: 0.85rem; padding: 8px 16px; }
    body.apple-theme .nav-row { gap: 8px; }
    body.apple-theme .nav-row.bottom-row { padding-right: 0; }
    body.apple-theme .ui-top-right { gap: 8px; }}

/* Shared top-center navigation capsule. Row wrappers retain existing links. */
body.apple-theme .nav-fx-layer {
    position: absolute;
    top: max(24px, env(safe-area-inset-top));
    left: 50%;
    width: min(760px, calc(100% - 32px));
    transform: translateX(-50%);
    filter: contrast(2.4);
    pointer-events: auto;
}
body.apple-theme .nav-fx-layer::before {
    content: "";
    position: absolute;
    z-index: 2;
    top: 5px;
    left: 50%;
    width: calc(100% - 9px);
    height: calc(100% - 10px);
    transform: translateX(-50%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    filter: blur(1px);
    pointer-events: none;
}
body.apple-theme .ui-top-right {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    width: 100%;
    max-width: none;
    transform: none;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-evenly;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    isolation: isolate;
    overflow: visible;
    border: 0.75px solid rgba(0, 0, 0, 0.48);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.02);
    box-shadow:
        inset 2px -2px 1px -1px rgba(255, 255, 255, 0.9),
        inset -2px 2px 1px -1px rgba(255, 255, 255, 0.9),
        inset 6px -6px 1px -6px rgba(255, 255, 255, 0.55),
        inset -6px 6px 1px -6px rgba(255, 255, 255, 0.55),
        inset 0 0 2px rgba(0, 0, 0, 0.8),
        0 2px 3px rgba(18, 22, 27, 0.18),
        0 10px 24px -14px rgba(18, 22, 27, 0.42);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    filter: brightness(0.9);
}
body.apple-theme .ui-top-right::before,
body.apple-theme .ui-top-right::after {
    content: "";
    position: absolute;
    z-index: 0;
    pointer-events: none;
    border-radius: inherit;
}
body.apple-theme .ui-top-right::before {
    z-index: 1;
    top: 35%;
    left: 50%;
    width: calc(100% - 16px);
    height: calc(100% - 16px);
    transform: translateX(-50%);
    border: 1px solid rgba(0, 0, 0, 0.9);
    filter: blur(8px);
}
body.apple-theme .ui-top-right::after {
    z-index: 2;
    inset: 0;
    filter: blur(7px);
    background: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.8) 0%,
        transparent 15%,
        transparent 85%,
        rgba(255, 255, 255, 0.8) 100%
    );
}
body.apple-theme .ui-top-right .nav-row {
    display: contents;
    padding: 0;
}
body.apple-theme .ui-top-right .nav-link {
    position: relative;
    z-index: 3;
    min-height: 38px;
    padding: 8px 16px;
    font-size: 13px;
    line-height: 20px;
    white-space: nowrap;
    color: #1d1d1f;
    background: transparent;
    border: 0.75px solid transparent;
    border-radius: 999px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transform: none;
}
body.apple-theme .ui-top-right .nav-link:hover {
    color: #000;
    background: #f4f4f6;
    transform: none;
}
body.apple-theme .ui-top-right .nav-link.active {
    color: #111;
    background: rgba(111, 111, 118, 0.24);
    border-color: transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}
body.apple-theme .ui-top-right .nav-link:focus-visible {
    outline: 2px solid #8ec7ff;
    outline-offset: -2px;
}
body.apple-theme .ui-top-right .nav-icon { display: none; }
@media (min-width: 701px) and (max-width: 900px) {
    body.apple-theme .nav-fx-layer {
        top: max(18px, calc(env(safe-area-inset-top) + 12px));
    }}
@media (max-width: 700px) {
    /* Mobile navigation lives above the home indicator and remains centered. */
    body.apple-theme .nav-fx-layer {
        top: auto;
        bottom: max(12px, calc(env(safe-area-inset-bottom) + 8px));
        width: min(430px, calc(100% - 20px));
    }
    body.apple-theme .ui-top-right {
        flex-wrap: nowrap;
        gap: 4px;
        padding: 5px 6px;
    }
    body.apple-theme .ui-top-right .nav-link {
        flex: 1 1 0;
        min-width: 0;
        min-height: 44px;
        padding: 0;
        justify-content: center;
    }
    body.apple-theme .ui-top-right .nav-label { display: none; }
    body.apple-theme .ui-top-right .nav-icon {
        display: block;
        width: 19px;
        height: 19px;
        stroke-width: 1.8;
    }
    body.apple-theme .sound-toggle {
        position: static;
        z-index: auto;
        flex: 0 0 36px;
        width: 36px;
        height: 36px;
        margin: 0;
        padding: 0;
        justify-content: center;
        pointer-events: auto;
    }
    body.apple-theme .sound-toggle .sound-icon {
        width: 20px;
        height: 20px;
    }
    body.apple-theme .sound-toggle .sound-status { display: none; }
    body.apple-theme #nav-guide {
        display: flex;
        align-items: center;
        gap: 8px;
    }}
@media (max-width: 560px) {
    body.apple-theme .nav-fx-layer {
        width: calc(100% - 24px);
    }
    body.apple-theme .ui-top-right {
        padding: 5px;
        gap: 4px;
        border-radius: 28px;
    }
    body.apple-theme .ui-top-right .nav-link {
        min-height: 42px;
        padding: 0;
    }}

/* ---- Sound toggle ---- */
body.apple-theme .sound-toggle { color: var(--ap-sub); letter-spacing: 0; text-transform: none; font-weight: 500; }
body.apple-theme .sound-toggle:hover,
body.apple-theme .sound-toggle.muted:hover { color: var(--ap-blue); transform: none; }
body.apple-theme .sound-toggle .sound-mute-line,
body.apple-theme .sound-toggle.muted .sound-mute-line { stroke: var(--ap-red); }

/* The cube stays visually anchored while the transparent WebGL canvas remains interactive. */
body.apple-theme .cube-ground-shadow {
    position: fixed;
    z-index: 29;
    top: 62%;
    left: 50%;
    width: clamp(240px, 34vw, 520px);
    height: clamp(34px, 5vw, 72px);
    border-radius: 50%;
    background: radial-gradient(ellipse at center,
        rgba(20, 24, 29, 0.28) 0%,
        rgba(20, 24, 29, 0.15) 38%,
        rgba(20, 24, 29, 0.05) 68%,
        transparent 80%);
    filter: blur(9px);
    opacity: 0;
    transform: translate(-50%, -50%) scaleX(0.9);
    transition: opacity 500ms ease, transform 700ms cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}
body.apple-theme:is(.experience-live, .plain-home-bg) .cube-ground-shadow {
    opacity: 0.72;
    transform: translate(-50%, -50%) scaleX(1);
}
body.apple-theme.page-panel-open .cube-ground-shadow { opacity: 0; }

@media (max-width: 700px) {
    body.apple-theme .cube-ground-shadow {
        top: 62.5%;
        width: min(72vw, 340px);
        height: clamp(30px, 8vw, 46px);
        filter: blur(7px);
    }}
/* Mid-size screens use one continuous rounded-square glass field below the separate nav. */
@media (min-width: 701px) and (max-width: 1229px) {
    body.apple-theme .ui-top-left { top: calc(var(--home-panel-top, 16px) + 18px); }}

@media (min-width: 501px) and (max-width: 700px) {
    body.apple-theme .ui-top-left {
        top: calc(var(--home-panel-top, 16px) + 18px);
        left: 28px;
    }
    body.apple-theme .ui-bottom-left {
        top: calc(var(--home-panel-top, 16px) + 18px);
        right: 28px;
        max-width: min(42vw, 230px);
    }
    body.apple-theme .portfolio-desc {
        display: block;
        max-width: 28ch;
        margin-top: 34px;
        font-size: clamp(0.62rem, 1.5vw, 0.72rem);
        line-height: 1.35;
    }
    body.apple-theme #nav-guide {
        bottom: calc(100dvh - var(--home-panel-bottom, calc(100dvh - 110px)) + 22px);
    }}

/* Keep the small-phone glass field clear of the bottom navigation.
   --home-nav-gap = puwang sa pagitan ng malaking liquid glass at ng nav bar.
   Dagdagan para lumaki ang gap, bawasan para lumiit. */
@media (max-width: 500px) {
    body.apple-theme {
        --home-nav-gap: 24px;
        --home-glass-bottom: max(calc(12px + 54px + var(--home-nav-gap)), calc(env(safe-area-inset-bottom) + 8px + 54px + var(--home-nav-gap)));
    }
    body.apple-theme #swipe-progress {
        bottom: calc(var(--home-glass-bottom) + 14px);
    }}

/* ---- Focus + motion ---- */
body.apple-theme :is(a, button):focus-visible { outline: 3px solid rgba(0, 113, 227, 0.45); outline-offset: 2px; }
body.apple-theme ::selection { background: rgba(0, 113, 227, 0.25); }
@media (prefers-reduced-motion: reduce) {
    body.apple-theme .nav-link { transition: none; }}

/* Persistent cube UI: fluid placement across wide, narrow and short viewports. */
body.apple-theme .ui-top-left {
    left: clamp(16px, 3.5vw, 50px);
}
body.apple-theme .ui-bottom-left {
    left: clamp(16px, 3.5vw, 50px);
    max-width: min(350px, calc(100vw - 32px));
}
body.apple-theme #nav-guide {
    max-width: calc(100vw - 32px);
}

@media (min-width: 701px) and (max-width: 1099px) {
    body.apple-theme .ui-top-left {
        left: calc(clamp(16px, 1.8vw, 28px) + 18px);
    }
    body.apple-theme .ui-bottom-left {
        bottom: calc(100dvh - var(--home-panel-bottom, calc(100dvh - 20px)) + 18px);
        left: calc(clamp(16px, 1.8vw, 28px) + 18px);
        max-width: min(34vw, 320px);
    }
    body.apple-theme .portfolio-desc {
        font-size: clamp(0.72rem, 1.25vw, 0.9rem);
    }}

@media (min-width: 701px) and (max-width: 1200px) {
    body.apple-theme #nav-guide,
body.apple-theme #nav-guide.visible {
        right: clamp(32px, 4vw, 64px);
        left: auto;
        transform: none;
    }
    body.apple-theme #face-counter {
        top: calc(var(--home-panel-top, 24px) + 18px);
        right: clamp(32px, 4vw, 64px);
        transform: none;
    }}

@media (max-width: 700px) {
    body.apple-theme .ui-top-left {
        left: max(16px, env(safe-area-inset-left));
        font-size: clamp(0.68rem, 2.5vw, 0.82rem);
    }
    body.apple-theme .ui-bottom-left {
        top: max(16px, calc(env(safe-area-inset-top) + 8px));
        right: auto;
        bottom: auto;
        left: max(16px, env(safe-area-inset-left));
        display: flex;
        align-items: flex-start;
    }
    body.apple-theme .portfolio-title {
        display: flex !important;
        font-size: clamp(1rem, 4.8vw, 1.3rem);
        letter-spacing: -0.025em;
    }
    body.apple-theme #face-counter {
        top: max(10px, calc(env(safe-area-inset-top) + 6px));
        right: max(10px, env(safe-area-inset-right));
    }
    body.apple-theme #nav-guide {
        width: min(320px, calc(100vw - 28px));
        max-width: calc(100vw - 28px);
        justify-content: center;
    }
    body.apple-theme .face-counter-name { font-size: clamp(0.68rem, 2.4vw, 0.8rem); }}

@media (max-width: 700px) {
    body.apple-theme #nav-guide,
body.apple-theme #nav-guide.visible {
        right: auto;
        bottom: max(121px, calc(env(safe-area-inset-bottom) + 117px));
        left: calc(50% - 20px - min(230px, 58vw) / 2 - 26px);
        z-index: 57;
        width: 36px;
        max-width: none;
        transform: translateX(-50%);
    }
    body.apple-theme.drag-coach-complete #nav-guide { opacity: 1; }}

@media (max-width: 700px) {
    /* Compact identity and selected-work cards frame the cube without competing with it. */
    body.apple-theme .cube-widget-profile {
        top: max(54px, calc(env(safe-area-inset-top) + 46px));
        right: auto;
        bottom: auto;
        left: max(12px, env(safe-area-inset-left));
        display: flex;
        gap: 7px;
        width: min(180px, 46vw);
        min-height: 50px;
        padding: 6px 7px;
        border-radius: 14px;
    }
    body.apple-theme .cube-widget-profile img {
        width: 34px;
        height: 34px;
        border-radius: 9px;
    }
    body.apple-theme .cube-widget-copy { gap: 3px; }
    body.apple-theme .cube-widget-copy strong { font-size: 0.7rem; }
    body.apple-theme .cube-widget-copy > span {
        gap: 3px;
        font-size: clamp(0.6rem, 2.6vw, 0.68rem);
    }
    body.apple-theme .cube-widget-copy > span > i {
        width: 5px;
        height: 5px;
    }
    body.apple-theme .cube-widget-reel {
        top: max(64px, calc(env(safe-area-inset-top) + 58px));
        right: max(10px, env(safe-area-inset-right));
        bottom: auto;
        left: auto;
        display: block;
        width: min(132px, 34vw);
        border-radius: 14px;
        transform: none;
    }
    body.apple-theme .cube-widget-reel-label {
        right: 8px;
        bottom: 7px;
        left: 8px;
        gap: 1px;
    }
    body.apple-theme .cube-widget-reel-label small { font-size: 0.5rem; }
    body.apple-theme .cube-widget-reel-label strong { font-size: 0.7rem; }
    body.apple-theme .cube-widget-play {
        top: 7px;
        right: 7px;
        width: 11px;
        height: 11px;
        padding: 4px;
    }}

/* Large-phone / compact-tablet layout: every persistent UI item follows the glass bounds. */
@media (min-width: 501px) and (max-width: 700px) {
    body.apple-theme .ui-bottom-left {
        top: calc(var(--home-panel-top, 16px) + 18px);
        right: auto;
        left: 28px;
    }
    body.apple-theme .portfolio-desc { display: none !important; }
    body.apple-theme #face-counter {
        top: calc(var(--home-panel-top, 16px) + 18px);
        right: 28px;
    }
    body.apple-theme .cube-widget-profile {
        top: calc(var(--home-panel-top, 16px) + 56px);
        left: 28px;
    }
    body.apple-theme .cube-widget-reel {
        top: calc(var(--home-panel-top, 16px) + 84px);
        right: 28px;
    }
    body.apple-theme #swipe-progress {
        bottom: calc(100dvh - var(--home-panel-bottom, calc(100dvh - 110px)) + 14px);
    }
    body.apple-theme .engagement-widget {
        bottom: calc(100dvh - var(--home-panel-bottom, calc(100dvh - 110px)) + 29px);
    }}

@media (max-width: 380px), (max-height: 680px) and (max-width: 700px) {
    body.apple-theme #nav-guide { gap: 6px; }
    body.apple-theme #nav-guide .sound-toggle {
        flex-basis: 32px;
        width: 32px;
        height: 32px;
    }
    body.apple-theme #nav-guide .sound-icon {
        width: 18px;
        height: 18px;
    }}

@media (max-width: 500px) {
    body.apple-theme .ui-bottom-left {
        top: max(28px, calc(env(safe-area-inset-top) + 20px));
        left: max(24px, env(safe-area-inset-left));
    }
    body.apple-theme #face-counter {
        top: max(28px, calc(env(safe-area-inset-top) + 20px));
        right: max(24px, env(safe-area-inset-right));
    }
    body.apple-theme .cube-widget-profile {
        top: max(66px, calc(env(safe-area-inset-top) + 58px));
        left: max(24px, env(safe-area-inset-left));
    }
    body.apple-theme .cube-widget-reel {
        top: max(92px, calc(env(safe-area-inset-top) + 84px));
        right: max(24px, env(safe-area-inset-right));
    }}

/* ---- section-flow ---- */
/* The cube opens a section in this continuous portfolio. */
body.apple-theme #page-panels {
    --about-model-curve-height: clamp(70px, min(12dvh, 18vw), 126px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scroll-behavior: auto;
    perspective: none;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    scrollbar-width: none;
}
body.apple-theme #page-panels::-webkit-scrollbar { display: none; }
body.apple-theme.page-panel-open #page-panels {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}
body.apple-theme:not(.page-panel-open) #page-panels > .page-panel[data-page] {
    visibility: hidden !important;
    pointer-events: none !important;
}
body.apple-theme #page-panels > .page-panel[data-page="DECO"] { display: none !important; }
body.apple-theme .section-flow-back {
    position: fixed;
    z-index: 130;
    display: none;
    align-items: center;
    top: max(clamp(12px, 2vw, 24px), env(safe-area-inset-top));
    left: max(clamp(16px, 3vw, 48px), env(safe-area-inset-left));
    min-height: 44px;
    padding: 4px 0;
    border: 0;
    background: transparent;
    color: #fff;
    mix-blend-mode: difference;
    font: 500 clamp(0.7rem, 1.5vw, 0.78rem) Inter, sans-serif;
    cursor: pointer;
}
body.apple-theme.page-panel-open .section-flow-back { display: inline-flex; }
body.apple-theme .section-flow-back:hover { opacity: .65; }
body.apple-theme #page-panels > .page-panel[data-page]:not([data-page="HOME"]):not([data-page="DECO"]) {
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    flex: 0 0 auto;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    box-sizing: border-box;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    animation: none !important;
    transition: none !important;
    transform: none !important;
    clip-path: none !important;
    -webkit-clip-path: none !important;
    mask: none !important;
    -webkit-mask: none !important;
    will-change: auto;
}
body.apple-theme #page-panels > .page-panel .page-panel-content {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    -webkit-clip-path: none !important;
}
body.apple-theme .section-flow-next {
    position: absolute;
    right: clamp(20px, 4vw, 64px);
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 5;
    padding: 12px 18px;
    border: 1px solid rgba(50, 50, 50, .35);
    border-radius: 999px;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(16px);
    color: #222;
    font: 600 12px/1 Inter, sans-serif;
    letter-spacing: .06em;
    cursor: pointer;
}
body.apple-theme .section-flow-next:hover { background: #fff; }
@media (max-width: 700px) {
    body.apple-theme .section-flow-next {
        padding: 4px;
        border: 0;
        border-radius: 0;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: none;
        font-size: 10px;
    }
    body.apple-theme .section-flow-next:hover { background: transparent; }}
@media (prefers-reduced-motion: reduce) {
    body.apple-theme #page-panels { scroll-behavior: auto; }}

/* ---- about-to-models ---- */


body.apple-theme #page-panels[data-about-models] {
    overflow-y: hidden;
    overflow-anchor: none;
}

/* Lighter glass on devices using the cube's low-end quality tier. */
body.apple-theme.low-end-glass .ui-top-right::before {
    border: 0;
    filter: none;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.2), transparent 72%);
}
body.apple-theme.low-end-glass .ui-top-right::after {
    filter: none;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.5), transparent 24%, transparent 76%, rgba(255, 255, 255, 0.5));
}
body.apple-theme.low-end-glass .cube-widget {
    -webkit-backdrop-filter: blur(8px) saturate(145%) brightness(1.06);
    backdrop-filter: blur(8px) saturate(145%) brightness(1.06);
}
body.apple-theme.low-end-glass :is(.cube-drag-coach-hand, .cube-face-coach-target) {
    -webkit-backdrop-filter: blur(4px) saturate(140%);
    backdrop-filter: blur(4px) saturate(140%);
}
body.apple-theme.low-end-glass .engagement-widget {
    -webkit-backdrop-filter: blur(4px) saturate(125%);
    backdrop-filter: blur(4px) saturate(125%);
}

/* ---- models-to-motion ---- */
/* Keep the Motion Graph panel in its scroll slot while its center opens over Models. */
body.apple-theme #page-panels[data-models-motion] {
    overflow-y: hidden;
    overflow-anchor: none;
}
