/* ===================================
   Reset & Base
=================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
    --bg:        #0f0f0f;
    --surface:   #1c1c1c;
    --border:    #2e2e2e;
    --text:      #f0f0f0;
    --muted:     #888;
    --accent:    #ff9f43;
    --primary:   #2ed573;
    --danger:    #ff4757;
    --wave:      #00d2d3;
    --radius:    12px;
    --gap:       16px;
}

html, body {
    height: 100%;
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}


/* ===================================
   공통 버튼
=================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
}
.btn:active { opacity: 0.75; }

.btn--primary  { background: var(--primary); color: #000; }
.btn--danger   { background: var(--danger);  color: #fff; }
.btn--ghost    { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn--lg       { padding: 14px 36px; font-size: 1.05rem; }
.btn--sm       { padding: 6px 14px;  font-size: 0.85rem; }


/* ===================================
   목차 페이지 (index.html)
=================================== */
.site-header {
    padding: 40px var(--gap) 20px;
    text-align: center;
}
.site-header h1 {
    font-size: 1.6rem;
    color: var(--accent);
    margin-bottom: 8px;
}
.subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* 관측소 번호 입력 바 */
.station-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px var(--gap);
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.station-bar__label {
    font-size: 0.85rem;
    color: var(--muted);
    white-space: nowrap;
}
.station-bar__input {
    flex: 1;
    min-width: 80px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50px;
    color: var(--text);
    font-size: 0.92rem;
    padding: 6px 14px;
    outline: none;
}
.station-bar__input:focus { border-color: var(--primary); }
.station-bar__status {
    font-size: 0.8rem;
    min-width: 80px;
}

.activity-grid {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    padding: var(--gap);
    max-width: 480px;
    margin: 0 auto;
}

/* 카드 */
.card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    position: relative;
    transition: border-color 0.2s;
}
.card--active  { border-color: var(--primary); cursor: pointer; }
.card--active:active { opacity: 0.8; }
.card--disabled { opacity: 0.45; cursor: default; }

.card__number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 40px;
}
.card__body { flex: 1; }
.card__title { font-size: 1.05rem; margin-bottom: 4px; }
.card__desc  { font-size: 0.82rem; color: var(--muted); line-height: 1.4; }
.card__arrow { font-size: 1.2rem; color: var(--primary); }
.card__badge {
    position: absolute;
    top: 12px; right: 12px;
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 50px;
    background: var(--border);
    color: var(--muted);
}

.site-footer {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 24px var(--gap) 40px;
}


/* ===================================
   모달
=================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--gap);
    z-index: 100;
}
.modal[hidden] { display: none; }
.modal__box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px 24px;
    max-width: 360px;
    width: 100%;
}
.modal__box h3 { font-size: 1.1rem; margin-bottom: 16px; color: var(--accent); }
.modal__box ol { padding-left: 20px; line-height: 2; font-size: 0.92rem; }
.modal__note   { font-size: 0.8rem; color: var(--muted); margin: 16px 0; }
.modal__box .btn { width: 100%; margin-top: 8px; }


/* ===================================
   Activity 페이지 공통
=================================== */
.activity-page {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    transition: background-color 0.3s ease;
}

.activity-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px var(--gap);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.activity-header h1 { font-size: 1rem; color: var(--accent); }

.activity-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    padding: var(--gap);
    overflow: hidden;
}

/* 배경색 표시 영역 */
.color-display {
    text-align: center;
    padding: 16px;
}
.color-display__label {
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1;
}
.color-display__unit { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }

/* 파형 캔버스 */
.chart-wrapper {
    width: 100%;
    height: 40vh;
    max-height: 280px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}
.chart-wrapper canvas { width: 100% !important; height: 100% !important; }

/* 컨트롤 버튼 그룹 */
.controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

/* 상태 메시지 */
.status-msg {
    font-size: 0.82rem;
    color: var(--muted);
    text-align: center;
    min-height: 1.4em;
}

/* GPS 좌표 표시 (activity2) */
.gps-display {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    font-size: 0.88rem;
    color: var(--muted);
}
.gps-display__item strong {
    color: var(--text);
    font-weight: 600;
}
.gps-display__acc {
    color: var(--muted);
    font-size: 0.78rem;
}

/* 스펙트로그램 패널 (activity3) */
.spectrogram-panel {
    width: 100%;
    height: 30vh;
    max-height: 220px;
    position: relative;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    background: #0a0a0a;
}
.spectrogram-panel canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}
.spectrogram-freq-overlay {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 30px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3px 0;
    pointer-events: none;
}
.spectrogram-freq-overlay span {
    font-size: 9px;
    color: #777;
    line-height: 1;
    text-align: center;
    display: block;
}

