/* The shell reuses the site's dark-cyan tokens from site-chrome.css. */

:root {
  --offline-panel: rgba(17, 24, 39, 0.88);
  --offline-panel-strong: #141d2e;
  --offline-border: rgba(148, 163, 184, 0.16);
  --offline-warning: #fbbf24;
  --offline-danger: #fb7185;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

button, select { font: inherit; }

button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.app-header, .offline-main, .app-footer { position: relative; z-index: 1; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.2rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.app-header .site-logo { color: var(--text); text-decoration: none; }
.back-link { color: var(--text-dim); font-size: .82rem; text-decoration: none; }
.back-link:hover { color: var(--primary); }

.offline-main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 2.2rem 1.25rem 4rem;
}

.eyebrow, .panel-kicker {
  color: var(--primary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin: .45rem 0 1.5rem;
}

h1, h2, h3 { font-family: 'Space Grotesk', sans-serif; }
h1 { margin: 0; font-size: clamp(2.2rem, 7vw, 4.6rem); line-height: .98; letter-spacing: -.055em; }
h2 { margin: .35rem 0 .65rem; font-size: 1.35rem; letter-spacing: -.025em; }
h3 { margin: 0; font-size: 1rem; }
.lede { max-width: 38rem; margin: .8rem 0 0; color: var(--text-dim); font-size: 1rem; }

.connection-badge, .cached-badge, .live-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: .4rem;
  border: 1px solid var(--live-border);
  border-radius: 999px;
  padding: .35rem .7rem;
  background: var(--live-bg);
  color: var(--live-text);
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}

.connection-badge::before, .cached-badge::before, .live-badge::before {
  width: .42rem;
  height: .42rem;
  border-radius: 50%;
  background: currentColor;
  content: '';
}

.connection-badge.offline, .cached-badge {
  border-color: rgba(251, 191, 36, .35);
  background: rgba(251, 191, 36, .1);
  color: var(--offline-warning);
}

.notice {
  margin: 0 0 1rem;
  border: 1px solid var(--offline-border);
  border-left: 3px solid var(--primary);
  border-radius: .45rem;
  padding: .75rem .9rem;
  background: rgba(34, 211, 238, .07);
  color: var(--text-dim);
  font-size: .86rem;
}
.notice-warning { border-left-color: var(--offline-warning); background: rgba(251, 191, 36, .08); color: #fde68a; }
.notice-error { border-left-color: var(--offline-danger); background: rgba(251, 113, 133, .08); color: #fecdd3; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); gap: 1rem; }
.panel {
  border: 1px solid var(--offline-border);
  border-radius: .75rem;
  background: var(--offline-panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .16);
}
.package-builder, .saved-panel, .viewer { padding: 1.25rem; }
.panel-intro, .viewer-meta, .form-status, .viewer-status { color: var(--text-dim); font-size: .84rem; }
.panel-intro { margin: 0 0 1rem; }

.button {
  min-height: 2.8rem;
  border: 1px solid transparent;
  border-radius: .35rem;
  padding: .65rem .95rem;
  cursor: pointer;
  font-weight: 700;
  transition: transform .2s ease, background .2s ease, border-color .2s ease, opacity .2s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button-primary { width: 100%; background: var(--primary); color: #06131a; }
.button-primary:hover:not(:disabled) { background: #67e8f9; }
.button-secondary { border-color: rgba(34, 211, 238, .35); background: rgba(34, 211, 238, .08); color: var(--primary); }
.button-small { min-height: 2.2rem; padding: .4rem .7rem; font-size: .78rem; }
.button-danger { border-color: rgba(251, 113, 133, .3); background: transparent; color: #fda4af; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 1.25rem 0; }
.field { display: grid; gap: .4rem; color: var(--text-dim); font-size: .78rem; font-weight: 600; }
.field small { color: var(--text-muted); font-weight: 400; }
select {
  width: 100%;
  min-height: 2.8rem;
  border: 1px solid var(--offline-border);
  border-radius: .35rem;
  padding: .6rem .7rem;
  background: var(--offline-panel-strong);
  color: var(--text);
}
select:disabled { color: var(--text-muted); }

.choice-group { margin: 0 0 1.1rem; border: 0; padding: 0; }
.choice-group legend { margin-bottom: .55rem; color: var(--text-dim); font-size: .78rem; font-weight: 600; }
.choice-row { display: flex; align-items: flex-start; gap: .7rem; margin: .55rem 0; cursor: pointer; }
.choice-row input { width: 1.1rem; height: 1.1rem; margin: .15rem 0 0; accent-color: var(--primary); }
.choice-row span { display: grid; gap: .1rem; font-size: .86rem; }
.choice-row small { color: var(--text-dim); font-size: .75rem; font-weight: 400; }
.form-status { min-height: 1.3rem; margin: .75rem 0 0; }
.form-status.error, .viewer-status.error { color: #fda4af; }
.form-status.success { color: var(--live-text); }

.section-heading-row, .subheading-row, .viewer-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.section-heading-row { margin-bottom: .85rem; }
.section-heading-row h2 { margin-bottom: 0; }
.count-label { color: var(--text-muted); font-size: .72rem; }
.saved-packages { display: grid; gap: .7rem; }
.empty-state { margin: 1rem 0; color: var(--text-muted); font-size: .85rem; }
.package-card { border: 1px solid var(--offline-border); border-radius: .5rem; padding: .85rem; background: rgba(20, 29, 46, .75); }
.package-card h3 { margin-bottom: .25rem; font-size: 1rem; }
.package-scope, .package-time { margin: 0; color: var(--text-dim); font-size: .75rem; }
.package-time { margin-top: .45rem; color: var(--offline-warning); }
.package-stats { display: flex; flex-wrap: wrap; gap: .35rem .8rem; margin: .7rem 0; color: var(--text-dim); font-size: .72rem; }
.package-actions { display: flex; flex-wrap: wrap; gap: .45rem; }

.viewer { margin-top: 1rem; }
.viewer-heading { align-items: flex-start; }
.viewer-meta { margin: .8rem 0 .35rem; }
.viewer-status { min-height: 1.2rem; margin-bottom: 1rem; }
.viewer-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 1rem; }
.map-panel, .locations-panel { min-width: 0; }
.subheading-row { margin-bottom: .6rem; }

.offline-map-canvas {
  position: relative;
  min-height: 18rem;
  overflow: hidden;
  border: 1px solid var(--offline-border);
  border-radius: .5rem;
  background-color: #0d1724;
  background-image: linear-gradient(rgba(34, 211, 238, .08) 1px, transparent 1px), linear-gradient(90deg, rgba(34, 211, 238, .08) 1px, transparent 1px);
  background-size: 2rem 2rem;
}
.offline-map-canvas::after { position: absolute; inset: 0; border: 1px solid rgba(34, 211, 238, .09); content: ''; pointer-events: none; }
.map-empty { display: grid; min-height: 18rem; place-items: center; padding: 1.5rem; color: var(--text-dim); text-align: center; font-size: .85rem; }
.map-pin {
  position: absolute;
  width: .85rem;
  height: .85rem;
  border: 2px solid #06242a;
  border-radius: 50% 50% 50% 0;
  background: var(--primary);
  box-shadow: 0 0 0 .25rem rgba(34, 211, 238, .18), 0 4px 14px rgba(0, 0, 0, .4);
  transform: translate(-50%, -100%) rotate(-45deg);
}
.map-pin-label { position: absolute; transform: translate(.7rem, -.95rem); color: var(--text); font-size: .68rem; white-space: nowrap; }

.saved-locations { display: grid; gap: .55rem; max-height: 24rem; overflow: auto; }
.location-card { border-left: 2px solid var(--primary); padding: .7rem .8rem; background: rgba(20, 29, 46, .65); }
.location-card h4 { margin: 0 0 .3rem; font-family: 'Space Grotesk', sans-serif; font-size: .9rem; }
.location-card p { margin: .18rem 0; color: var(--text-dim); font-size: .76rem; line-height: 1.45; }
.location-type { color: var(--primary); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; }
.network-dependent { color: var(--text-muted); font-size: .7rem; }
.location-empty { color: var(--text-muted); font-size: .82rem; }

.app-footer { border-top: 1px solid var(--border); padding: 1rem 1.25rem; color: var(--text-muted); text-align: center; font-size: .72rem; }

@media (max-width: 760px) {
  .title-row { display: block; }
  .connection-badge { margin-top: 1rem; }
  .workspace-grid, .viewer-grid { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
  .offline-main { padding-top: 1.5rem; }
  .field-grid { grid-template-columns: 1fr; }
  .viewer-heading { display: grid; }
  .cached-badge { width: fit-content; }
  .offline-map-canvas, .map-empty { min-height: 14rem; }
}
