/* ═══════════════════════════════════════════════════════════════
   ResourceMesh – Minimalist Monochrome Design System
   Pure B&W · Sharp Corners · Editorial Typography
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Strictly Monochrome Palette */
  --bg-primary:   #FFFFFF;
  --bg-inverted:  #000000;
  --bg-subtle:    #F5F5F5;
  
  --fg-primary:   #000000;
  --fg-inverted:  #FFFFFF;
  --fg-muted:     #525252;

  --border-hairline: 1px solid #E5E5E5;
  --border-thin:     1px solid #000000;
  --border-med:      2px solid #000000;
  --border-thick:    4px solid #000000;
  --border-ultra:    8px solid #000000;

  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Source Serif 4', Georgia, serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Type Scale */
  --text-xs:   12px;
  --text-sm:   14px;
  --text-base: 16px;
  --text-lg:   18px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  32px;
  --text-4xl:  40px;
  --text-5xl:  56px;
  --text-6xl:  72px;

  /* Motion */
  --t-instant: 0ms;
  --t-fast:    100ms;

  /* Spacing */
  --sp-xs:  4px;
  --sp-sm:  8px;
  --sp-md:  16px;
  --sp-lg:  24px;
  --sp-xl:  32px;
  --sp-2xl: 48px;
  --sp-3xl: 64px;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--fg-primary);
  line-height: 1.625;
  min-height: 100vh;
  position: relative;
}

/* Global Noise Texture */
.texture-noise {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.02;
  pointer-events: none;
  z-index: 9999;
}

/* Splash Screen */
.splash-screen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-inverted); z-index: 10000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s;
}
.splash-logo {
  display: flex; flex-direction: column; align-items: center;
}
.logo-part {
  opacity: 0;
  animation: logoFadeIn 0.8s forwards cubic-bezier(0.1, 0.9, 0.2, 1);
}
.logo-part.d1 { animation-delay: 0.1s; }
.logo-part.p1 { animation-delay: 0.2s; }
.logo-part.d2 { animation-delay: 0.3s; }
.logo-part.p2 { animation-delay: 0.4s; }
.logo-part.d3 { animation-delay: 0.5s; }

@keyframes logoFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.splash-text {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 700; letter-spacing: 6px;
  color: var(--fg-inverted); margin-top: 32px;
  opacity: 0; animation: fadeUp 1s 0.7s forwards;
}
.splash-subtext {
  font-family: var(--font-body); font-size: 14px; color: #888;
  margin-top: 12px; font-style: italic;
  opacity: 0; animation: fadeUp 1s 0.9s forwards;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--bg-inverted);
  color: var(--fg-inverted);
  padding: 8px 16px;
  z-index: 10000;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: top var(--t-fast);
}
.skip-link:focus { top: 0; }

/* ── App Container ─────────────────────────────────────────── */
#app {
  max-width: 480px; /* Mobile focused */
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  position: relative;
  z-index: 1;
  border-left: var(--border-thin);
  border-right: var(--border-thin);
}

/* ── Focus States (A11y) ───────────────────────────────────── */
:focus-visible {
  outline: 3px solid var(--fg-primary);
  outline-offset: 3px;
}

/* ── Common Elements ───────────────────────────────────────── */
.section-rule {
  height: 0;
  border-bottom: var(--border-thick);
  width: 100%;
}

.panel-header {
  padding: var(--sp-xl) var(--sp-md);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    #000 1px,
    #000 2px
  );
  background-size: 100% 4px;
  background-position: 0 0;
  /* Mask to make the texture very subtle */
  position: relative;
}
.panel-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.97);
  z-index: -1;
}

.panel-title {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.05em;
  text-transform: uppercase;
}
.panel-title em {
  font-style: italic;
  font-weight: 400;
  text-transform: none;
}

