:root {
  /* Colors */
  --bg-app: #09090b;
  --bg-card: #1c1c1e;
  --bg-card-hover: #27272a;
  --bg-elevated: #2c2c2e;
  
  --text-main: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  
  --accent-red: #ef4444;
  --accent-green: #10b981;
  --accent-blue: #3b82f6;
  --accent-orange: #f59e0b;
  
  --border-subtle: #27272a;
  --border-highlight: #3f3f46;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  
  /* Radius */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  padding-bottom: 100px; /* Space for bottom nav */
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p {
  margin: 0;
}

/* Utilities */
.container {
  max-width: 600px; /* Constrain width to look like mobile app on desktop, as per screenshot vibe */
  margin: 0 auto;
  padding: var(--space-md);
  width: 100%;
}

@media (min-width: 768px) {
  .container {
    max-width: 900px; /* Allow wider layout on tablet/desktop */
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    align-items: start;
  }
  
  .full-width-on-desktop {
    grid-column: 1 / -1;
  }
  
  .col-1 {
    grid-column: 1;
  }
  
  .col-2 {
    grid-column: 2;
  }
}

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent-red { color: var(--accent-red); }
.text-accent-green { color: var(--accent-green); }
.text-accent-blue { color: var(--accent-blue); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.uppercase { text-transform: uppercase; letter-spacing: 0.05em; }

.flex { display: flex; }
.flex-col { display: flex; flexDirection: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

/* Components */

/* Header */
.app-header {
  padding: var(--space-md) 0;
  margin-bottom: var(--space-md);
}
.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--text-main);
  text-transform: uppercase;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  position: relative;
  overflow: hidden;
}

/* Alert Card */
.alert-card {
  background-color: var(--bg-card-hover);
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  margin-bottom: var(--space-md);
}
.alert-icon {
  color: #fbbf24; /* Amber for warning/lightbulb */
  flex-shrink: 0;
}

/* Dashboard Section */
.dashboard-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

/* Compass */
.compass-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
}
.compass-ring {
  width: 100%;
  max-width: 120px;
  height: auto;
  position: relative;
}
.compass-value {
  margin-top: var(--space-sm);
  text-align: center;
}
.compass-degrees {
  font-size: 1.5rem;
  font-weight: 700;
}
.compass-direction {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Stats List */
.stats-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 0.8rem;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
.stat-label {
  color: var(--text-secondary);
}
.stat-value {
  font-weight: 600;
  text-align: right;
}

/* Step Card */
.step-card {
  margin-bottom: var(--space-md);
  background: var(--bg-elevated);
}
.step-header {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-sm);
}
.step-content {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: var(--space-md);
}
.step-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.btn-nav {
  background: var(--bg-card);
  border: 1px solid var(--border-highlight);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-nav:hover {
  background: var(--border-highlight);
}

/* Main Grid Nav */
.nav-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
.nav-tile {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  cursor: pointer;
  transition: transform 0.2s, background-color 0.2s;
  aspect-ratio: 3/2;
}
.nav-tile:hover {
  background-color: var(--bg-card-hover);
  transform: translateY(-2px);
}
.nav-tile svg {
  width: 32px;
  height: 32px;
  color: var(--text-main);
}
.nav-label {
  font-weight: 600;
  font-size: 1rem;
}

/* Quick Tools */
.section-title {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  text-align: center;
  font-weight: 600;
}
.quick-tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.tool-btn {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  aspect-ratio: 1/1;
  cursor: pointer;
}
.tool-btn:hover {
  background-color: var(--bg-card-hover);
}
.tool-btn svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}
.tool-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(9, 9, 11, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-sm) var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: flex-end; /* Align to bottom so SOS button can stick up */
  z-index: 100;
  padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.7rem;
  flex: 1;
  padding: 8px 0;
}

.nav-item.active {
  color: var(--text-main);
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.sos-btn-container {
  flex: 1;
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.sos-btn {
  background-color: var(--accent-red);
  color: white;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  font-weight: 800;
  font-size: 0.7rem;
  border: none;
  cursor: pointer;
  position: relative;
  top: -10px; /* Popped up slightly */
}
.sos-btn svg {
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
}
