/* IAM Permission Explorer — dark, data-dense, utilitarian */
:root {
  --bg: #0a0e16;
  --bg-2: #0e1420;
  --panel: #121a29;
  --panel-2: #16203255;
  --line: #1e2a40;
  --line-soft: #18223a;
  --text: #e9eef8;
  --muted: #8d9bb3;
  --faint: #5b6a84;
  --accent: #ff9900;
  --accent-soft: #ff990022;
  --c-list: #38bdf8;
  --c-read: #34d399;
  --c-write: #fbbf24;
  --c-perm: #f87171;
  --c-tag: #c084fc;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, #16203a66, transparent 60%),
    radial-gradient(900px 500px at -10% 20%, #1a153066, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; }
button { font-family: inherit; }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
  flex-shrink: 0;
}
.brand-mark { width: 28px; height: 28px; color: var(--accent); }
.brand-name { font-size: 15px; letter-spacing: .2px; white-space: nowrap; }
.brand-name b { font-weight: 700; }
.search-wrap {
  position: relative; flex: 1; max-width: 640px; margin: 0 auto;
}
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--faint); pointer-events: none;
}
#global-search {
  width: 100%; height: 40px;
  padding: 0 40px 0 36px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text); font-size: 14.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#global-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#global-search::placeholder { color: var(--faint); }