.panel-count {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  border: var(--border-thin);
  padding: 4px 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

/* ── Masthead ──────────────────────────────────────────────── */
.masthead {
  border-bottom: var(--border-thick);
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 100;
}

.masthead-top {
  padding: var(--sp-md);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.masthead-left {
  display: flex;
  flex-direction: column;
}

.masthead-logotype {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1;
}

.masthead-edition {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 4px;
}

.masthead-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.masthead-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-indicator {
  width: 8px; height: 8px;
  background-color: var(--fg-primary);
  border: 1px solid var(--fg-primary);
}
.status-indicator.connected {
  background-color: var(--bg-primary);
  border: var(--border-med);
}

.status-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ── Context Ticker ────────────────────────────────────────── */
.context-rule {
  border-top: var(--border-thin);
  border-bottom: var(--border-thin);
  padding: 6px var(--sp-md);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.context-rule::-webkit-scrollbar { display: none; }

.context-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
}
.context-key {
  font-weight: 700;
  text-transform: uppercase;
}
.context-val {
  color: var(--fg-muted);
}
.context-sep {
  color: var(--fg-muted);
  font-size: 10px;
}
.context-live {
  background: var(--fg-primary);
  color: var(--fg-inverted);
  padding: 2px 6px;
}
.context-live .context-val { color: var(--fg-inverted); }
.context-live-dot {
  width: 4px; height: 4px;
  background-color: var(--bg-primary);
}

/* ── Navigation Tabs ───────────────────────────────────────── */
.nav-tabs {
  display: flex;
  border-bottom: var(--border-thin);
}

.nav-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-right: var(--border-thin);
  padding: 12px 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  color: var(--fg-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-tab:last-child { border-right: none; }

.nav-tab:hover {
  color: var(--fg-primary);
  background: var(--bg-subtle);
}

.nav-tab.active {
  background: var(--bg-inverted);
  color: var(--fg-inverted);
}

/* ── Content Area ──────────────────────────────────────────── */
.content-area {
  flex: 1;
  padding-bottom: 80px; /* space for FAB */
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* ── Stats Row ─────────────────────────────────────────────── */
.stat-row {
  display: flex;
  background: var(--bg-inverted);
  color: var(--fg-inverted);
  /* Vertical lines texture for inverted section */
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 1px,
    #fff 1px,
    #fff 2px
  );
  background-size: 4px 100%;
  background-position: 0 0;
  position: relative;
}
.stat-row::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.97);
  z-index: 0;
}

.stat-cell {
  flex: 1;
  padding: var(--sp-md) var(--sp-xs);
  text-align: center;
  position: relative;
  z-index: 1;
}

.stat-divider {
  width: 1px;
  background: rgba(255,255,255,0.2);
  z-index: 1;
}

.stat-num {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
}

/* ── Controls Row (Filters & Sort) ─────────────────────────── */
.controls-row {
  padding: var(--sp-md);
  border-bottom: var(--border-hairline);
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-pill {
  background: transparent;
  border: var(--border-thin);
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--t-fast);
}

.filter-pill:hover,
.filter-pill.active {
  background: var(--bg-inverted);
  color: var(--fg-inverted);
}

.sort-row {
  padding: var(--sp-md);
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

.sort-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.sort-chips {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.sort-chips::-webkit-scrollbar { display: none; }

.sort-chip {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding-bottom: 2px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t-fast);
}

.sort-chip:hover {
  color: var(--fg-primary);
}
.sort-chip.active {
  color: var(--fg-primary);
  border-bottom-color: var(--fg-primary);
  font-weight: 700;
}

/* ── Resource Cards ────────────────────────────────────────── */
.resource-list {
  display: flex;
  flex-direction: column;
}

.resource-card {
  padding: var(--sp-lg);
  border-bottom: var(--border-thick);
  background: var(--bg-primary);
  transition: all var(--t-fast);
  cursor: pointer;
}

.resource-card:hover {
  background: var(--bg-inverted);
  color: var(--fg-inverted);
}

/* Inverse styling for hover */
.resource-card:hover .card-type,
.resource-card:hover .meta-icon,
.resource-card:hover .card-trust,
.resource-card:hover .card-source-badge {
  color: var(--fg-inverted);
  border-color: var(--fg-inverted);
}
.resource-card:hover .meta-item { color: rgba(255,255,255,0.7); }
.resource-card:hover .meta-value { color: var(--fg-inverted); }
.resource-card:hover .capacity-bar-track { background: rgba(255,255,255,0.2); }
.resource-card:hover .capacity-bar-fill { background: var(--bg-primary); }
.resource-card:hover .ttl-bar { background: var(--bg-primary); }
.resource-card:hover .ttl-bar-wrap { background: rgba(255,255,255,0.2); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--sp-md);
}

.card-name {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.card-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.card-source-badge {
  border: var(--border-thin);
  padding: 2px 4px;
}

.card-trust {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  border: var(--border-med);
  padding: 4px 8px;
}

.card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-lg);
  font-size: var(--text-sm);
}

.meta-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--fg-muted);
}
.meta-value { color: var(--fg-primary); font-weight: 600; }
.meta-icon { font-family: var(--font-mono); color: var(--fg-primary); }

.capacity-bar-wrap, .ttl-bar-wrap { margin-bottom: var(--sp-sm); }

.capacity-header, .ttl-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.capacity-bar-track, .ttl-bar-wrap {
  height: 2px; /* ultra thin lines */
  background: var(--border-hairline);
  width: 100%;
}

