/* ─── CSS Custom Properties ─────────────────────────────────────────────── */
:root {
  --green-dark:   #1e5631;
  --green:        #27ae60;
  --green-mid:    #2ecc71;
  --green-light:  #eafaf1;
  --green-faint:  #f2fdf6;
  --amber:        #e67e22;
  --amber-light:  #fef9e7;
  --red:          #e74c3c;
  --red-light:    #fdf2f2;
  --blue:         #2980b9;
  --blue-light:   #ebf5fb;
  --purple:       #8e44ad;
  --surface:      #ffffff;
  --surface-alt:  #f8f9fa;
  --border:       #e2e8e4;
  --border-light: #f0f4f1;
  --text:         #1a2e1e;
  --text-mid:     #3d5440;
  --muted:        #6b8c72;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
  --shadow:       0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg:    0 4px 20px rgba(0,0,0,0.13);
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    16px;
  --nav-h:        60px;
  --header-h:     52px;
  --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition:   0.18s ease;
}

/* ─── Reset & Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--surface-alt);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: var(--green); text-decoration: none; }

/* ─── App Shell ─────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

/* ─── Header ────────────────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--green-dark);
  color: #fff;
  flex-shrink: 0;
  z-index: 10;
}
.app-header__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.app-header__logo-icon { font-size: 1.4rem; }
.app-header__actions   { display: flex; gap: 8px; align-items: center; }
.header-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background var(--transition);
}
.header-btn:hover { background: rgba(255,255,255,0.25); }
.header-btn--icon { padding: 6px 8px; font-size: 1rem; }

/* ─── Screen Container ──────────────────────────────────────────────────── */
.screens { flex: 1; overflow: hidden; position: relative; }
.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.screen.active { opacity: 1; pointer-events: auto; }

/* ─── Bottom Nav ────────────────────────────────────────────────────────── */
.bottom-nav {
  height: var(--nav-h);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 6px 4px 8px;
  transition: color var(--transition);
  position: relative;
}
.nav-btn__icon { font-size: 1.35rem; line-height: 1; }
.nav-btn.active { color: var(--green); }
.nav-btn.active::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--green);
  border-radius: 0 0 2px 2px;
}
.nav-btn--builder.active { color: var(--amber); }
.nav-btn--builder.active::before { background: var(--amber); }

