/* 지구 — 프리사이언스와 같은 무채색 판. 흐림(backdrop-filter)·알약 단추 쓰지 않음, 단추 모서리 8 */
:root {
  --bg: #050607;
  --panel: #111215;
  --panel-2: #17181c;
  --line: #24262b;
  --line-2: #33363c;
  --text: #ededef;
  --sub: #a2a4ab;
  --faint: #6a6c73;
  --accent: #f2f2f3;
  --q-shallow: #ff5a3c; --q-mid: #ffc23a; --q-deep: #4aa8ff;
  --div: #ff6b5b; --con: #5aa9ff; --tra: #7ee08a;
  --volc: #ff8a2a;
  --r: 12px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --pw: 340px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); overflow: hidden;
  font: 14px/1.55 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  letter-spacing: -0.01em; -webkit-font-smoothing: antialiased; touch-action: none;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

#globe { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; outline: none; }
#globe.drag { cursor: grabbing; }

/* 위 막대 */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: 60px; padding: 0 16px;
  display: flex; align-items: center; gap: 14px; pointer-events: none;
  background: linear-gradient(180deg, rgba(5, 6, 7, .92), rgba(5, 6, 7, 0));
}
.bar > * { pointer-events: auto; }
.home { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--text); }
.home:hover { background: var(--panel-2); }
.mark { width: 24px; height: 24px; }
.ttl { display: flex; align-items: baseline; gap: 9px; white-space: nowrap; }
.ttl b { font-size: 20px; font-weight: 750; letter-spacing: -0.03em; }
.ttl span { font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--faint); }
.modes { display: flex; gap: 4px; margin-left: 18px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.modes button { height: 32px; padding: 0 14px; border: 0; border-radius: 7px; background: none; color: var(--sub); cursor: pointer; font-size: 14px; white-space: nowrap; }
.modes button:hover { color: var(--text); }
.modes button[aria-selected="true"] { background: var(--accent); color: #0b0c0e; font-weight: 650; }
.clock { margin-left: auto; color: var(--sub); font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: right; line-height: 1.35; white-space: nowrap; }
.clock b { color: var(--text); font-weight: 600; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); cursor: pointer; transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--panel-2); border-color: var(--line-2); }
.layers-btn { display: none; }

/* 판 공통 */
.panel {
  position: fixed; z-index: 15; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; display: flex; flex-direction: column;
}
.sheet-head { display: none; }

