/* Only the main, About, Works index and error page load this sheet. */
.page-about .mobile-only { display: none !important; }
@media (hover: none), (pointer: coarse), (max-width: 767px) {
    #cursor-follower, #cursor-bg-layer, #cursor-text-layer { display: none !important; }
}

.page-home .menu-wrapper a { text-decoration: none; }
.page-home .chat-header, .page-home .chat-input-area { flex-shrink: 0; }
.page-home .chat-body { min-height: 0; overscroll-behavior: contain; overflow-wrap: anywhere; }
.page-home .chat-input { min-width: 0; font-size: inherit; }
.page-home .win-btn { border: 0; background: transparent; }
.page-home #chat-interface { z-index: 16000; }

/* Expanded desktop columns keep complete labels and share one bottom edge. */
@media (min-width: 1024px) {
    .page-about .bento-grid:has(.expanded) { align-items: stretch; }
    .page-about .bento-grid:has(.expanded) > .bento-card { height: auto; min-height: 360px; }
    .page-about .bento-grid:has(.expanded) > .bento-card > .card-inner { flex: 1; }
    .page-about .bento-grid:has(.expanded) .col-stack .card-experience { flex: 1; min-height: 250px; }
    .page-about .bento-grid:has(.expanded) .col-connect .card-connect { flex: 1; min-height: 200px; }
    .page-about .bento-grid:has(.expanded) .circle-wrapper { flex-shrink: 0; }
    .page-about .bento-grid:has(.expanded) > div:not(.expanded) :is(.card-title, .sub-card-title) {
        font-size: 24px; white-space: nowrap !important; word-break: normal !important; overflow-wrap: normal !important;
    }
    .page-about .bento-grid[data-state="education"] > div:not(.expanded) :is(.card-title, .sub-card-title) { font-size: 16px; }
}

@media (max-width: 1023px) {
    .page-about .bento-grid { display: grid; grid-template-columns: 1fr 1fr; height: auto; gap: 16px; }
    .page-about .bento-grid > div { width: 100%; min-width: 0; }
    .page-about .card-back { min-width: 0; }
    .page-about .bento-grid > .expanded { grid-column: 1 / -1; height: auto; min-height: 360px; }
    .page-about .bento-grid:has(.expanded) > div:not(.expanded) :is(.edu-content, .exp-content, .capa-list, .lang-list, .connect-front-list) {
        opacity: 1; filter: none; white-space: normal !important;
    }
    .page-about .card-education.expanded { height: 520px; }
    .page-about .card-education.expanded .card-inner { min-height: 520px; }
}

