/* ─────────────────────────────────────────────
   물때 — 해도(海圖)에서 가져온 색
   잉크: 깊은 바다 / 곡선: 수로 청록 / 강조: 부표 노랑
   ───────────────────────────────────────────── */
:root {
    --paper: #E9EFF1;      /* 바탕 */
    --panel: #F7FAFB;      /* 카드 */
    --ink: #12303A;        /* 글자 */
    --muted: #5B727A;      /* 보조 글자 */
    --rule: #C9D5DA;       /* 테두리·눈금 */
    --tide: #1F7A8C;       /* 물 높이 곡선 */
    --water: rgba(31, 122, 140, 0.14);
    --night: #CBD6DC;      /* 밤 */
    --twilight: #DEE6EA;   /* 박명 */
    --buoy: #C98A0E;       /* 지금·다음 물때 강조 */
    --error: #A3402E;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #0D1B21;
        --panel: #13252C;
        --ink: #DCE8EB;
        --muted: #8DA4AB;
        --rule: #24404A;
        --tide: #62C3D4;
        --water: rgba(98, 195, 212, 0.16);
        --night: #08141A;
        --twilight: #0F2027;
        --buoy: #F2B640;
        --error: #E58A74;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: "IBM Plex Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    padding-bottom: env(safe-area-inset-bottom);
}

button, input { font: inherit; color: inherit; }

:focus-visible {
    outline: 2px solid var(--buoy);
    outline-offset: 2px;
}

.boot, .notice {
    color: var(--muted);
    margin: 0;
    padding: 12px 0;
}
.boot { padding: 48px 16px; text-align: center; }
.notice.error { color: var(--error); }

/* ── 날짜 이동 ── */
.datebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 48px 1fr 48px;
    align-items: center;
    max-width: 560px;
    margin: 0 auto;
    padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
    background: var(--paper);
}
.datebar > button {
    height: 48px;
    border: 0;
    background: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    border-radius: 10px;
}
.datebar .date-label {
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: inherit;
    line-height: 1.2;
    padding: 4px 0;
}
.date-label strong { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.date-label span { font-size: 13px; color: var(--muted); }

/* ── 카드 ── */
.cards {
    max-width: 560px;
    margin: 0 auto;
    padding: 4px 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: 16px;
    padding: 16px 16px 14px;
}

.card-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
}
.card-head h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
}
/* 물때 이름이 카드에서 가장 큰 글자 */
.card-head .multtae {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    color: var(--tide);
    letter-spacing: -0.02em;
    line-height: 1;
}
.card-head .lunar {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}
.card-head .remove {
    margin-left: auto;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 13px;
    padding: 4px 2px;
    cursor: pointer;
}

/* ── 물 높이 곡선 ── */
.tide-chart {
    display: block;
    width: 100%;
    height: auto;
    margin: 4px 0 10px;
}
.tide-chart .night { fill: var(--night); }
.tide-chart .twilight { fill: var(--twilight); }
.tide-chart .grid { stroke: var(--rule); stroke-width: 0.6; }
.tide-chart .hour { fill: var(--muted); font-size: 10px; }
.tide-chart .water { fill: var(--water); }
.tide-chart .curve { fill: none; stroke: var(--tide); stroke-width: 2.2; stroke-linejoin: round; }
.tide-chart .dot { stroke: var(--panel); stroke-width: 1.5; }
.tide-chart .dot.high { fill: var(--tide); }
.tide-chart .dot.low { fill: var(--muted); }
.tide-chart .now { stroke: var(--buoy); stroke-width: 1.4; stroke-dasharray: 3 3; }
.tide-chart .now-dot { fill: var(--buoy); stroke: var(--panel); stroke-width: 2; }

