:root {
    --bg: #0d0d0f;
    --panel-bg: #121216;
    --block: #17171b;
    --line: #2a2a30;
    --text: #cfcfd6;
    --text-dim: #7c7c88;
    --accent: #5f7d9c;
}

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

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
    overscroll-behavior: none;
}

#layout {
    display: flex;
    height: 100vh;
}

#canvas-holder {
    flex: 0 0 40%;
    min-width: 320px;
    position: relative;
}
#canvas-holder canvas { display: block; }

#panel {
    flex: 1 1 auto;
    max-width: none; /* 좌측을 줄이고 남은 공간 전부 사용 */
    background: var(--panel-bg);
    border-left: 1px solid var(--line);
    padding: 32px 28px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

#panel-header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
}
.tagline {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-dim);
}

#data-notice {
    border-left: 2px solid var(--accent);
    padding: 4px 0 4px 14px;
    font-size: 13px;
    line-height: 1.75;
    color: var(--text-dim);
    word-break: keep-all;
    text-align: justify;
}
#data-notice p + p { margin-top: 8px; }
#data-notice .notice-strong {
    color: var(--text);
    font-weight: 600;
}

#revisit-banner {
    background: rgba(95, 125, 156, 0.12);
    border: 1px solid rgba(95, 125, 156, 0.4);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.6;
}

/* ---- 통계 ---- */
#stats-content {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 넓어진 패널: 유형/연령대를 나란히 */
    gap: 26px 36px;
}
#stats-content > .stat-big,
#stats-content > .stat-row,
#stats-content > .stat-speed,
#stats-content > .stat-section.wide { grid-column: 1 / -1; }
@media (max-width: 1100px) {
    #stats-content { grid-template-columns: 1fr; }
}

/* 평균 속도 */
.stat-speed {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px 22px;
    background: var(--block);
}
.stat-speed .speed-value {
    font-size: 30px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #fff;
}
.stat-speed .speed-value .per { color: var(--text-dim); font-weight: 400; margin: 0 6px; }
.stat-speed .label { font-size: 12.5px; color: var(--text-dim); margin-top: 6px; }