.capacity-bar-fill, .ttl-bar {
  height: 100%;
  background: var(--fg-primary);
  transition: width 0.3s ease;
}

/* ── Mesh Tab ──────────────────────────────────────────────── */
.canvas-wrap {
  padding: var(--sp-lg);
  border-bottom: var(--border-thick);
  background-image:
    linear-gradient(#00000008 1px, transparent 1px),
    linear-gradient(90deg, #00000008 1px, transparent 1px);
  background-size: 40px 40px;
}

#meshCanvas {
  width: 100%;
  height: 260px;
  border: var(--border-thin);
  background: var(--bg-primary);
}

.canvas-caption {
  display: flex;
  gap: var(--sp-md);
  margin-top: var(--sp-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.mesh-controls {
  padding: var(--sp-lg);
  display: flex;
  gap: var(--sp-sm);
}

.btn-primary, .btn-outline, .btn-ghost {
  flex: 1;
  padding: 16px 8px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all var(--t-fast);
}

.btn-primary {
  background: var(--bg-inverted);
  color: var(--fg-inverted);
  border: none;
}
.btn-primary:hover { background: var(--fg-muted); }

.btn-outline {
  background: transparent;
  color: var(--fg-primary);
  border: var(--border-med);
}
.btn-outline:hover { background: var(--bg-inverted); color: var(--fg-inverted); }

.btn-ghost {
  background: transparent;
  border: none;
  text-decoration: underline;
}

.sources-block, .log-block {
  padding: var(--sp-lg);
}

.sources-header-row, .log-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--sp-md);
}

.sources-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
}

.source-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: var(--border-hairline);
}
.source-item:last-child { border-bottom: none; }

.source-dot {
  width: 8px; height: 8px;
  border: 1px solid var(--fg-primary);
}
.source-dot.live { background: var(--fg-primary); }
.source-dot.error { background: transparent; border-style: dashed; }

.source-name {
  font-size: var(--text-sm);
  font-weight: 600;
  flex: 1;
}
.source-url {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--fg-muted);
}
.source-count {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.log-entry {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: var(--border-hairline);
  font-size: var(--text-sm);
}
.log-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-muted);
  width: 60px;
  flex-shrink: 0;
}
.log-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  border: var(--border-thin);
  padding: 2px 4px;
  align-self: flex-start;
}
.log-msg { flex: 1; }

/* ── SMS Tab ───────────────────────────────────────────────── */
.sms-facts {
  display: grid;
  grid-template-columns: 1fr;
}
.sms-fact {
  padding: var(--sp-md);
  border-bottom: var(--border-hairline);
}
.sms-fact-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 4px;
}
.sms-fact-val {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
}
.sms-fact-val code {
  font-family: var(--font-mono);
  border: var(--border-thin);
  padding: 0 4px;
}

.sms-panel {
  display: flex;
  flex-direction: column;
  height: 400px;
}

.sms-header {
  padding: var(--sp-md);
  border-bottom: var(--border-thick);
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

.sms-avatar {
  width: 40px; height: 40px;
  background: var(--bg-inverted);
  color: var(--fg-inverted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--text-xl);
}
.sms-contact-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
}
.sms-contact-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.status-indicator.small { width: 6px; height: 6px; display: inline-block; }

.sms-messages {
  flex: 1;
  padding: var(--sp-lg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  background: repeating-linear-gradient(45deg, transparent, transparent 40px, #00000004 40px, #00000004 42px);
}

.sms-bubble {
  max-width: 85%;
  border: var(--border-med);
  background: var(--bg-primary);
}
.sms-bubble.sent {
  align-self: flex-end;
  background: var(--bg-inverted);
  color: var(--fg-inverted);
}
.sms-bubble.received {
  align-self: flex-start;
}
.sms-text {
  padding: 12px 16px;
  font-size: var(--text-sm);
  white-space: pre-line;
}
.sms-meta {
  border-top: var(--border-thin);
  padding: 4px 16px;
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
}
.sms-bubble.sent .sms-meta {
  border-top-color: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
}

.sms-hint {
  padding: 8px var(--sp-md);
  font-family: var(--font-mono);
  font-size: 9px;
  border-top: var(--border-thick);
  background: var(--bg-subtle);
  color: var(--fg-muted);
}

.sms-input-row {
  display: flex;
  border-top: var(--border-thin);
}
.sms-input {
  flex: 1;
  border: none;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.sms-input:focus {
  outline: none;
  box-shadow: inset 0 -3px 0 var(--fg-primary);
}
.sms-send {
  background: var(--bg-inverted);
  color: var(--fg-inverted);
  border: none;
  padding: 0 24px;
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  cursor: pointer;
  transition: opacity var(--t-fast);
}
.sms-send:hover { opacity: 0.8; }

/* ── Architecture Tab ───────────────────────────────────────── */
.arch-layer {
  padding: var(--sp-xl);
  border-bottom: var(--border-thin);
  border-left: var(--accent-wt, 0px) solid var(--fg-primary);
  background: var(--bg-primary);
  transition: all var(--t-fast);
}
.arch-layer:hover {
  background: var(--bg-inverted);
  color: var(--fg-inverted);
  border-left-color: var(--bg-inverted);
}
.arch-layer:hover .arch-tag { color: var(--fg-inverted); border-color: var(--fg-inverted); }
.arch-layer:hover .arch-layer-desc { color: rgba(255,255,255,0.8); }

.arch-layer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-sm);
}
.arch-layer-name {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
}
.arch-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  border: var(--border-thin);
  padding: 2px 6px;
}
.arch-layer-desc {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}
.arch-arrow {
  text-align: center;
  padding: 8px 0;
  border-bottom: var(--border-thin);
  font-family: var(--font-mono);
  font-size: var(--text-xl);
}

