:root {
  --bg: #030810;
  --panel: rgba(7, 18, 31, 0.76);
  --panel-strong: rgba(7, 18, 31, 0.93);
  --line: rgba(135, 189, 231, 0.16);
  --line-strong: rgba(135, 189, 231, 0.32);
  --text: #edf8ff;
  --muted: #7d9cb2;
  --cyan: #32d6ff;
  --blue: #468cff;
  --green: #49efb2;
  --yellow: #ffd45a;
  --orange: #ff9148;
  --red: #ff4f6d;
  --purple: #b888ff;
  --shadow: 0 16px 70px rgba(0, 0, 0, 0.38);
  --topbar-h: 74px;
  --bottom-h: 46px;
  --left-w: 320px;
  --right-w: 360px;
}

* { box-sizing: border-box; }
html, body.world-pulse-page { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body.world-pulse-page {
  background:
    radial-gradient(circle at 50% 45%, rgba(25, 77, 119, 0.16), transparent 33%),
    linear-gradient(180deg, #07101c 0%, var(--bg) 72%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.app-shell {
  width: 100vw;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--left-w) minmax(360px, 1fr) var(--right-w);
  grid-template-rows: var(--topbar-h) 1fr var(--bottom-h);
  background-image:
    linear-gradient(rgba(87, 139, 176, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(87, 139, 176, 0.025) 1px, transparent 1px);
  background-size: 32px 32px;
}

.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(115%);
  -webkit-backdrop-filter: blur(18px) saturate(115%);
}

.topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 22px;
  border-width: 0 0 1px;
}
.brand, .topbar-center, .topbar-actions { display: flex; align-items: center; }
.brand { gap: 12px; color: inherit; text-decoration: none; }
.brand:hover { color: inherit; }
.brand-mark { width: 35px; height: 35px; position: relative; display: grid; place-items: center; }
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; inset: 2px; border: 1px solid rgba(50,214,255,.45); border-radius: 50%;
}
.brand-mark::after { inset: 8px; border-color: rgba(50,214,255,.8); }
.brand-mark span { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.brand-mark span:nth-child(1) { transform: translate(0, -13px); }
.brand-mark span:nth-child(2) { transform: translate(12px, 8px); }
.brand-mark span:nth-child(3) { transform: translate(-12px, 8px); }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: .18em; font-weight: 800; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 9px; letter-spacing: .19em; }
.topbar-center { gap: 13px; color: #a9c7db; font-size: 12px; letter-spacing: .07em; }
.live-badge { display: flex; align-items: center; gap: 7px; color: var(--green); font-size: 11px; font-weight: 800; }
.live-badge i, .ticker-label i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(73,239,178,.65); animation: pulse 1.8s infinite; }
.updated-at { padding-left: 13px; border-left: 1px solid var(--line-strong); color: var(--muted); }
.topbar-actions { justify-self: end; gap: 8px; }
.icon-button {
  height: 36px; min-width: 68px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); background: rgba(20,45,64,.44); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 7px;
}
.icon-button:hover { border-color: rgba(50,214,255,.5); background: rgba(25,63,86,.6); }
.icon-button[aria-pressed="false"] { color: var(--muted); }
.button-icon { color: var(--cyan); font-size: 16px; }
.button-label { font-size: 9px; font-weight: 800; letter-spacing: .15em; }

