html {
    overflow-x: hidden; /* Prevent horizontal scroll on some mobile browsers */
    min-height: 100%;
    /* Ensure Safari/iOS always has a dark paint behind the body during viewport resize/overscroll */
    background: linear-gradient(-45deg, #1a1a1a, #2d2d2d, #1f2937, #374151);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    background-attachment: fixed;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body {
    font-family: 'Segoe UI', 'Noto Sans JP', Arial, sans-serif;
    background: transparent; /* html要素の背景を使用 */
    color: #e0e0e0;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Global image safety: constrain images within containers */
img {
    max-width: 100%;
    height: auto;
}

/* =============================
   Design tokens (site-wide)
   ============================= */
:root {
    /* Colors */
    --brand: #82b5d1;
    --brand-weak: #a0c8e1;
    --text-primary: #e0e0e0;
    --surface: #2a2a2a;
    --bg: #1a1a1a;
    --border: rgba(130, 181, 209, 0.25);
    --border-strong: rgba(130, 181, 209, 0.45);
    --glass-bg: rgba(42, 42, 42, 0.85);
    --glass-bg-strong: rgba(42, 42, 42, 0.9);
    --glass-hover: rgba(130, 181, 209, 0.15);

    /* Link palette (distinct states) */
    --link: var(--brand);
    --link-hover: var(--brand-weak);
    --link-visited: var(--brand); /* visited = unvisited per request */

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);

    /* Motion */
    --duration-quick: 150ms;
    --duration-base: 200ms;
    --easing: ease;
}

/* =============================
   Global Page Loader Overlay
   ============================= */
/* Show a calm, full-screen loader by default to mask initial layout shifts. */
html::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 9998;
    /* Reuse the site's calm animated background */
    background: linear-gradient(-45deg, #1a1a1a, #2d2d2d, #1f2937, #374151);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    opacity: 1;
    transition: opacity 200ms ease;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
}

/* Subtle floating orbs over the loader background */
html::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: 
        radial-gradient(circle at 20% 80%, rgba(130, 181, 209, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(157, 168, 199, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(130, 181, 209, 0.04) 0%, transparent 50%);
    animation: floatingOrbs 20s ease-in-out infinite;
    pointer-events: auto; /* Block interaction until loaded */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
}

/* Center spinner element using a fixed child via the :root overlay */
/* Use a dedicated element via CSS-only by leveraging a nested fixed element with box-shadow trick */
.page-loader-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid rgba(160, 200, 225, 0.25);
    border-top-color: #82b5d1;
    animation: loaderSpin 1s linear infinite;
    box-shadow: 0 0 24px rgba(130, 181, 209, 0.25);
}

/* Inject the spinner without extra HTML: create it via a pseudo of body */
body::after {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 56px;
    height: 56px;
    margin-left: -28px;
    margin-top: -28px;
    z-index: 10000;
    border-radius: 50%;
    border: 3px solid rgba(160, 200, 225, 0.25);
    border-top-color: #82b5d1;
    animation: loaderSpin 1s linear infinite, loaderBreath 2.4s ease-in-out infinite;
    box-shadow: 0 0 24px rgba(130, 181, 209, 0.25);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
}

@keyframes loaderSpin {
    to { transform: rotate(360deg); }
}

@keyframes loaderBreath {
    0%, 100% { box-shadow: 0 0 16px rgba(130, 181, 209, 0.18); }
    50% { box-shadow: 0 0 28px rgba(130, 181, 209, 0.34); }
}

/* Disable scroll and interactions during loading to avoid shifts */
html:not(.page-loaded) body {
    overflow: hidden;
}

/* Re-enable scroll when page is loaded */
html.page-loaded body {
    overflow: visible !important;
}

/* When page is ready, fade out overlay and spinner */
html.page-loaded::before,
html.page-loaded::after,
html.page-loaded body::after {
    opacity: 0;
    transition: opacity 200ms ease;
    pointer-events: none;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    html::before,
    html::after,
    body::after {
        animation: none !important;
    }
}

/* アニメーション背景（全ページ共通） */
body.animated-bg {
    background: linear-gradient(-45deg, #1a1a1a, #2d2d2d, #1f2937, #374151);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    position: relative;
    overflow-x: hidden;
}

body.animated-bg::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(130, 181, 209, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(157, 168, 199, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(130, 181, 209, 0.05) 0%, transparent 50%);
    animation: floatingOrbs 20s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes floatingOrbs {
    0%, 100% {
        opacity: 0.8;
        transform: translateY(0px) rotate(0deg);
    }
    33% {
        opacity: 1;
        transform: translateY(-20px) rotate(120deg);
    }
    66% {
        opacity: 0.6;
        transform: translateY(10px) rotate(240deg);
    }
}

/* リンクの色設定（訪問済みとホバーが被らないよう明確化） */
a { color: var(--link); }
a:visited { color: var(--link-visited) !important; }
a:hover { color: var(--link-hover); }
/* 訪問済み+ホバー時はホバー色を優先して明確に */
a:visited:hover { color: var(--link-hover) !important; }

header {
    background: #2a2a2a;
    color: #e0e0e0;
    padding: 2rem 0 1rem 0;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

header h1 {
    font-size: 2.2rem;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: inline-flex;
    gap: 2rem;
}

nav a {
    color: #e0e0e0 !important;
    text-decoration: none;
    font-weight: 500;
    font-size: 1.1rem;
    transition: color 0.2s;
}

nav a:visited {
    color: #e0e0e0 !important;
}

nav a:hover {
    color: #82b5d1 !important;
}

section {
    max-width: 700px;
    margin: 2.5rem auto;
    background: rgba(42, 42, 42, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    padding: 2rem 2.5rem;
    /* 横幅をしっかり確保 */
    min-width: 320px;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(130, 181, 209, 0.15);
}

h2 {
    font-size: 1.5rem;
    color: #e0e0e0;
    border-bottom: 2px solid #82b5d1;
    display: inline-block;
    margin-bottom: 1.2rem;
    padding-bottom: 0.2rem;
}

audio {
    width: 100%;
    margin: 1rem 0;
}

.profile-image {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm), 0 2px 8px rgba(0, 0, 0, 0.30);
    transition: none; /* No hover animation */
    /* Revert to bottom-only spacing */
    margin-bottom: 1rem;
}

@media (prefers-reduced-motion: reduce) {
    .profile-image {
        transition: none;
    }
}

.logo-image {
    width: 80px;
    height: auto;
    display: block;
}

/* SNSリンクのレスポンシブ対応 */
.sns-list {
    list-style: none;
    padding: 0;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.sns-list li {
    margin-bottom: 0.5rem;
}

.sns-list a {
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.55em;
    font-size: 1rem;
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius-md);
    color: var(--text-primary) !important;
    background: var(--glass-bg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: background-color var(--duration-base) var(--easing), border-color var(--duration-base) var(--easing), box-shadow var(--duration-base) var(--easing), transform var(--duration-quick) var(--easing);
}

.sns-list a:visited {
    color: #e0e0e0 !important;
}

.sns-list a:hover {
    background: var(--glass-hover);
    border-color: var(--border-strong);
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
    transform: translateY(-1px);
}

.sns-list a:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(130, 181, 209, 0.5), 0 4px 14px rgba(0,0,0,0.3);
}

.sns-list a:active {
    transform: translateY(0);
}

.sns-list a i {
    font-size: 1.05em;
}

.nav-link.active {
    color: #82b5d1 !important;
    border-bottom: 2px solid #82b5d1;
    background: #3a3a3a;
    border-radius: 4px 4px 0 0;
}

@media (max-width: 900px) {
    section {
        max-width: calc(100vw - 2rem);
        min-width: 0;
        padding: 1.5rem 1rem;
        margin-left: 1rem;
        margin-right: 1rem;
    }
}

@media (max-width: 600px) {
    header h1 {
        font-size: 1.3rem;
    }

    nav ul {
        gap: 1rem;
        font-size: 1rem;
    }

    section {
        max-width: calc(100vw - 1rem);
        padding: 1rem 0.5rem;
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    .profile-image {
        width: 90px;
        height: 90px;
    }

    .logo-image {
        width: 50px;
    }

    .sns-list {
        gap: 0.7rem;
    }
}

@media (max-width: 400px) {
    section {
        max-width: calc(100vw - 0.5rem);
        padding: 0.5rem 0.2rem;
        margin-left: 0.25rem;
        margin-right: 0.25rem;
    }
}



/* フッター */
footer {
    text-align: center;
    padding: 1.2rem 0;
    background: #2a2a2a;
    color: #e0e0e0;
    font-size: 0.95rem;
    letter-spacing: 1px;
    border-top: 1px solid #444;
}

/* The footer is injected inside a container div (#common-footer).
   Since the body is a flex column, we need the container itself to flex-push to the bottom. */
#common-footer { 
    margin-top: auto; 
}

@media (max-width: 600px) {
    /* Mobile styles can be added here if needed */
}

/* =============================
   Back to top button
   ============================= */
.back-to-top {
    position: fixed;
    right: clamp(12px, 2vw, 24px);
    bottom: calc(clamp(12px, 2vw, 24px) + env(safe-area-inset-bottom, 0px));
    width: clamp(42px, 6vw, 52px);
    height: clamp(42px, 6vw, 52px);
    border-radius: var(--radius-pill);
    background: rgba(42, 42, 42, 0.7);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 22px rgba(0,0,0,0.35), 0 0 12px rgba(130, 181, 209, 0.18);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: 
        opacity var(--duration-base) var(--easing),
        transform var(--duration-base) var(--easing),
        box-shadow var(--duration-base) var(--easing),
        background-color var(--duration-base) var(--easing),
        border-color var(--duration-base) var(--easing),
        color var(--duration-base) var(--easing);
    z-index: 950;
    text-decoration: none;
}

.back-to-top i {
    pointer-events: none;
    font-size: clamp(16px, 2.8vw, 20px);
    line-height: 1;
}

.back-to-top.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.back-to-top:hover {
    background: var(--glass-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
    transform: translateY(0) scale(1.03);
    box-shadow: 0 10px 26px rgba(0,0,0,0.45), 0 0 16px rgba(130, 181, 209, 0.28);
}

.back-to-top:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(130, 181, 209, 0.5), 0 8px 22px rgba(0,0,0,0.35);
}

.back-to-top:active {
    transform: translateY(0) scale(0.97);
    background: rgba(130, 181, 209, 0.24);
}

@media (prefers-reduced-motion: reduce) {
    .back-to-top {
        transition: none;
    }
}