.schema-section, .decisions-section, .api-section {
  padding: var(--sp-lg);
}
.schema-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--sp-md);
}
.schema-table {
  border-top: var(--border-med);
}
.schema-row {
  display: flex;
  padding: 12px 0;
  border-bottom: var(--border-hairline);
  font-family: var(--font-mono);
  font-size: 11px;
}
.schema-key { width: 30%; font-weight: 700; }
.schema-type { width: 25%; text-transform: uppercase; }
.schema-desc { flex: 1; color: var(--fg-muted); font-family: var(--font-body); font-size: var(--text-sm); }

.decision-item {
  display: flex;
  gap: var(--sp-md);
  margin-bottom: var(--sp-lg);
}
.decision-num {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 900;
  line-height: 0.8;
  color: var(--fg-muted);
}
.decision-title {
  font-weight: 700;
  font-size: var(--text-lg);
  margin-bottom: 4px;
}
.decision-desc {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}
.decision-desc code {
  font-family: var(--font-mono);
  border: var(--border-thin);
  padding: 0 4px;
  color: var(--fg-primary);
}

.api-source-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: var(--border-hairline);
}
.api-name { font-weight: 600; font-size: var(--text-sm); }
.api-url { font-family: var(--font-mono); font-size: 10px; color: var(--fg-muted); display: block; margin-top: 2px; }
.api-status { font-family: var(--font-mono); font-size: 10px; border: var(--border-thin); padding: 2px 6px; }

/* ── Floating Action Button ────────────────────────────────── */
.fab {
  position: fixed;
  bottom: var(--sp-lg);
  right: calc(50% - 240px + var(--sp-lg));
  width: 56px;
  height: 56px;
  background: var(--bg-inverted);
  color: var(--fg-inverted);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: background var(--t-fast);
}
.fab:hover { background: var(--fg-muted); }
.fab.spinning svg { animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }
@media (max-width: 480px) { .fab { right: var(--sp-lg); } }

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-primary);
  border: var(--border-thick);
  padding: 12px 24px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all var(--t-fast);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  padding: var(--sp-3xl) var(--sp-lg);
  text-align: center;
}
.empty-icon { font-size: var(--text-4xl); margin-bottom: var(--sp-md); }
.empty-title { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 700; margin-bottom: var(--sp-sm); }
.empty-desc { color: var(--fg-muted); font-size: var(--text-sm); }

/* ── Shimmer Loading ───────────────────────────────────────── */
.loading-card {
  background: repeating-linear-gradient(45deg, transparent, transparent 10px, #00000008 10px, #00000008 20px);
  animation: pulse 1.5s infinite alternate;
}
@keyframes pulse {
  0% { opacity: 0.8; }
  100% { opacity: 0.3; }
}

/* ── Onboarding Overlay ────────────────────────────────────── */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  padding: var(--sp-2xl) var(--sp-lg);
  border-left: var(--border-thick);
  border-right: var(--border-thick);
  max-width: 480px;
  margin: 0 auto;
  overflow-y: auto;
}

.onboarding-header {
  margin-bottom: var(--sp-2xl);
  border-bottom: var(--border-thick);
  padding-bottom: var(--sp-md);
}

.onboarding-logotype {
  font-family: var(--font-display);
  font-size: var(--text-6xl);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.05em;
}

.onboarding-phonetic {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin-top: 8px;
}

.onboarding-description {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  line-height: 1.5;
  margin-bottom: var(--sp-3xl);
  padding-left: var(--sp-md);
  border-left: var(--border-med);
}