/* ===================================
   모드 탭 (activity3)
=================================== */
.mode-tabs {
    display: flex;
    gap: 4px;
    padding: 10px var(--gap) 0;
    flex-shrink: 0;
}
.mode-tabs__btn {
    flex: 1;
    padding: 9px 0;
    border: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.mode-tabs__btn--active {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--bg);
}

/* ===================================
   activity3 패널 레이아웃
=================================== */
#panel-sensor,
#panel-file {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    width: 100%;
    min-height: 0;
}

#drop-zone {
    flex: 1;
    min-height: 30vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ===================================
   드롭존 (activity3 파일 선택)
=================================== */
.drop-zone {
    width: 100%;
    padding: 36px 20px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.drop-zone--hover {
    border-color: var(--primary);
    color: var(--primary);
}
.drop-zone__hint {
    font-size: 0.78rem;
    margin-top: 6px;
    color: var(--muted);
}

/* ===================================
   CSV 파일 정보 (activity3)
=================================== */
.csv-file-info {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}
.csv-file-info strong {
    color: var(--text);
    font-weight: 600;
}

/* ===================================
   피크 주파수 표시 (activity3)
=================================== */
.peak-freq-display {
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
    color: var(--muted);
    padding: 4px 0;
}
.peak-freq-display span {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.1rem;
}


/* ===================================
   MMI 색상 오버레이 (activity1)
=================================== */
.color-display__mmi {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    min-height: 1.4em;
    color: rgba(255,255,255,0.9);
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    margin-bottom: 4px;
}

.btn--accent { background: var(--accent); color: #000; }

/* MMI 진도 안내 모달 */
.modal__box--wide {
    max-width: 440px;
    max-height: 80vh;
    overflow-y: auto;
}
.mmi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 16px;
}
.mmi-table td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.mmi-table td:first-child {
    width: 10px;
    padding: 0;
}
.mmi-table td:nth-child(2) { font-weight: 700; white-space: nowrap; }
.mmi-table td:nth-child(4) { font-size: 0.76rem; color: var(--muted); }

/* 진도 안내 버튼 (activity1) */
.mmi-info-btn {
    align-self: center;
    backdrop-filter: blur(4px);
    background: rgba(28,28,28,0.85);
    border: 1px solid var(--border);
    color: var(--text);
    white-space: nowrap;
}

/* MMI 토글 스위치 (activity1) */
.mmi-toggle {
    display: flex;
    align-items: center;
    align-self: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.mmi-toggle__label { font-size: 0.82rem; color: var(--muted); }
.mmi-toggle__track {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--border);
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.mmi-toggle input:checked ~ .mmi-toggle__track { background: var(--accent); }
.mmi-toggle__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: left 0.2s;
}
.mmi-toggle input:checked ~ .mmi-toggle__track .mmi-toggle__thumb { left: 23px; }
.mmi-toggle input { display: none; }

/* 축 선택 버튼 그룹 (activity3) */
.axis-selector {
    display: flex;
    gap: 6px;
    justify-content: center;
    align-items: center;
}
.axis-btn {
    padding: 4px 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.axis-btn--active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}
.axis-btn:disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* 리뷰 컨트롤 바 (activity1) */
.review-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    justify-content: space-between;
    padding: 6px 4px;
}
.review-bar__time {
    font-size: 0.82rem;
    color: var(--muted);
}
.review-bar__mmi {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    width: 100%;
}


/* ===================================
   분석 모드 탭 (activity3)
=================================== */
.analysis-tabs {
    display: flex;
    gap: 4px;
    width: 100%;
    flex-shrink: 0;
}
.analysis-tabs__btn {
    flex: 1;
    padding: 7px 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.analysis-tabs__btn--active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--bg);
}
.analysis-tabs__btn:disabled {
    opacity: 0.35;
    pointer-events: none;
}
.analysis-info-btn {
    flex: 0 0 auto;
    padding: 7px 10px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.9rem;
    border-radius: var(--radius);
    cursor: pointer;
}
.psd-controls {
    display: flex;
    justify-content: flex-end;
    padding: 4px 6px 2px;
}

/* ===================================
   시계 동기화 모달
=================================== */
.time-clock {
    font-family: 'Courier New', monospace;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    letter-spacing: 0.04em;
    padding: 12px 0 4px;
}
.ntp-section {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}
.ntp-result {
    font-size: 0.88rem;
    padding: 8px 16px;
    border-radius: 8px;
    text-align: center;
    width: 100%;
}
.ntp-result--ok   { color: var(--primary); background: rgba(46, 213, 115, 0.12); }
.ntp-result--warn { color: var(--accent);  background: rgba(255, 159,  67, 0.12); }
.ntp-result--err  { color: var(--danger);  background: rgba(255,  71,  87, 0.12); }

