:root {
    --bg: #10190F;
    --panel: #1B2519;
    --panel-hair: #33422F;
    --ink: #EEEBDE;
    --ink-dim: #A9B3A2;
    --amber: #C97A34;
    --sage: #8FA283;
    --alert: #C1453B;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; }
  body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    overflow: hidden;
  }
  #app { display: flex; height: 100%; width: 100%; }
  #map { flex: 1; height: 100%; }
  .leaflet-container { background: var(--bg); }

  #sidebar {
    width: 300px;
    min-width: 300px;
    background: var(--panel);
    border-right: 1px solid var(--panel-hair);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  #sidebar-header {
    padding: 20px 18px 14px;
    border-bottom: 1px solid var(--panel-hair);
  }
  #sidebar-header h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 19px;
    margin: 0 0 2px;
    letter-spacing: 0.01em;
  }
  #sidebar-header p {
    margin: 0;
    font-size: 12.5px;
    color: var(--ink-dim);
  }

  #tracker-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
  }
  .tracker-row {
    padding: 14px 18px;
    border-bottom: 1px solid var(--panel-hair);
    cursor: pointer;
    transition: background 0.15s ease;
  }
  .tracker-row:hover { background: #212D1E; }
  .tracker-row.selected { background: #26331F; }
  .tracker-top {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 8px;
  }
  .swatch {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .tracker-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14.5px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tracker-status {
    font-size: 10.5px;
    text-transform: lowercase;
    padding: 2px 7px;
    border-radius: 3px;
    color: var(--ink);
    background: #33422F;
    letter-spacing: 0.02em;
  }
  .tracker-status.ended { background: #3A2624; color: #E0958D; }
  .tracker-status.error { background: #3A2624; color: #E0958D; }
  .tracker-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
  }
  .stat-num {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 17px;
    line-height: 1.1;
  }
  .stat-label {
    font-size: 10.5px;
    color: var(--ink-dim);
    margin-top: 1px;
  }
  .tracker-meta {
    margin-top: 8px;
    font-size: 11px;
    color: var(--ink-dim);
    display: flex;
    justify-content: space-between;
  }
  .remove-btn {
    background: none;
    border: none;
    color: var(--ink-dim);
    cursor: pointer;
    font-size: 11px;
    padding: 0;
    text-decoration: underline;
  }
  .remove-btn:hover { color: var(--alert); }

  #empty-state {
    padding: 40px 22px;
    color: var(--ink-dim);
    font-size: 13.5px;
    line-height: 1.6;
  }

  #sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--panel-hair);
    font-size: 11px;
    color: var(--ink-dim);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  #sidebar-footer button {
    background: none;
    border: none;
    color: var(--sage);
    cursor: pointer;
    font-size: 11px;
    text-decoration: underline;
  }

  #fab {
    position: absolute;
    bottom: 22px;
    right: 22px;
    width: 54px; height: 54px;
    border-radius: 50%;
    background: var(--amber);
    color: #10190F;
    border: none;
    font-size: 28px;
    font-family: var(--font-display);
    cursor: pointer;
    box-shadow: 0 3px 14px rgba(0,0,0,0.4);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
  }
  #fab:hover { filter: brightness(1.08); }

  #sheet-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: none;
  }
  #sheet-backdrop.open { display: block; }
  #sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%) translateY(100%);
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--panel-hair);
    border-bottom: none;
    border-radius: 14px 14px 0 0;
    padding: 22px 20px 26px;
    z-index: 2001;
    transition: transform 0.25s ease;
  }
  #sheet-backdrop.open #sheet { transform: translateX(-50%) translateY(0); }
  #sheet h2 {
    font-family: var(--font-display);
    font-size: 17px;
    margin: 0 0 16px;
  }
  .field { margin-bottom: 14px; }
  .field label {
    display: block;
    font-size: 11.5px;
    color: var(--ink-dim);
    margin-bottom: 5px;
  }
  .field input {
    width: 100%;
    background: #10190F;
    border: 1px solid var(--panel-hair);
    color: var(--ink);
    padding: 10px 11px;
    border-radius: 6px;
    font-size: 13.5px;
    font-family: var(--font-body);
  }
  .field input:focus {
    outline: none;
    border-color: var(--amber);
  }
  .field-hint {
    font-size: 10.5px;
    color: var(--ink-dim);
    margin-top: 4px;
    line-height: 1.4;
  }
  .sheet-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
  }
  .btn {
    flex: 1;
    padding: 11px;
    border-radius: 6px;
    border: none;
    font-size: 13.5px;
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
  }
  .btn-primary { background: var(--amber); color: #10190F; }
  .btn-secondary { background: transparent; color: var(--ink-dim); border: 1px solid var(--panel-hair); }
  #sheet-error {
    color: var(--alert);
    font-size: 12px;
    margin-top: 10px;
    display: none;
  }

  .runner-marker {
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2.5px solid var(--bg);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
  }
  .runner-label {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 11px;
    background: rgba(16,25,15,0.88);
    color: var(--ink);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    transform: translateY(-26px);
    border: 1px solid var(--panel-hair);
  }

  @media (max-width: 720px) {
    #sidebar { position: absolute; z-index: 900; height: 40%; width: 100%; min-width: 0; bottom: 0; border-right: none; border-top: 1px solid var(--panel-hair); }
    #map { height: 100%; }
  }