/* 층 (왼쪽) */
.layers { left: 16px; top: 72px; width: 268px; max-height: calc(100% - 88px); }
.layers-in { overflow-y: auto; padding: 8px 0 10px; scrollbar-width: thin; }
.grp { padding: 6px 14px 2px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; color: var(--faint); }
.grp + .row { margin-top: 0; }
.row { display: flex; align-items: flex-start; gap: 11px; width: 100%; padding: 8px 14px; border: 0; background: none; text-align: left; cursor: pointer; }
.row:hover { background: var(--panel-2); }
.row .sw { flex: none; position: relative; width: 30px; height: 18px; margin-top: 2px; border-radius: 9px; background: var(--line-2); transition: background .2s; }
.row .sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #c8cad0; transition: transform .2s var(--ease), background .2s; }
.row[aria-pressed="true"] .sw { background: var(--accent); }
.row[aria-pressed="true"] .sw::after { transform: translateX(12px); background: #0b0c0e; }
.row .t { flex: 1; min-width: 0; }
.row .t b { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; }
.row .t small { display: block; margin-top: 1px; color: var(--faint); font-size: 12px; line-height: 1.4; }
.row .n { color: var(--faint); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.key { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.seg { display: flex; gap: 4px; padding: 2px 14px 8px 55px; flex-wrap: wrap; }
.seg button { height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: none; color: var(--sub); font-size: 12.5px; cursor: pointer; }
.seg button:hover { color: var(--text); border-color: var(--line-2); }
.seg button[aria-pressed="true"] { color: #0b0c0e; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.seg.wide { padding-left: 14px; }
.sep { height: 1px; margin: 6px 14px; background: var(--line); }

/* 정보 (오른쪽) */
.info { right: 16px; top: 72px; width: var(--pw); max-height: calc(100% - 88px); }
.info-in { overflow-y: auto; padding: 18px 18px 20px; scrollbar-width: thin; }
.grip { display: none; }
.info h2 { margin: 0; font-size: 21px; line-height: 1.3; font-weight: 750; letter-spacing: -0.03em; }
.info h3 { margin: 22px 0 8px; font-size: 12px; font-weight: 700; color: var(--faint); letter-spacing: .04em; }
.info p { margin: 8px 0 0; color: var(--sub); }
.info .kicker { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--sub); font-size: 12.5px; }
.info .back { display: inline-flex; align-items: center; gap: 2px; height: 28px; margin: -4px 0 10px -6px; padding: 0 8px 0 2px; border: 0; border-radius: 7px; background: none; color: var(--sub); cursor: pointer; font-size: 13px; }
.info .back:hover { background: var(--panel-2); color: var(--text); }
.big { display: flex; align-items: baseline; gap: 10px; margin-top: 4px; }
.big b { font-size: 40px; line-height: 1; font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.big span { color: var(--sub); }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 14px 0 0; font-size: 13.5px; }
dl.kv dt { color: var(--faint); white-space: nowrap; }
dl.kv dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; }
.stats3 div { padding: 10px 12px; min-width: 0; }
.stats3 div + div { border-left: 1px solid var(--line); }
.stats3 b { display: block; font-size: 19px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stats3 span { display: block; color: var(--faint); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list { margin: 0; padding: 0; list-style: none; }
.list button { display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 6px; margin: 0 -6px; width: calc(100% + 12px); border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.list button:hover { background: var(--panel-2); }
.mag { flex: none; display: grid; place-items: center; width: 40px; height: 30px; border-radius: 7px; font-weight: 750; font-size: 14.5px; color: #0b0c0e; font-variant-numeric: tabular-nums; }
.list .tx { flex: 1; min-width: 0; }
.list .tx b { display: block; font-weight: 550; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .tx small { color: var(--faint); font-size: 12px; }
.note { margin-top: 14px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--sub); font-size: 13px; line-height: 1.6; }
.note b { color: var(--text); font-weight: 600; }
.src { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; line-height: 1.6; }
.src a { color: var(--sub); text-underline-offset: 2px; }
.ext { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--text); font-size: 13px; }
.ext:hover { background: var(--panel-2); border-color: var(--line-2); }
.ext .ic { width: 15px; height: 15px; }
.orig { color: var(--faint); font-size: 12.5px; }
.summary-en { margin-top: 8px; color: var(--sub); font-size: 13px; line-height: 1.65; }
.summary { margin: 8px 0 0; color: var(--text); font-size: 13.5px; line-height: 1.75; }
.orig-en { margin-top: 10px; }
.orig-en summary { cursor: pointer; color: var(--faint); font-size: 12.5px; }
.orig-en summary:hover { color: var(--sub); }
/* 지구과학 백과 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: none; color: var(--sub); font: inherit; font-size: 13px; cursor: pointer; }
.chips button:hover { color: var(--text); border-color: var(--line-2); background: var(--panel-2); }
.chips .g { flex-basis: 100%; margin: 6px 0 0; color: var(--faint); font-size: 12px; }
.chips .g:first-child { margin-top: 0; }
.article p { margin: 12px 0 0; color: var(--text); font-size: 14px; line-height: 1.78; }
.article p b { font-weight: 650; }
.go-btn { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; height: 40px; margin-top: 16px; border: 0; border-radius: 8px; background: var(--text); color: var(--bg); font: inherit; font-size: 14px; font-weight: 650; cursor: pointer; }
.go-btn:hover { opacity: .9; }
.go-btn .ic { width: 16px; height: 16px; }
.stats3.n2 { grid-template-columns: repeat(2, 1fr); }
.stats3.n1 { grid-template-columns: 1fr; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--sub); font-size: 12px; font-weight: 600; }
.badge.warn { border-color: #6b4a14; color: #ffc23a; }

/* 차트 (기후 변화) */
.chart { margin-top: 10px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .ax { stroke: var(--line-2); stroke-width: 1; }
.chart .gl { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--faint); font-size: 10.5px; font-family: inherit; }
.chart .cap { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.chart .cap b { font-size: 14px; }
.chart .cap span { color: var(--faint); font-size: 12px; }

/* 범례 */
.legend {
  position: fixed; z-index: 14; left: 50%; transform: translateX(-50%); bottom: 18px;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: 12px; color: var(--sub);
}
.legend .bar-c { width: 220px; height: 8px; border-radius: 4px; }
.legend .lab { display: flex; justify-content: space-between; width: 220px; margin-top: 3px; font-variant-numeric: tabular-nums; font-size: 11px; color: var(--faint); }
.legend .keys { display: flex; gap: 12px; flex-wrap: wrap; }
.legend .keys span { display: inline-flex; align-items: center; gap: 6px; }

/* 옛 지구 시간 막대 */
.paleo {
  position: fixed; z-index: 16; left: 50%; transform: translateX(-50%); bottom: 18px; width: min(720px, calc(100% - 2 * 300px));
  padding: 12px 16px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
}
.paleo-read { display: flex; align-items: center; gap: 12px; }
.paleo-read b { display: block; font-size: 18px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.paleo-read span { display: block; color: var(--sub); font-size: 12.5px; }
.play { width: 40px; height: 40px; }
.paleo-track { position: relative; margin-top: 10px; }
.eras { display: flex; height: 8px; border-radius: 4px; overflow: hidden; }
.eras i { display: block; height: 100%; }
.paleo input[type=range] { width: 100%; margin: 4px 0 0; accent-color: var(--accent); height: 24px; cursor: pointer; direction: rtl; }
.ticks { display: flex; justify-content: space-between; color: var(--faint); font-size: 11px; }

/* 오른쪽 아래 도구 */
.tools { position: fixed; z-index: 14; right: calc(var(--pw) + 32px); bottom: 18px; display: flex; flex-direction: column; gap: 6px; }

/* 말풍선 */
.tip {
  position: fixed; z-index: 30; pointer-events: none; padding: 6px 9px; max-width: 260px;
  background: #0b0c0e; border: 1px solid var(--line-2); border-radius: 8px; font-size: 12.5px; color: var(--text); line-height: 1.45;
  transform: translate(-50%, calc(-100% - 12px));
}
.tip small { color: var(--sub); }
.toast {
  position: fixed; z-index: 40; left: 50%; top: 70px; transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
  padding: 9px 14px; background: #0b0c0e; border: 1px solid var(--line-2); border-radius: 10px; font-size: 13px; transition: opacity .3s, transform .3s var(--ease);
  max-width: calc(100% - 32px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; cursor: pointer; }
.loading { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); color: var(--sub); font-size: 14px; transition: opacity .5s; }
.loading span { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .9s linear infinite; }
.loading.done { opacity: 0; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 넓지 않은 화면: 층 판을 접는다 */
@media (max-width: 1180px) {
  .layers { display: none; }
  .layers.open { display: flex; }
  .layers-btn { display: inline-grid; }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 4px 16px; }
  .sheet-head b { font-size: 15px; }
  .paleo { width: min(640px, calc(100% - var(--pw) - 64px)); left: calc((100% - var(--pw) - 16px) / 2); }
  .legend { left: calc((100% - var(--pw) - 16px) / 2); }
}

/* 폰·세로 화면: 정보는 아래 판, 층은 위에서 덮는 판 */
@media (max-width: 760px) {
  :root { --pw: 0px; }
  .bar { height: auto; padding: 8px 10px 0; flex-wrap: wrap; gap: 8px 10px; background: linear-gradient(180deg, rgba(5, 6, 7, .95) 60%, rgba(5, 6, 7, 0)); padding-bottom: 14px; }
  .ttl span { display: none; }
  .clock { font-size: 11.5px; }
  .modes { order: 5; margin: 0; width: 100%; }
  .modes button { flex: 1; height: 34px; padding: 0 6px; }
  .layers { left: 8px; right: 8px; top: 8px; width: auto; max-height: calc(100% - 16px); z-index: 25; }
  .info {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; border-radius: 16px 16px 0 0; border-bottom: 0;
    max-height: 72%; height: var(--sheet-h, 168px); transition: height .32s var(--ease);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .info.dragging { transition: none; }
  .grip { display: block; flex: none; height: 22px; cursor: grab; touch-action: none; position: relative; }
  .grip::after { content: ''; position: absolute; left: 50%; top: 8px; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--line-2); }
  .info-in { padding: 0 16px 18px; touch-action: pan-y; }
  .info h2 { font-size: 19px; }
  .big b { font-size: 34px; }
  .tools { right: 10px; bottom: calc(var(--sheet-h, 168px) + 10px); flex-direction: row; transition: bottom .32s var(--ease); }
  .paleo { left: 8px; right: 8px; transform: none; width: auto; bottom: calc(var(--sheet-h, 168px) + 8px); transition: bottom .32s var(--ease); }
  .legend { left: 8px; right: 96px; transform: none; width: auto; bottom: calc(var(--sheet-h, 168px) + 10px); justify-content: center; padding: 6px 9px; font-size: 11px; transition: bottom .32s var(--ease); }
  .legend .keys { gap: 4px 10px; justify-content: center; }
  .legend .bar-c, .legend .lab { width: 170px; }
  .paleo { padding: 10px 12px 8px; }
  .toast { top: 108px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* 폰: 머리의 로고·분야 글자는 보이는 크기가 작다 — 누르는 자리만 넓힘 */
@media (pointer: coarse) {
  .fsb-logo, .fsb-field { position: relative; }
  .fsb-logo::after { content: ''; position: absolute; inset: -8px -8px -3px; }
  .fsb-field::after { content: ''; position: absolute; inset: -3px -8px -8px; }
}
