
  :root {
    --bg: #f4f0e8; --bg2: #ede8dc; --surface: #faf8f3; --border: #d4cfc3;
    --text: #1c1a16; --text2: #6b6459; --text3: #9c9488;
    --accent-green: #3d6b47; --accent-green-light: #e8f0ea;
    --accent-amber: #b87333; --accent-amber-light: #f5ede0;
    --accent-blue: #3a5a8b; --accent-blue-light: #e8eef5;
    --urgent: #c0392b; --urgent-bg: #fdf0ef;
    --soon: #d68910; --soon-bg: #fef9ec;
    --later: #27ae60; --later-bg: #edfbf3;
    --waiting: #7f8c8d; --waiting-bg: #f4f6f6;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; line-height: 1.5; }

  header { background: var(--text); color: var(--bg); padding: 20px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
  .header-left h1 { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 600; letter-spacing: 0.01em; }
  .header-left p { font-family: 'DM Mono', monospace; font-size: 11px; opacity: 0.5; margin-top: 2px; letter-spacing: 0.05em; }
  .weather-pill { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15); border-radius: 20px; padding: 6px 14px; font-family: 'DM Mono', monospace; font-size: 12px; display: flex; align-items: center; gap: 8px; }
  .weather-pill .temp { font-weight: 500; } .weather-pill .desc { opacity: 0.6; }

  button, .btn { cursor: pointer; border: none; border-radius: 6px; font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500; padding: 7px 16px; transition: all 0.15s; }
  .btn-primary { background: var(--accent-green); color: white; } .btn-primary:hover { background: #2e5236; }
  .btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); } .btn-secondary:hover { background: var(--bg2); }
  .btn-secondary.copied { color: var(--accent-green); border-color: var(--accent-green); }
  .btn-amber { background: var(--accent-amber); color: white; } .btn-amber:hover { background: #9a612a; }

  .app { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 65px); }

  aside { background: var(--surface); border-right: 1px solid var(--border); padding: 24px 0; position: sticky; top: 0; height: calc(100vh - 65px); overflow-y: auto; }
  .sidebar-section { padding: 0 20px; margin-bottom: 28px; }
  .sidebar-label { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 0.12em; color: var(--text3); text-transform: uppercase; margin-bottom: 10px; }
  .nav-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: 8px; cursor: pointer; transition: all 0.12s; margin-bottom: 2px; color: var(--text2); font-size: 13px; }
  .nav-item:hover { background: var(--bg2); color: var(--text); }
  .nav-item.active { background: var(--accent-green-light); color: var(--accent-green); font-weight: 500; }
  .nav-item .nav-icon { font-size: 15px; margin-right: 8px; }
  .nav-badge { background: var(--urgent); color: white; border-radius: 10px; font-size: 10px; font-family: 'DM Mono', monospace; padding: 2px 7px; font-weight: 500; }
  .nav-badge.green { background: var(--later); }
  .nav-badge.amber { background: var(--accent-amber); }

  /* PRODUCTS — "needs replenishing" panel */
  .replenish-card { background: var(--accent-amber-light); border: 1px solid #e6cfa6; border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; }
  .replenish-head { font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-amber); display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
  .replenish-count { background: var(--accent-amber); color: #fff; border-radius: 10px; font-size: 10px; padding: 1px 7px; }
  .replenish-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #e6cfa6; cursor: pointer; transition: opacity 0.12s; }
  .replenish-row:hover { opacity: 0.7; }
  .replenish-name { font-weight: 500; font-size: 13px; color: var(--text); }
  .replenish-where { margin-left: auto; font-size: 12px; color: var(--text2); font-family: 'DM Mono', monospace; white-space: nowrap; }
  .stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filter-sublabel { font-size: 9px; color: var(--text3); font-family: 'DM Mono', monospace; letter-spacing: 0.1em; text-transform: uppercase; margin: 12px 0 5px; }
  .stat-card { background: var(--bg2); border-radius: 8px; padding: 10px 12px; text-align: center; cursor: pointer; transition: all 0.15s; border: 1.5px solid transparent; }
  .stat-card:hover { background: var(--accent-green-light); border-color: var(--accent-green); }
  .stat-card.active { background: var(--accent-green-light); border-color: var(--accent-green); }
  .stat-card .num { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 600; color: var(--accent-green); line-height: 1; }
  .stat-card .lbl { font-size: 10px; color: var(--text3); margin-top: 3px; font-family: 'DM Mono', monospace; letter-spacing: 0.05em; }

  main { padding: 28px 32px; overflow-y: auto; }
  .section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
  .section-title { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 600; }
  .section-subtitle { font-size: 12px; color: var(--text3); margin-top: 2px; font-family: 'DM Mono', monospace; }

  #ai-panel { background: var(--text); color: var(--bg); border-radius: 12px; padding: 24px; margin-bottom: 20px; position: relative; overflow: hidden; }
  #ai-panel::before { content: ''; position: absolute; top: -40px; right: -40px; width: 160px; height: 160px; background: radial-gradient(circle, rgba(61,107,71,0.3) 0%, transparent 70%); pointer-events: none; }
  .ai-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
  .ai-label { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 0.12em; opacity: 0.5; text-transform: uppercase; }
  .ai-content { font-size: 14px; line-height: 1.7; opacity: 0.9; }
  .ai-loading { display: flex; align-items: center; gap: 10px; opacity: 0.6; font-family: 'DM Mono', monospace; font-size: 13px; }
  .dot-pulse { display: flex; gap: 4px; }
  .dot-pulse span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
  .dot-pulse span:nth-child(2) { animation-delay: 0.2s; } .dot-pulse span:nth-child(3) { animation-delay: 0.4s; }
  @keyframes pulse { 0%,80%,100% { opacity:0.2; transform:scale(0.8); } 40% { opacity:1; transform:scale(1); } }
  .refresh-btn { background: none; border: 1px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.7); border-radius: 6px; padding: 5px 12px; font-size: 12px; font-family: 'DM Mono', monospace; cursor: pointer; transition: all 0.15s; }
  .refresh-btn:hover { background: rgba(255,255,255,0.1); color: white; }
  .refresh-btn.copied { color: var(--accent-green); border-color: var(--accent-green); background: rgba(255,255,255,0.06); }

  /* CHAT */
  #chat-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 20px; overflow: hidden; }
  .chat-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
  .chat-header-title { font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text2); }
  .chat-toggle { background: none; border: none; padding: 0; font-size: 13px; color: var(--text3); cursor: pointer; font-family: 'DM Mono', monospace; }
  #chat-body { display: none; } #chat-body.open { display: block; }
  #chat-messages { padding: 16px; max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
  .chat-msg { padding: 10px 14px; border-radius: 10px; font-size: 13px; line-height: 1.6; max-width: 88%; }
  .chat-msg.user { background: var(--accent-green); color: white; align-self: flex-end; border-bottom-right-radius: 3px; }
  .chat-msg.assistant { background: var(--bg2); color: var(--text); align-self: flex-start; border-bottom-left-radius: 3px; }
  .chat-msg.loading { background: var(--bg2); align-self: flex-start; color: var(--text3); }

  /* DB ACTION NOTICE */
  .chat-action { background: var(--accent-green-light); border: 1px solid #b8d4bc; border-radius: 8px; padding: 8px 12px; font-size: 12px; color: var(--accent-green); font-family: 'DM Mono', monospace; align-self: flex-start; max-width: 88%; }
  .chat-action-icon { margin-right: 6px; }

  .chat-empty { text-align: center; padding: 20px; color: var(--text3); font-size: 12px; font-family: 'DM Mono', monospace; }
  .chat-input-row { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg); }
  #chat-input { flex: 1; font-family: 'DM Sans', sans-serif; font-size: 13px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); outline: none; resize: none; line-height: 1.4; }
  #chat-input:focus { border-color: var(--accent-green); }
  #chat-send { background: var(--accent-green); color: white; border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; transition: all 0.15s; align-self: flex-end; }
  #chat-send:hover { background: #2e5236; } #chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
  .chat-footer { padding: 6px 16px 10px; font-family: 'DM Mono', monospace; font-size: 10px; color: var(--text3); display: flex; justify-content: space-between; align-items: center; background: var(--bg); border-top: 1px solid var(--border); }
  .chat-clear { cursor: pointer; color: var(--text3); background: none; border: none; font-family: 'DM Mono', monospace; font-size: 10px; padding: 0; }
  .chat-clear:hover { color: var(--accent-red, #8b3a3a); }

  /* TASKS */
  .weather-bar { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; margin-bottom: 20px; display: flex; gap: 24px; flex-wrap: wrap; align-items: center; }
  .weather-stat { text-align: center; }
  .weather-stat .val { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 600; color: var(--accent-green); line-height: 1; }
  .weather-stat.measured .val { color: var(--accent-blue); }
  .weather-stat .key { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--text3); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.06em; }
  .weather-divider { width: 1px; background: var(--border); align-self: stretch; }
  .forecast-pills { display: flex; gap: 8px; flex-wrap: wrap; }
  .forecast-pill { background: var(--bg2); border-radius: 8px; padding: 6px 10px; text-align: center; font-family: 'DM Mono', monospace; }
  .forecast-pill .day { font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; }
  .forecast-pill .ftemp { font-size: 13px; font-weight: 500; color: var(--text); }
  .forecast-pill .ficon { font-size: 14px; }

  .task-group { margin-bottom: 28px; }
  .task-group-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .urgency-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
  .urgency-dot.urgent { background: var(--urgent); } .urgency-dot.soon { background: var(--soon); } .urgency-dot.later { background: var(--later); } .urgency-dot.waiting { background: var(--waiting); }
  .task-group-title { font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text2); font-weight: 500; }
  .task-count { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text3); margin-left: auto; }
  .task-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 8px; display: flex; gap: 14px; align-items: flex-start; transition: all 0.15s; }
  .task-card:hover { border-color: #bbb8ae; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
  .task-card.urgent { border-left: 3px solid var(--urgent); } .task-card.soon { border-left: 3px solid var(--soon); } .task-card.later { border-left: 3px solid var(--later); } .task-card.waiting { border-left: 3px solid var(--border); }
  .task-check { width: 20px; height: 20px; border: 1.5px solid var(--border); border-radius: 5px; cursor: pointer; flex-shrink: 0; margin-top: 1px; display: flex; align-items: center; justify-content: center; transition: all 0.15s; background: transparent; font-size: 12px; color: var(--accent-green); }
  .task-check:hover { border-color: var(--accent-green); background: var(--accent-green-light); }
  .task-body { flex: 1; min-width: 0; }
  .task-name { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 3px; }
  .task-name-link { color: var(--accent-green); font-weight: 600; }
  .task-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; }
  .task-tag { font-family: 'DM Mono', monospace; font-size: 10px; padding: 2px 7px; border-radius: 4px; letter-spacing: 0.04em; }
  .tag-garden { background: var(--accent-green-light); color: var(--accent-green); } .tag-household { background: var(--accent-blue-light); color: var(--accent-blue); } .tag-veggie { background: #f0f5e8; color: #4a7a2e; } .tag-linked { background: var(--bg2); color: var(--text2); }
  .task-reason { font-size: 12px; color: var(--text2); line-height: 1.5; font-style: italic; }
  .task-last-done { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--text3); margin-top: 4px; }
  .task-notes { font-size: 11px; color: var(--text3); margin-top: 3px; font-family: 'DM Mono', monospace; }
  .urgency-badge { font-family: 'DM Mono', monospace; font-size: 10px; padding: 3px 8px; border-radius: 4px; font-weight: 500; flex-shrink: 0; align-self: flex-start; margin-top: 1px; white-space: nowrap; }
  .badge-urgent { background: var(--urgent-bg); color: var(--urgent); } .badge-soon { background: var(--soon-bg); color: var(--soon); } .badge-later { background: var(--later-bg); color: var(--later); } .badge-waiting { background: var(--waiting-bg); color: var(--waiting); }
  .done-card { opacity: 0.4; } .done-card .task-name { text-decoration: line-through; }

  /* BROWSE */
  .browse-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
  .browse-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; transition: all 0.15s; }
  .browse-card:hover { border-color: #bbb8ae; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
  .browse-card-title { font-weight: 500; font-size: 14px; margin-bottom: 4px; }
  .browse-card-sub { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text3); margin-bottom: 8px; font-style: italic; }
  .browse-card-detail { font-size: 12px; color: var(--text2); line-height: 1.5; }
  .browse-card-zone { display: inline-block; font-family: 'DM Mono', monospace; font-size: 10px; padding: 2px 7px; border-radius: 4px; background: var(--bg2); color: var(--text2); margin-top: 8px; }

  /* ANALYSIS HISTORY */
  .analysis-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
  .analysis-card-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; cursor: pointer; gap: 12px; }
  .analysis-card-header:hover { background: var(--bg2); }
  .analysis-card-date { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text2); white-space: nowrap; }
  .analysis-card-preview { font-size: 12px; color: var(--text3); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .analysis-card-chevron { font-size: 12px; color: var(--text3); flex-shrink: 0; }
  .analysis-card-body { display: none; padding: 16px; border-top: 1px solid var(--border); font-size: 13px; line-height: 1.7; color: var(--text); background: var(--bg); }
  .analysis-card-body.open { display: block; }
  /* markdown rendered by mdFmt() in chat + analysis — conservative sizing, tweak to taste */
  .ai-content h2, .ai-content h3, .ai-content h4, .analysis-card-body h2, .analysis-card-body h3, .analysis-card-body h4, .chat-msg h2, .chat-msg h3, .chat-msg h4 { font-weight: 700; line-height: 1.3; margin: 0.7em 0 0.3em; }
  .ai-content h2, .analysis-card-body h2, .chat-msg h2 { font-size: 1.3em; }
  .ai-content h3, .analysis-card-body h3, .chat-msg h3 { font-size: 1.15em; }
  .ai-content h4, .analysis-card-body h4, .chat-msg h4 { font-size: 1.05em; opacity: 0.85; }
  .ai-content ul, .ai-content ol, .analysis-card-body ul, .analysis-card-body ol, .chat-msg ul, .chat-msg ol { margin: 0.3em 0; padding-left: 1.4em; }
  .ai-content li, .analysis-card-body li, .chat-msg li { margin: 0.15em 0; }
  .analysis-weather-summary { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text3); margin-bottom: 12px; padding: 8px 10px; background: var(--surface); border-radius: 6px; border: 1px solid var(--border); }

  /* TABS */
  .tab-bar { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg2); padding: 4px; border-radius: 8px; width: fit-content; }
  .tab { padding: 6px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text2); transition: all 0.12s; }
  .tab.active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

  /* MODAL */
  .modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; align-items: center; justify-content: center; }
  .modal-overlay.open { display: flex; }
  /* sub-action modals open from inside an entity editor (e.g. task/care from the veg or plant modal) — keep them above it. Entity editors (plant/item/veg) stay at z 100. */
  #done-modal, #task-modal, #care-modal, #log-modal, #product-modal { z-index: 110; }
  .modal { background: var(--surface); border-radius: 12px; padding: 28px; width: 90%; max-width: 460px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
  .modal h3 { font-family: 'Playfair Display', serif; font-size: 18px; margin-bottom: 6px; }
  .modal label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 6px; color: var(--text2); }
  .modal textarea { width: 100%; font-family: 'DM Sans', sans-serif; font-size: 13px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); resize: vertical; min-height: 80px; outline: none; margin-bottom: 16px; }
  .modal textarea:focus { border-color: var(--accent-green); }
  .modal-actions { display: flex; gap: 10px; justify-content: flex-end; }


  /* ADD PLANT / ITEM MODAL */
  .modal-wide { max-width: 680px; max-height: 88vh; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
  .modal-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 28px 28px 14px; }
  .modal-wide .modal-actions { flex-shrink: 0; padding: 14px 28px; border-top: 1px solid var(--border); background: var(--surface); }
  .modal-wide h3 { font-family: 'Playfair Display', serif; font-size: 18px; margin-bottom: 4px; }
  .modal-wide .modal-sub { font-size: 12px; color: var(--text3); font-family: 'DM Mono', monospace; margin-bottom: 20px; }

  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
  .form-grid.single { grid-template-columns: 1fr; }
  .form-field { display: flex; flex-direction: column; gap: 5px; }
  .form-field label { font-size: 12px; font-weight: 500; color: var(--text2); }
  .form-field input, .form-field select, .form-field textarea {
    font-family: 'DM Sans', sans-serif; font-size: 13px;
    padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px;
    background: var(--bg); color: var(--text); outline: none;
  }
  .form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--accent-green); }
  .form-field textarea { resize: vertical; min-height: 150px; }

  .suggest-btn {
    width: 100%; padding: 10px; margin: 4px 0 16px;
    background: var(--text); color: var(--bg);
    border: none; border-radius: 8px; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all 0.15s; font-family: 'DM Sans', sans-serif;
    display: flex; align-items: center; justify-content: center; gap: 8px;
  }
  .suggest-btn:hover { background: #2e2c28; }
  .suggest-btn:disabled { opacity: 0.5; cursor: not-allowed; }

  .suggested-tasks { margin-bottom: 16px; }
  .suggested-tasks-label { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text3); margin-bottom: 10px; }

  .suggested-task-card {
    background: var(--bg); border: 1px solid var(--border); border-radius: 9px;
    padding: 12px 14px; margin-bottom: 8px; position: relative;
  }
  .suggested-task-card .stc-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px; }
  .suggested-task-card input[type="text"] { font-size: 13px; font-weight: 500; border: none; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; padding: 2px 0; width: 100%; }
  .suggested-task-card input[type="text"]:focus { border-bottom-color: var(--accent-green); outline: none; }
  .stc-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 8px; }
  .stc-field { display: flex; flex-direction: column; gap: 3px; }
  .stc-field label { font-size: 10px; color: var(--text3); font-family: 'DM Mono', monospace; }
  .stc-field input, .stc-field select { font-size: 12px; padding: 4px 7px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text); font-family: 'DM Sans', sans-serif; }
  .stc-weather { font-size: 11px; color: var(--text2); font-style: italic; margin-top: 6px; padding: 5px 8px; background: var(--surface); border-radius: 5px; border: 1px solid var(--border); }
  .stc-weather-edit { width: 100%; font-size: 11px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text2); font-family: 'DM Sans', sans-serif; font-style: italic; margin-top: 6px; resize: none; min-height: 40px; }
  .stc-notes-edit { width: 100%; font-size: 12px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text); font-family: 'DM Sans', sans-serif; margin-top: 4px; resize: vertical; min-height: 54px; }
  .stc-mini-label { display: block; font-family: 'DM Mono', monospace; font-size: 9px; letter-spacing: 0.08em; color: var(--text3); text-transform: uppercase; margin-top: 8px; }
  .stc-weather-edit:focus { outline: none; border-color: var(--accent-green); }
  .stc-remove { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px; padding: 0 4px; flex-shrink: 0; }
  .stc-remove:hover { color: var(--urgent); }

  .modal-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }


  /* TASK EDIT PANEL */
  .task-edit-toggle { background: none; border: none; color: var(--text3); font-size: 11px; font-family: 'DM Mono', monospace; cursor: pointer; padding: 2px 6px; border-radius: 4px; }
  .task-edit-toggle:hover { background: var(--bg2); color: var(--text2); }
  .task-edit-toggle.copied { color: var(--accent-green); }
  .task-meta-actions { margin-left: auto; display: flex; gap: 2px; }
  /* (inline task-edit panel removed — editing now happens in the task modal) */


  /* PLANT EDIT & TASKS PANEL */
  .plant-edit-toggle { background: none; border: 1px solid var(--border); color: var(--text3); font-size: 11px; font-family: 'DM Mono', monospace; cursor: pointer; padding: 3px 8px; border-radius: 4px; margin-top: 8px; margin-right: 6px; }
  .plant-edit-toggle:hover { background: var(--bg2); color: var(--text2); }
  .plant-tasks-toggle { background: none; border: 1px solid var(--border); color: var(--text3); font-size: 11px; font-family: 'DM Mono', monospace; cursor: pointer; padding: 3px 8px; border-radius: 4px; margin-top: 8px; }
  .plant-tasks-toggle:hover { background: var(--bg2); color: var(--text2); }
  .plant-panel { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
  .plant-panel.open { display: block; }
  /* (inline plant-edit fields removed — editing now happens in the plant modal) */
  .plant-task-item { padding: 6px 0; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 8px; }
  .plant-task-item:last-child { border-bottom: none; }
  .plant-task-urgency { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
  .plant-task-urgency.urgent { background: var(--urgent); }
  .plant-task-urgency.soon { background: var(--soon); }
  .plant-task-urgency.later { background: var(--later); }
  .plant-task-urgency.waiting { background: var(--waiting); }
  .product-picker { display: flex; flex-wrap: wrap; gap: 6px; }
  .product-chip { font-size: 12px; padding: 5px 10px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg2); color: var(--text2); cursor: pointer; transition: all 0.12s; user-select: none; }
  .product-chip:hover { border-color: var(--accent-green); }
  .product-chip.selected { background: var(--accent-green-light); border-color: var(--accent-green); color: var(--accent-green); font-weight: 500; }
  .product-group-label { font-family:'DM Mono',monospace; font-size:11px; letter-spacing:0.08em; text-transform:uppercase; color:var(--text3); margin:18px 0 10px; }
  .product-group-label:first-child { margin-top:0; }
  .product-picker-empty { font-size: 12px; color: var(--text3); font-style: italic; }
  /* grouped picker: type headers mirror the Products page; stock hint on chips */
  .product-picker .picker-group-label { flex-basis: 100%; font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text3); margin: 8px 0 2px; }
  .product-picker .picker-group-label:first-child { margin-top: 0; }
  .product-chip.stock-out { opacity: 0.55; }
  .chip-stock { font-size: 10px; color: var(--soon); margin-left: 3px; }
  .plant-task-name { font-size: 12px; font-weight: 500; color: var(--text); }
  .plant-task-meta { font-size: 11px; color: var(--text3); font-family: 'DM Mono', monospace; margin-top: 1px; }
  .task-tick { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; padding: 0; border-radius: 50%; border: 1.5px solid var(--border); background: transparent; color: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; line-height: 1; transition: background .12s, border-color .12s, color .12s; }
  .task-tick:hover { border-color: var(--accent-green); color: var(--accent-green); }
  .task-tick.done { background: var(--accent-green); border-color: var(--accent-green); color: #fff; }

  .empty-state { text-align: center; padding: 60px 20px; color: var(--text3); }
  .empty-state .icon { font-size: 40px; margin-bottom: 12px; }
  ::-webkit-scrollbar { width: 6px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
  #toast-host { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
  .toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); display: flex; align-items: center; gap: 14px; pointer-events: auto; animation: toastIn 0.18s ease; max-width: 90vw; }
  .toast button { background: none; border: none; color: var(--later); font-family: 'DM Mono', monospace; font-size: 12px; font-weight: 500; cursor: pointer; padding: 2px 4px; letter-spacing: 0.04em; }
  .toast button:hover { text-decoration: underline; }
  @keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
  .hidden { display: none !important; }

  .forecast-pill.past { opacity: 0.5; }
  .forecast-pill .ftemp.rain { color: var(--accent-blue); font-weight: 600; }
  .forecast-pill .ftemp .mm { font-size: 8px; opacity: 0.7; margin-left: 1px; }
  .forecast-pills .pill-div { width: 1px; align-self: stretch; background: var(--border); margin: 2px 2px; }

  /* desktop: the mobile-only affordances stay hidden (full detail always shown, filters always open) */
  .task-more { display: none; }
  .filter-chevron { display: none; }

  /* ---- mobile: stack the two-column layout so content isn't crammed into a side strip ---- */
  @media (max-width: 768px) {
    /* iOS Safari auto-zooms (and stays zoomed) when a focused field is under 16px — force all form controls to 16px on mobile (!important outranks the ID/classed desktop rules like #chat-input) */
    input, select, textarea { font-size: 16px !important; }
    .app { grid-template-columns: 1fr; min-height: 0; }            /* sidebar on top, content full width below */
    aside {
      position: static;                                            /* stop it sticking full-height */
      height: auto;
      overflow: visible;
      border-right: none;
      padding: 0;                                                  /* sections own their padding; aside collapses to 0 when the filter strip is hidden */
    }
    main { padding: 20px 16px 84px; }                              /* trim desktop sides; bottom space clears the fixed tab bar */
    header { padding: 16px 18px; }
    .form-grid { grid-template-columns: 1fr; }                     /* modal form fields stack instead of cramming */
    .form-grid > .form-field { grid-column: auto !important; }    /* a field spanning 1/3 was auto-creating a 2nd column and re-cramming the modal */
    .form-field > input, .form-field > select, .form-field > textarea { width: 100%; box-sizing: border-box; }  /* fill the cell, never exceed it (skips the flex repeat-every row) */

    /* modals: use the screen width instead of a centred desktop card, and trim inner padding */
    .modal { width: 94%; max-width: none; }
    .modal:not(.modal-wide) { padding: 20px; }
    .modal-wide { max-width: none; }
    .modal-scroll { padding: 20px 18px 12px; }
    .modal-wide .modal-actions { padding: 12px 18px; }
    /* action buttons: keep all four on one row, shrink to fit, and center icon+label
       (the clipboard emoji on Copy was throwing its baseline off vs the others) */
    .modal-actions { gap: 6px; flex-wrap: nowrap; }
    .modal-actions .btn { padding: 8px 10px; font-size: 12px; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }

    /* weather bar: temps on row one, forecast on row two, both shrunk to fit */
    .weather-bar { gap: 8px 10px; padding: 12px 12px; }
    .weather-stat .val { font-size: 15px; }
    .weather-stat .key { font-size: 8px; letter-spacing: 0.02em; }
    .weather-divider { display: none; }                           /* reclaim the horizontal space; stats read fine without */
    .forecast-pills { flex-basis: 100%; width: 100%; gap: 5px; }  /* force the pills onto their own row */
    .forecast-pill { flex: 1 1 0; min-width: 0; padding: 5px 4px; } /* equal width so all days fit one row */
    .forecast-pill .day { font-size: 8px; }
    .forecast-pill .ftemp { font-size: 12px; }
    .forecast-pill .ficon { font-size: 13px; }
    .forecast-pills .pill-div { margin: 2px 1px; }

    /* chat composer: stack so the long placeholder gets full width and stops wrapping to two lines */
    .chat-input-row { flex-direction: column; align-items: stretch; }

    /* ---- nav: turn the sidebar "Views" list into a fixed bottom tab bar (thumb-reachable, always visible) ---- */
    aside .sidebar-section:first-child {
      position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
      margin: 0; padding: 0; display: flex;
      background: var(--surface); border-top: 1px solid var(--border);
      box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
    }
    aside .sidebar-section:first-child .sidebar-label { display: none; }   /* "Views" heading is redundant as a bar */
    aside .sidebar-section:first-child .nav-item {
      flex: 1; margin: 0; padding: 7px 2px 6px; border-radius: 0;
      flex-direction: column; align-items: center; justify-content: center;
      gap: 2px; color: var(--text2); position: relative;
    }
    aside .sidebar-section:first-child .nav-item.active {
      background: transparent; color: var(--accent-green);                 /* JS still toggles .active by id; just restyle it as a tab */
      box-shadow: inset 0 -2px 0 var(--accent-green);
    }
    aside .sidebar-section:first-child .nav-item > span:first-child {
      display: flex; flex-direction: column; align-items: center; gap: 2px; /* stack icon over the label */
      text-align: center; line-height: 1.15; font-size: 10px;
    }
    aside .sidebar-section:first-child .nav-icon { margin-right: 0; font-size: 19px; }
    aside .sidebar-section:first-child .nav-badge {
      position: absolute; top: 5px; right: calc(50% - 22px);               /* urgent count rides the corner of the Tasks tab */
      font-size: 9px; padding: 1px 5px; line-height: 1.4;
    }

    /* ---- filters: compact horizontal strip, shown only on the Tasks view (body[data-view] is set by showView) ---- */
    aside .sidebar-section:nth-child(2) {
      padding: 9px 12px 7px; margin-bottom: 0;
      border-bottom: 1px solid var(--border);                              /* divider when present; gone (with the section) on other views */
    }
    aside .sidebar-section:nth-child(2) .sidebar-label { margin-bottom: 6px; }
    aside .sidebar-section:nth-child(2) .filter-sublabel { margin: 6px 0 4px; }       /* tighter than the desktop 12px/5px */
    aside .sidebar-section:nth-child(2) .stat-grid {
      display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px;
      margin-bottom: 2px; -webkit-overflow-scrolling: touch;
    }
    aside .sidebar-section:nth-child(2) .stat-card {
      flex: 0 0 auto; padding: 5px 10px;
      display: flex; align-items: baseline; gap: 6px;                      /* "3 Now" pill instead of a stacked card */
    }
    aside .sidebar-section:nth-child(2) .stat-card .num { font-size: 15px; }
    aside .sidebar-section:nth-child(2) .stat-card .lbl { margin-top: 0; }
    body[data-view="analyses"] aside .sidebar-section:nth-child(2),
    body[data-view="things"]   aside .sidebar-section:nth-child(2),
    body[data-view="log"]      aside .sidebar-section:nth-child(2) { display: none; }
    /* filters collapse behind the label; tap to expand (default folded so the top stays calm) */
    #filter-section .sidebar-label { cursor: pointer; display: flex; align-items: center; }
    .filter-chevron { display: inline-block; margin-left: 6px; transition: transform 0.15s; color: var(--text3); }
    #filter-section.filters-open .filter-chevron { transform: rotate(180deg); }
    #filter-section #filter-clear { margin-left: auto; float: none !important; }
    #filter-section .filter-body { display: none; }
    #filter-section.filters-open .filter-body { display: block; }

    /* ---- backup/import/restore are a desktop job: on mobile keep only Log out (first-run import still works via the overlay) ---- */
    #export-bar { padding: 6px 12px !important; }
    #export-bar > * { display: none !important; }
    #export-bar > #auth-btn { display: inline-flex !important; margin-left: auto !important; font-size: 12px !important; padding: 5px 12px !important; }
    /* ---- let long tab rows scroll ---- */
    .tab-bar { width: auto; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab { white-space: nowrap; }

    /* ---- tasks: short teaser by default; fold notes + last-done behind a "More info" toggle (Tasks view only) ---- */
    #task-list-container .task-reason {
      display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    }
    #task-list-container .task-card.expanded .task-reason { -webkit-line-clamp: unset; overflow: visible; }
    #task-list-container .task-detail { display: none; }
    #task-list-container .task-card.expanded .task-detail { display: block; }
    #task-list-container .task-more {
      display: inline-block; margin-top: 6px; padding: 2px 0;
      background: none; border: none; color: var(--accent-green);
      font-family: 'DM Mono', monospace; font-size: 11px; cursor: pointer;
    }
    #task-list-container .task-more .less-lbl { display: none; }
    #task-list-container .task-card.expanded .task-more .more-lbl { display: none; }
    #task-list-container .task-card.expanded .task-more .less-lbl { display: inline; }

    /* replenish rows: let "where to buy" drop to its own line instead of overflowing */
    .replenish-row { flex-wrap: wrap; }
    .replenish-where { margin-left: 0; flex-basis: 100%; }
  }
