:root {
    --text: #181818;
    --text-secondary: #000000;
    --muted: #6b6b6b;
    --card: rgba(255, 255, 255, .82);
    --border: rgba(255, 255, 255, .45);
    --shadow: 0 10px 30px rgba(0, 0, 0, .08);

    --grass-0: rgba(0, 0, 0, 0.06);
    --grass-1: #acd5b3;
    --grass-2: #7fa985;
    --grass-3: #4d7c54;
    --grass-4: #1e4c25;
}

body[data-theme="dark"] {
    --text: #f0f0f0;
    --text-secondary: #dbdbdb;
    --muted: #8b8b8b;
    --card: rgba(22, 27, 34, .82);
    --border: rgba(255, 255, 255, .05);

    --grass-0: #161b22;
    --grass-1: #0e4429;
    --grass-2: #006d32;
    --grass-3: #26a641;
    --grass-4: #39d353;
    font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    color: var(--text);
    font-family: Inter, sans-serif;
    padding: 32px;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("/assets/backgrounds/desktop.avif");
    background-size: cover;
    background-position: center;
    z-index: -2;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    backdrop-filter: blur(5px);
    background: rgba(255, 255, 255, .18);
    z-index: -1;
}

body[data-theme="dark"]::after {
    background: rgba(0, 0, 0, .35);
}

/* =========================
   Layout
========================= */
.page-layout {
    max-width: 1400px;
    margin: auto;
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 24px;
}

.profile-column {
    position: sticky;
    top: 24px;
    height: fit-content;
}

.content-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

.card {
    background: var(--card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 32px;
    padding: 24px;
    box-shadow: var(--shadow);
}

/* =========================
   Profile
========================= */
.avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 24px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cert-icon {
    width: 36px;
    height: 36px;
}

#title {
    margin-top: 12px;
    color: var(--muted);
}

#bio {
    margin-top: 20px;
    line-height: 1.8;
    white-space: pre-line;
}

.icon-credit {
    margin-top: 16px;
    text-align: center;
    font-size: .85rem;
    color: var(--text-secondary);
}

.icon-credit a {
    color: inherit;
    text-decoration: none;
}

.icon-credit a:hover {
    text-decoration: underline;
}

/* =========================
   Social Grid (PC基準)
========================= */
#socials {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: 56px;
    gap: 16px;
}

.social-card {
    text-decoration: none;
    color: inherit;
    transition: transform .2s ease, box-shadow .2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

.social-square {
    grid-column: span 1;
    grid-row: span 2;
    flex-direction: column;
}

.social-wide {
    grid-column: span 2;
    grid-row: span 2;
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    padding-left: 18px;
}

.social-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
}

body[data-theme="dark"] .social-icon-svg,
body[data-theme="dark"] #theme-icon {
    filter: brightness(0) invert(0.85);
}

.social-card span {
    color: var(--text-secondary);
    font-size: .95rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================
   GitHub Card
========================= */
.github-header {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

#github-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: max-content;
}

/* 月ラベルの親コンテナ */
#github-months {
    position: relative;
    width: 100%;
    height: 18px;
    overflow: hidden;
}

/* 個々の月ラベル */
.month-label {
    position: absolute;
    top: 0;
    font-size: 9px;
    color: var(--muted);
    white-space: nowrap;
    line-height: 18px;
    transform: translateX(0);
}

/* 草専用のグリッド */
#github-days {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, 12px);
    gap: 3px;
    margin-top: 4px;
}

/* 草（日）のスタイル */
.day {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* スクロールバーの発生源を抑止 */
.github-wrapper {
    margin-top: 20px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

.day[data-level="0"] { background: var(--grass-0); }
.day[data-level="1"] { background: var(--grass-1); }
.day[data-level="2"] { background: var(--grass-2); }
.day[data-level="3"] { background: var(--grass-3); }
.day[data-level="4"] { background: var(--grass-4); }

/* =========================
   Gallery
========================= */
.gallery-card {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    padding: 0;
}

.gallery-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 1s ease;
    opacity: 0;
}

.gallery-image.active {
    opacity: 1;
}

.gallery-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    pointer-events: none;
}

.gallery-overlay::before {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 40%;
    background: linear-gradient(to top, rgba(0,0,0,.75), rgba(0,0,0,.45), rgba(0,0,0,0));
}

#gallery-caption {
    position: relative;
    z-index: 1;
    padding: 0 20px 16px 20px;
    color: white;
    font-size: .95rem;
    font-weight: 500;
    text-shadow: 0 2px 8px rgba(0,0,0,.4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================
   Theme Toggle Button Base
========================= */
#theme-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border: 1px solid var(--border);
    border-radius: 50%;
    z-index: 999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--card);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, background 0.3s ease;
}

#theme-toggle:hover {
    transform: scale(1.05);
}

#theme-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    transition: filter 0.3s ease;
}

/* =========================
   Responsive
========================= */
@media (max-width: 1100px) {
    body::before {
        background-image: url("/assets/backgrounds/tablet.avif");
    }
    .page-layout {
        grid-template-columns: 1fr;
    }
    .profile-column {
        position: static;
    }
}

@media (max-width: 700px) {
    body {
        padding: 16px;
    }
    body::before {
        background-image: url("/assets/backgrounds/mobile.avif");
    }

    #socials {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 56px;
        gap: 12px;
    }
    .social-square {
        grid-column: span 1;
        grid-row: span 1;
    }
    .social-wide {
        grid-column: span 3;
        grid-row: span 1;
        padding-left: 16px;
        gap: 12px;
    }
    .social-icon {
        width: 32px;
        height: 32px;
    }
    .social-card span {
        font-size: .85rem;
    }
}