/* ─── Section Headers ───────────────────────────────────────────────────── */
.section-header {
  padding: 16px 16px 8px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.section-title  { font-size: 1.1rem; font-weight: 700; }
.section-sub    { font-size: 0.78rem; color: var(--muted); }
.section-action { font-size: 0.8rem; color: var(--green); font-weight: 600; background: none; border: none; }

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.card--pad    { padding: 14px 16px; }
.card--shadow { box-shadow: var(--shadow-sm); }

/* ─── HOME SCREEN ───────────────────────────────────────────────────────── */
#screen-home { background: var(--green-faint); }

.home-weather {
  background: linear-gradient(135deg, var(--green-dark) 0%, #2d6a4f 100%);
  color: #fff;
  padding: 16px;
  margin: 12px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.weather-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.weather-location { font-size: 0.78rem; opacity: 0.8; margin-bottom: 2px; }
.weather-temp     { font-size: 2.6rem; font-weight: 700; line-height: 1; }
.weather-desc     { font-size: 0.85rem; opacity: 0.85; margin-top: 2px; }
.weather-icon     { font-size: 3rem; }
.weather-row {
  display: flex;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.2);
}
.weather-stat { font-size: 0.75rem; opacity: 0.85; }
.weather-stat strong { display: block; font-size: 0.95rem; font-weight: 700; }

.watering-banner {
  margin: 0 12px 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 600;
}
.watering-banner--skip  { background: var(--blue-light);  color: var(--blue); }
.watering-banner--water { background: var(--green-light); color: var(--green-dark); }
.watering-banner--alert { background: var(--amber-light); color: var(--amber); }
.watering-banner__icon   { font-size: 1.3rem; flex-shrink: 0; }
.watering-banner__text   { flex: 1; }
.watering-banner__reason { font-size: 0.75rem; font-weight: 400; margin-top: 2px; opacity: 0.8; }

.home-alerts { margin: 0 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.alert-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
}
.alert-chip--warning { background: var(--amber-light); color: #7d5a00; }
.alert-chip--danger  { background: var(--red-light);   color: #8b1a1a; }
.alert-chip--info    { background: var(--blue-light);  color: #1a4a6e; }

.home-tasks { margin: 0 12px 12px; }
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  font-size: 0.85rem;
}
.task-emoji { font-size: 1.1rem; flex-shrink: 0; }
.task-plant { font-weight: 600; }
.task-note  { color: var(--muted); font-size: 0.78rem; }
.task-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-left: auto; }

.forecast-row {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 0 12px 12px;
  scrollbar-width: none;
}
.forecast-row::-webkit-scrollbar { display: none; }
.forecast-day {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  min-width: 60px;
}
.forecast-day__name { font-weight: 600; color: var(--muted); }
.forecast-day__icon { font-size: 1.4rem; }
.forecast-day__hi   { font-weight: 700; color: #c0392b; }
.forecast-day__lo   { color: var(--blue); }
.forecast-day__rain { color: var(--blue); font-size: 0.7rem; }
.forecast-day.today { border-color: var(--green); background: var(--green-light); }

/* ─── GARDEN SCREEN ─────────────────────────────────────────────────────── */
#screen-garden { display: flex; flex-direction: column; background: var(--surface-alt); }

.garden-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.garden-toolbar::-webkit-scrollbar { display: none; }
.tool-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-mid);
  white-space: nowrap;
  transition: all var(--transition);
}
.tool-btn:hover  { border-color: var(--green); color: var(--green); }
.tool-btn.active { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }
.tool-sep        { width: 1px; height: 24px; background: var(--border); flex-shrink: 0; }

.garden-canvas-wrap {
  flex: 1;
  overflow: auto;
  padding: 12px;
  background: var(--surface-alt);
  position: relative;
}
#garden-canvas {
  display: block;
  cursor: crosshair;
  border-radius: var(--radius-sm);
  touch-action: none;
}

.garden-statusbar {
  padding: 6px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}
.statusbar-item strong { color: var(--text); }

/* Plant picker */
.plant-picker {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 12px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
  z-index: 20;
  max-height: 60%;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.plant-picker.open { transform: translateY(0); }
.picker-handle-row {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 12px;
  cursor: ns-resize;
  touch-action: none;
}
.picker-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.picker-shrink-btn {
  position: absolute;
  right: 0; top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}
.picker-shrink-btn:hover { background: var(--green-light); border-color: var(--green); }
.plant-picker.shrunk {
  max-height: 88px !important;
  overflow: hidden;
}

/* Under-grid plant list */
.garden-plant-list {
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.garden-plant-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.garden-plant-list__badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--green-light);
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 700;
}
.garden-plant-list__caret {
  transition: transform 0.2s ease;
  color: var(--muted);
}
.garden-plant-list.collapsed .garden-plant-list__caret { transform: rotate(-90deg); }
.garden-plant-list.collapsed .garden-plant-list__body { display: none; }
.garden-plant-list__body {
  max-height: 160px;
  overflow-y: auto;
  padding: 0 10px 10px;
}
.plant-list-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.plant-list-row:last-child { border-bottom: none; }
.plant-list-row__emoji { font-size: 1.05rem; }
.plant-list-row__name { flex: 1; color: var(--text); }
.plant-list-row__count { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.plant-list-row__locate {
  border: none;
  background: transparent;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 2px 4px;
}
.plant-list-empty {
  padding: 12px 4px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* Planted-date field in plant info panel */
.plant-info-date-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  font-size: 0.85rem;
  color: var(--muted);
}
.plant-info-date-row label { flex-shrink: 0; }
.plant-info-date-row input[type="date"] {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.85rem;
}

.picker-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 10px;
  background: var(--surface-alt);
}
.picker-qty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px 10px;
  font-size: 0.82rem;
}
.picker-qty-label { color: var(--muted); flex: 1; }
.qty-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.qty-btn:hover { background: var(--green-light); border-color: var(--green); }
#qty-value { font-weight: 700; font-size: 1rem; min-width: 20px; text-align: center; }