.onboarding-step {
  display: none;
  animation: fadeIn var(--t-fast) ease-in;
}
.onboarding-step.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-label {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--sp-sm);
}

.step-desc {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-lg);
}

.minimal-input {
  width: 100%;
  border: none;
  border-bottom: var(--border-med);
  padding: 16px 0;
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  background: transparent;
  color: var(--fg-primary);
  margin-bottom: var(--sp-xl);
  border-radius: 0;
}
.minimal-input:focus {
  outline: none;
  border-bottom: var(--border-thick);
}

.location-fallback {
  margin-top: var(--sp-2xl);
  border-top: var(--border-hairline);
  padding-top: var(--sp-lg);
}

.fallback-text {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--fg-muted);
  margin-bottom: var(--sp-sm);
  display: block;
}

.zip-row {
  display: flex;
  gap: var(--sp-md);
  align-items: flex-end;
}
.zip-input {
  margin-bottom: 0;
  flex: 1;
}

.location-status {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-muted);
  margin-top: var(--sp-md);
  padding: 8px;
  border: var(--border-hairline);
  background: var(--bg-subtle);
  display: none;
}
.location-status.visible {
  display: block;
}

/* ── Cinematic Transition ──────────────────────────────────── */
.transition-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-inverted);
  color: var(--fg-inverted);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.transition-content {
  text-align: center;
  padding: var(--sp-lg);
  max-width: 480px;
  width: 100%;
}
.transition-logotype {
  font-family: var(--font-display);
  font-size: var(--text-5xl);
  font-weight: 900;
  letter-spacing: -0.05em;
  margin-bottom: var(--sp-2xl);
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUpIn 0.8s forwards 0.2s;
}
.transition-sequence {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-align: left;
  border: var(--border-thin);
  border-color: var(--fg-muted);
  padding: var(--sp-lg);
  background: repeating-linear-gradient(90deg, transparent, transparent 1px, #ffffff05 1px, #ffffff05 2px);
  opacity: 0;
  animation: fadeUpIn 0.5s forwards 1s;
}
.trans-step {
  margin-bottom: var(--sp-md);
  opacity: 0.3;
  transition: opacity 0.3s;
}
.trans-step.active {
  opacity: 1;
}
.trans-step::before {
  content: "> ";
  opacity: 0.5;
}
@keyframes fadeUpIn {
  to { opacity: 1; transform: translateY(0); }
}

/* ── Resource Detail Modal ─────────────────────────────────── */
.resource-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.resource-modal {
  width: 100%;
  max-width: 480px;
  background: var(--bg-primary);
  border-top: var(--border-thick);
  border-left: var(--border-thin);
  border-right: var(--border-thin);
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.resource-modal.open {
  transform: translateY(0);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-md) var(--sp-lg);
  border-bottom: var(--border-thin);
  background: var(--bg-subtle);
}
.modal-type-row {
  display: flex;
  gap: var(--sp-md);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
}
.modal-type {
  border: var(--border-thin);
  padding: 4px 8px;
}
.modal-distance {
  color: var(--fg-muted);
  padding: 4px 0;
}
.modal-close {
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  cursor: pointer;
}
.modal-body {
  padding: var(--sp-lg);
}
.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: var(--sp-sm);
}
.modal-address {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin-bottom: var(--sp-xl);
}
.modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: var(--border-thick);
  margin-bottom: var(--sp-xl);
}
.m-stat {
  padding: var(--sp-md) 0;
  text-align: center;
  border-right: var(--border-thin);
}
.m-stat:last-child { border-right: none; }
.m-stat-val {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1;
}
.m-stat-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  margin-top: 4px;
}
.modal-section-title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  margin: var(--sp-lg) 0 var(--sp-md);
}
.capacity-drain-wrap {
  margin-bottom: var(--sp-xl);
}
.drain-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  margin-bottom: 8px;
}
.drain-bar-track {
  height: 4px;
  background: var(--border-hairline);
  width: 100%;
  margin-bottom: 8px;
}
.drain-bar-fill {
  height: 100%;
  background: var(--fg-primary);
  width: 0%;
  transition: width 1s ease-out;
}
.drain-desc {
  font-size: var(--text-xs);
  color: var(--fg-muted);
}
.modal-metadata {
  margin-bottom: var(--sp-2xl);
}
.md-row {
  display: flex;
  padding: 8px 0;
  border-bottom: var(--border-hairline);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.md-key { width: 30%; font-weight: 700; }
.md-val { flex: 1; color: var(--fg-muted); }

.modal-action {
  width: 100%;
  text-align: center;
}