.stat-big { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.stat-big .num {
    font-size: 52px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #fff;
    line-height: 1;
}
.stat-big .label { font-size: 13px; color: var(--text-dim); }

.stat-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.stat-cell .num {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.stat-cell .label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.stat-section h3 {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

.bar-row {
    display: grid;
    grid-template-columns: 96px 1fr 40px;
    align-items: center;
    gap: 10px;
    margin-bottom: 7px;
    font-size: 13px;
}
.bar-row .bar-label { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-track { background: #1d1d22; border-radius: 3px; height: 14px; overflow: hidden; }
.bar-row .bar-fill { display: block; background: #4a6b8a; height: 100%; border-radius: 3px; min-width: 2px; }
.bar-row.unknown .bar-fill { background: #3a3a42; }
.bar-row .bar-count { text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.month-wrap { display: flex; gap: 10px; }
.month-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    height: 72px;
    font-size: 10px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
.month-main { flex: 1; min-width: 0; }
.month-plot {
    position: relative;
    height: 72px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
}
.m-grid { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); }
.m-bar { flex: 1; background: #4a6b8a; border-radius: 2px 2px 0 0; min-height: 2px; position: relative; z-index: 1; }
.month-labels { display: flex; gap: 4px; margin-top: 5px; }
.month-labels span { flex: 1; text-align: center; font-size: 9.5px; color: var(--text-dim); }

#panel-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    font-size: 11px;
    line-height: 1.7;
    color: var(--text-dim);
}

/* ---- 이 작업에 대하여 (패널 상단 — '이 숫자는 전부가 아닙니다' 공지 위, 2026-08-08 이동) ----
   데스크톱은 패널이 늘 펼쳐져 있어 항상 보이고, 모바일은 정보 뷰를 열었을 때만 보인다
   (헤더 밖 패널 자식은 info-open이 아니면 숨겨지는 기존 규칙을 그대로 탄다). */
#about-sec { margin-top: -8px; /* 패널 gap(24px)이 헤더와 공지 사이에 두 번 들어가 벌어지는 것을 보정 */ }
/* 버튼이 아니라 밑줄 텍스트 — 모바일 제목(정보 뷰 토글)과 같은 어법 */
.about-go {
    display: inline-block;
    font-size: 13px;
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 5px;
    text-decoration-thickness: 1px;
    text-decoration-color: var(--text-dim);
}
.about-go:hover { text-decoration-color: var(--accent); }

/* ---- 현재로 버튼 ---- */
#follow-btn {
    position: fixed;
    left: 24px;
    bottom: 24px;
    background: var(--block);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 9px 18px;
    font-size: 13px;
    cursor: pointer;
    z-index: 20;
}
#follow-btn:hover { border-color: var(--accent); color: #fff; }
/* 정보 뷰가 열려 있는 동안은 블럭 화면이 아니므로 '현재로'가 떠 있을 이유가 없다 */
body.info-open #follow-btn { display: none; }

/* ---- 추모 꽃 아이콘 (flower.js — 설치 버전 FloralArc 이식, pid 시드로 사람마다 고정) ---- */
.ack-num { display: flex; align-items: center; gap: 8px; }
.flower-ic { width: 25px; height: 25px; flex-shrink: 0; }

/* ---- 상세 오버레이 ---- */
#detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    padding: 20px;
}
#detail-card {
    background: var(--panel-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    max-width: 520px;
    width: 100%;
    padding: 28px;
    position: relative;
}
#detail-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 22px;
    cursor: pointer;
}
#detail-close:hover { color: #fff; }
#detail-date { font-size: 13px; color: var(--accent); margin-bottom: 6px; }
#detail-title { font-size: 18px; margin-bottom: 10px; line-height: 1.5; }
#detail-meta { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; }
#detail-summary { font-size: 14px; line-height: 1.8; margin-bottom: 18px; word-break: keep-all; }
#detail-link { font-size: 13px; color: #7ea7cc; text-decoration: none; }
#detail-link:hover { text-decoration: underline; }

#detail-ack {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
#ack-count { font-size: 13px; color: var(--text-dim); }
#ack-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--block);
    border: 1px solid var(--line);
    border-radius: 28px;
    padding: 7px 16px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}
#ack-btn:hover:not(:disabled) { border-color: var(--accent); }
#ack-btn:disabled { opacity: 0.55; cursor: default; }

/* ---- 모바일 상세 뷰 (포스트 형식) ---- */
/* 스크롤 없음 — 한 화면에 한 사람. 다른 기록은 뒤로가기로 블럭 화면에 돌아가 선택 */
#post-view {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: var(--bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100dvh;
}
#post-topbar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: rgba(13, 13, 15, 0.92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line);
}
#post-back {
    background: none;
    border: none;
    color: var(--text);
    font-size: 22px;
    line-height: 1;
    padding: 6px 10px;
    cursor: pointer;
}
#post-back:hover { color: #fff; }
#post-subscribe,
#panel-subscribe {
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
}
#post-subscribe:hover,
#panel-subscribe:hover { background: rgba(95, 125, 156, 0.12); }

/* 패널 우상단 알림받기 — 상세(포스트 뷰) 상단바와 같은 자리.
   데스크톱은 패널이 늘 열려 있으므로 항상 표시. 모바일은 정보 뷰가 열려 있는
   동안만 보인다 (아래 미디어 쿼리에서 닫힘 상태를 숨김). 패널 하단에 있던
   '알림 받기' 섹션은 이 버튼으로 통합하며 제거 (2026-08-08 작가 결정). */
#panel-header { position: relative; }
#panel-subscribe { position: absolute; top: -3px; right: 0; }

/* 이미지 영역 — 사진 없이 사고 요약이 초상 역할.
   배경은 캔버스 금속 블럭과 동일 공식(가로 미러 그라데이션 + 수직 베벨). */
#post-image {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative; /* 카드 이미지(#post-card)의 기준 */
    padding: 30px 26px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.02) 18%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.26)),
        linear-gradient(90deg, hsl(228, 6%, 11%), hsl(228, 7%, 27%) 50%, hsl(228, 6%, 11%));
    border-bottom: 1px solid var(--line);
}
/* 사고 경위를 그대로 그린 카드 이미지 — 길게 누르면 네이티브 '이미지 저장' 메뉴가 뜬다.
   밑의 #post-summary(DOM 텍스트)는 스크린리더용으로 남는다 (sharecard.js). */