.picker-categories {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 10px;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.picker-categories::-webkit-scrollbar { display: none; }
.cat-pill {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.cat-pill.active { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }

.plant-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.plant-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  cursor: grab;
  font-size: 0.7rem;
  text-align: center;
  color: var(--text-mid);
  transition: all var(--transition);
  user-select: none;
}
.plant-chip:active     { cursor: grabbing; transform: scale(0.96); }
.plant-chip__emoji     { font-size: 1.6rem; }
.plant-chip__name      { font-weight: 600; line-height: 1.2; }
.plant-chip__space     { color: var(--muted); font-size: 0.65rem; }

/* Selected plant info */
.plant-info-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.1);
  z-index: 15;
  display: none;
}
.plant-info-panel.visible    { display: block; }
.plant-info-panel__header    { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.plant-info-panel__name      { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 700; }
.plant-info-panel__zone      { font-size: 0.75rem; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.zone-green       { background: #eafaf1; color: #1e5631; }
.zone-orange      { background: #fef9e7; color: #7d5a00; }
.zone-deep_orange { background: #fdf2e9; color: #a04000; }
.zone-red         { background: var(--red-light); color: #8b1a1a; }
.plant-info-stats { display: flex; gap: 16px; font-size: 0.78rem; color: var(--muted); margin-bottom: 12px; }
.plant-info-stats span strong { color: var(--text); display: block; font-size: 0.85rem; }
.plant-info-actions { display: flex; gap: 8px; }
.info-btn         { flex: 1; padding: 8px; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 600; border: 1px solid var(--border); background: var(--surface-alt); color: var(--text-mid); }
.info-btn--danger { border-color: var(--red); color: var(--red); background: var(--red-light); }
.variety-select   { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.82rem; background: var(--surface-alt); margin-bottom: 8px; }

/* ─── PLANTS SCREEN ─────────────────────────────────────────────────────── */
#screen-plants { background: var(--surface-alt); }
.plants-search-bar {
  display: flex; gap: 8px; padding: 10px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.plants-search-bar input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.88rem; background: var(--surface-alt);
}
.plants-filter-btn {
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-alt); font-size: 0.85rem;
}
.plant-list { padding: 8px 12px; }
.plant-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 8px;
  overflow: hidden; cursor: pointer; transition: box-shadow var(--transition);
}
.plant-card:hover            { box-shadow: var(--shadow); }
.plant-card__header          { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.plant-card__emoji           { font-size: 2rem; flex-shrink: 0; }
.plant-card__info            { flex: 1; min-width: 0; }
.plant-card__name            { font-weight: 700; font-size: 0.95rem; }
.plant-card__cat             { font-size: 0.72rem; color: var(--muted); text-transform: capitalize; }
.plant-card__badges          { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.badge                       { font-size: 0.65rem; font-weight: 600; padding: 2px 6px; border-radius: 10px; }
.badge--sun-full             { background: #fef9e7; color: #7d5a00; }
.badge--sun-partial          { background: #eaf4fb; color: #1a4a6e; }
.badge--water-high           { background: #ebf5fb; color: #1a4a6e; }
.badge--water-med            { background: #e8f8f5; color: #0e6655; }
.badge--water-low            { background: #f9f9f9; color: #555; }
.badge--frost                { background: #ebf5fb; color: #1a4a6e; }
.badge--agri-excellent       { background: #eafaf1; color: #1e5631; }
.badge--agri-good            { background: #e9f7ef; color: #1e5631; }
.plant-card__body            { padding: 0 14px 12px; font-size: 0.8rem; color: var(--muted); display: none; border-top: 1px solid var(--border-light); }
.plant-card.expanded .plant-card__body { display: block; }
.plant-detail-grid           { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 10px 0; }
.detail-item                 { font-size: 0.78rem; }
.detail-item strong          { display: block; color: var(--text); font-size: 0.82rem; }
.companions-row, .antagonists-row { margin-top: 8px; font-size: 0.78rem; }
.companion-tag               { display: inline-block; margin: 2px; padding: 2px 7px; border-radius: 10px; font-size: 0.7rem; font-weight: 600; }
.companion-tag--good         { background: var(--green-light); color: var(--green-dark); }
.companion-tag--bad          { background: var(--red-light); color: var(--red); }
.varieties-list              { margin-top: 8px; }
.variety-item                { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border-light); font-size: 0.78rem; }
.variety-item:last-child     { border-bottom: none; }
.variety-item__name          { font-weight: 600; }
.variety-item__days          { color: var(--muted); }
.variety-btn                 { padding: 3px 10px; border: 1px solid var(--green); border-radius: 20px; background: none; color: var(--green); font-size: 0.72rem; font-weight: 600; }

/* ─── SCHEDULE SCREEN ───────────────────────────────────────────────────── */
#screen-schedule { background: var(--surface); }
.schedule-frost-banner {
  margin: 10px 12px 0; padding: 8px 12px;
  background: var(--amber-light); border-radius: var(--radius-sm);
  font-size: 0.8rem; color: #7d5a00; display: flex; gap: 8px; align-items: center;
}

/* ─── SETTINGS SCREEN ───────────────────────────────────────────────────── */
#screen-settings { background: var(--surface-alt); padding-bottom: 24px; }
.settings-section        { margin: 12px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.settings-section__title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 14px 6px; }
.settings-row            { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px; border-top: 1px solid var(--border-light); font-size: 0.88rem; }
.settings-row:first-of-type { border-top: none; }
.settings-row__label     { color: var(--text); }
.settings-row__sub       { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.settings-input          { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; max-width: 140px; text-align: right; background: var(--surface-alt); }
.settings-toggle         { position: relative; width: 44px; height: 24px; cursor: pointer; }
.settings-toggle input   { opacity: 0; width: 0; height: 0; }
.toggle-track            { position: absolute; inset: 0; background: var(--border); border-radius: 12px; transition: background var(--transition); }
.toggle-thumb            { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: var(--shadow-sm); transition: transform var(--transition); }
.settings-toggle input:checked ~ .toggle-track { background: var(--green); }
.settings-toggle input:checked ~ .toggle-thumb { transform: translateX(20px); }
.settings-btn            { width: 100%; padding: 12px; border: none; background: none; font-size: 0.88rem; color: var(--green); font-weight: 600; text-align: left; padding-left: 14px; }
.settings-btn--danger    { color: var(--red); }
.size-inputs             { display: flex; align-items: center; gap: 8px; }
.size-inputs input       { width: 60px; text-align: center; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; }
.size-inputs span        { color: var(--muted); font-size: 0.8rem; }

/* ─── Builder Screen ────────────────────────────────────────────────────── */
#screen-builder { background: var(--surface); }
#screen-builder .builder-wrap { height: 100%; }

/* ─── Toast ─────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: calc(var(--nav-h) + 12px); left: 50%;
  transform: translateX(-50%); z-index: 100;
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none; width: calc(100% - 32px); max-width: 400px;
}
.toast {
  padding: 10px 14px; border-radius: var(--radius); font-size: 0.85rem;
  font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.5s forwards;
  pointer-events: auto;
}
.toast--success { background: var(--green-dark); color: #fff; }
.toast--error   { background: var(--red);        color: #fff; }
.toast--info    { background: var(--blue);        color: #fff; }
.toast--warning { background: var(--amber);       color: #fff; }
@keyframes toast-in  { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; } }

/* ─── Loading / Empty ───────────────────────────────────────────────────── */
.spinner { width:32px; height:32px; border:3px solid var(--border); border-top-color:var(--green); border-radius:50%; animation:spin 0.7s linear infinite; margin:32px auto; }
@keyframes spin { to { transform:rotate(360deg); } }
.loading-state { display:flex; flex-direction:column; align-items:center; padding:40px 20px; color:var(--muted); font-size:0.85rem; gap:12px; }
.empty-state   { text-align:center; padding:40px 24px; color:var(--muted); }
.empty-state__icon  { font-size:3rem; margin-bottom:12px; }
.empty-state__title { font-size:1rem; font-weight:700; color:var(--text); margin-bottom:6px; }
.empty-state__sub   { font-size:0.85rem; margin-bottom:16px; }
.empty-state__btn   { padding:10px 24px; background:var(--green); color:#fff; border:none; border-radius:var(--radius); font-size:0.9rem; font-weight:600; }

/* ─── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:50;
  display:flex; align-items:flex-end; justify-content:center;
  opacity:0; pointer-events:none; transition:opacity 0.25s;
}
.modal-overlay.open { opacity:1; pointer-events:auto; }
.modal {
  background:var(--surface); border-radius:var(--radius-lg) var(--radius-lg) 0 0;
  padding:20px 16px 32px; width:100%; max-width:480px; max-height:85vh;
  overflow-y:auto; transform:translateY(40px);
  transition:transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.modal-overlay.open .modal { transform:none; }
.modal__handle { width:36px; height:4px; background:var(--border); border-radius:2px; margin:0 auto 16px; }
.modal__title  { font-size:1.05rem; font-weight:700; margin-bottom:12px; }

/* ─── Utility ───────────────────────────────────────────────────────────── */
.hidden  { display:none !important; }
.flex    { display:flex; }
.gap-8   { gap:8px; }
.gap-12  { gap:12px; }
.p-12    { padding:12px; }
.p-16    { padding:16px; }
.mt-8    { margin-top:8px; }
.mt-12   { margin-top:12px; }
.text-sm { font-size:0.82rem; }
.text-xs { font-size:0.72rem; }
.muted   { color:var(--muted); }
.bold    { font-weight:700; }
.center  { text-align:center; }
.w-full  { width:100%; }

::-webkit-scrollbar       { width:4px; height:4px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:2px; }

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav { padding-bottom:env(safe-area-inset-bottom); height:calc(var(--nav-h) + env(safe-area-inset-bottom)); }
}

/* ─── Compass & Companion ───────────────────────────────────────────────── */
.companion-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 55%;
  overflow-y: auto;
  z-index: 18;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
  padding-bottom: 12px;
}
.companion-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.companion-close {
  background: var(--surface-alt);
  border: none;
  border-radius: 50%;
  width: 26px; height: 26px;
  font-size: 0.85rem;
  color: var(--muted);
}
.companion-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.82rem;
}
.companion-item:last-child { border-bottom: none; }
.companion-item__name { font-weight: 700; margin-bottom: 4px; }
.companion-tag-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.comp-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
}
.comp-tag--good    { background: var(--green-light); color: var(--green-dark); }
.comp-tag--bad     { background: var(--red-light);   color: var(--red); }
.comp-tag--missing { background: var(--surface-alt); color: var(--muted); border: 1px dashed var(--border); }

/* Zone legend */
.zone-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 0.68rem;
  flex-shrink: 0;
}
.zone-legend-item { display: flex; align-items: center; gap: 3px; }
.zone-dot { width: 10px; height: 10px; border-radius: 2px; border: 1px solid rgba(0,0,0,0.15); }

/* North picker */
.north-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.north-btn {
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  font-size: 0.88rem;
  font-weight: 500;
  text-align: center;
  transition: all var(--transition);
}
.north-btn:hover  { border-color: var(--green); background: var(--green-light); }
.north-btn.active { border-color: var(--blue,#2980b9); background: #ebf5fb; color: var(--blue,#2980b9); font-weight: 700; }