/* ── 바람 ── */
.wind { margin: -4px 0 10px; }
.wind-summary {
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 600;
}
.wind-chart { display: block; width: 100%; height: auto; }
.wind-chart .w path { stroke: none; }
.wind-chart .w text { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.wind-chart .calm path, .wind-chart .calm text { fill: var(--muted); }
.wind-chart .breezy path, .wind-chart .breezy text { fill: var(--ink); }
.wind-chart .strong path, .wind-chart .strong text { fill: var(--error); }
.wind-caption {
    margin: 2px 0 0;
    font-size: 11px;
    color: var(--muted);
}
.card > .wind-caption { margin: -4px 0 10px; }

/* ── 만조·간조 목록 ── */
.tides {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px 16px;
}
.tides li {
    display: flex;
    flex-direction: column;
    padding: 6px 0 6px 10px;
    border-left: 3px solid transparent;
    font-variant-numeric: tabular-nums;
}
.tides .meta {
    display: flex;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}
.tides li.high .kind { color: var(--tide); font-weight: 600; }
.tides time { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
/* 다음 물때: 부표 노랑 줄 */
.tides li.next { border-left-color: var(--buoy); }
.tides li.next time { color: var(--buoy); }
.tides .next-tag { color: var(--buoy); font-weight: 600; }

/* ── 일출·일몰 ── */
.sun {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px 16px;
    margin: 10px 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--rule);
    font-variant-numeric: tabular-nums;
}
.sun div { display: flex; gap: 8px; align-items: baseline; padding-left: 13px; }
.sun dt { font-size: 13px; color: var(--muted); }
.sun dd { margin: 0; font-weight: 600; }
.sun .soft dd { font-weight: 400; color: var(--muted); }

/* ── 포인트 추가 (이름 검색) ── */
.add { margin-top: 6px; }
.add label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}
.add input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--rule);
    border-radius: 10px;
    background: var(--panel);
    -webkit-appearance: none;
    appearance: none;
}
.add input::placeholder { color: var(--muted); }
.suggest {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.suggest button {
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--tide);
    border-radius: 20px;
    background: none;
    color: var(--tide);
    font-weight: 600;
    cursor: pointer;
}
.suggest button small { font-weight: 400; margin-left: 4px; opacity: 0.8; }
.suggest button:hover { background: var(--water); }
.find-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}
.near-btn {
    width: 100%;
    height: 44px;
    border: 1px dashed var(--tide);
    border-radius: 10px;
    background: none;
    color: var(--tide);
    font-weight: 600;
    cursor: pointer;
}
.near-btn:disabled { opacity: 0.6; cursor: default; }
.suggest button:disabled { opacity: 0.5; cursor: default; }
.add .notice { padding: 8px 0 0; font-size: 14px; }

/* ── 지도 화면 ── */
.map-sheet {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: var(--paper);
}
.map-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.map-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.map-close {
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--rule);
    border-radius: 10px;
    background: var(--panel);
    cursor: pointer;
}
.map-canvas {
    flex: 1 1 auto;
    min-height: 240px;
    background: var(--twilight);
}
.map-panel {
    flex: 0 0 auto;
    max-height: 58vh;
    overflow-y: auto;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--rule);
}
.map-panel .card { margin-top: 8px; }
/* PC처럼 넓은 화면에서도 카드는 폰 폭으로 */
.map-panel > * { max-width: 560px; margin-left: auto; margin-right: auto; }
.map-pick { margin: 0; font-weight: 600; }
.map-error { padding: 0 16px 10px; }
.map-add {
    margin-left: auto;
    height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: var(--ink);
    color: var(--paper);
    font-weight: 600;
    cursor: pointer;
}
.map-added { margin-left: auto; font-size: 13px; color: var(--muted); }
.leaflet-container { font-family: inherit; }

/* ── 데이터 출처 ── */
.sources {
    max-width: 560px;
    margin: 0 auto;
    padding: 8px 16px 32px;
    color: var(--muted);
    font-size: 12px;
}
.sources h3 { font-size: 12px; font-weight: 600; margin: 0 0 4px; }
.sources ul { margin: 0 0 6px; padding-left: 16px; }
.sources p { margin: 0; }

/* ── Blazor 오류 표시 ── */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--error);
    color: #fff;
    z-index: 100;
}
#blazor-error-ui a { color: #fff; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