.search-hint {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 11px; color: var(--faint);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
  pointer-events: none;
}
.top-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.source-badge {
  font-family: var(--mono); font-size: 11px; letter-spacing: .4px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
  white-space: nowrap; cursor: default;
}
.source-badge.live { color: #7dd3a8; border-color: #1f4436; background: #0f241c; }
.source-badge.snapshot { color: #fbbf24; border-color: #4a3a14; background: #241d0c; }
.source-badge.error { color: #f87171; border-color: #4a1d1d; background: #241010; }
.policy-btn {
  display: flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 14px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 13.5px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.policy-btn:hover { border-color: var(--accent); }
.policy-btn svg { width: 16px; height: 16px; color: var(--accent); }
.policy-count {
  background: var(--accent); color: #1a1206;
  font-weight: 700; font-size: 11.5px;
  min-width: 19px; height: 19px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

/* ---------- stream progress ---------- */
.streambar { height: 2px; background: var(--line-soft); position: sticky; top: var(--topbar-h); z-index: 39; }
.streambar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), #ffc46b);
  transition: width .25s ease;
}

/* ---------- generic ---------- */
#view { max-width: 1180px; margin: 0 auto; padding: 28px 20px 90px; outline: none; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 3px 11px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted);
  font-size: 12.5px; text-decoration: none;
  cursor: pointer; transition: border-color .12s, color .12s;
  font-family: inherit;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.level-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 650; letter-spacing: .5px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 6px;
  border: 1px solid; white-space: nowrap;
}
.badge .level-dot { width: 7px; height: 7px; }
.badge.lv-list  { color: var(--c-list);  border-color: #38bdf840; background: #38bdf812; }
.badge.lv-read  { color: var(--c-read);  border-color: #34d39940; background: #34d39912; }
.badge.lv-write { color: var(--c-write); border-color: #fbbf2440; background: #fbbf2412; }
.badge.lv-perm  { color: var(--c-perm);  border-color: #f8717140; background: #f8717112; }
.badge.lv-tag   { color: var(--c-tag);   border-color: #c084fc40; background: #c084fc12; }

.section-title {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 13px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); margin: 38px 0 14px;
}
.section-title .count { font-family: var(--mono); font-weight: 500; color: var(--faint); text-transform: none; letter-spacing: 0; }

/* ---------- hero ---------- */
.hero { padding: 34px 0 8px; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 14px;
}
.hero-eyebrow .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 #ff990066; }
  50% { box-shadow: 0 0 0 7px #ff990000; }
}
.hero h1 {
  font-size: clamp(34px, 5.6vw, 62px);
  line-height: 1.04; letter-spacing: -1.5px;
  margin: 0 0 16px; font-weight: 800;
  max-width: 15ch;
}
.hero h1 .hl { color: var(--accent); }
.hero p.lede { color: var(--muted); font-size: clamp(15px, 1.7vw, 18px); max-width: 62ch; margin: 0 0 30px; }
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin: 8px 0 10px;
}
.stat-card {
  background: linear-gradient(180deg, var(--panel), #101828);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 16px;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--sc, var(--accent)), transparent);
  opacity: .7;
}
.stat-num {
  font-family: var(--mono); font-weight: 700;
  font-size: clamp(26px, 3.4vw, 40px); letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.stat-label { color: var(--muted); font-size: 12.5px; letter-spacing: .8px; text-transform: uppercase; margin-top: 2px; }
.stat-sub { color: var(--faint); font-size: 11.5px; font-family: var(--mono); margin-top: 6px; }

.hero-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; margin-top: 22px; align-items: stretch; }
.panel {
  background: linear-gradient(180deg, var(--panel), #0f1726);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px;
}
.panel h3 {
  margin: 0 0 4px; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted);
  display: flex; justify-content: space-between; align-items: baseline;
}
.panel h3 .hint { font-size: 11px; color: var(--faint); text-transform: none; letter-spacing: 0; font-weight: 400; }
#constellation { width: 100%; height: 340px; display: block; cursor: crosshair; border-radius: 8px; }
.constellation-tip {
  position: fixed; z-index: 60; pointer-events: none;
  background: #0c1220f2; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 11px; font-size: 12.5px;
  font-family: var(--mono);
  box-shadow: 0 8px 24px #0009;
}
.constellation-tip b { color: var(--accent); }

.topbars { display: flex; flex-direction: column; gap: 9px; margin-top: 10px; }
.topbar-row {
  display: grid; grid-template-columns: 150px 1fr 52px; gap: 10px; align-items: center;
  text-decoration: none; color: var(--text); font-size: 13px;
  padding: 3px 4px; border-radius: 7px;
}
.topbar-row:hover { background: var(--panel-2); }
.topbar-row .tb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-row .tb-name .prefix { color: var(--faint); font-family: var(--mono); font-size: 11.5px; margin-left: 6px; }
.topbar-row .tb-track { height: 8px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.topbar-row .tb-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #b36b00, var(--accent)); width: 0; transition: width .8s cubic-bezier(.2,.8,.2,1); }
.topbar-row .tb-num { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.level-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
.level-legend .ll { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.level-legend .ll b { color: var(--text); font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }

/* distribution bar */
.dist-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; margin-top: 14px; background: var(--line-soft); }
.dist-bar > div { transition: width .8s cubic-bezier(.2,.8,.2,1); }

/* ---------- skeletons ---------- */
.sk { background: linear-gradient(100deg, var(--panel) 40%, #1a2440 50%, var(--panel) 60%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-hero { height: 120px; margin-bottom: 22px; }
.sk-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 22px; }
.sk-card { height: 92px; }
.sk-block { height: 180px; margin-bottom: 16px; }
.sk-line { height: 44px; margin-bottom: 8px; }

/* ---------- search results ---------- */
.search-meta { color: var(--muted); font-size: 13.5px; margin: 6px 0 4px; }
.search-meta b { color: var(--text); font-family: var(--mono); }
.result-group { margin-bottom: 26px; }
.result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px;
  text-decoration: none; color: var(--text);
  border: 1px solid transparent;
}
.result-item:hover, .result-item.kb-focus { background: var(--panel); border-color: var(--line); }
.result-item .ri-main { min-width: 0; flex: 1; }
.result-item .ri-title { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-item .ri-title mark { background: none; color: var(--accent); font-weight: 700; }
.result-item .ri-sub { font-size: 12px; color: var(--faint); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-item .ri-kind { font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--faint); flex-shrink: 0; }
.more-note { color: var(--faint); font-size: 12.5px; padding: 4px 14px; font-family: var(--mono); }
.empty-state {
  text-align: center; padding: 70px 20px; color: var(--muted);
}
.empty-state .big { font-size: 44px; margin-bottom: 10px; }
.empty-state h2 { color: var(--text); margin: 0 0 8px; font-size: 20px; }
.empty-state code { font-family: var(--mono); color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 6px; }
.empty-state .sugg { margin-top: 18px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- service detail ---------- */
.svc-head { margin-bottom: 8px; }
.svc-head .crumbs { font-size: 12.5px; color: var(--faint); margin-bottom: 10px; font-family: var(--mono); }
.svc-head .crumbs a { color: var(--muted); text-decoration: none; }
.svc-head .crumbs a:hover { color: var(--accent); }
.svc-head h1 { font-size: clamp(26px, 4vw, 40px); letter-spacing: -.8px; margin: 0 0 4px; }
.svc-head h1 .prefix { color: var(--accent); font-family: var(--mono); font-weight: 600; font-size: .55em; vertical-align: middle; background: var(--accent-soft); padding: 4px 10px; border-radius: 8px; margin-left: 10px; letter-spacing: 0; }
.svc-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; color: var(--muted); font-size: 13.5px; margin: 12px 0 4px; }
.svc-stats b { color: var(--text); font-family: var(--mono); font-variant-numeric: tabular-nums; }

.filter-row {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin: 18px 0 6px; position: sticky; top: calc(var(--topbar-h) + 2px); z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 10px 0;
}
.filter-chip { min-height: 36px; font-size: 13px; }
.filter-chip[aria-pressed="true"] { border-color: currentColor; color: var(--text); background: var(--panel-2); }
.filter-chip .count { font-family: var(--mono); font-size: 11.5px; opacity: .75; }
.filter-chip.fc-all[aria-pressed="true"] { border-color: var(--accent); }
.svc-search {
  height: 36px; padding: 0 12px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  font-size: 13px; outline: none; min-width: 170px; flex: 1; max-width: 260px;
}
.svc-search:focus { border-color: var(--accent); }

.action-group { margin-bottom: 10px; }
.action-group-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 4px 8px; font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
  position: sticky; top: calc(var(--topbar-h) + 58px); z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.action-group-head .count { font-family: var(--mono); font-weight: 500; color: var(--faint); }

.action-row { border: 1px solid var(--line-soft); border-radius: 10px; margin-bottom: 7px; background: var(--panel); overflow: hidden; }
.action-row.expanded { border-color: var(--line); }
.action-row.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); } 100% { } }
.action-line {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 0 12px;
}
.a-expand {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  min-height: 46px; padding: 0;
  background: none; border: none; color: var(--text);
  cursor: pointer; text-align: left; font-size: 14px; font-family: inherit;
}
.action-line:hover { background: #ffffff06; }
.a-expand:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.a-expand .a-name { font-family: var(--mono); font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-expand .a-name mark { background: none; color: var(--accent); font-weight: 700; }
.a-expand .a-meta { color: var(--faint); font-size: 11.5px; font-family: var(--mono); white-space: nowrap; }
.chevron { width: 14px; height: 14px; color: var(--faint); transition: transform .18s; flex-shrink: 0; }
.action-row.expanded .chevron { transform: rotate(90deg); color: var(--accent); }
.add-btn {
  flex-shrink: 0; min-width: 34px; height: 34px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--muted);
  font-size: 15px; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: all .12s;
}
.add-btn:hover { border-color: var(--accent); color: var(--accent); }
.add-btn.added { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.action-detail {
  border-top: 1px solid var(--line-soft);
  padding: 14px 16px 16px 26px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  background: #0c1220;
}
.action-detail h4 { margin: 0 0 8px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); }
.ad-name { grid-column: 1 / -1; font-size: 13px; color: var(--accent); word-break: break-all; padding-bottom: 4px; border-bottom: 1px dashed var(--line-soft); margin-bottom: -6px; }
.action-detail h4 .count { font-family: var(--mono); text-transform: none; letter-spacing: 0; }
.res-item { margin-bottom: 10px; }
.res-item .res-name { font-family: var(--mono); font-size: 13px; }
.res-item .res-name a { color: var(--text); text-decoration: none; border-bottom: 1px dotted var(--faint); }
.res-item .res-name a:hover { color: var(--accent); border-color: var(--accent); }
.arn {
  display: block; font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  color: var(--muted); word-break: break-all;
  background: #00000030; border: 1px solid var(--line-soft);
  border-radius: 7px; padding: 6px 9px; margin-top: 5px;
}
.arn .ph { color: var(--accent); }
.ck-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ck {
  font-family: var(--mono); font-size: 12px;
  padding: 4px 9px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px;
}
.ck:hover { border-color: var(--accent); color: var(--accent); }
.ck .ck-type { color: var(--faint); font-size: 10.5px; }
.ck .ph { color: var(--accent); }
.detail-note { color: var(--faint); font-size: 12px; font-style: italic; }

/* ---------- xref views ---------- */
.xref-head h1 { font-size: clamp(22px, 3.4vw, 34px); letter-spacing: -.5px; margin: 0 0 6px; font-family: var(--mono); font-weight: 650; word-break: break-all; }
.xref-head h1 .ph { color: var(--accent); }
.xref-meta { color: var(--muted); font-size: 13.5px; display: flex; gap: 8px 20px; flex-wrap: wrap; margin-bottom: 6px; }
.xref-meta b { color: var(--text); font-family: var(--mono); }
.xref-svc { border: 1px solid var(--line-soft); border-radius: 10px; background: var(--panel); margin-bottom: 8px; overflow: hidden; }
.xref-svc-head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: var(--text);
  padding: 12px 14px; cursor: pointer; font-size: 14px; text-align: left;
}
.xref-svc-head:hover { background: #ffffff06; }
.xref-svc-head .count { margin-left: auto; font-family: var(--mono); color: var(--faint); font-size: 12px; }
.xref-actions { border-top: 1px solid var(--line-soft); padding: 8px 14px 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.xref-action {
  font-family: var(--mono); font-size: 12.5px; text-decoration: none;
  color: var(--text); background: #0c1220; border: 1px solid var(--line-soft);
  padding: 4px 9px; border-radius: 7px;
}
.xref-action:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- drawer ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(480px, 100vw);
  background: var(--bg-2); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  transform: translateX(0);
  animation: slidein .22s cubic-bezier(.2,.8,.2,1);
  box-shadow: -30px 0 60px #000a;
}
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
.drawer-scrim { position: fixed; inset: 0; z-index: 49; background: #0009; backdrop-filter: blur(2px); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line-soft);
}
.drawer-head h2 { margin: 0; font-size: 17px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 9px;
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 40px; }
.drawer-empty { color: var(--muted); text-align: center; padding: 46px 12px; }
.drawer-empty .big { font-size: 36px; margin-bottom: 8px; }
.pol-group { margin-bottom: 16px; }
.pol-group-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 7px; }
.pol-item {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 7px 10px; margin-bottom: 6px;
  font-family: var(--mono); font-size: 12.5px;
}
.pol-item .pi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pol-item .rm {
  background: none; border: none; color: var(--faint); cursor: pointer;
  font-size: 15px; padding: 4px 6px; border-radius: 6px; line-height: 1;
}
.pol-item .rm:hover { color: var(--c-perm); }
.pol-json-wrap { margin-top: 20px; }
.pol-json-wrap h3 { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.pol-json {
  font-family: var(--mono); font-size: 11.8px; line-height: 1.55;
  background: #090d15; border: 1px solid var(--line);
  border-radius: 10px; padding: 14px; margin: 0;
  overflow-x: auto; white-space: pre; color: #c9d6ea;
}
.pol-json .k { color: #7dd3fc; } .pol-json .s { color: #fbbf24; }
.drawer-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn {
  min-height: 42px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font-size: 13.5px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: border-color .12s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1206; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger:hover { border-color: var(--c-perm); color: var(--c-perm); }
.btn svg { width: 15px; height: 15px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 70; background: #101828f5; border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 11px 18px;
  font-size: 13.5px; box-shadow: 0 12px 34px #000c;
  animation: toastin .2s ease;
  max-width: calc(100vw - 40px);
}
@keyframes toastin { from { transform: translate(-50%, 8px); opacity: 0; } }

/* ---------- error / fallback states ---------- */
.err-panel {
  max-width: 620px; margin: 70px auto; text-align: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 40px 30px;
}
.err-panel .big { font-size: 42px; margin-bottom: 12px; }
.err-panel h2 { margin: 0 0 10px; }
.err-panel p { color: var(--muted); margin: 0 0 8px; }
.err-panel .mono-detail { font-family: var(--mono); font-size: 12px; color: var(--faint); word-break: break-all; margin: 12px 0 22px; }
.err-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.failed-notice {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1px solid #4a3a14; background: #241d0c; color: #fbbf24;
  border-radius: 10px; padding: 11px 15px; font-size: 13px; margin: 14px 0;
}
.failed-notice button { min-height: 34px; }

/* ---------- footer ---------- */
.foot { margin-top: 60px; padding-top: 20px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 12px; display: flex; gap: 6px 20px; flex-wrap: wrap; }
.foot .mono { font-size: 11px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; }
  #constellation { height: 260px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  #topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  :root { --topbar-h: 108px; }
  .brand-name b { display: none; }
  .brand-name::after { content: "Explorer"; font-weight: 700; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; margin: 0; }
  #global-search { height: 44px; font-size: 16px; }
  .policy-btn { min-height: 40px; }
  .policy-btn-label { display: none; }
  .source-badge { font-size: 10px; padding: 3px 8px; }
  #view { padding: 20px 14px 80px; }
  .hero { padding-top: 16px; }
  .action-detail { grid-template-columns: 1fr; padding-left: 14px; }
  .action-line { gap: 8px; }
  .a-expand { min-height: 50px; }
  .a-expand .a-meta { display: none; }
  .add-btn { min-width: 40px; height: 40px; }
  .drawer { width: 100vw; border-left: none; }
  .filter-row { top: var(--topbar-h); flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 8px; }
  .filter-row::-webkit-scrollbar { display: none; }
  .filter-chip { flex-shrink: 0; min-height: 40px; }
  .svc-search { min-width: 140px; height: 40px; }
  .action-group-head { top: calc(var(--topbar-h) + 56px); }
  .topbar-row { grid-template-columns: 110px 1fr 44px; }
  .sk-row { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