@media (max-width: 767px), (pointer: coarse) and (max-width: 1023px) {
    html { overflow-x: clip; }
    .page-about .mobile-only { display: block !important; }
    .page-about .desktop-only { display: none !important; }
    .page-home { height: 100dvh; width: 100%; overscroll-behavior: none; }
    .page-home .grid-container {
        position: fixed; display: block; padding: 0 max(24px, env(safe-area-inset-left)); z-index: 10;
    }
    .page-home .grid-col { display: none; }
    .page-home .menu-wrapper { margin-top: max(24px, env(safe-area-inset-top)); }
    .page-home .menu-text { font-size: clamp(30px, 8vw, 40px); line-height: 1.1; padding: 6px 12px 6px 0; }
    .page-home .base-layer { opacity: 1; }
    .page-home #theme-toggle {
        top: calc(max(24px, env(safe-area-inset-top)) + 112px); left: 20px;
        transform: none; flex-direction: row; gap: 0; height: 44px;
    }
    .page-home .arrow-btn { width: 44px; height: 44px; padding: 8px; opacity: .65; }
    .page-home .arrow-icon { transform: rotate(-90deg); width: 24px; height: 24px; }
    .page-home .theme-dot {
        width: 44px; height: 44px; border: none !important; background: none !important;
        display: grid; place-items: center; color: #1a1a1a; -webkit-appearance: none; appearance: none;
    }
    .page-home .theme-dot::after { content: ''; width: 14px; height: 14px; border: 1.5px solid currentColor; border-radius: 50%; opacity: .5; }
    .page-home .theme-dot.active::after { background: currentColor; opacity: 1; }
    .page-home.theme-dark .theme-dot { color: white; }
    .page-home #canvas-container, .page-home #hero-sphere-container { position: fixed; height: 100dvh; touch-action: none; }
    .page-home #chat-interface {
        position: fixed; box-sizing: border-box; left: 12px; right: 12px; bottom: auto;
        top: calc(var(--visual-top, 0px) + var(--visual-height, 100dvh) - min(520px, var(--visual-height, 100dvh) - 24px) - 12px);
        width: auto; height: min(520px, var(--visual-height, 100dvh) - 24px);
        border-radius: 22px; background: rgba(250,250,252,.96);
    }
    .page-home.theme-dark #chat-interface { background: rgba(20,20,24,.96); }
    .page-home .chat-header { padding: 10px 14px 10px 20px; }
    .page-home .win-btn { width: 44px; height: 44px; }
    .page-home .chat-controls { gap: 0; }
    .page-home .chat-body { padding: 16px; }
    .page-home .chat-input-area { flex-wrap: nowrap; }
    .page-home .chat-input { width: 0; flex: 1; }
    .page-home .chat-input-area { padding: 12px 12px max(12px, env(safe-area-inset-bottom)); align-items: center; }
    .page-home .send-btn { width: 44px; height: 44px; flex-shrink: 0; }
    .page-home #chat-minimized-icon { position: fixed; right: 20px; bottom: max(20px, env(safe-area-inset-bottom)); width: 52px; height: 52px; }

    :is(.page-about, .page-works) #global-header,
    :is(.page-about, .page-works) #global-header.at-top { height: calc(64px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); box-sizing: border-box; }
    :is(.page-about, .page-works) .header-inner { padding: 0 20px; gap: 12px; }
    :is(.page-about, .page-works) .header-left { gap: clamp(16px, 5vw, 28px); }
    :is(.page-about, .page-works) #global-header .header-logo img { height: 23px; }
    :is(.page-about, .page-works) .header-nav { gap: 16px; }
    :is(.page-about, .page-works) .nav-link { font-size: 15px; min-height: 44px; display: flex; align-items: center; }
    :is(.page-about, .page-works) .nav-link.active::after { bottom: 8px; }
    :is(.page-about, .page-works) .header-right { gap: 2px; font-size: 12px; }
    :is(.page-about, .page-works) .lang-btn { min-width: 30px; min-height: 44px; }
    :is(.page-about, .page-works) .container { width: 100%; padding: 0 24px; box-sizing: border-box; }
    .page-works main { padding-top: calc(96px + env(safe-area-inset-top)); padding-bottom: calc(120px + env(safe-area-inset-bottom)); min-height: 100svh; box-sizing: border-box; }
    .page-works .works-grid { gap: 36px; grid-template-columns: minmax(0, 1fr); }
    .page-works .work-title { font-size: 18px; overflow-wrap: anywhere; }
    .page-works .work-cat { font-size: 12px; }
    .page-works .thumb-wrapper { margin-bottom: 14px; }
    .page-works .floating-dock { bottom: max(16px, env(safe-area-inset-bottom)); max-width: calc(100% - 32px); padding: 6px; }
    .page-works .dock-btn { min-height: 44px; padding: 10px 22px; }

    .page-about #hero-section { min-height: auto; padding-bottom: 40px; }
    .page-about .hero-layout-new { align-items: flex-start; padding-top: calc(112px + env(safe-area-inset-top)); }
    .page-about .hero-text-block { font-size: clamp(22px, 5.8vw, 32px); line-height: 1.65; text-align: left; margin-bottom: 32px; }
    .page-about .profile-card { width: min(68vw, 280px); height: auto; aspect-ratio: 3 / 4; align-self: flex-end; margin: 0; }
    .page-about .scroll-indicator { margin: 20px 0 40px; }
    .page-about #philosophy-section { height: 400svh; }
    .page-about .philo-container { height: 100svh; flex-direction: column; padding-top: calc(64px + env(safe-area-inset-top)); box-sizing: border-box; }
    .page-about .text-col { width: auto; height: auto; flex: 0 0 46%; margin: 0 max(24px, env(safe-area-inset-left)); padding: 0; }
    .page-about .text-block { top: 50%; }
    .page-about .philo-intro-title { font-size: clamp(36px, 10vw, 48px); }
    .page-about .philo-label { font-size: 28px; }
    .page-about .philo-desc { font-size: clamp(16px, 4.5vw, 20px); line-height: 1.6; margin: 8px 0 0; }
    .page-about .philo-desc br { display: none; }
    .page-about .visual-col { width: 100%; height: auto; min-height: 0; flex: 1; }
    .page-about #key-detail-section { padding: 64px 0 40px; }
    .page-about .key-detail-title { font-size: 40px; margin-bottom: 28px; }
    .page-about .bento-grid { grid-template-columns: minmax(0, 1fr); }
    .page-about .bento-grid > div { gap: 16px; }
    .page-about .bento-card { height: auto !important; transform: none !important; }
    .page-about .bento-card .card-inner { height: auto !important; min-height: 0; transform: none; }
    .page-about .bento-card .card-front { position: relative; height: auto; min-height: 170px; padding: 24px !important; }
    .page-about .bento-card .card-back { display: none; position: relative; height: auto; min-width: 0; padding: 24px !important; transform: none; }
    .page-about .bento-card.expanded > .card-inner > .card-front,
    .page-about .bento-card.flipped > .card-inner > .card-front { display: none; }
    .page-about .bento-card.expanded > .card-inner > .card-back,
    .page-about .bento-card.flipped > .card-inner > .card-back { display: flex; opacity: 1; pointer-events: auto; }
    .page-about .card-education.expanded .edu-back-list,
    .page-about .card-education.expanded .edu-back-list > div:nth-child(3) { display: block; }
    .page-about .card-capabilities.expanded .tools-vertical-list { grid-template-columns: 1fr 1fr; }
    .page-about .col-stack.expanded .card-experience .card-back { display: flex; opacity: 1; pointer-events: auto; }
    .page-about .col-stack.expanded .card-experience .exp-back-content { flex-direction: column !important; gap: 24px; }
    .page-about .card-title { font-size: 28px; margin-bottom: 24px; }
    .page-about .tool-items-v, .page-about .item-sub-text { font-size: 14px; line-height: 1.5; }
    .page-about .circle-btn { width: 96px; height: 96px; align-self: flex-end; }
    .page-about .circle-arrow { width: 48px; height: 48px; }
    .page-about .card-language .card-front {
        display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center;
        gap: 20px; min-height: 0; padding: 20px 24px !important;
    }
    .page-about .card-language .sub-card-title { margin: 0 !important; font-size: clamp(18px, 5vw, 22px); }
    .page-about .card-language .lang-list { min-width: 0; gap: 8px; }
    .page-about .card-language .lang-item { align-items: baseline; }
    .page-about .card-language .lang-name { flex-shrink: 0; }
    .page-about .card-language .lang-level { min-width: 0; }
    .page-about .card-skills .capa-list { flex-direction: row; flex-wrap: wrap; gap: 10px; }
    .page-about .card-skills .capa-row { display: contents; }
    .page-about .card-skills .capa-tag { font-size: 14px; line-height: 1.4; }
    .page-about .bento-grid > .col-connect { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; }
    .page-about .card-connect :is(.card-front, .card-back) { padding: 20px 16px !important; min-height: 0; }
    .page-about .card-connect .sub-card-title { font-size: 20px; margin-bottom: 20px; }
    .page-about .contact-back-content { overflow-wrap: anywhere; }
    .page-about .col-connect .circle-wrapper { height: auto; justify-content: center; }
    .page-about .col-connect .circle-btn { width: min(100%, 150px); height: auto; aspect-ratio: 1; box-sizing: border-box; align-self: center; }
    .page-about .col-connect .circle-arrow { width: 50%; height: auto; aspect-ratio: 1; }

    .page-about .footer { margin-top: 40px; padding-bottom: max(32px, env(safe-area-inset-bottom)); }
    .page-error { height: 100dvh; }
    .page-error .ui-container { bottom: max(32px, env(safe-area-inset-bottom)); padding: 0 24px; }
}

@media (max-width: 1023px) and (max-height: 500px) {
    .page-home .menu-wrapper { margin-top: 16px; }
    .page-home .menu-text { font-size: 28px; }
    .page-home #theme-toggle { top: 100px; }
    .page-about .philo-container { flex-direction: row; }
    .page-about .text-col { width: auto; height: 100%; flex: 1; margin-right: 0; }
    .page-about .visual-col { width: 45%; height: 100%; flex: 0 0 45%; }
}