#post-card {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
#post-summary {
    font-size: 16px;
    line-height: 2.0;
    word-break: keep-all;
    color: #e8e8ee;
    max-width: 32em;
    text-align: justify;
    /* 분량과 무관하게 크기 고정 — 넘치면 JS(fitSummary)가 텍스트를 잘라 " …"로 마무리.
       (-webkit-line-clamp는 justify와 겹치면 …가 마지막 글자 위에 찍혀서 쓰지 않음) */
    overflow: hidden;
}

#post-actions { padding: 14px 16px 4px; }
#post-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
#post-status-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
}
#post-share-msg {
    font-size: 12.5px;
    color: var(--text-dim);
    flex-shrink: 0;
}
#post-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}
#post-share-btn:hover { border-color: var(--accent); }
#post-share-btn svg { width: 18px; height: 18px; }
#post-ack-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--block);
    border: 1px solid var(--line);
    border-radius: 32px;
    padding: 11px 18px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
}
#post-ack-btn:hover:not(:disabled) { border-color: var(--accent); }
#post-ack-btn:disabled { opacity: 0.75; cursor: default; }
#post-ack-count { font-size: 14px; font-weight: 700; }

#post-caption { padding: 12px 16px 40px; }
#post-caption h2 { font-size: 16px; line-height: 1.55; margin-bottom: 6px; }
#post-meta { font-size: 13.5px; color: var(--text-dim); margin-bottom: 14px; }
#post-link { font-size: 13.5px; color: #7ea7cc; text-decoration: none; }
#post-link:hover { text-decoration: underline; }
#post-date { margin-top: 16px; font-size: 12px; color: var(--text-dim); letter-spacing: 0.02em; }

[hidden] { display: none !important; }

/* ---- 반응형 ----
   모바일: 화면 전체가 블럭(캔버스). 상단에 제목+태그라인만 얇은 고정 헤더로 남기고
   패널의 나머지(공지/통계/구독)는 숨김. 아래로 스크롤하면 헤더가 위로 숨고,
   위로 스크롤하면 다시 나타남 (body.hdr-hidden 토글은 sketch.js 터치 스크롤에서). */
@media (max-width: 800px) {
    #layout { display: block; height: 100dvh; }
    #canvas-holder {
        position: fixed;
        inset: 0;
        height: 100dvh;
        min-width: 0;
    }
    #canvas-holder canvas { touch-action: none; }
    #panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 10;
        border-left: none;
        border-bottom: 1px solid var(--line);
        background: rgba(13, 13, 15, 0.92);
        backdrop-filter: blur(6px);
        padding: 14px 16px 12px;
        padding-top: calc(14px + env(safe-area-inset-top));
        overflow: visible;
        transition: transform 0.25s ease;
    }
    body.hdr-hidden #panel { transform: translateY(-100%); }
    /* 기본: 헤더(제목+태그라인)만. 제목을 누르면(info-open) 패널이 전체 화면으로 펼쳐짐 */
    body:not(.info-open) #panel > :not(#panel-header) { display: none; }
    body.info-open #panel {
        bottom: 0;
        height: 100dvh;
        overflow-y: auto;
        transform: none; /* hdr-hidden 상태여도 열리면 보이게 */
    }
    /* 정보 뷰가 열려 있는 동안만 우상단에 알림받기 — 포스트 뷰 상단바와 같은 자리라
       상세를 보다가 온 사람이 같은 위치에서 같은 버튼을 만난다. 닫으면 사라짐. */
    body:not(.info-open) #panel-subscribe { display: none; }
    body.info-open #panel-header { padding-right: 90px; }
    /* 정보 뷰의 맨 끝 여백 — 홈 인디케이터 영역까지 감안 (마지막 요소가 무엇이든) */
    body.info-open #panel { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
    /* 제목이 정보 뷰 토글 — 밑줄로 "눌린다"는 것을 표시 (구 i 버튼, 2026-08-08 제거).
       열려 있는 동안은 밑줄이 강조색 — 다시 누르면 닫힌다는 신호. */
    #panel-header h1 {
        font-size: 17px;
        margin-bottom: 6px;
        cursor: pointer;
        text-decoration: underline;
        text-underline-offset: 5px;
        text-decoration-thickness: 1px;
        text-decoration-color: var(--text-dim);
    }
    body.info-open #panel-header h1 { text-decoration-color: var(--accent); }
    .tagline { font-size: 12px; line-height: 1.6; }
}