.sync-status {
    font-size: 0.82rem;
    padding: 6px 12px;
    border-radius: 8px;
    text-align: center;
    margin-top: 4px;
}
.sync-status--ok   { color: var(--primary); background: rgba(46,213,115,0.10); }
.sync-status--none { color: var(--muted); }


/* ===================================
   Activity 4 — 주시곡선 탐사
=================================== */
.activity4-body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Step progress nav */
.step-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px var(--gap);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.step-nav__item {
    min-width: 52px;
    padding: 6px 4px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--muted);
    line-height: 1.2;
}
.step-nav__item small { font-size: 0.68rem; font-weight: 400; display: block; }
.step-nav__item--active { border-color: var(--primary); color: var(--primary); }
.step-nav__item--done   { background: var(--primary); border-color: var(--primary); color: #000; }
.step-nav__arrow { color: var(--border); font-size: 0.9rem; }

/* Main content column */
.activity4-main {
    max-width: 520px;
    margin: 0 auto;
    padding: var(--gap);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Step section */
.step-section { display: flex; flex-direction: column; gap: 14px; }
.step-title { font-size: 1rem; color: var(--accent); }
.sub-title  { font-size: 0.9rem; color: var(--text); margin-top: 4px; }
.step-desc  { font-size: 0.83rem; color: var(--muted); line-height: 1.5; }

/* Timing warning */
.timing-warning {
    padding: 10px 14px;
    background: rgba(255, 71, 87, 0.10);
    border: 1px solid rgba(255, 71, 87, 0.35);
    border-radius: 8px;
    font-size: 0.82rem;
    color: var(--danger);
    line-height: 1.5;
}

/* Station card (step 1) */
.station-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
}
.station-card__id   { font-weight: 700; color: var(--text); }
.station-card__meta { color: var(--muted); flex: 1; }
.station-card__file { font-size: 0.76rem; color: var(--border); width: 100%; }
.text-warn          { color: var(--danger); }

/* Source radio options (step 2) */
.source-opts { display: flex; flex-direction: column; gap: 8px; }
.source-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.88rem;
    cursor: pointer;
}
.source-opt input[type="radio"] { accent-color: var(--primary); }
.source-opt small { color: var(--muted); font-size: 0.78rem; }
.source-badge {
    display: inline-block;
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 20px;
    background: var(--accent);
    color: #000;
    font-weight: 700;
    margin-left: 4px;
    vertical-align: middle;
}

/* Distance rows (step 2) */
.dist-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
.dist-row__id   { flex: 1; }
.dist-row__unit { color: var(--muted); }
.dist-input {
    width: 90px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.88rem;
    padding: 5px 10px;
    outline: none;
    text-align: right;
}
.dist-input:focus { border-color: var(--primary); }

/* Pick cards (step 3) */
.pick-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
}
.pick-card--source  { border-color: var(--accent); }
.pick-card--picked  { border-color: var(--primary); }
.pick-card__hdr {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    font-size: 0.83rem;
    border-bottom: 1px solid var(--border);
}
.pick-card__id   { font-weight: 700; flex: 1; }
.pick-card__dist { color: var(--muted); white-space: nowrap; }
.pick-card__time { color: var(--primary); font-size: 0.78rem; white-space: nowrap; }
.pick-card__wave { height: 68px; background: #111; }
.pick-card__wave canvas { width: 100% !important; height: 100% !important; display: block; }

/* Hodochron canvas (step 4) */
.hodo-wrap {
    width: 100%;
    height: 260px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    background: #0a0a0a;
}
.hodo-wrap canvas { width: 100% !important; height: 100% !important; display: block; }

/* Segment slider (step 4) */
.segment-ctrl {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}
.seg-label   { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.split-slider { flex: 1; accent-color: var(--primary); }

/* Results grid (step 4) */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.result-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
}
.result-item__label { font-size: 0.75rem; color: var(--muted); margin-bottom: 2px; }
.result-item__value { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.result-item__unit  { font-size: 0.76rem; color: var(--muted); }
.result-detail {
    font-size: 0.79rem;
    color: var(--muted);
    text-align: center;
    min-height: 1.2em;
}


/* ===================================
   PC 반응형 (768px+)
=================================== */
@media (min-width: 768px) {
    .activity-main {
        max-width: 860px;
        margin: 0 auto;
        width: 100%;
    }
    .chart-wrapper {
        max-height: 360px;
    }
    .spectrogram-panel {
        max-height: 300px;
    }
}