.left-panel, .right-panel { grid-row: 2; z-index: 11; overflow: hidden; border-top: 0; border-bottom: 0; }
.left-panel { grid-column: 1; border-left: 0; }
.right-panel { grid-column: 3; border-right: 0; display: flex; flex-direction: column; }
.panel-section { padding: 18px 18px 16px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.section-heading.compact { margin-bottom: 12px; }
.eyebrow { display: block; color: var(--cyan); font-size: 8px; font-weight: 800; letter-spacing: .2em; margin-bottom: 4px; }
.section-heading h2 { margin: 0; font-size: 14px; letter-spacing: .04em; }
.signal-chip { border: 1px solid rgba(255,212,90,.34); background: rgba(255,212,90,.08); color: var(--yellow); padding: 5px 8px; border-radius: 999px; font-size: 9px; white-space: nowrap; }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.metric-card { min-height: 78px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(17,40,57,.35); position: relative; overflow: hidden; }
.metric-card::after { content:""; position:absolute; inset:auto 0 0; height:2px; background: linear-gradient(90deg, transparent, rgba(50,214,255,.6), transparent); }
.metric-card span { display: block; font-size: 10px; color: #a2bdcf; }
.metric-card strong { display: block; margin-top: 5px; font-size: 23px; line-height: 1; font-variant-numeric: tabular-nums; }
.metric-card small { display: block; margin-top: 7px; color: #57768b; font-size: 8px; text-transform: uppercase; letter-spacing: .1em; }
.text-button { padding: 0; border: 0; background: none; color: var(--muted); font-size: 10px; cursor: pointer; }
.text-button:hover { color: var(--cyan); }
.layer-filters { display: grid; gap: 7px; }
.layer-filter { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 9px; padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: rgba(14,33,48,.36); cursor: pointer; transition: .2s ease; }
.layer-filter:hover { transform: translateX(2px); border-color: var(--line-strong); }
.layer-filter.off { opacity: .48; filter: saturate(.3); }
.layer-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; font-size: 13px; background: color-mix(in srgb, var(--layer-color) 14%, transparent); color: var(--layer-color); }
.layer-copy strong { display: block; font-size: 11px; font-weight: 700; }
.layer-copy span { color: var(--muted); font-size: 8px; }
.layer-count { min-width: 31px; padding: 3px 6px; border-radius: 999px; text-align: center; font-size: 9px; background: rgba(255,255,255,.045); color: #b8d0df; }
.segmented-control { display: grid; grid-template-columns: repeat(4, 1fr); padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: rgba(0,0,0,.16); }
.segmented-control button { border: 0; border-radius: 5px; padding: 7px 4px; background: transparent; color: var(--muted); font-size: 9px; font-weight: 800; cursor: pointer; }
.segmented-control button.active { color: #031019; background: var(--cyan); box-shadow: 0 0 18px rgba(50,214,255,.24); }
.source-health { display: grid; gap: 8px; }
.source-row { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 8px; font-size: 9px; color: #b4cbd9; }
.source-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.source-row.online .source-dot { background: var(--green); box-shadow: 0 0 7px rgba(73,239,178,.7); }
.source-row.demo .source-dot { background: var(--yellow); }
.source-row.error .source-dot { background: var(--red); }
.source-row span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

.globe-stage { grid-column: 2; grid-row: 2; min-width: 0; position: relative; overflow: hidden; }
#globeCanvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#globeCanvas:active { cursor: grabbing; }
.globe-vignette { pointer-events:none; position:absolute; inset:0; box-shadow: inset 0 0 130px 40px rgba(2,7,12,.84); }
.scanline { pointer-events:none; position:absolute; inset:0; opacity:.22; background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(136,199,238,.035) 4px); mix-blend-mode: screen; }
.globe-label { position: absolute; top: 18px; left: 20px; z-index: 5; }
.globe-label span { display: block; color: var(--cyan); font-size: 8px; letter-spacing: .2em; font-weight: 800; }
.globe-label strong { display: block; margin-top: 5px; color: rgba(187,213,228,.58); font-size: 9px; font-weight: 500; }
.zoom-controls { position: absolute; right: 18px; top: 18px; z-index: 5; display: grid; border-radius: 9px; overflow: hidden; }
.zoom-controls button { width: 34px; height: 34px; border: 0; border-bottom: 1px solid var(--line); background: rgba(8,25,38,.68); color: #b7d0df; cursor: pointer; }
.zoom-controls button:last-child { border-bottom: 0; }
.zoom-controls button:hover { color: var(--cyan); background: rgba(25,60,82,.76); }
.hover-tooltip { position: absolute; z-index: 30; max-width: 270px; pointer-events: none; transform: translate(12px, 12px); padding: 9px 11px; border-radius: 7px; border: 1px solid var(--line-strong); background: rgba(2,12,21,.93); box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 10px; }
.hover-tooltip strong { display: block; margin-bottom: 4px; font-size: 11px; }
.hover-tooltip span { color: var(--muted); }
.space-weather { position: absolute; left: 18px; bottom: 18px; z-index: 5; width: 210px; padding: 10px; border-radius: 9px; display: grid; grid-template-columns: 34px 1fr; gap: 4px 9px; align-items: center; }
.space-weather-icon { grid-row: 1 / 3; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--yellow); background: rgba(255,212,90,.1); box-shadow: inset 0 0 13px rgba(255,212,90,.17); }
.space-weather span { display:block; color: var(--muted); font-size: 7px; letter-spacing:.14em; }
.space-weather strong { font-size: 14px; }
.space-weather small { grid-column: 1 / -1; color: var(--muted); font-size: 8px; }
.kp-scale { height: 4px; border-radius:999px; background: linear-gradient(90deg, var(--green), var(--yellow), var(--orange), var(--red)); overflow:hidden; }
.kp-scale i { display:block; height:100%; width:0%; background:#fff; opacity:.8; box-shadow:0 0 8px #fff; transition: width .45s ease; }
.globe-counter { position:absolute; right:18px; bottom:18px; z-index:5; width:92px; padding:9px; border-radius:8px; text-align:center; }
.globe-counter span, .globe-counter small { display:block; font-size:7px; color:var(--muted); letter-spacing:.16em; }
.globe-counter strong { display:block; font-size:22px; margin:3px 0; }

.feed-header { flex: 0 0 auto; }
.feed-count { min-width: 34px; height: 28px; border-radius: 6px; display: grid; place-items: center; background: rgba(50,214,255,.09); border: 1px solid rgba(50,214,255,.19); color: var(--cyan); font-size: 11px; }
.search-box { height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: rgba(0,0,0,.16); }
.search-box span { color: var(--cyan); font-size: 16px; }
.search-box input { width:100%; border:0; outline:0; background:transparent; color:var(--text); font-size:10px; }
.search-box input::placeholder { color:#527187; }
.sort-row { display:flex; gap:7px; margin-top:10px; }
.sort-row button { flex:1; padding:6px 4px; border-radius:5px; border:1px solid var(--line); background:transparent; color:var(--muted); font-size:8px; cursor:pointer; }
.sort-row button.active { color:var(--cyan); border-color:rgba(50,214,255,.35); background:rgba(50,214,255,.07); }
.event-list-wrap { min-height:0; overflow:auto; scrollbar-width:thin; scrollbar-color:rgba(90,145,180,.25) transparent; }
.event-list { padding: 8px 10px 18px; }
.event-card { position:relative; display:grid; grid-template-columns:34px 1fr; gap:9px; padding:11px 9px; border-bottom:1px solid var(--line); cursor:pointer; transition:.18s ease; }
.event-card:hover, .event-card:focus-visible { background:rgba(40,87,112,.13); }
.event-card.active { background:linear-gradient(90deg, rgba(50,214,255,.11), transparent); }
.event-card.active::before { content:""; position:absolute; left:0; top:9px; bottom:9px; width:2px; background:var(--cyan); box-shadow:0 0 10px var(--cyan); }
.event-type-icon { width:32px; height:32px; display:grid; place-items:center; border:1px solid color-mix(in srgb, var(--card-color) 33%, transparent); border-radius:50%; color:var(--card-color); background:color-mix(in srgb, var(--card-color) 9%, transparent); }
.event-meta { display:flex; align-items:center; gap:6px; margin-bottom:5px; }
.event-meta span { color:var(--card-color); font-size:7px; font-weight:800; letter-spacing:.11em; text-transform:uppercase; }
.event-meta time { color:#607e91; font-size:8px; margin-left:auto; }
.event-card h3 { margin:0; font-size:11px; line-height:1.45; font-weight:650; }
.event-card p { margin:5px 0 0; color:var(--muted); font-size:8.5px; line-height:1.45; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.event-footer { display:flex; gap:7px; margin-top:7px; align-items:center; }
.severity-pill { padding:3px 6px; border-radius:999px; font-size:7px; border:1px solid color-mix(in srgb, var(--severity-color) 35%, transparent); color:var(--severity-color); background:color-mix(in srgb, var(--severity-color) 7%, transparent); }
.source-label { color:#547286; font-size:7px; }
.demo-label { color:var(--yellow); font-size:7px; margin-left:auto; }
.empty-state { padding:40px 20px; text-align:center; color:var(--muted); font-size:10px; line-height:1.8; }

.bottom-strip { grid-column:1/-1; grid-row:3; z-index:21; display:grid; grid-template-columns:auto 1fr auto; align-items:center; border-width:1px 0 0; overflow:hidden; }
.ticker-label { height:100%; display:flex; align-items:center; gap:8px; padding:0 18px; color:var(--green); font-size:8px; font-weight:800; letter-spacing:.17em; border-right:1px solid var(--line); }
.ticker-window { overflow:hidden; min-width:0; }
.ticker-track { display:flex; width:max-content; animation:ticker 55s linear infinite; }
.ticker-item { white-space:nowrap; padding:0 28px; font-size:9px; color:#a9c3d3; }
.ticker-item b { color:var(--cyan); margin-right:7px; }
.attribution { padding:0 16px; border-left:1px solid var(--line); color:#486678; font-size:7px; letter-spacing:.08em; white-space:nowrap; }

.detail-dialog { width:min(560px, calc(100vw - 34px)); max-height:min(720px, calc(100dvh - 34px)); padding:0; color:var(--text); border:1px solid var(--line-strong); border-radius:12px; background:var(--panel-strong); box-shadow:0 30px 100px rgba(0,0,0,.75); backdrop-filter:blur(24px); }
.detail-dialog::backdrop { background:rgba(0,5,10,.72); backdrop-filter:blur(3px); }
.dialog-close { position:absolute; right:12px; top:12px; z-index:2; width:32px; height:32px; border-radius:50%; border:1px solid var(--line); background:rgba(0,0,0,.25); cursor:pointer; }
.dialog-close:hover { color:var(--cyan); }
.dialog-hero { padding:26px 54px 18px 22px; border-bottom:1px solid var(--line); background:radial-gradient(circle at 10% 0%, color-mix(in srgb, var(--dialog-color) 15%, transparent), transparent 55%); }
.dialog-kicker { color:var(--dialog-color); font-size:9px; letter-spacing:.16em; font-weight:800; }
.dialog-hero h2 { margin:8px 0; font-size:20px; line-height:1.4; }
.dialog-hero p { margin:0; color:var(--muted); font-size:11px; line-height:1.65; }
.dialog-body { padding:18px 22px 24px; }
.detail-grid { display:grid; grid-template-columns:repeat(2, 1fr); gap:9px; }
.detail-cell { padding:10px; border-radius:7px; background:rgba(255,255,255,.025); border:1px solid var(--line); }
.detail-cell span { display:block; color:var(--muted); font-size:8px; }
.detail-cell strong { display:block; margin-top:5px; font-size:11px; overflow-wrap:anywhere; }
.dialog-actions { display:flex; gap:9px; margin-top:16px; }
.dialog-actions a, .dialog-actions button { flex:1; display:grid; place-items:center; min-height:38px; border-radius:7px; text-decoration:none; cursor:pointer; font-size:10px; }
.dialog-actions a { color:#041017; background:var(--cyan); }
.dialog-actions button { border:1px solid var(--line); background:transparent; color:var(--text); }
.disclaimer { margin-top:15px; padding-top:13px; border-top:1px solid var(--line); color:#587489; font-size:8px; line-height:1.65; }
.toast-region { position:fixed; right:18px; bottom:64px; z-index:100; display:grid; gap:8px; }
.toast { max-width:330px; padding:10px 12px; border-radius:8px; border:1px solid var(--line-strong); background:rgba(5,17,27,.95); box-shadow:var(--shadow); font-size:10px; animation:toast-in .25s ease; }
.toast.error { border-color:rgba(255,79,109,.35); color:#ffd7de; }

@keyframes pulse { 70% { box-shadow:0 0 0 7px rgba(73,239,178,0); } 100% { box-shadow:0 0 0 0 rgba(73,239,178,0); } }
@keyframes ticker { to { transform:translateX(-50%); } }
@keyframes toast-in { from { opacity:0; transform:translateY(8px); } }

@media (max-width: 1120px) {
  :root { --left-w: 276px; --right-w: 320px; }
  .metric-card { min-height:72px; }
  .attribution { display:none; }
}
@media (max-width: 880px) {
  body.world-pulse-page { overflow-x:clip; overflow-y:auto; }
  .app-shell { width:100%; max-width:100%; height:auto; min-height:100dvh; grid-template-columns:minmax(0, 1fr); grid-template-rows:64px 68dvh auto auto 44px; }
  .topbar, .globe-stage, .left-panel, .right-panel, .bottom-strip { width:100%; max-width:100%; min-width:0; }
  .topbar { grid-column:1; grid-row:1; padding:0 12px; grid-template-columns:minmax(0, 1fr) auto; }
  .brand, .brand > div:last-child { min-width:0; }
  .brand h1 { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .topbar-center { display:none; }
  .button-label { display:none; }
  .icon-button { width:44px; min-width:44px; height:44px; padding:0; }
  .globe-stage { grid-column:1; grid-row:2; }
  .left-panel { grid-column:1; grid-row:3; overflow:visible; border-right:0; }
  .right-panel { grid-column:1; grid-row:4; max-height:680px; border-left:0; overflow:hidden; }
  .bottom-strip { position:sticky; bottom:0; grid-column:1; grid-row:5; }
  .overview-section .metric-grid { grid-template-columns:repeat(4, minmax(0, 1fr)); }
  .layer-filters { grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .sources-section { display:none; }
  .space-weather { bottom:12px; left:12px; }
  .globe-counter { bottom:12px; right:12px; }
}
@media (max-width: 570px) {
  .topbar { gap:6px; }
  .brand { gap:8px; }
  .brand-mark { width:32px; height:32px; flex:0 0 32px; }
  .topbar-actions { gap:4px; }
  .brand p { display:none; }
  .brand h1 { font-size:14px; }
  .overview-section .metric-grid { grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .metric-card { min-width:0; }
  .layer-filters { grid-template-columns:minmax(0, 1fr); }
  .panel-section { padding-inline:14px; }
  .globe-label strong { display:none; }
  .space-weather { width:180px; }
  .zoom-controls { top:12px; right:12px; }
  .attribution { display:none; }
  .ticker-label { padding:0 10px; }
  .detail-grid { grid-template-columns:1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration:.001ms !important; animation-iteration-count:1 !important; scroll-behavior:auto !important; }
}

/* Expanded source/layer catalog */
.left-panel .filters-section { min-height: 0; }
.layer-filters { max-height: 34vh; overflow-y: auto; padding-right: 3px; scrollbar-width: thin; }
.source-health { max-height: 31vh; overflow-y: auto; padding-right: 3px; scrollbar-width: thin; }
.layer-filters::-webkit-scrollbar, .source-health::-webkit-scrollbar { width: 5px; }
.layer-filters::-webkit-scrollbar-thumb, .source-health::-webkit-scrollbar-thumb { background: rgba(117, 205, 255, .22); border-radius: 99px; }
.source-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-row span { white-space: nowrap; }
@media (max-width: 1180px) {
  .layer-filters, .source-health { max-height: none; overflow: visible; }
}
