/* ---------- Color and spacing tokens ---------- */
/* Garden-journal look: warm paper, forest green ink, terracotta and mustard accents,
   a serif for headings (Fraunces) and a friendly sans for everything else. */
:root {
  --bg: #f4eedf;          /* paper */
  --panel: #fffcf4;       /* cards */
  --text: #26331f;        /* forest ink */
  --muted: #7a6f5d;
  --border: #e3d8bf;
  --accent: #2e4a2b;      /* forest green */
  --accent-hover: #233a21;
  --accent-soft: #e8ead6;
  --terracotta: #c8663a;
  --mustard: #e3a33a;
  --danger: #b3261e;
  --canvas-bg: #ebe3cd;
  --space-fill: #efe6cf;
  --radius: 12px;
  --sidebar-width: clamp(280px, 30vw, 350px); /* narrower on medium screens, so the plan gets room */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow-card: 0 1px 0 rgba(80, 60, 30, 0.04), 0 2px 10px rgba(80, 60, 30, 0.06);
  font-family: var(--font-ui);
  color: var(--text);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
}

[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.brand { margin: 0; font-size: 1.2rem; color: var(--accent); }

/* Garden switcher */
.garden-switch { position: relative; }
.garden-switch-btn { display: flex; align-items: center; gap: 6px; background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-weight: 600; max-width: 240px; }
.garden-switch-btn:hover, .garden-switch-btn[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); }
#garden-switch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.garden-switch-btn .caret { color: var(--muted); font-size: 0.75rem; }
.garden-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; width: 300px; max-width: calc(100vw - 24px); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16); padding: 8px; }
.garden-menu-head { margin: 2px 6px 6px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.garden-menu-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.garden-option { display: grid; grid-template-columns: 22px 1fr; gap: 2px 8px; align-items: center; width: 100%; text-align: left; background: none; color: inherit; border: 0; border-radius: 8px; padding: 7px 8px; font-weight: 400; }
.garden-option:hover { background: var(--accent-soft); }
.garden-option.active { background: var(--accent-soft); }
.garden-option .check { grid-row: span 2; color: var(--accent); font-weight: 700; text-align: center; }
.garden-option .g-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.garden-option .g-meta { font-size: 0.75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.garden-menu-actions { display: flex; flex-direction: column; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.garden-menu-actions button { background: none; color: var(--text); border: 0; text-align: left; padding: 6px 8px; border-radius: 6px; font-weight: 500; }
.garden-menu-actions button:hover:not(:disabled) { background: var(--accent-soft); }
.garden-menu-actions button:disabled { color: var(--muted); opacity: 0.6; }
.garden-menu-actions .danger-text { color: #b3261e; }
.garden-menu-note { margin: 6px 8px 2px; }

/* Calendar: this garden / all gardens */
.cal-scope { display: inline-flex; align-self: flex-start; width: fit-content; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: #fff; margin-bottom: 12px; }
.cal-scope button { border: 0; border-radius: 0; background: none; color: var(--text); padding: 6px 14px; font-weight: 500; }
.cal-scope button + button { border-left: 1px solid var(--border); }
.cal-scope button.active { background: var(--accent); color: #fff; }
.tl-garden { margin: 14px 0 4px; padding-top: 8px; border-top: 1px solid var(--border); font-weight: 700; font-size: 0.9rem; color: var(--accent); }

/* All gardens on the map */
.map-gardens { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.map-gardens h3 { margin: 0 0 6px; font-size: 0.85rem; }
.map-garden-list { list-style: none; margin: 0; padding: 0; }
.map-garden-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 0.85rem; }
.map-garden-list .link-btn { padding: 0 2px; }
.map-garden-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.map-garden-dot { width: 12px; height: 12px; border-radius: 50%; background: #3f7d2c; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); flex: none; }
.map-garden-dot.active { background: #b3261e; }
.garden-pin-popup { font: 13px/1.4 system-ui, sans-serif; }
.garden-pin-popup button { margin-top: 6px; padding: 4px 10px; font-size: 0.8rem; }

.tabs { display: flex; gap: 4px; margin-right: auto; }
.tab {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
}
.tab:hover { background: var(--accent-soft); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.units { display: flex; }
.units button {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
  padding: 4px 10px;
}
.units button:first-child { border-radius: 6px 0 0 6px; }
.units button:last-child { border-radius: 0 6px 6px 0; border-left: none; }
.units button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Views: sidebar on the left, work area fills the rest ---------- */
.view {
  flex: 1;
  min-height: 0;
  display: flex;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; }

/* A small "+" in the middle of the map, for "set location to map center" */
.map-crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  z-index: 500;
  pointer-events: none;
  background:
    linear-gradient(#fff, #fff) center / 2px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 2px no-repeat;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.9));
}

.location-line { margin: 0 0 8px; }
.location-line .link-btn { padding: 0 0 0 6px; font-size: inherit; }
.send-head { margin-top: 14px !important; font-size: 0.9rem !important; }

/* On phones, stack the work area on top and the sidebar below it */
@media (max-width: 640px) {
  body { height: auto; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .view { flex-direction: column; }
  .map-wrap { height: 60vh; flex: none; }
  .sidebar { width: 100%; border-right: none; border-top: 1px solid var(--border); order: 2; }
  .statusbar #mode-hint { display: none; }
}

/* ---------- Sidebar pieces ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.panel h2 { margin: 0 0 8px; font-size: 1rem; }
.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0 8px;
}
#total-area { width: 100%; margin: -4px 0 8px; font-size: 0.8rem; }
#total-area:empty { display: none; }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.status { margin: 6px 0 0; font-size: 0.85rem; color: var(--muted); min-height: 1em; }
.readout { margin: 4px 0 6px; font-size: 0.9rem; }
.error { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; margin: 8px 0 0; }

/* ---------- Form controls ---------- */
input, select, textarea, button { font: inherit; }

input[type="text"], input[type="search"], input[type="number"], select, textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 10px;
}
label > input, label > select, label > textarea, label > .unit-input { margin-top: 4px; font-weight: 400; }

/* A number box with its unit ("ft" or "m") shown on the right */
.unit-input { display: flex; align-items: center; gap: 6px; }
.unit-input input { flex: 1; min-width: 0; }
.unit-label:empty { display: none; }
input.length-input { font-variant-numeric: tabular-nums; }
input.length-input.invalid { border-color: #c0392b; background: #fdf0ee; }
.unit-label { color: var(--muted); font-weight: 400; min-width: 1.4em; }

button {
  padding: 7px 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.45; cursor: default; }
button.secondary { background: #fff; color: var(--accent); }
button.secondary:hover { background: var(--accent-soft); }
button.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #fdecea; }
button.big { padding: 10px 12px; font-weight: 600; }

.link-btn, .icon-btn {
  background: none;
  border: none;
  color: var(--accent);
  padding: 4px 0;
}
.link-btn:hover, .icon-btn:hover { background: none; text-decoration: underline; }
.icon-btn { font-size: 1.3rem; line-height: 1; color: var(--muted); }

.search { display: flex; gap: 6px; }
.search input { flex: 1; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* ---------- Lists of plots / beds ---------- */
.plot-list { list-style: none; margin: 0; padding: 0; }
.plot-list li + li { margin-top: 4px; }

.plot-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.plot-item:hover { background: var(--accent-soft); }
.plot-item.selected { border-color: var(--accent); background: var(--accent-soft); }

.swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.plot-item-text { display: flex; flex-direction: column; min-width: 0; }
.plot-item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plot-item-meta { font-size: 0.8rem; color: var(--muted); }

.hint { font-size: 0.85rem; color: var(--muted); margin: 0; }
.hint p { margin: 0 0 4px; color: var(--text); }
.hint ol { margin: 0; padding-left: 18px; }
.hint li + li { margin-top: 3px; }

.area-readout { margin: 0 0 10px; }
.backup { margin-top: auto; }
.backup p { margin: 0 0 8px; }

/* ---------- Map labels ---------- */
.plot-label {
  background: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 4px;
  box-shadow: none;
  padding: 1px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}
.plot-label::before { display: none; }

/* ---------- Garden editor canvas ---------- */
.canvas-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  background: var(--canvas-bg);
  overflow: hidden;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
#canvas:active { cursor: grabbing; }
#canvas.drawing { cursor: crosshair; }

/* Lines stay the same thickness on screen no matter how far you zoom */
#canvas polygon, #canvas path, #canvas polyline, #canvas line, #canvas circle,
.builder-preview polygon, .builder-preview line, .builder-preview circle {
  vector-effect: non-scaling-stroke;
}

/* Textures and plant drawings scale with the plan (they're artwork, not lines) */
#canvas pattern *, #canvas symbol * { vector-effect: none; }

#canvas .space { fill: url(#pat-grass); stroke: none; }
#canvas .space-edge { fill: none; stroke: #6b5a3e; stroke-width: 2; pointer-events: none; }
#canvas .space-edge.selected { stroke: var(--accent); stroke-width: 3; stroke-dasharray: 8 4; }
#canvas .grid-minor { stroke: rgba(70, 60, 35, 0.08); stroke-width: 1; fill: none; pointer-events: none; }
#canvas .grid-major { stroke: rgba(70, 60, 35, 0.2); stroke-width: 1; fill: none; pointer-events: none; }

/* Bed artwork (drawn under the clickable outline) */
#canvas [class^="art-"] { pointer-events: none; }
#canvas .art-shadow { fill: rgba(60, 42, 20, 0.2); stroke: none; }
#canvas .art-shadow.big { fill: rgba(60, 42, 20, 0.24); }
#canvas .art-wood { fill: url(#pat-wood); stroke: #6e4a2c; stroke-width: 1.5; }
#canvas .art-soil { fill: url(#pat-soil); stroke: none; }
#canvas .art-soil.edge { stroke: #7a5a3a; stroke-width: 1.5; stroke-dasharray: 2 3; }
#canvas .art-rows { fill: url(#pat-rows); stroke: #8a6a45; stroke-width: 1; }
#canvas .art-orchard { fill: url(#pat-orchard); stroke: #5f7f45; stroke-width: 1.5; stroke-dasharray: 6 4; }
#canvas .art-gravel { fill: url(#pat-gravel); stroke: #b3a585; stroke-width: 1; }
#canvas .art-path-edge { fill: none; stroke-width: 3; stroke-linejoin: miter; }
#canvas .art-path { stroke: none; }
#canvas .art-roof { fill: url(#pat-roof); stroke: #6b4a3a; stroke-width: 2; }
#canvas .art-glass { fill: url(#pat-glass); stroke: #8fb3a8; stroke-width: 2; }
#canvas .art-canopy { fill: #5f7f45; stroke: #4a6636; stroke-width: 1; }
#canvas .art-canopy-light { fill: #7b9b58; stroke: none; }
#canvas .art-canopy-top { fill: #9ab873; stroke: none; opacity: 0.8; }
#canvas .art-other { fill: rgba(200, 102, 58, 0.18); stroke: var(--terracotta); stroke-width: 1.5; }

/* The clickable outline of each bed */
#canvas .item { fill: transparent; stroke: transparent; stroke-width: 2; cursor: move; }
#canvas .item:hover { fill: rgba(255, 252, 244, 0.12); stroke: rgba(46, 74, 43, 0.55); }
#canvas .item.selected { fill: rgba(227, 163, 58, 0.1); stroke: var(--mustard); stroke-width: 3; }
#canvas.drawing .item { cursor: crosshair; }

#canvas text {
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: #fff;
  stroke-linejoin: round;
  pointer-events: none;
}
#canvas .label { font-family: var(--font-display); font-weight: 600; fill: var(--text); stroke: rgba(255, 252, 244, 0.9); }
#canvas .dim { fill: #1f4e8c; }
#canvas .dim.live { text-anchor: start; }

#canvas .handle { fill: #fff; stroke: var(--accent); stroke-width: 2; cursor: pointer; }
#canvas .handle:hover { fill: var(--accent); }

/* Walkway knobs: "+" past each end and in the middle of each stretch */
#canvas .walk-center { fill: none; stroke: var(--mustard); stroke-width: 1.5; stroke-dasharray: 2 4; pointer-events: none; }
#canvas .walk-knob { cursor: copy; }
#canvas .edge-handle { fill: #fff; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: move; }
#canvas .edge-handle:hover { fill: var(--mustard); stroke: var(--accent-hover); }
#canvas .handle.walk-end { fill: var(--mustard); stroke: #fff; stroke-width: 2.5; cursor: grab; }
#canvas .handle.walk-end:hover { fill: var(--terracotta); }
#canvas .walk-knob circle { fill: var(--panel); stroke: var(--terracotta); stroke-width: 2; }
#canvas .walk-knob path { stroke: var(--terracotta); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
#canvas .walk-knob:hover circle { fill: var(--terracotta); }
#canvas .walk-knob:hover path { stroke: #fff; }

/* Plants: a soft circle showing the room each plant needs */
#canvas .plant circle.pc { fill: rgba(255, 252, 244, 0.01); stroke: rgba(60, 45, 25, 0.22); stroke-width: 1; stroke-dasharray: 2 3; cursor: move; }
#canvas .plant use, #canvas .plant .pa-dot { pointer-events: none; }
#canvas .plant:hover circle.pc { fill: rgba(255, 252, 244, 0.18); stroke: rgba(46, 74, 43, 0.7); }
#canvas .plant.selected circle.pc { stroke: var(--mustard) !important; stroke-width: 2.5; stroke-dasharray: none; fill: rgba(227, 163, 58, 0.12); }
#canvas .plant.crowded circle { stroke: #d0261b !important; stroke-width: 2.5; stroke-dasharray: 4 2; }
#canvas .plant-icon { stroke: none; paint-order: normal; }
#canvas .plant.pair-good circle.pc { stroke: #3fae2a !important; stroke-width: 4; fill-opacity: 0.45; }
#canvas .plant.pair-bad circle.pc { stroke: #d0261b !important; stroke-width: 4; fill-opacity: 0.45; }
#canvas .companion-link { stroke-width: 2.5; stroke-dasharray: 6 4; pointer-events: none; stroke-linecap: round; }
#canvas .companion-link.good { stroke: #3fae2a; }
#canvas .companion-link.bad { stroke: #d0261b; }
#canvas .plant-ghost circle { fill: rgba(63, 125, 44, 0.2); stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 3; pointer-events: none; }
#canvas .plant-ghost.bad circle { fill: rgba(208, 38, 27, 0.15); stroke: #d0261b; }
#canvas .plant-ghost text { opacity: 0.7; }
#canvas.drawing .plant circle { cursor: crosshair; }

#canvas .rot-stem { stroke: var(--accent); stroke-width: 1.5; pointer-events: none; }
#canvas .rot-handle { fill: var(--accent); stroke: #fff; stroke-width: 2; cursor: grab; }
#canvas .rot-handle:hover { fill: var(--accent-hover); }

#canvas .draft { fill: none; stroke: var(--accent); stroke-width: 2; pointer-events: none; }
#canvas .draft-close { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 4; pointer-events: none; }
#canvas .draft-pt { fill: var(--accent); cursor: context-menu; }
#canvas .draft-pt.first { fill: #fff; stroke: var(--accent); stroke-width: 2; }
#canvas .draft-cursor { fill: none; stroke: var(--accent); stroke-width: 1.5; pointer-events: none; }

/* Compass: the needle always points to true north; click to straighten the view */
.compass-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.compass-btn:hover { background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); }
.compass-btn.turned { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.compass-needle {
  position: absolute;
  inset: 6px;
  transition: transform 0.05s linear;
}
.compass-needle::before, .compass-needle::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  transform: translateX(-50%);
}
.compass-needle::before { top: 9px; border-bottom: 13px solid #c62f2f; }  /* north half */
.compass-needle::after { bottom: 9px; border-top: 13px solid #5d6670; }   /* south half */
.compass-n { position: absolute; top: -3px; left: 50%; transform: translateX(-50%); font-size: 0.62rem; font-weight: 800; color: #c62f2f; }

.toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  flex-wrap: wrap;               /* on narrow screens, wrap onto a second line */
  max-width: calc(100% - 84px);  /* (leaving room for the compass) */
}
.tool { background: #fff; color: var(--text); border-color: transparent; padding: 5px 10px; white-space: nowrap; }
.tool:hover { background: var(--accent-soft); }
.tool.active { background: var(--accent); color: #fff; }
.sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 2px; }

.statusbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 5px 12px;
  font-size: 0.8rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.85);
  border-top: 1px solid var(--border);
}
#cursor-pos { min-width: 13em; font-variant-numeric: tabular-nums; }
#mode-hint { flex: 1; }
.snap { display: flex; align-items: center; gap: 5px; margin: 0; font-weight: 400; white-space: nowrap; }

.toast {
  position: absolute;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: var(--radius);
  background: #2c3527;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.toast .link-btn { color: #b9e39e; padding: 0 0 0 6px; }

/* ---------- Plant picker and plant details ---------- */
.plant-palette {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.plant-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  text-align: left;
  min-width: 0;
}
.plant-chip:hover { background: var(--accent-soft); }
.plant-chip.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.plant-chip-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  color: #fff;
  font-weight: 700;
  background-blend-mode: lighten;
}
.plant-chip-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8rem; }
.plant-chip-meta { color: var(--muted); font-size: 0.7rem; }
#plant-search { margin-top: 2px; }
#plant-hint { margin: 6px 0 0; }

.prop-plants { border-top: 1px solid var(--border); margin: 10px 0; padding-top: 10px; }
.prop-plants h3 { margin: 0 0 4px; font-size: 0.9rem; }
.prop-plants p { margin: 0 0 8px; }
.fill-row { display: flex; gap: 6px; }
.fill-row select { flex: 1; min-width: 0; }

.plant-chip.mine .plant-chip-name { font-style: italic; }
.palette-actions { margin-top: 8px; gap: 4px 14px; }
.palette-actions .link-btn { font-size: 0.85rem; padding: 0; }

/* Issue lists (plant details and Garden check) */
.issues { list-style: none; margin: 0 0 10px; padding: 0; font-size: 0.82rem; }
.issue { position: relative; padding: 6px 8px 6px 26px; border-radius: 6px; margin-bottom: 4px; line-height: 1.35; }
.issue::before { position: absolute; left: 8px; top: 6px; font-weight: 700; }
.issue.warn { background: #fdf0e6; color: #7a3a10; }
.issue.warn::before { content: "!"; color: #d9730d; }
.issue.note { background: #eef3f8; color: #2f4a63; }
.issue.note::before { content: "i"; color: #4a7aa8; font-style: italic; }
.issue.ok { background: var(--accent-soft); color: var(--accent); }
.issue.ok::before { content: "✓"; }
.issue.good { background: #eaf5e3; color: #2f5f1f; }
.issue.good::before { content: "✓"; color: #3f8f2c; }
.issues.clickable { max-height: 260px; overflow-y: auto; }
.issues.clickable .issue { cursor: pointer; }
.issues.clickable .issue:hover { filter: brightness(0.96); }

/* Sun & shade layer */
#canvas .shadows polygon { fill: #1d2a3a; stroke: none; pointer-events: none; }
#canvas .shadows { opacity: 0.28; pointer-events: none; }
#canvas .shadows.light { opacity: 0.1; }
#canvas .light-rays { stroke: #e8a317; stroke-width: 1.5; fill: none; opacity: 0.55; pointer-events: none; stroke-linecap: round; stroke-linejoin: round; }
#canvas .sun-mark circle { fill: #ffd34d; stroke: #e8a317; stroke-width: 2; pointer-events: none; }
#canvas .sun-mark path { stroke: #e8a317; stroke-width: 2.5; stroke-linecap: round; pointer-events: none; }
#canvas .sun-label { fill: #8a5a00; font-weight: 600; }
#canvas .wind-arrows { stroke: #3d7fc4; stroke-width: 2; fill: none; opacity: 0.6; pointer-events: none; stroke-linecap: round; stroke-linejoin: round; }
#canvas .wind-label { fill: #24578c; font-weight: 600; }
#canvas .night { fill: #0d1830; opacity: 0.35; pointer-events: none; }
#canvas .compass circle { fill: rgba(255, 255, 255, 0.85); stroke: var(--border); stroke-width: 1; pointer-events: none; }
#canvas .compass line { stroke: var(--text); stroke-width: 2; pointer-events: none; }
#canvas .compass .tip { fill: #b3261e; stroke: none; }
#canvas .compass text { fill: #b3261e; font-weight: 800; stroke: #fff; }

#canvas .select-box { fill: rgba(63, 125, 44, 0.08); stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; pointer-events: none; }

#canvas .issue-badge { fill: #f29d38; stroke: #fff; stroke-width: 1.5; pointer-events: none; }
#canvas .issue-mark { fill: #fff; stroke: none; font-weight: 800; pointer-events: none; }

/* Plant list editor */
.library-dialog { width: min(860px, calc(100vw - 32px)); }
.library { display: grid; grid-template-columns: 240px 1fr; gap: 18px; }
.library-list-wrap { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.library-list-wrap h2 { margin: 0; }
.lib-list { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.lib-item {
  display: flex; align-items: center; gap: 6px; width: 100%;
  background: #fff; color: var(--text); border: none; border-radius: 0; text-align: left; padding: 6px 8px; font-size: 0.85rem;
}
.lib-item:hover { background: var(--accent-soft); }
.lib-item.active { background: var(--accent); color: #fff; }
.lib-tag { margin-left: auto; font-size: 0.7rem; padding: 0 6px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.lib-item.active .lib-tag { background: rgba(255, 255, 255, 0.25); color: #fff; }
.library-form h3 { margin: 0 0 2px; }
.lib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin-top: 10px; }
.lib-grid .wide { grid-column: 1 / -1; }
.lib-subhead { margin: 8px 0 6px; font-size: 0.9rem; border-top: 1px solid var(--border); padding-top: 10px; }
.lib-grid .unit-label { font-size: 0.72rem; min-width: auto; }
.lib-subhead .link-btn { float: right; font-weight: 400; }
.look-preview-wrap { margin-bottom: 8px; }
.look-preview { height: 240px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: #dfeaf0; cursor: grab; }
.look-preview:active { cursor: grabbing; }
.look-preview canvas { display: block; }
.lib-grid input[type="range"] { width: 100%; accent-color: var(--accent); margin-top: 6px; }

/* ---------- Bed health: score ring, soil card, crop history ---------- */
.bed-health { margin: 12px 0; padding-top: 12px; border-top: 1px solid var(--border); }
.health-head { display: flex; align-items: center; gap: 12px; }
.health-ring .ring-track { fill: none; stroke: var(--border); }
.health-reasons { list-style: none; margin: 8px 0 4px; padding: 0; font-size: 0.82rem; }
.health-reasons li { padding: 2px 0 2px 20px; position: relative; }
.health-reasons li::before { position: absolute; left: 2px; font-weight: 700; }
.health-reasons li.good::before { content: '✓'; color: #3f9a3f; }
.health-reasons li.bad::before { content: '!'; color: #d0453a; left: 6px; }
.health-reasons li.info { color: var(--muted); }
.health-reasons li.info::before { content: 'i'; left: 6px; font-style: italic; }
.health-sec { margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; background: #fff; }
.health-sec > summary { cursor: pointer; padding: 9px 0; font-weight: 600; list-style-position: inside; }
.health-sec > summary .muted { font-weight: 400; margin-left: 4px; }
.health-sec[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.health-sub { margin: 12px 0 6px; font-size: 0.85rem; }
.soil-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.soil-label { font-size: 0.82rem; font-weight: 600; min-width: 92px; }
.soil-about { margin: 2px 0 6px; }
.soil-row select, .soil-row input[type="date"] { width: auto; flex: 0 1 auto; padding: 4px 6px; }
.ph-cell, .lab-cell { display: flex; align-items: center; gap: 6px; }
.lab-input { width: 80px !important; padding: 4px 6px !important; }
.chips { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: #fff; }
.chip { border: 0; border-radius: 0; background: none; color: inherit; padding: 4px 10px; font-size: 0.8rem; font-weight: 500; }
.chip + .chip { border-left: 1px solid var(--border); }
.chip:hover { background: var(--accent-soft); }
.chip.on { background: var(--accent); color: #fff; }
.level-tag { font-size: 0.7rem; padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.level-tag.low { background: #fde4e1; color: #a8332a; }
.level-tag.ok { background: #e3f3dc; color: #2f7a2f; }
.level-tag.high { background: #fdf0d2; color: #8a6210; }
.lab-toggle { margin: 6px 0; }
.fixes { list-style: none; margin: 0; padding: 0; }
.fix { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: start; padding: 7px 0; border-top: 1px dashed var(--border); font-size: 0.85rem; }
.fix:first-child { border-top: 0; }
.fix p { margin: 2px 0 0; }
.fix-icon { font-size: 1.05rem; line-height: 1.3; }
.fix-done { color: #3f9a3f; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
button.small { padding: 3px 9px; font-size: 0.8rem; }
.tiny { font-size: 0.72rem; }
.soil-log { list-style: none; margin: 0 0 6px; padding: 0; font-size: 0.84rem; }
.soil-log li { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.soil-log .icon-btn { margin-left: auto; padding: 0 4px; }
.log-add, .add-past { display: flex; gap: 6px; align-items: center; margin: 4px 0 10px; flex-wrap: wrap; }
.log-add input { flex: 1; min-width: 120px; padding: 5px 8px; }
.add-past select { flex: 1; min-width: 80px; padding: 4px 6px; width: auto; }
.history { list-style: none; margin: 0; padding: 0; }
.hist-row { display: grid; grid-template-columns: 54px 1fr; gap: 6px; padding: 5px 0; border-top: 1px dashed var(--border); font-size: 0.82rem; }
.hist-row:first-child { border-top: 0; }
.hist-row.now .hist-year { color: var(--accent); }
.hist-year { font-weight: 700; }
.hist-year small { display: block; font-weight: 400; font-size: 0.7rem; }
.hist-fams { display: flex; flex-direction: column; gap: 2px; }
.fam { display: flex; align-items: center; gap: 6px; }
.fam .icon-btn { padding: 0 4px; margin-left: auto; }
.fam-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12); }
.next-up { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); font-size: 0.85rem; }
.season-switch { display: inline-flex; align-items: center; gap: 2px; }
.season-arrow { padding: 2px 8px; font-size: 1rem; line-height: 1.2; background: none; color: var(--accent); border: 1px solid transparent; border-radius: 6px; }
.season-arrow:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--border); }
.season-arrow:disabled { color: var(--muted); opacity: 0.4; cursor: default; }
.season-year { font-weight: 700; padding: 0 4px; font-variant-numeric: tabular-nums; }
.toolbar .season-switch { padding: 0 2px; }
.season-banner { position: absolute; top: var(--below-toolbar, 58px); left: 50%; transform: translateX(-50%); z-index: 5; background: #fff8e1; border: 1px solid #ecd58a; color: #5d4a10; border-radius: 999px; padding: 5px 14px; font-size: 0.82rem; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
.season-banner .link-btn { padding: 0 0 0 6px; font-size: inherit; }
.season-line { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.season-actions { display: flex; gap: 10px; }
.season-line .link-btn { padding: 0; font-size: inherit; }
.plot-item-ring { margin-left: auto; display: flex; color: var(--text, #2a2a2a); }

.quiz-dialog { width: min(520px, calc(100vw - 32px)); }
.quiz-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 14px; }
.quiz-option { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; background: #fff; color: inherit; border: 1px solid var(--border); border-radius: 10px; text-align: center; font-weight: 400; }
.quiz-option:hover { border-color: var(--accent); background: var(--accent-soft); }
.quiz-icon { font-size: 2rem; }
.rotation-dialog { width: min(560px, calc(100vw - 32px)); }
.rotation-list { list-style: none; margin: 8px 0 14px; padding: 0; max-height: 55vh; overflow-y: auto; }
.rotation-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: #fff; color: inherit; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font-weight: 400; }
.rotation-row:hover { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 520px) { .quiz-options { grid-template-columns: 1fr; } }

/* Canvas layers */
.health-tint { fill-opacity: 0.42; stroke-width: 3px; stroke-opacity: 0.9; vector-effect: non-scaling-stroke; pointer-events: none; }
.health-tint.unknown { fill-opacity: 0.12; stroke-dasharray: 6 4; }
.health-badge { text-anchor: middle; dominant-baseline: central; font-weight: 700; paint-order: stroke; stroke: #fff; pointer-events: none; }
.ghost-plant { pointer-events: none; }
.ghost-plant circle { fill: none; stroke-width: 1.5px; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; opacity: 0.75; }
.ghost-plant .plant-icon { opacity: 0.4; }
.check-label { display: flex; align-items: center; gap: 6px; font-weight: 400; align-self: end; padding-bottom: 8px; }
.lib-grid input[type="color"] { width: 100%; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.icon-field { display: flex; gap: 6px; margin-top: 4px; font-weight: 400; }
.icon-field input { flex: 1; min-width: 0; }
.icon-preview {
  width: 40px; height: 36px; padding: 0; flex-shrink: 0;
  background: #fff; border: 1px solid var(--border); color: var(--text); font-size: 1.25rem; line-height: 1;
}
.icon-preview:hover { background: var(--accent-soft); }
.emoji-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 2px;
  max-height: 210px;
  overflow-y: auto;
  padding: 6px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfaf6;
}
.emoji-group { grid-column: 1 / -1; font-size: 0.72rem; font-weight: 600; color: var(--muted); margin-top: 4px; }
.emoji-btn { padding: 4px 0; background: none; border: 1px solid transparent; color: var(--text); font-size: 1.2rem; line-height: 1.2; }
.emoji-btn:hover { background: var(--accent-soft); border-color: var(--border); }
.emoji-btn.none { font-size: 0.8rem; font-weight: 700; }

@media (max-width: 640px) {
  .library, .lib-grid { grid-template-columns: 1fr; }
  .lib-list { max-height: 180px; }
}

.companions { margin: 0 0 10px; }
.companion-list { font-size: 0.82rem; border-radius: 6px; padding: 6px 8px; margin-bottom: 4px; }
.companion-list.good { background: #f1f8ec; }
.companion-list.bad { background: #fcf0ee; }
.companion-list summary { cursor: pointer; font-weight: 600; line-height: 1.35; }
.companion-list.good summary { color: #2f5f1f; }
.companion-list.bad summary { color: #8a2a1f; }
.companion-list ul { margin: 6px 0 0; padding-left: 16px; }
.companion-list li { margin-bottom: 4px; line-height: 1.35; }
.companions p { margin: 4px 0 0; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 10px; font-size: 0.85rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.warn { color: #b3261e; }

/* ---------- Calendar tab ---------- */
#view-calendar { overflow-y: auto; }
.calendar-page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.cal-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cal-empty { text-align: center; padding: 28px; }
.climate-line { margin: 0 0 8px; color: var(--accent); }
.climate-line .link-btn { padding: 0 0 0 4px; font-size: inherit; }

.big-facts { font-size: 0.92rem; gap: 6px 14px; }
.big-facts dd { font-weight: 600; }

.frost-alert { padding: 8px 10px; border-radius: 8px; margin-bottom: 8px; font-size: 0.9rem; }
.frost-alert.frost { background: #eef4fb; color: #1f4e8c; border: 1px solid #c9dbf0; }
.frost-alert.freeze { background: #e6efff; color: #173f7a; border: 1px solid #9fbbe8; }
.wind-now { margin: 4px 0 8px; }
.forecast { display: flex; flex-direction: column; max-height: 330px; overflow-y: auto; border-top: 1px solid var(--border); }
.fc-row { display: grid; grid-template-columns: 36px 7.5em 3.5em 1fr; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.fc-row img { width: 36px; height: 36px; border-radius: 6px; }
.fc-row .fc-emoji { width: 36px; height: 36px; display: grid; place-items: center; font-size: 1.5rem; border-radius: 6px; background: var(--panel-2, rgba(0,0,0,0.04)); }
.fc-row.night { color: var(--muted); }
.fc-name { font-weight: 600; }
.fc-temp { font-weight: 700; font-variant-numeric: tabular-nums; }
.fc-temp.cold { color: #1f5fbf; }

.todo-list { list-style: none; margin: 0; padding: 0; }
.todo { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px; margin-bottom: 4px; border-left: 4px solid var(--border); background: #fbfaf6; }
.todo.indoor { border-left-color: #8e6cc4; }
.todo.plant { border-left-color: #3f9a3f; }
.todo.harvest, .todo.fall-harvest { border-left-color: #e08a2a; }
.todo.fall-sow { border-left-color: #2a9d8f; }
.todo-icon { font-size: 1.1rem; text-align: center; }

.timeline-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.75rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend .bar { position: static; display: inline-block; width: 18px; height: 9px; }
.legend .line { display: inline-block; width: 2px; height: 12px; }
.legend .line.frost { background: #3b6fb6; }
.legend .line.today { background: #d0261b; }

.timeline { margin: 10px 0; }
.tl-row { display: grid; grid-template-columns: 170px 1fr; align-items: center; min-height: 26px; border-bottom: 1px solid #efece4; }
.tl-head { min-height: 20px; border-bottom: 1px solid var(--border); }
.tl-label { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; line-height: 1.15; padding: 3px 6px 3px 0; }
.tl-track { position: relative; height: 26px; background: repeating-linear-gradient(90deg, transparent 0, transparent calc(100% / 12 - 1px), #efece4 calc(100% / 12 - 1px), #efece4 calc(100% / 12)); }
.tl-head .tl-track { height: 20px; background: none; }
.tl-month { position: absolute; top: 2px; font-size: 0.72rem; color: var(--muted); padding-left: 3px; }
.tl-mark { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; z-index: 2; }
.tl-mark.frost { background: rgba(59, 111, 182, 0.55); }
.tl-mark.today { background: #d0261b; }
.tl-note { font-size: 0.75rem; color: var(--muted); padding: 2px 0 6px 170px; }
.tl-note.warn { color: #9a4a10; }
.bar { position: absolute; top: 7px; height: 12px; border-radius: 6px; }
.bar.indoor { background: #a88bd6; }
.bar.plant { background: #3f9a3f; }
.bar.planted { background: #1f6b2a; width: 6px !important; min-width: 6px; border-radius: 3px; box-shadow: 0 0 0 2px #fff; z-index: 2; }
.tl-planted { font-size: 0.68rem; color: #1f6b2a; background: #e3f1df; border-radius: 8px; padding: 0 5px; white-space: nowrap; }
.bar.grow { background: #cfe5c0; top: 10px; height: 6px; }
.bar.harvest { background: #e8973a; }
.bar.fall-sow { background: #2a9d8f; }
.bar.fall-harvest { background: #f0b45a; }

@media (max-width: 760px) {
  .cal-cards { grid-template-columns: 1fr; }
  .tl-row { grid-template-columns: 110px 1fr; }
  .tl-note { padding-left: 110px; }
  .calendar-page { padding: 10px; }
}

/* ---------- 3D view ---------- */
.view3d { position: absolute; inset: 0; z-index: 5; background: #d5e6f0; }
.view3d-stage { position: absolute; inset: 0; overflow: hidden; }
.view3d-stage canvas { display: block; }
.labels3d { position: absolute; top: 0; left: 0; pointer-events: none; }
.label3d {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.view3d .statusbar { justify-content: center; }

/* ---------- Layers menu and sun controls ---------- */
.layers-menu {
  position: absolute;
  top: var(--below-toolbar, 54px);
  left: 10px;
  z-index: 6;
  width: 280px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.layer-opt { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 8px; border-radius: 6px; font-weight: 400; cursor: pointer; }
.layer-opt:hover { background: var(--accent-soft); }
.layer-opt input { margin-top: 3px; }
.layer-opt.disabled { opacity: 0.55; cursor: default; }
.layer-opt.disabled:hover { background: none; }

.sun-panel {
  position: absolute;
  right: 10px;
  bottom: 40px;
  z-index: 7; /* above the 3D view too, so you can scrub the sun in 3D */
  width: 330px;
  max-width: calc(100% - 20px);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.sun-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.sun-head .icon-btn { padding: 0 4px; }
.sun-panel.small { width: 260px; }
.sun-panel.small .sun-extra { display: none; }
.sun-panel.small .sun-row { margin-bottom: 0; }
.sun-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.sun-row input[type="date"] { width: auto; flex: 1; min-width: 130px; padding: 4px 6px; }
.sun-row input[type="range"] { flex: 1; min-width: 100px; accent-color: #e8a317; }
.sun-row .tool { padding: 3px 8px; border: 1px solid var(--border); }
.sun-time-label { min-width: 5.5em; text-align: right; font-variant-numeric: tabular-nums; }
.mini-seg { display: flex; }
.mini-seg button { padding: 3px 7px; font-size: 0.75rem; background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 0; }
.mini-seg button + button { border-left: none; }
.mini-seg button:first-child { border-radius: 5px 0 0 5px; }
.mini-seg button:last-child { border-radius: 0 5px 5px 0; }
.mini-seg button:hover { background: #fff6dc; }
.sun-readout { margin: 0 0 6px; color: var(--muted); line-height: 1.4; }
#tool-layers.on, #sun-3d.on { background: #fff3cf; color: #8a5a00; }

/* ---------- Right-click menu ---------- */
.context-menu {
  position: absolute;
  z-index: 10;
  min-width: 190px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.menu-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 6px 10px;
}
.menu-item:hover:not(:disabled) { background: var(--accent-soft); }
.menu-key { color: var(--muted); font-size: 0.8rem; }
.menu-sep { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---------- "Are you sure?" box ---------- */
.ask-dialog { width: min(420px, calc(100vw - 32px)); }
.ask-text { margin: 0 0 18px; white-space: pre-line; line-height: 1.45; }
button.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger-solid:hover { background: #8f1d17; }

/* ---------- Shape builder pop-up ---------- */
dialog {
  width: min(720px, calc(100vw - 32px));
  border: none;
  border-radius: 12px;
  padding: 20px;
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(30, 40, 25, 0.45); }
dialog h2 { margin: 0 0 14px; font-size: 1.2rem; }

.builder-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.seg { display: flex; margin-bottom: 14px; }
.seg button {
  flex: 1;
  background: #fff;
  color: var(--text);
  border-color: var(--border);
  border-radius: 0;
}
.seg button + button { border-left: none; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.seg button.active + button { border-left: 1px solid var(--accent); }

.builder-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.builder-inputs p:first-child { margin-top: 0; }

.builder-preview {
  width: 100%;
  aspect-ratio: 1;
  background: var(--space-fill);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.builder-preview polygon { fill: rgba(63, 125, 44, 0.25); stroke: var(--accent); stroke-width: 2; }
.builder-preview .closing { stroke: var(--danger); stroke-width: 2; stroke-dasharray: 5 4; }
.builder-preview .start { fill: var(--danger); }
.builder-preview text { text-anchor: middle; dominant-baseline: middle; fill: #1f4e8c; }

.sides-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; max-height: 300px; overflow-y: auto; }
.side-row { display: grid; grid-template-columns: 3.4em minmax(0, 1fr) 12.5em 1.4em; gap: 6px; align-items: center; font-size: 0.85rem; }
.side-name { font-weight: 600; }
.side-turn { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.side-turn input { width: 3.8em; padding: 6px 4px; }
.side-turn select { width: 6em; padding: 6px 4px; }
.side-row .icon-btn { padding: 0 4px; }

@media (max-width: 640px) {
  .builder-body, .builder-meta { grid-template-columns: 1fr; }
}

/* Phones: give the editor a fixed share of the screen (this has to come after
   the .canvas-wrap rule above, or that rule would win). */
@media (max-width: 640px) {
  .canvas-wrap { height: 65vh; flex: none; }
}

/* ---------- Notebook: journal, harvests, seeds, materials, pests ---------- */
#view-notebook { overflow-y: auto; }
.notebook-page { width: 100%; max-width: 980px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.notebook-page > div > div { display: flex; flex-direction: column; gap: 14px; }
.nb-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.nb-tabs button { background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-weight: 500; }
.nb-tabs button:hover { border-color: var(--accent); }
.nb-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.nb-kinds { display: flex; flex-wrap: wrap; border-radius: 12px; margin: 4px 0 10px; }
.nb-kinds .chip { padding: 6px 12px; }
.nb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 12px; }
.nb-grid .wide { grid-column: 1 / -1; }
.nb-grid input[type="date"], .nb-grid select { display: block; width: 100%; margin-top: 4px; }
.nb-grid .unit-input select { display: inline-block; width: auto; margin-top: 0; }
.nb-grid textarea { width: 100%; resize: vertical; font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
.nb-photo-row input[type="file"] { margin-top: 4px; font-weight: 400; }
.nb-new .row { align-items: center; margin-top: 8px; }
.nb-list-head { flex-wrap: wrap; gap: 8px; }
.nb-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.nb-filters select { width: auto; padding: 4px 6px; }
.nb-month { margin: 14px 0 6px; font-size: 0.82rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.nb-entry { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 8px; margin-bottom: 6px; background: #fff; }
.nb-entry.harvest { border-left-color: #e08a2a; }
.nb-entry.pest { border-left-color: #c0392b; }
.nb-entry.planted, .nb-entry.sprouted { border-left-color: #3f9a3f; }
.nb-entry.flowering { border-left-color: #d063a0; }
.nb-entry.weather { border-left-color: #5b8def; }
.nb-icon { font-size: 1.25rem; line-height: 1.4; }
.nb-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.85rem; }
.nb-main p { margin: 4px 0 0; white-space: pre-wrap; }
.nb-tag { display: inline-flex; gap: 4px; align-items: center; font-size: 0.75rem; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--text); }
.nb-tag.pest { background: #fde4e1; color: #8a2a20; }
.nb-tag.harvest { background: #fdf0d2; color: #7a5410; font-weight: 600; }
.nb-thumb { display: block; margin-top: 6px; padding: 0; border: 0; background: none; cursor: zoom-in; }
.nb-thumb img { max-width: 180px; max-height: 130px; border-radius: 6px; display: block; object-fit: cover; }
.photo-dialog { max-width: min(92vw, 1000px); }
.photo-dialog img { max-width: 100%; max-height: 75vh; display: block; margin: 0 auto 10px; border-radius: 6px; }
.nb-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.nb-table th { text-align: left; font-size: 0.75rem; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.nb-table td { padding: 6px; border-bottom: 1px dashed var(--border); vertical-align: top; }
.nb-table select { width: auto; padding: 3px 6px; }
.hv-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 12px; }
.hv-card { display: flex; flex-direction: column; align-items: center; padding: 12px; border-radius: 10px; background: var(--accent-soft); }
.hv-card b { font-size: 1.4rem; color: var(--accent); }
.hv-card span { font-size: 0.8rem; color: var(--muted); }
.shop-list, .stash-list, .soil-pests { list-style: none; margin: 0 0 8px; padding: 0; }
.shop-list li, .stash-list li, .soil-pests li { padding: 5px 0; border-bottom: 1px dashed var(--border); display: flex; gap: 8px; align-items: center; }
.stash-list .icon-btn { margin-left: auto; }
.sd-add { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.sd-add select, .sd-add input { width: auto; padding: 5px 8px; }
.sd-add input[type="number"] { width: 80px; }
.warn-text { color: #a8332a; }
.inline-label { display: flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; }
.inline-label select { width: auto; padding: 3px 6px; margin: 0; }
.mt-bed { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; background: #fff; }
.mt-bed h3 { margin: 2px 0 6px; font-size: 0.95rem; }
.mt-bed ul { list-style: none; margin: 0; padding: 0; }
.mt-bed li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px dashed var(--border); font-size: 0.88rem; }
.mt-total { font-size: 1.05rem; text-align: right; margin: 8px 0 2px; }
.price-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px; margin-top: 10px; }
.pest-card { border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; margin-bottom: 8px; background: #fff; }
.pest-card > summary { display: flex; align-items: center; gap: 8px; padding: 10px 0; cursor: pointer; flex-wrap: wrap; }
.pest-card[open] > summary { border-bottom: 1px solid var(--border); }
.pest-icon { font-size: 1.2rem; }
.pest-type { font-size: 0.7rem; padding: 1px 8px; border-radius: 999px; background: #eef1f4; color: #4a5560; }
.pest-type.disease { background: #f3e8fb; color: #6a3a8a; }
.pest-type.insect { background: #fdf0d2; color: #7a5410; }
.pest-type.animal { background: #e3f3dc; color: #2f6a2f; }
.pest-soil { font-size: 0.7rem; padding: 1px 8px; border-radius: 999px; background: #fde4e1; color: #8a2a20; margin-left: auto; }
.pest-card dl { margin: 8px 0; font-size: 0.88rem; }
.pest-card dt { font-weight: 700; margin-top: 6px; }
.pest-card dd { margin: 2px 0 0; }
.pest-card > button { margin-bottom: 10px; }
.after-crop { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: #fdf8ea; border: 1px solid #f0e2b4; font-size: 0.85rem; }
.after-crop p { margin: 4px 0; }
.after-options { display: flex; flex-wrap: wrap; gap: 4px; }
@media (max-width: 760px) {
  .nb-grid, .price-grid { grid-template-columns: 1fr; }
  .hv-summary { grid-template-columns: 1fr 1fr 1fr; }
  .notebook-page { padding: 10px; }
}

/* ---------- 3D: watch it grow ---------- */
.grow-panel { position: absolute; left: 10px; bottom: 40px; z-index: 40; width: 360px; max-width: calc(100% - 20px); padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); font-size: 0.85rem; }
.grow-panel input[type="range"] { flex: 1; min-width: 120px; accent-color: #3f9a3f; }
.grow-date { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.grow-play { min-width: 34px; }
.grow-months { flex-wrap: wrap; margin-bottom: 6px; }
.grow-months button:hover { background: var(--accent-soft); }
.grow-readout { margin: 0; line-height: 1.45; max-height: 6.5em; overflow-y: auto; }
#grow-3d.on { background: #e3f3dc; color: #2f6a2f; }

/* ---------- Installable app ---------- */
.install-btn { background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 6px 14px; font-weight: 600; white-space: nowrap; }
.install-btn:hover { filter: brightness(1.08); }
.install-btn:not(.ready) { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.net-banner { padding: 7px 16px; font-size: 0.85rem; text-align: center; border-bottom: 1px solid var(--border); }
.net-banner.offline { background: #fff4d6; color: #5d4a10; }
.net-banner.update { background: #e3f3dc; color: #2f5a2f; }
.net-banner .link-btn { font-size: inherit; padding: 0 0 0 6px; font-weight: 700; }
/* Phones that put the app under a notch or a home bar */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.topbar { padding-top: max(10px, env(safe-area-inset-top)); }

/* You are here (GPS) */
#canvas .here-accuracy { fill: rgba(40, 120, 230, 0.12); stroke: rgba(40, 120, 230, 0.4); stroke-width: 1px; vector-effect: non-scaling-stroke; pointer-events: none; }
#canvas .here-dot { fill: #2878e6; stroke: #fff; pointer-events: none; filter: drop-shadow(0 0 3px rgba(40, 120, 230, 0.7)); }
#tool-here.on { background: #e1edfc; color: #1a5bb5; }

/* ---------- Sun hours layer ---------- */
.sunhours-panel { position: absolute; left: 10px; bottom: 40px; z-index: 7; width: 330px; max-width: calc(100% - 20px); max-height: calc(100% - 140px); overflow-y: auto; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); font-size: 0.85rem; }
.sunhours-panel select { width: 100%; padding: 4px 6px; }
.sh-legend { margin: 8px 0 2px; }
.sh-bar { display: block; height: 10px; border-radius: 5px; background: linear-gradient(90deg, rgb(52,74,148) 0%, rgb(70,140,190) 18%, rgb(120,190,110) 36%, rgb(245,205,60) 55%, rgb(245,140,40) 73%, rgb(215,70,40) 100%); }
.sh-ticks { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--muted); margin-top: 2px; }
.sh-words { margin: 4px 0; }
.sh-status { margin: 4px 0 8px; min-height: 2.6em; }
.sh-best { display: flex; gap: 6px; border-top: 1px solid var(--border); padding-top: 8px; }
.sh-best select { flex: 1; }
.best-list { list-style: none; margin: 6px 0 0; padding: 0; }
.best-list li { display: grid; grid-template-columns: 24px 1fr auto; gap: 6px; align-items: center; padding: 5px 2px; border-top: 1px dashed var(--border); cursor: pointer; }
.best-list li:hover { background: var(--accent-soft); }
.best-rank { width: 22px; height: 22px; border-radius: 50%; background: #2f7a2f; color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 0.75rem; }
#canvas .sun-heat { pointer-events: none; opacity: 0.62; }
#canvas .best-spot circle { fill: #2f7a2f; stroke: #fff; vector-effect: non-scaling-stroke; stroke-width: 2px; }
#canvas .best-spot .ring { fill: none; stroke: #2f7a2f; stroke-dasharray: 4 3; stroke-width: 2px; }
#canvas .best-spot text { fill: #fff; font-weight: 800; text-anchor: middle; dominant-baseline: central; }
#canvas .best-spot { pointer-events: none; }
@media (max-width: 640px) { .sunhours-panel { bottom: 36px; max-height: 55%; } }

/* Square-foot grid */
#canvas .sfg-grid { fill: none; stroke: rgba(255, 255, 255, 0.75); stroke-width: 1.5px; vector-effect: non-scaling-stroke; pointer-events: none; }
.sfg-toggle { margin: 4px 0 6px; }

/* Season warmth (degree days) */
.warmth-sub { margin: 12px 0 4px; font-size: 0.9rem; }
.warmth-pests { list-style: none; margin: 0; padding: 0; font-size: 0.88rem; }
.warmth-pest { padding: 6px 8px; border-left: 4px solid var(--border); margin-bottom: 4px; border-radius: 4px; background: #fbfaf6; }
.warmth-pest.now { border-left-color: #c0392b; background: #fdf0ee; }
.warmth-pest.soon { border-left-color: #e0a020; background: #fdf8ea; }
.warmth-pest.past { opacity: 0.6; }
.todo.pest { border-left-color: #c0392b; }

/* Water planner */
.water-list { list-style: none; margin: 8px 0; padding: 0; }
.water-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 8px; margin-bottom: 6px; background: #fff; }
.water-row.yes { border-left-color: #2878e6; }
.water-row.wait { border-left-color: #e0a020; }
.water-row.no { border-left-color: #3f9a3f; }
.water-mark { font-size: 1.2rem; text-align: center; }
#wt-roof { width: 100px; }

/* ---------- Welcome and help ---------- */
.welcome-dialog { width: min(640px, calc(100vw - 32px)); padding: 0; overflow: hidden auto; }
.welcome-dialog > :not(.welcome-art) { margin-left: 24px; margin-right: 24px; }
.welcome-art { height: 170px; border-bottom: 1px solid var(--border); }
.welcome-art svg { display: block; width: 100%; height: 100%; }
.welcome-hero { text-align: center; margin-top: 18px; }
.welcome-kicker { margin: 0; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--terracotta); }
.welcome-hero h2 { margin: 4px 0 8px; font-family: var(--font-display); font-size: clamp(1.7rem, 5vw, 2.4rem); line-height: 1.1; color: var(--accent); }
.welcome-hero h2 em { color: var(--terracotta); }
.welcome-hero p:last-child { color: var(--muted); max-width: 48ch; margin: 0 auto; }
.welcome-points { list-style: none; padding: 0; margin: 14px 24px 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; font-size: 0.86rem; color: var(--text); }
.welcome-points li { display: flex; align-items: center; gap: 5px; }
.welcome-points .ic { color: var(--accent); width: 16px; height: 16px; }
.welcome-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0 10px; }
.welcome-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 12px; background: var(--panel); color: inherit; border: 1px solid var(--border); border-radius: 14px; text-align: center; font-weight: 400; box-shadow: var(--shadow-card); transition: transform 0.12s, border-color 0.12s; }
.welcome-card:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.welcome-card b { font-family: var(--font-display); font-size: 1.12rem; }
.welcome-card.primary-card { background: var(--accent); color: #f4eedf; border-color: var(--accent); }
.welcome-card.primary-card:hover { background: var(--accent-hover); }
.welcome-card.primary-card .small { opacity: 0.85; }
.welcome-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.primary-card .welcome-icon { background: rgba(244, 238, 223, 0.16); color: #f4eedf; }
.welcome-icon .ic { width: 24px; height: 24px; }
.welcome-dialog > .row.end { margin-bottom: 18px; }
.welcome-note { text-align: center; }
@media (max-width: 520px) { .welcome-options { grid-template-columns: 1fr; } }
.help-btn { width: 32px; height: 32px; border-radius: 50%; padding: 0; background: #fff; color: var(--accent); border: 1px solid var(--accent); font-weight: 800; font-size: 1rem; }
.help-btn:hover { background: var(--accent-soft); }
.help-dialog { width: min(680px, calc(100vw - 32px)); }
.help-dialog details { border-top: 1px solid var(--border); padding: 8px 0; }
.help-dialog summary { cursor: pointer; font-weight: 700; }
.help-dialog p, .help-dialog ol { margin: 6px 0 2px; line-height: 1.5; }
.help-dialog code { background: #f2efe4; padding: 0 4px; border-radius: 4px; }

/* ---------- Print or save as PDF ---------- */
.print-view { display: none; }
@media print {
  body > *:not(#print-view) { display: none !important; }
  body { background: #fff; padding: 0; }
  .print-view { display: block; color: #000; font-size: 11pt; }
  .print-head h1 { margin: 0; font-size: 20pt; color: #2f6a24; }
  .print-head p { margin: 2px 0 10px; color: #444; }
  .print-plan { border: 1px solid #bbb; border-radius: 6px; overflow: hidden; }
  .print-drawing { display: block; width: 100%; height: 115mm; }
  .print-view h2 { font-size: 13pt; margin: 12px 0 4px; }
  .print-table { width: 100%; border-collapse: collapse; }
  .print-table th, .print-table td { text-align: left; border-bottom: 1px solid #ddd; padding: 3px 6px; vertical-align: top; }
  .print-table tr { break-inside: avoid; }
  .print-foot { margin-top: 10px; color: #666; font-size: 9pt; }
  @page { margin: 12mm; }
}

/* =====================================================================
   Garden-journal theme: type, paper, buttons, cards, top bar, phone tabs
   ===================================================================== */
body {
  background-color: var(--bg);
  /* a faint paper grain */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.27 0 0 0 0 0.15 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .panel h2, dialog h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; color: var(--accent); }
.panel h2 { font-size: 1.12rem; }
.sidebar { background: transparent; }
.panel { background: var(--panel); border-color: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); }
dialog { background: var(--panel); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 24px 60px rgba(60, 45, 20, 0.25); color: var(--text); }
dialog::backdrop { background: rgba(38, 51, 31, 0.45); backdrop-filter: blur(2px); }

/* Icons from icons/ui.svg */
.ic { width: 18px; height: 18px; flex: none; vertical-align: -3px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool .ic, .tab .ic { margin-right: 6px; }

/* Buttons: soft pills */
button { border-radius: 999px; font-weight: 600; transition: background 0.15s, border-color 0.15s, transform 0.08s; }
button:active:not(:disabled) { transform: translateY(1px); }
button.secondary { background: var(--panel); border-color: #cfc3a6; color: var(--accent); }
button.secondary:hover { background: var(--accent-soft); border-color: var(--accent); }
button.big { padding: 12px 16px; font-size: 1rem; box-shadow: 0 6px 16px rgba(46, 74, 43, 0.22); }
.link-btn { color: var(--terracotta); font-weight: 600; }
.icon-btn { border-radius: 8px; }
input[type="text"], input[type="search"], input[type="number"], select, textarea { border-color: #d9cdb2; border-radius: 10px; background: #fffdf8; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--mustard); outline-offset: 2px; }

/* Top bar */
.topbar { background: rgba(255, 252, 244, 0.86); backdrop-filter: blur(6px); border-bottom-color: var(--border); padding: 10px 18px; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 1.45rem; color: var(--accent); letter-spacing: -0.02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; flex: none; }
.brand-slogan { font-family: var(--font-display); font-style: italic; font-weight: 400; font-size: 0.85rem; color: var(--terracotta); letter-spacing: 0; }
.tab { border-radius: 999px; font-weight: 600; color: var(--muted); padding: 7px 14px; display: inline-flex; align-items: center; }
.tab.active { background: var(--accent); color: #fffcf4; border-color: var(--accent); }
.tab:hover:not(.active) { background: var(--accent-soft); color: var(--accent); }
.units button.active, .cal-scope button.active, .chip.on { background: var(--accent); border-color: var(--accent); }

/* Canvas toolbar */
.toolbar { background: rgba(255, 252, 244, 0.95); border-color: var(--border); border-radius: 14px; box-shadow: 0 6px 20px rgba(60, 45, 20, 0.12); }
.tool { border-radius: 10px; font-weight: 600; color: var(--text); display: inline-flex; align-items: center; background: transparent; }
.tool.active { background: var(--accent); color: #fffcf4; }
.tool:hover:not(.active) { background: var(--accent-soft); }
.statusbar { background: rgba(255, 252, 244, 0.9); }

/* Lists */
.plot-item { border-radius: 10px; }
.plot-item.selected { background: var(--accent-soft); border-color: var(--accent); }

/* Phones: the four main tabs become a tab bar at the bottom, like an app */
@media (max-width: 640px) {
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; margin: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; background: rgba(255, 252, 244, 0.97); border-top: 1px solid var(--border); box-shadow: 0 -4px 18px rgba(60, 45, 20, 0.1); }
  .tab { flex-direction: column; gap: 2px; font-size: 0.72rem; padding: 6px 10px; border-radius: 12px; }
  .tab .ic { width: 22px; height: 22px; margin: 0; }
  body { padding-bottom: 70px; }
  .brand-slogan { display: none; }
  .topbar { backdrop-filter: none; background: var(--panel); } /* (a blur here would trap the fixed tab bar inside the top bar) */
}
/* ---------- Loading screen ---------- */
#splash { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: var(--bg); transition: opacity 0.45s ease; }
#splash img { border-radius: 20px; box-shadow: var(--shadow-card); animation: splash-grow 1.4s ease-in-out infinite alternate; }
#splash .splash-name { margin-top: 10px; font-family: var(--font-display); font-size: 2rem; font-weight: 600; color: var(--accent); }
#splash .splash-slogan { font-style: italic; color: var(--terracotta); }
#splash.gone { opacity: 0; pointer-events: none; }
@keyframes splash-grow { from { transform: scale(0.96); } to { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { #splash img { animation: none; } }

/* ---------- Plant pictures (little top-down drawings) ---------- */
.pthumb { display: block; flex: none; overflow: visible; }
.pthumb * { vector-effect: none; }
.theme-pics { font-size: 1.4rem; line-height: 1.2; letter-spacing: 2px; }
.rep-icon { font-size: 1.3rem; width: 28px; text-align: center; }
.todo-icon { display: grid; place-items: center; }
#plant-props-title { display: flex; align-items: center; gap: 8px; }
#prop-plant-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.count-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 3px; border-radius: 999px; background: var(--accent-soft); font-size: 0.82rem; }
#canvas .ghost-plant use { opacity: 0.45; }
#canvas .plant-ghost use { opacity: 0.75; pointer-events: none; }

/* ---------- Sidebar: foldable sections ---------- */
.fold-head { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 8px; cursor: pointer; font: inherit; color: inherit; }
.fold-head:focus-visible { outline: 2px solid var(--mustard); outline-offset: 3px; border-radius: 6px; }
.fold-head > span { flex: 1; }
.fold-head .ic { color: var(--accent); }
.fold-chev { color: var(--muted) !important; transition: transform 0.2s ease; }
.panel.folded .fold-chev { transform: rotate(-90deg); }
.panel.foldable.folded > :not(h2) { display: none !important; }
.panel.foldable.folded > h2 { margin-bottom: 0; }
.sheet-handle { display: none; }

/* ---------- Phones: the editor sidebar is a sheet that slides up over the plan ---------- */
@media (max-width: 640px) {
  #view-editor .canvas-wrap { height: calc(100dvh - var(--topbar-h, 110px) - 70px - 92px); min-height: 280px; }
  #view-editor .sidebar {
    position: fixed; left: 0; right: 0; bottom: 70px; z-index: 55;
    height: var(--sheet-drag, var(--sheet-h, 92px)); max-height: calc(100dvh - var(--topbar-h, 110px) - 80px);
    overflow-y: auto; overscroll-behavior: contain;
    background: var(--panel); border: 1px solid var(--border); border-bottom: none; border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 30px rgba(60, 45, 20, 0.18); padding: 0 10px 12px;
    transition: height 0.25s ease;
  }
  #view-editor .sidebar[data-sheet="peek"] { --sheet-h: 92px; }
  #view-editor .sidebar[data-sheet="half"] { --sheet-h: 46dvh; }
  #view-editor .sidebar[data-sheet="full"] { --sheet-h: calc(100dvh - var(--topbar-h, 110px) - 80px); }
  #view-editor .sidebar .panel { box-shadow: none; }
  .sheet-handle { display: grid; place-items: center; position: sticky; top: 0; z-index: 2; width: calc(100% + 20px); margin: 0 -10px 4px; height: 26px; padding: 0; border: none; border-radius: 20px 20px 0 0; background: var(--panel); cursor: grab; touch-action: none; }
  .sheet-handle span { width: 44px; height: 5px; border-radius: 999px; background: #cfc3a6; }
}
@media (max-width: 640px) and (prefers-reduced-motion: reduce) { #view-editor .sidebar { transition: none; } }

/* ---------- Little animations ---------- */
#canvas .pop { transform-box: fill-box; transform-origin: center; animation: plant-pop 0.42s cubic-bezier(.3, 1.6, .5, 1) backwards; }
@keyframes plant-pop { from { transform: scale(0.25); opacity: 0; } 60% { opacity: 1; } to { transform: scale(1); } }
#canvas .settle { transform-box: fill-box; transform-origin: center; animation: bed-settle 0.32s ease-out; }
@keyframes bed-settle { from { transform: scale(1.035); } to { transform: scale(1); } }
#canvas .plant.not-yet circle.pc { stroke-dasharray: 1 4; stroke: rgba(60, 45, 25, 0.3); }
.panel.foldable > :not(h2) { animation: fold-open 0.2s ease-out; }
@keyframes fold-open { from { opacity: 0; transform: translateY(-4px); } }
dialog[open] { animation: dialog-in 0.22s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) {
  #canvas .pop, #canvas .settle, .panel.foldable > :not(h2), dialog[open] { animation: none; }
}

/* ---------- Smart fill ---------- */
.smart-fill-btn { width: 100%; margin: 6px 0 4px; display: flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent-soft); color: var(--accent); border: 1px dashed var(--accent); }
.smart-fill-btn:hover { background: #dfe3c8; }
.smart-fill-dialog { width: min(640px, calc(100vw - 32px)); }
.smart-fill-dialog h2 { display: flex; align-items: center; gap: 8px; }
.smart-fill-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 10px; }
.theme-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; text-align: left; background: var(--panel); color: inherit; border: 1px solid var(--border); border-radius: 14px; font-weight: 400; transition: transform 0.12s, border-color 0.12s; }
.theme-card:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.theme-card b { font-family: var(--font-display); font-size: 1.02rem; }
.theme-pics { display: flex; margin-bottom: 2px; }
.theme-pics .pthumb { margin-right: -6px; background: #efe6cf; border-radius: 50%; box-shadow: 0 0 0 2px var(--panel); }

dialog { box-sizing: border-box; max-width: calc(100vw - 24px); }

/* ---------- Top bar: ask and reminders ---------- */
.round-btn { position: relative; width: 32px; height: 32px; border-radius: 50%; padding: 0; display: grid; place-items: center; background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.round-btn:hover { background: var(--accent-soft); }
.round-btn .ic { margin: 0; }
.reminders-wrap { position: relative; }
.bell-count { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px; box-sizing: border-box; border-radius: 999px; background: var(--terracotta); color: #fff; font-size: 0.68rem; font-weight: 800; line-height: 17px; text-align: center; }
#reminders-btn.has-some .ic { animation: bell-ring 1.2s ease-in-out 1; transform-origin: 50% 10%; }
@keyframes bell-ring { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-4deg); } }
.reminders-panel { position: absolute; right: -40px; top: 40px; z-index: 80; width: min(340px, calc(100vw - 24px)); padding: 12px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 16px 40px rgba(60, 45, 20, 0.22); animation: dialog-in 0.18s ease-out; }
.reminders-panel h3 { margin: 0 0 8px; font-family: var(--font-display); }
.reminders-items { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; max-height: 50vh; overflow-y: auto; }
.rem { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border-radius: 10px; background: #fbf7ec; border-left: 3px solid var(--accent); }
.rem .ic { color: var(--accent); margin-top: 2px; }
.rem-warn { border-left-color: var(--terracotta); background: #fbefe7; }
.rem-warn .ic { color: var(--terracotta); }
@media (prefers-reduced-motion: reduce) { #reminders-btn.has-some .ic { animation: none; } }

/* ---------- Ask Dirt Smart ---------- */
.helper-dialog { width: min(560px, calc(100vw - 24px)); display: none; flex-direction: column; gap: 8px; max-height: min(720px, calc(100dvh - 40px)); }
.helper-dialog[open] { display: flex; }
.helper-dialog h2 { display: flex; align-items: center; gap: 8px; }
.ask-log { flex: 1; min-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.ask-msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; line-height: 1.4; font-size: 0.92rem; animation: dialog-in 0.18s ease-out; }
.ask-msg p { margin: 0 0 6px; }
.ask-msg p:last-child { margin-bottom: 0; }
.ask-msg ul { margin: 4px 0 6px; padding-left: 18px; }
.ask-msg li { margin-bottom: 4px; }
.ask-msg.you { align-self: flex-end; background: var(--accent); color: #f4eedf; border-bottom-right-radius: 4px; }
.ask-msg.bot { align-self: flex-start; background: #f3ecdb; border-bottom-left-radius: 4px; }
.ask-examples { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-chip { padding: 4px 10px; font-size: 0.8rem; font-weight: 500; background: var(--panel); color: var(--accent); border: 1px solid var(--border); border-radius: 999px; }
.ask-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.ask-form { display: flex; gap: 6px; }
.ask-form input { flex: 1; min-width: 0; }
.ask-send { width: 42px; padding: 0; display: grid; place-items: center; }
@media (prefers-reduced-motion: reduce) { .ask-msg { animation: none; } }

/* ---------- Drip lines, fences, trellises, barrels, notes ---------- */
#canvas .art-drip { fill: #3d7fc4; stroke: #2a5d93; stroke-width: 1; }
#canvas .art-emitter { fill: #9cc8f0; stroke: #2a5d93; stroke-width: 1; }
#canvas .art-fence { fill: #a07a52; stroke: #6e4a2c; stroke-width: 1.5; }
#canvas .art-post { fill: #6e4a2c; stroke: #4f341e; stroke-width: 1; }
#canvas .art-trellis { fill: rgba(160, 122, 82, 0.55); stroke: #7a5a3a; stroke-width: 1.5; stroke-dasharray: 5 2; }
#canvas .art-tie { stroke: #7a5a3a; stroke-width: 1.2; fill: none; }
#canvas .art-barrel { fill: #2f5d93; stroke: #1f4170; stroke-width: 2; }
#canvas .art-barrel-lid { fill: #3d6fb6; stroke: #2a5d93; stroke-width: 1; }
#canvas .art-barrel-cap { fill: #1f4170; stroke: none; }
#canvas .art-note { fill: #f6dd8a; stroke: #d6b44a; stroke-width: 1; }
#canvas .art-note-fold { fill: #e5c463; stroke: none; }
#canvas .label.note-text { font-family: var(--font-display); font-style: italic; font-weight: 500; fill: #5b4512; stroke: none; }
#canvas .art-post { vector-effect: non-scaling-stroke; }

/* ---------- Season report ---------- */
.nb-report-btn { margin-left: auto; background: var(--accent); color: #f4eedf; }
.nb-report-btn .ic { color: #f4eedf; }
.report-dialog { width: min(680px, calc(100vw - 24px)); }
.report-body h3 { font-family: var(--font-display); margin: 16px 0 6px; }
.rep-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 6px; }
.rep-stats div { display: flex; flex-direction: column; align-items: center; padding: 10px 6px; border-radius: 12px; background: var(--accent-soft); text-align: center; }
.rep-stats b { font-family: var(--font-display); font-size: 1.3rem; color: var(--accent); }
.rep-stats span { font-size: 0.75rem; color: var(--muted); }
.rep-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.rep-list li { display: flex; align-items: center; gap: 8px; }
.rep-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.rep-table th, .rep-table td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--border); }
.rep-next li { margin-bottom: 5px; }
@media (max-width: 520px) { .rep-stats { grid-template-columns: 1fr 1fr; } }
@media print { .report-print .rep-stats { display: flex; gap: 12px; } .report-print .rep-stats div { border: 1px solid #ccc; padding: 6px; } }

/* The top bar (and its drop-downs: reminders, garden menu) sits above the plan and panels. */
.topbar { position: relative; z-index: 90; }
@media (max-width: 600px) { .reminders-panel { position: fixed; left: 12px; right: 12px; top: calc(var(--topbar-h, 64px) + 4px); width: auto; } }

/* ---------- Share by link, calendar export ---------- */
.share-dialog { width: min(520px, calc(100vw - 24px)); }
.share-row { display: flex; gap: 6px; margin: 10px 0 4px; }
.share-row input { flex: 1; min-width: 0; font-size: 0.85rem; color: var(--muted); }
#cal-export { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Soil temperature ---------- */
.soil-box { margin: 8px 0 10px; padding: 10px 12px; border-radius: 12px; background: #f3ecdb; border-left: 3px solid #8a5a3a; display: grid; gap: 3px; }
.yield-line { margin: 4px 0 6px; padding: 6px 10px; border-radius: 10px; background: #fbf0d8; color: #6b4a10; }

/* ---------- First-run tour ---------- */
.tour-spot { position: fixed; z-index: 200; border-radius: 14px; pointer-events: none; box-shadow: 0 0 0 4px var(--mustard), 0 0 0 9999px rgba(38, 51, 31, 0.5); transition: all 0.25s ease; }
.tour-card { position: fixed; z-index: 201; width: min(320px, calc(100vw - 20px)); padding: 14px 16px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 18px 44px rgba(38, 51, 31, 0.3); transition: top 0.25s ease, left 0.25s ease; }
.tour-count { margin: 0; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--terracotta); }
.tour-title { margin: 2px 0 4px; font-family: var(--font-display); font-size: 1.2rem; color: var(--accent); }
.tour-text { margin: 0 0 10px; color: var(--text); font-size: 0.92rem; }
.tour-buttons { display: flex; align-items: center; gap: 6px; }
.tour-buttons > span { flex: 1; }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-card { transition: none; } }

/* ---------- Garden check fixes ---------- */
.issues .issue { position: relative; }
.fix-btn { float: right; margin: -2px 0 2px 8px; padding: 2px 10px; font-size: 0.75rem; font-weight: 700; border-radius: 999px; background: var(--accent); color: #f4eedf; border: none; }
.fix-btn:hover { background: var(--accent-hover); }
.fix-all-row { list-style: none; margin-bottom: 6px; }

/* ---------- Seed starting ---------- */
.ss-now { padding: 10px 12px; margin-bottom: 10px; border-radius: 12px; background: var(--accent-soft); }
.ss-now ul { margin: 4px 0 0; padding-left: 18px; }
.ss-guides { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.ss-guides h3 { font-family: var(--font-display); margin: 0 0 6px; }
.ss-guides ul, .ss-harden { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.nb-table-wrap { overflow-x: auto; }
.mt-bed li.optional { opacity: 0.75; }
@media (max-width: 700px) { .ss-guides { grid-template-columns: 1fr; } }

/* ---------- Photo timeline ---------- */
.pt-add { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--accent); color: var(--accent); font-weight: 700; cursor: pointer; margin: 4px 8px 10px 0; }
.pt-add:hover { background: var(--accent-soft); }
.pt-view { margin: 6px 0 10px; }
.pt-view img { display: block; width: 100%; max-height: 60vh; object-fit: contain; background: #1f261b; border-radius: 12px; }
.pt-controls { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.pt-controls input { flex: 1; accent-color: var(--accent); }
.pt-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.pt-thumb { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px; background: none; border: 2px solid transparent; border-radius: 10px; color: var(--muted); font-size: 0.72rem; }
.pt-thumb img { width: 84px; height: 64px; object-fit: cover; border-radius: 7px; background: #e9e1cc; }
.pt-thumb.on { border-color: var(--mustard); color: var(--text); }

/* ---------- Plant labels (printed) ---------- */
.labels-sheet { display: grid; grid-template-columns: repeat(2, 3.4in); gap: 0.15in; }
.label-card { display: flex; align-items: center; gap: 0.1in; height: 1.15in; padding: 0.1in 0.12in; border: 1px dashed #999; border-radius: 0.08in; break-inside: avoid; font-family: var(--font-ui); }
.label-text { flex: 1; min-width: 0; }
.label-name { font-family: var(--font-display); font-size: 15pt; font-weight: 700; line-height: 1.1; }
.label-count { font-size: 10pt; font-weight: 400; color: #555; }
.label-bed { font-size: 9pt; color: #555; margin-top: 2px; }
.label-dates { font-size: 9pt; margin-top: 3px; }
.label-qr { width: 0.85in; height: 0.85in; flex: none; }
.label-qr svg { width: 100%; height: 100%; }

/* ---------- Perennials ---------- */
.perennial-box { margin: 8px 0; padding: 10px 12px; border-radius: 12px; background: #eef0de; border-left: 3px solid var(--accent); }
.perennial-box input { width: 90px; margin-left: 6px; }
.perennial-box ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 3px; }
.perennial-box p { margin: 6px 0 0; }

/* ---------- Accessibility ---------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
#canvas:focus-visible { outline: 3px solid var(--mustard); outline-offset: -3px; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--mustard); outline-offset: 2px; }

/* ---------- Plant list categories ---------- */
.plant-cats { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: thin; }
.cat-chip { flex: none; padding: 4px 10px; font-size: 0.78rem; font-weight: 600; border-radius: 999px; background: var(--panel); color: var(--muted); border: 1px solid var(--border); }
.cat-chip:hover { border-color: var(--accent); color: var(--accent); }
.cat-chip.on { background: var(--accent); color: #f4eedf; border-color: var(--accent); }

/* ---------- 3D: names toggle and clear view ---------- */
.clean-exit { display: none; }
.view3d.clean .toolbar, .view3d.clean .statusbar, .view3d.clean .labels3d { display: none !important; }
body.clean-3d .grow-panel, body.clean-3d .sun-panel, body.clean-3d .compass-btn, body.clean-3d #season-banner { display: none !important; }
.view3d.clean .clean-exit { display: inline-flex; align-items: center; gap: 6px; position: absolute; right: 12px; bottom: 12px; z-index: 6; padding: 7px 12px; border-radius: 999px; background: rgba(255, 252, 244, 0.55); color: var(--accent); border: 1px solid rgba(255, 255, 255, 0.6); backdrop-filter: blur(6px); font-size: 0.8rem; font-weight: 700; opacity: 0.55; transition: opacity 0.2s; }
.view3d.clean .clean-exit:hover, .view3d.clean .clean-exit:focus-visible { opacity: 1; }
/* Softer floating names */
.label3d { background: rgba(255, 252, 244, 0.78) !important; color: #26331f !important; border: 1px solid rgba(110, 90, 60, 0.18) !important; box-shadow: 0 2px 8px rgba(40, 30, 10, 0.12) !important; font-family: var(--font-ui); font-weight: 600; font-size: 11px !important; padding: 2px 8px !important; border-radius: 999px !important; backdrop-filter: blur(4px); }
/* Clear view also hides the app's own bars, so the garden fills the window. */
body.clean-3d .topbar, body.clean-3d #view-editor > .sidebar { display: none !important; }
body.clean-3d { padding-bottom: 0 !important; }
body.clean-3d #view-editor .canvas-wrap { height: 100dvh !important; }

/* ---------- Water: sources, hoses, supply lines ---------- */
#canvas .art-hose { fill: #3a8a3a; stroke: #2a6a2a; stroke-width: 1.5; }
#canvas .art-mainline { fill: #2a2a2a; stroke: #111; stroke-width: 1.5; }
#canvas .art-spigot { fill: #6f94b8; stroke: #3a5f86; stroke-width: 2; }
#canvas .art-spigot-handle { stroke: #b0302a; stroke-width: 3; stroke-linecap: round; fill: none; }
#canvas .art-spigot-cap { fill: #d8dde2; stroke: #3a5f86; stroke-width: 1; }

/* ---------- Drip designer ---------- */
.drip-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 6px 0 10px; }
.drip-summary div { display: flex; flex-direction: column; align-items: center; padding: 10px 6px; border-radius: 12px; background: #e6eef4; text-align: center; }
.drip-summary b { font-family: var(--font-display); font-size: 1.25rem; color: #2f5d93; }
.drip-summary span { font-size: 0.75rem; color: var(--muted); }
.small-head { font-family: var(--font-display); margin: 14px 0 6px; font-size: 1rem; }
.drip-parts { list-style: none; padding: 0; margin: 0 0 6px; display: grid; gap: 4px; }
.drip-parts li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dashed var(--border); font-size: 0.9rem; }
.source-fields { display: grid; gap: 6px; padding: 8px 10px; border-radius: 10px; background: #e6eef4; margin: 6px 0; }
@media (max-width: 520px) { .drip-summary { grid-template-columns: 1fr 1fr; } }

/* ---------- Sidebar tabs ---------- */
.side-tabs { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0 0 10px; padding: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-card); }
.side-tabs button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border: none; border-radius: 10px; background: transparent; color: var(--muted); font-size: 0.74rem; font-weight: 700; }
.side-tabs button .ic { width: 20px; height: 20px; margin: 0; }
.side-tabs button:hover { background: var(--accent-soft); color: var(--accent); }
.side-tabs button.on { background: var(--accent); color: #f4eedf; }
.side-badge { position: absolute; top: 2px; right: calc(50% - 22px); min-width: 17px; height: 17px; padding: 0 4px; box-sizing: border-box; border-radius: 999px; background: var(--terracotta); color: #fff; font-size: 0.66rem; line-height: 17px; text-align: center; }
#view-editor .sidebar[data-tab="garden"] [data-side]:not([data-side="garden"]),
#view-editor .sidebar[data-tab="details"] [data-side]:not([data-side="details"]),
#view-editor .sidebar[data-tab="plants"] [data-side]:not([data-side="plants"]),
#view-editor .sidebar[data-tab="check"] [data-side]:not([data-side="check"]) { display: none !important; }
.details-empty { text-align: center; padding: 26px 16px; }
.details-empty .ic { width: 30px; height: 30px; color: var(--muted); margin-bottom: 6px; }
.details-empty p { margin: 2px 0; }
.panel > h2 .ic { margin-right: 6px; color: var(--accent); }
/* On phones the tabs sit just under the panel's handle. */
@media (max-width: 640px) { #view-editor .side-tabs { top: 26px; box-shadow: none; } }

/* ---------- Medium windows (a narrow desktop window, a tablet) ---------- */
.install-btn { display: inline-flex; align-items: center; gap: 6px; }
.install-btn .ic { margin: 0; }
.topbar { flex-wrap: nowrap; }
@media (max-width: 1180px) { .brand-slogan { display: none; } }
@media (max-width: 1120px) {
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .install-label { display: none; }
  .install-btn { padding: 6px 9px; }
  .garden-switch-btn { max-width: 170px; }
  .tab { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 960px) {
  .brand-name { display: none; }
  .tab { font-size: 0.82rem; }
}
@media (min-width: 641px) and (max-width: 820px) {
  .tab { font-size: 0; gap: 0; padding: 8px 10px; } /* icons only; each tab has its name for screen readers and a hover tip */
  .tab .ic { width: 20px; height: 20px; margin: 0; }
}
@media (max-width: 640px) { .topbar { flex-wrap: wrap; } }

/* The plan's toolbar: icons only when the plan area is narrow (each button keeps its name as a tip). */
.canvas-wrap { container-type: inline-size; container-name: plan; }
@container plan (max-width: 720px) {
  .toolbar .tool { font-size: 0; gap: 0; padding: 8px 9px; }
  .toolbar .tool .ic { width: 20px; height: 20px; margin: 0; }
  .toolbar .tool .caret-ic { display: none; }
  .toolbar .tool .tool-label { font-size: 0; }
  .season-banner { font-size: 0.78rem; }
}
@media (min-width: 641px) and (max-width: 820px) { .garden-switch-btn { max-width: 130px; } .topbar { gap: 6px; } }
.topbar .round-btn, .topbar .help-btn, .topbar .install-btn, .topbar .units, .topbar .brand-mark { flex: none; }
@container plan (max-width: 560px) { .statusbar #mode-hint, .statusbar #cursor-pos { display: none; } }

/* ---------- Planted it today ---------- */
.planted-box { margin: 8px 0 10px; padding: 8px 10px; border-radius: 10px; background: #f1f7ec; border: 1px solid #d6e8cc; }
.planted-box .row { gap: 8px; align-items: center; flex-wrap: wrap; }
.planted-box input[type=date] { padding: 4px 6px; font-size: 0.85rem; }
.planted-box p { margin: 6px 0 0; }
.planted-note { color: #1f6b2a; }

/* ---------- Seed sprout tests ---------- */
.stash-list li { flex-wrap: wrap; }
.germ-tag { font-size: 0.72rem; border-radius: 8px; padding: 1px 6px; margin-left: 4px; white-space: nowrap; }
.germ-tag.good { background: #e3f1df; color: #1f6b2a; }
.germ-tag.mid { background: #fff1d6; color: #8a5a00; }
.germ-tag.low { background: #fbe1dc; color: #9b2c1c; }
.germ-test { flex-basis: 100%; margin: 6px 0 4px; padding: 8px 10px; border-radius: 8px; background: #f7f1e3; }
.germ-test input[type=number] { width: 4.2em; padding: 3px 5px; }

/* ---------- What can I plant today? ---------- */
.plant-now { border-left: 4px solid #3f9a3f; }
.plant-now-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.plant-now-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; background: #f6f9f1; }
.plant-now-row.wait { background: #fbf6ea; }
.plant-now-row .pn-text { flex: 1; min-width: 0; }
.plant-now-row .pn-text .small { margin-top: 2px; }
.plant-now-row button { flex: none; }
.pn-tag { font-size: 0.7rem; border-radius: 8px; padding: 1px 6px; margin-left: 2px; white-space: nowrap; }
.pn-tag.have { background: #e3f1df; color: #1f6b2a; }
.pn-tag.plan { background: #ece6f7; color: #5a3f8a; }

/* ---------- The week ahead (watering) ---------- */
.wk-scroll { overflow-x: auto; margin: 6px 0; }
.wk-table { border-collapse: separate; border-spacing: 3px; width: 100%; min-width: 520px; font-size: 0.82rem; }
.wk-table thead th { font-weight: 600; text-align: center; vertical-align: bottom; padding: 2px 4px; }
.wk-table thead th span { display: block; line-height: 1.2; }
.wk-rain { color: #2f6db5; font-size: 0.72rem; font-weight: 500; }
.wk-high { color: var(--muted); font-size: 0.72rem; font-weight: 400; }
.wk-table tbody th { text-align: left; font-weight: 400; padding: 4px 6px 4px 0; min-width: 7em; }
.wk-table tbody th span { display: block; }
.wk-table td { text-align: center; border-radius: 8px; height: 40px; background: #f5f1e7; font-size: 1rem; }
.wk-table td.wk-water { background: #dcebf8; }
.wk-table td.wk-rain { background: #e6eef7; }
.wk-table td.wk-skip { background: #f4efe2; }
.wk-amt { display: block; font-size: 0.68rem; color: #2f5d8a; }

/* ---------- Does the garden pay for itself? ---------- */
.hv-summary .payback, .hv-summary .payback-hint { grid-column: 1 / -1; }
.payback { margin-top: 4px; padding: 10px 12px; border-radius: 10px; background: #f6f9f1; border: 1px solid #d6e8cc; }
.payback-row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.9rem; }
.payback-bar { height: 10px; border-radius: 5px; background: #e6e0d0; margin: 8px 0 6px; overflow: hidden; }
.payback-bar i { display: block; height: 100%; background: linear-gradient(90deg, #6aa84f, #2e7d32); border-radius: 5px; }
.payback p { margin: 0; }
.nb-tag.spent { background: #eef3e2; color: #4a6b1f; }

/* ---------- Decks, steps and arches on the plan ---------- */
#canvas .art-deck { fill: #b8875a; stroke: #7a5232; stroke-width: 1.5; }
#canvas .art-deck-gap { stroke: #7f5634; stroke-width: 1; fill: none; vector-effect: non-scaling-stroke; opacity: 0.7; }
#canvas .art-steps { fill: #c9c3b6; stroke: #8d867a; stroke-width: 1.5; }
#canvas .art-step-edge { stroke: #7b7468; stroke-width: 1.6; fill: none; vector-effect: non-scaling-stroke; }
#canvas .art-arch { fill: rgba(160, 122, 82, 0.18); stroke: #7a5a3a; stroke-width: 2; }
#canvas .art-arch-slat { stroke: #8a6a45; stroke-width: 2.2; fill: none; vector-effect: non-scaling-stroke; }
.planted-note.late { color: #8a5a00; }
.pn-icon { display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; margin-right: 6px; border-radius: 50%; font-size: 0.95rem; vertical-align: -0.2em; }
.pn-icon.letters { color: #fff; font-size: 0.62rem; font-weight: 700; text-transform: capitalize; }
.wk-table tbody th, .wk-table thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); }
@media (max-width: 640px) { .wk-table { min-width: 470px; } .wk-table tbody th { min-width: 6.2em; max-width: 7.5em; } }
@media (max-width: 640px) { .sheet-handle { flex: none; } } /* keep its full height in the panel's column, so nothing shows above the tabs */

/* ---------- Several plants at once ---------- */
.pick-done { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 6; padding: 8px 16px; border-radius: 999px; border: none; background: var(--accent); color: #f4eedf; font-weight: 700; box-shadow: var(--shadow-card); }
body.picking #canvas { cursor: copy; }
.pick-more { margin: 2px 0 8px; }
.pick-more.on { color: var(--accent); font-weight: 700; }
.harvest-box { margin: 8px 0 10px; padding: 8px 10px; border-radius: 10px; background: #fbf4e6; border: 1px solid #eedfc0; }
.hv-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.hv-row .hv-name { flex: 1 1 8em; min-width: 0; font-size: 0.85rem; }
.hv-row input { width: 5.5em; padding: 4px 6px; }
.hv-row select { padding: 4px; }

/* ---------- Quick setup ---------- */
.quick-setup { width: min(560px, calc(100vw - 24px)); padding: 18px 20px 16px; border: none; border-radius: 18px; background: var(--panel); box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.quick-setup::backdrop { background: rgba(40, 32, 20, 0.45); }
.qs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.qs-steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; counter-reset: qs; }
.qs-steps li { counter-increment: qs; font-size: 0.75rem; color: var(--muted); padding: 3px 10px 3px 4px; border-radius: 999px; background: #f1ebdc; display: flex; align-items: center; gap: 5px; }
.qs-steps li::before { content: counter(qs); display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #e2d8c2; color: var(--muted); font-weight: 700; }
.qs-steps li.on { color: var(--accent); font-weight: 700; }
.qs-steps li.on::before { background: var(--accent); color: #f4eedf; }
.qs-steps li.done::before { content: '✓'; background: #b7d3a8; color: #1f4d22; }
.quick-setup h2 { margin: 8px 0 4px; }
.qs-search { display: flex; gap: 8px; margin: 10px 0 6px; }
.qs-search input { flex: 1; min-width: 0; font-size: 1rem; padding: 9px 11px; }
.qs-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.qs-result { width: 100%; text-align: left; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: #fffdf7; font-size: 0.85rem; }
.qs-result:hover { background: var(--accent-soft); }
.qs-nav { margin-top: 14px; align-items: center; }
.qs-nav .spacer { flex: 1; }
.qs-sizes, .qs-beds { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.qs-dims { display: flex; align-items: flex-end; gap: 8px; margin: 8px 0; }
.qs-dims input { width: 5.5em; }
.qs-themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 6px; }
.qs-themes .theme-card { padding: 8px; text-align: left; }
.qs-themes .theme-card.on { outline: 2px solid var(--accent); background: var(--accent-soft); }
.sd-quick { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: end; }
.sd-quick label { display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; color: var(--muted); }
.sd-quick .sd-row { display: flex; gap: 4px; }
.sd-quick #sd-amount { width: 4.5em; }
.sd-quick #sd-year { width: 5.5em; }
.sd-quick .sd-match { grid-column: 1 / -1; margin: 0; min-height: 1.2em; color: var(--accent); }
@media (max-width: 640px) { .sd-quick { grid-template-columns: 1fr 1fr; } .sd-quick .sd-name-wrap { grid-column: 1 / -1; } }

/* ---------- Grow panel: years row, and a slimmer panel on phones ---------- */
.grow-years { margin: 2px 0 6px; }
.mini-seg button.on { background: var(--accent); color: #f4eedf; border-color: var(--accent); }
@media (max-width: 640px) {
  .grow-panel { left: 6px; right: 6px; bottom: 34px; width: auto; max-width: none; padding: 6px 8px; font-size: 0.8rem; }
  .grow-panel .sun-head { margin-bottom: 2px; }
  .grow-months, .grow-years { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-bottom: 4px; }
  .grow-months::-webkit-scrollbar, .grow-years::-webkit-scrollbar { display: none; }
  .grow-months button, .grow-years button { flex: none; }
  .grow-readout { max-height: 2.9em; line-height: 1.4; }
}

/* ---------- What do you see? ---------- */
.ps-symptoms { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 6px; margin: 6px 0 10px; }
.ps-sym { display: flex; align-items: center; gap: 8px; text-align: left; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: #fffdf7; font-size: 0.82rem; line-height: 1.25; }
.ps-sym span { font-size: 1.3rem; flex: none; }
.ps-sym:hover { background: var(--accent-soft); }
.ps-sym.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.ps-other { margin: 0 0 10px; padding: 8px 10px; border-radius: 10px; background: #f6f9f1; font-size: 0.85rem; }
.frost-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.frost-list li { display: flex; gap: 6px; align-items: baseline; }
.frost-list input { flex: none; }

/* ---------- How did it do? ---------- */
.plant-notes { margin: 8px 0 10px; padding: 8px 10px; border-radius: 10px; background: #f4f1fa; border: 1px solid #e0d9ef; }
.plant-notes ul { list-style: none; margin: 4px 0 6px; padding: 0; display: grid; gap: 3px; }
.plant-notes li { display: flex; gap: 6px; align-items: baseline; }
.plant-notes li .icon-btn { margin-left: auto; }
.pn-year { font-weight: 700; color: #5a3f8a; font-size: 0.75rem; }
.pn-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pn-form input { flex: 1 1 10em; min-width: 0; padding: 5px 7px; }
.pn-rate { display: flex; gap: 2px; }
.pn-rate button { padding: 3px 6px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 1rem; line-height: 1; }
.pn-rate button.on { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- Calendar by bed ---------- */
.timeline-head .tl-mode { margin-left: auto; }
.tl-track.tl-lanes { height: calc(var(--lanes, 1) * 20px + 4px); }
.bar.lane { position: absolute; box-sizing: border-box; padding: 0 5px; border: 2px solid #fff; border-radius: 6px;
  background: color-mix(in srgb, var(--c) 55%, #fff); color: #1f2a1a; font-size: 0.68rem; line-height: 16px; font-style: normal;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar.lane.perennial { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--c) 45%, #fff) 0 6px, color-mix(in srgb, var(--c) 30%, #fff) 6px 12px); }
.bar.gap { position: absolute; top: 2px; bottom: 2px; height: auto; border: 2px dashed #c9b98f; border-radius: 6px; background: rgba(255, 248, 225, 0.6); }
@media print {
  .month-sheet h2 { border-bottom: 2px solid #2f6a24; padding-bottom: 2px; }
  .month-list { list-style: none; margin: 4px 0 8px; padding: 0; }
  .month-list li { display: flex; gap: 8px; padding: 3px 0; break-inside: avoid; }
  .month-list .box { flex: none; width: 11px; height: 11px; margin-top: 3px; border: 1.5px solid #333; border-radius: 2px; }
  .note-line { border-bottom: 1px solid #bbb; height: 26px; }
}

/* ---------- Account and sync ---------- */
.account-btn { position: relative; }
.sync-dot { position: absolute; right: 2px; bottom: 2px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--panel); background: #9aa; }
.sync-dot.synced { background: #3f9a3f; }
.sync-dot.syncing { background: #e3a33a; animation: sync-pulse 1s ease-in-out infinite alternate; }
.sync-dot.offline { background: #9aa4ad; }
.sync-dot.error { background: #c0392b; }
@keyframes sync-pulse { to { opacity: 0.35; } }
.account-dialog { width: min(480px, calc(100vw - 24px)); padding: 16px 18px; border: none; border-radius: 16px; background: var(--panel); box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.account-dialog::backdrop { background: rgba(40, 32, 20, 0.45); }
.acct-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.acct-form input { flex: 1 1 12em; min-width: 0; padding: 8px 10px; font-size: 1rem; }
.acct-google { width: 100%; margin: 4px 0 8px; }
.acct-sent { padding: 8px 10px; border-radius: 10px; background: #f6f9f1; }
.acct-status.synced { color: #1f6b2a; }
.acct-status.error { color: #9b2c1c; }
.acct-share { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.acct-share h3 { margin: 0 0 4px; font-size: 1rem; }
.acct-members { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.acct-members li { display: flex; gap: 8px; align-items: center; }
.acct-members li span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.share-banner { position: absolute; left: 50%; top: 172px; transform: translateX(-50%); z-index: 5; max-width: calc(100% - 24px); padding: 5px 12px; border-radius: 999px; background: #ece6f7; color: #4a3577; font-size: 0.8rem; box-shadow: var(--shadow-card); }
.acct-paste { margin: 4px 0 8px; }
.acct-paste summary { cursor: pointer; color: var(--accent); }
.acct-code input { letter-spacing: 0.25em; font-variant-numeric: tabular-nums; }
