:root {
  --bg: #0b1220; --panel: rgba(14, 22, 38, 0.86); --line: rgba(255, 255, 255, 0.14);
  --text: #e8eef8; --muted: #9fb0c8; --accent: #6cc3ff;
  --real: #2f9e6b; --est: #c58a16; --fx: #b0569b;
  --font: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }
#globe { position: absolute; inset: 0; }
/* 出典（Cesium の表示）: スケールの上に、読める大きさで常に出す */
.cesium-viewer-bottom { bottom: 70px !important; left: 10px !important; right: 10px !important; padding: 0 !important; }
.cesium-widget-credits { display: block !important; font-size: 10.5px !important; line-height: 1.45; color: #e8eef8 !important; background: rgba(14, 22, 38, 0.72); padding: 3px 8px; border-radius: 6px; max-height: 6.2em; overflow: auto; }
.cesium-widget-credits a { color: #9fd3ff !important; }
.cesium-credit-logoContainer { display: inline-block !important; margin-right: 6px; }
#search-list li.src { font-size: 11px; cursor: default; }
#search-list li.src a, #point a { color: var(--accent); }

/* 上のバー */
#top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 8px; align-items: center; pointer-events: none; }
#top > * { pointer-events: auto; }
.title { font-weight: 700; letter-spacing: 0.05em; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; white-space: nowrap; }
.icon { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 18px; cursor: pointer; flex: none; }
.icon:hover { border-color: var(--accent); }
#search { position: relative; flex: 1; max-width: 420px; }
#search-q { width: 100%; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; }
#search-q:focus { outline: none; border-color: var(--accent); }
#search-list { position: absolute; top: 42px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; max-height: 50vh; overflow: auto; }
#search-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; }
#search-list li:hover { background: rgba(108, 195, 255, 0.15); }
#search-list li.muted, .muted { color: var(--muted); cursor: default; }

/* 層のパネル */
#layers { position: absolute; top: 58px; left: 10px; width: 260px; max-height: calc(100% - 140px); overflow: auto; padding: 4px 12px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: none; }
body.layers-open #layers { display: block; }
#layers h3 { font-size: 12px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 6px; padding: 4px 0; cursor: pointer; flex-wrap: wrap; }
.row small { color: var(--muted); font-size: 11px; }
.row.slider input { flex: 1; min-width: 80px; }
.soon { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; }
.tag { display: inline-block; font-size: 10px; line-height: 1; padding: 3px 5px; border-radius: 4px; color: #fff; font-weight: 600; vertical-align: middle; }
.tag-real { background: var(--real); } .tag-est { background: var(--est); } .tag-fx { background: var(--fx); }

/* クリックした地点 */
#point { position: absolute; right: 10px; top: 58px; width: 280px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; line-height: 1.7; }
#point .ll { font-size: 12px; color: var(--muted); }
.x { position: absolute; top: 4px; right: 6px; border: none; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }

/* スケール */
#scale { position: absolute; left: 10px; right: 10px; bottom: 10px; padding: 6px 12px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.scale-now { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.scale-now span { color: var(--muted); }
.scale-now b { font-size: 16px; }
.scale-now .what span { color: var(--text); }
.scale-now .pow { margin-left: auto; font-variant-numeric: tabular-nums; }
#ruler-bar { position: relative; height: 18px; margin-top: 4px; border-radius: 4px; overflow: hidden; background: rgba(255, 255, 255, 0.04); }
.band { position: absolute; top: 0; bottom: 0; border-right: 1px solid var(--line); font-size: 10px; color: var(--muted); opacity: 0.45; overflow: hidden; white-space: nowrap; display: flex; align-items: center; justify-content: center; }
.band .ls { display: none; }
.band.ready { opacity: 1; background: rgba(108, 195, 255, 0.18); color: var(--text); }
#ruler-mark { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: #ffd25e; box-shadow: 0 0 6px #ffd25e; }

/* このアプリについて */
.modal { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal[hidden] { display: none; }
.card { position: relative; max-width: 620px; max-height: 100%; overflow: auto; padding: 16px 20px; background: #111a2c; border: 1px solid var(--line); border-radius: 14px; line-height: 1.7; }
.card h2 { margin: 0 0 6px; } .card h3 { font-size: 14px; margin: 14px 0 4px; color: var(--accent); }
.card ul { margin: 0; padding-left: 20px; } .small { font-size: 12px; }
#fatal { position: absolute; inset: 0; z-index: 20; background: var(--bg); line-height: 1.9; display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center; }
#fatal[hidden] { display: none; }
/* 読み込み中（Cesium.js と最初の地形・写真のタイルが来るまで。main.js が消す） */
#loading { position: absolute; inset: 0; z-index: 19; background: var(--bg); display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; color: var(--muted); font-size: 15px; transition: opacity .5s; }
#loading.done { opacity: 0; pointer-events: none; }
#loading .spin { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: gvspin 1s linear infinite; }
@keyframes gvspin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  #top { left: 8px; right: 8px; }
  .title { display: none; }
  #layers { left: 8px; right: 8px; width: auto; }
  #point { left: 8px; right: 8px; width: auto; top: 54px; }
  .cesium-viewer-bottom { left: 8px !important; right: 8px !important; bottom: 72px !important; }
  .cesium-widget-credits { max-height: 4.4em; font-size: 10px !important; }
  #scale { left: 8px; right: 8px; bottom: 8px; }
  .band span { display: none; }
}

/* 建物（v002） */
#layers h3 small { font-weight: 400; }
.status { font-size: 11px; color: var(--muted); min-height: 1em; padding: 2px 0 0 22px; }
#point .bldg { border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 6px; padding-right: 16px; }
#point .small { font-size: 11px; }

/* 地下（v004） */
.spots { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 2px; }
.spots button { font: inherit; font-size: 12px; color: var(--text); background: rgba(108, 195, 255, 0.12); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; cursor: pointer; }
.spots button:hover { border-color: var(--accent); }

/* 宇宙（v007） */
#space { position: absolute; inset: 0; width: 100%; height: 100%; display: none; background: #000; touch-action: none; opacity: 0; }
#space-labels { position: absolute; inset: 0; pointer-events: none; display: none; overflow: hidden; }
#space-labels div { position: absolute; transform: translate(10px, -50%); font-size: 12px; color: #dfe8f5; text-shadow: 0 0 3px #000, 0 0 6px #000; white-space: nowrap; }
#space-hint { position: absolute; left: 50%; top: 58px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 6px 12px; font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; display: none; text-align: center; }
body.in-space #space, body.in-space #space-labels, body.in-space #space-hint { display: block; }
/* 地図は重ね終わってから隠す（space-solid）。パネルなどは宇宙に入ったらすぐ隠す */
body.space-solid #globe, body.in-space #layers, body.in-space #point, body.in-space #search, body.in-space #btn-layers { visibility: hidden; }
#ruler-bar .band.ready { cursor: pointer; }
#space-credit { position: absolute; left: 10px; right: 10px; bottom: 70px; font-size: 10.5px; line-height: 1.5; color: #c9d4e4; background: rgba(14, 22, 38, 0.72); padding: 3px 8px; border-radius: 6px; display: none; }
#space-credit a { color: #9fd3ff; }
body.in-space #space-credit { display: block; }
@media (max-width: 640px) { #space-credit { bottom: 72px; font-size: 10px; max-height: 4.4em; overflow: auto; } }

/* ミクロ（v009） */
#micro { position: absolute; inset: 0; width: 100%; height: 100%; display: none; background: #07090f; touch-action: none; opacity: 0; }
#micro-info { position: absolute; left: 50%; top: 58px; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); padding: 8px 12px; font-size: 13px; line-height: 1.7; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; display: none; }
#micro-info small { color: var(--muted); font-size: 11px; }
.micro-links { margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.micro-links a { font-size: 12px; color: var(--text); background: rgba(108, 195, 255, 0.15); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; text-decoration: none; }
body.in-micro #micro, body.in-micro #micro-info { display: block; }
body.micro-solid #globe, body.in-micro #layers, body.in-micro #point, body.in-micro #search, body.in-micro #btn-layers { visibility: hidden; }

/* ミクロの道（v010） */
.micro-paths { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.micro-paths small { margin-right: 4px; }
.micro-paths button { font: inherit; font-size: 12px; color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; cursor: pointer; }
.micro-paths button.on { background: rgba(108, 195, 255, 0.25); border-color: var(--accent); }
.band.gap { background: repeating-linear-gradient(90deg, rgba(255,255,255,0.08) 0 3px, transparent 3px 6px); }

/* 地球をちぎる（v011） */
#btn-tear { position: absolute; right: 10px; bottom: 112px; display: none; font: inherit; font-size: 14px; font-weight: 700; color: #fff; background: rgba(200, 90, 40, 0.85); border: 1px solid rgba(255, 200, 150, 0.5); border-radius: 12px; padding: 8px 14px; cursor: pointer; }
#btn-tear:hover { background: rgba(225, 105, 45, 0.95); }
body.in-space.earth-near #btn-tear { display: block; }
#tear { position: absolute; inset: 0; width: 100%; height: 100%; display: none; background: #000; touch-action: none; z-index: 3; }
#tear-panel { position: absolute; top: 58px; left: 10px; width: 230px; max-height: calc(100% - 120px); overflow: auto; padding: 4px 10px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: none; z-index: 4; }
#tear-panel .th { font-size: 11px; color: var(--muted); margin: 8px 0 3px; }
.tseg { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tseg button { font: inherit; font-size: 12px; color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; cursor: pointer; }
.tseg button.on { background: rgba(108, 195, 255, 0.25); border-color: var(--accent); }
.tleg { margin-top: 8px; font-size: 11px; color: var(--muted); line-height: 1.6; }
.tleg span { display: block; height: 8px; border-radius: 4px; margin-bottom: 2px; }
.tleg i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin: 0 2px 0 4px; }
#tear-info { position: absolute; top: 58px; right: 10px; width: min(330px, calc(100% - 270px)); padding: 8px 12px; font-size: 13px; line-height: 1.65; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: none; z-index: 4; }
#tear-info table { margin-top: 6px; border-collapse: collapse; width: 100%; font-size: 12px; }
#tear-info th { text-align: left; font-weight: 400; color: var(--muted); padding: 1px 8px 1px 0; white-space: nowrap; }
#tear-info td { font-variant-numeric: tabular-nums; }
#tear-pop { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(0.6); font-size: 44px; font-weight: 900; color: #ffd27a; text-shadow: 0 0 8px #000, 0 2px 0 #7a3a10; opacity: 0; pointer-events: none; z-index: 5; }
#tear-pop.show { animation: tearpop 1.4s ease-out; }
@keyframes tearpop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }
@media (prefers-reduced-motion: reduce) { #tear-pop.show { animation-duration: 2.2s; } }
#tear-credit { position: absolute; left: 10px; right: 10px; bottom: 10px; font-size: 10.5px; line-height: 1.5; color: #c9d4e4; background: rgba(14, 22, 38, 0.72); padding: 3px 8px; border-radius: 6px; display: none; z-index: 4; }
body.in-tear #tear, body.in-tear #tear-panel, body.in-tear #tear-info, body.in-tear #tear-credit { display: block; }
body.in-tear #scale, body.in-tear #btn-tear, body.in-tear #space-hint, body.in-tear #space-labels, body.in-tear #space-credit, body.in-tear #search, body.in-tear #btn-layers { display: none !important; }
body.in-tear #top { z-index: 5; }
@media (max-width: 640px) {
  #btn-tear { bottom: 118px; right: 8px; }
  #tear-panel { left: 8px; right: 8px; width: auto; top: auto; bottom: 64px; max-height: 32%; padding-top: 0; }
  #tear-info { left: 8px; right: 8px; width: auto; top: 54px; font-size: 12px; }
  #tear-credit { left: 8px; right: 8px; bottom: 8px; font-size: 10px; max-height: 4.4em; overflow: auto; }
}
#tear-info .tw { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); font-size: 12px; }
/* language (I18N.md): hide the other language; JP / EN switch in the top bar */
:root[lang=en] [lang=ja], :root:not([lang=en]) [lang=en] { display: none !important; }
.langsw { flex: none; display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.langsw button { border: 0; background: none; color: inherit; opacity: 0.55; height: 36px; padding: 0 9px; font: inherit; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; cursor: pointer; }
.langsw button[aria-pressed="true"] { opacity: 1; background: rgba(255,255,255,0.1); }

/* v013（2026-10-20）: パネルをシンプルに・スマホは下から出るパネル・出典は1行・はじめの案内 */
#layers { z-index: 2; }
#layers .row > span { flex: none; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 0 4px; }
.seg button, #quick button { font: inherit; font-size: 12.5px; color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; min-height: 32px; cursor: pointer; }
.seg button.on { background: rgba(108, 195, 255, 0.25); border-color: var(--accent); }
.seg button:hover, #quick button:hover { border-color: var(--accent); }
#quick button { background: rgba(108, 195, 255, 0.12); }
#layers details { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 4px; }
#layers summary { cursor: pointer; font-size: 12.5px; color: var(--muted); padding: 6px 0; }
#layers summary:hover { color: var(--text); }
#layers .sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
#layers [hidden] { display: none !important; }
#time-box h3 b { color: var(--text); font-weight: 600; margin-left: 4px; }
.legend { font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); margin: 10px 0 0; padding-top: 8px; line-height: 1.9; }
.row input[type=checkbox] { width: 16px; height: 16px; margin: 0; }
/* 出典: ふだんは1行、押すと全部（地図・宇宙・ちぎる） */
.cesium-credit-logoContainer { display: none !important; }    /* Cesium ion は使っていない（トークンなし）のでロゴは出さない */
.cesium-widget-credits, #space-credit, #tear-credit { cursor: pointer; white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis; max-height: none !important; }
.cesium-widget-credits * { white-space: nowrap; }
body.credits-open .cesium-widget-credits, body.credits-open #space-credit, body.credits-open #tear-credit { white-space: normal; max-height: 40vh !important; overflow: auto !important; }
body.credits-open .cesium-widget-credits * { white-space: normal; }
.cesium-widget-credits::before, #space-credit::before, #tear-credit::before { content: '▸ '; color: var(--accent); }
body.credits-open .cesium-widget-credits::before, body.credits-open #space-credit::before, body.credits-open #tear-credit::before { content: '▾ '; }
.cesium-viewer-bottom { bottom: 72px !important; }
#space-credit { bottom: 72px; }
/* はじめの案内（数秒で消える）と、宇宙の案内も同じように消す */
#hint { position: absolute; left: 50%; bottom: 104px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); padding: 8px 14px; font-size: 13px; line-height: 1.6; text-align: center; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; z-index: 3; pointer-events: none; transition: opacity .8s; }
#hint.gone, #space-hint.gone { opacity: 0; pointer-events: none; }
#space-hint { transition: opacity .8s; }
body.in-space #hint, body.in-micro #hint { opacity: 0; }
@media (max-width: 640px) {
  /* スマホ: パネルは下から（地図は上に見えたまま）。押せる大きさに */
  #layers { top: auto; bottom: 72px; max-height: 52vh; border-radius: 14px; padding-bottom: 14px; }
  .cesium-viewer-bottom, #space-credit { bottom: 70px !important; }
  .cesium-widget-credits, #space-credit { font-size: 10px !important; }
  #layers .row { padding: 6px 0; }
  .seg button, #quick button { min-height: 36px; font-size: 13px; }
  #hint { bottom: 100px; font-size: 12.5px; }
  .band .lf { display: none; } .band .ls { display: inline; font-size: 9px; }
  #ruler-bar { height: 22px; }
}
#base-seg { flex-wrap: nowrap; }
#base-seg button { flex: 1; padding: 0 4px; }
@media (min-width: 641px) { #layers { max-height: calc(100% - 152px); } }
body.layers-open #hint { opacity: 0; }
@media (max-width: 640px) {
  #layers { bottom: 94px; max-height: 50vh; }
  body.layers-open .cesium-viewer-bottom { z-index: 3; }
}
/* v013d: スマホの下パネルのつまみ（いのちの系統樹と同じ。押すと広げる・縮める、ドラッグで高さ） */
.grip { display: none; }
@media (max-width: 640px) {
  .grip { position: sticky; top: 0; z-index: 2; display: flex; justify-content: center; align-items: center; height: 26px; margin: 0 -12px 2px; background: rgba(14, 22, 38, 0.97); cursor: pointer; touch-action: none; border-radius: 14px 14px 0 0; }
  .grip .bar { width: 44px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.35); }
  .grip:hover .bar, .grip:focus-visible .bar { background: var(--accent); }
  #layers, #tear-panel { max-height: none; padding-top: 0; transition: height .25s ease; }
  #layers.dragging, #tear-panel.dragging { transition: none; }
  #tear-panel .grip { margin: 0 -10px 2px; }
}
