/* ==========================================================================
   garden101.app — Design System & Stylesheet (Authoritative)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens & CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
  /* Light Theme Palette (Default) */
  --bg: #faf8f3;
  --surface: #ffffff;
  --surface-subtle: #f3eee3;
  --ink: #1c2e24;
  --muted: #5c6f64;
  --border: #e7e0d4;
  --border-focus: #2d6a4f;

  /* Accents */
  --green: #2d6a4f;
  --green-hover: #245640;
  --green-light: #e8f3ec;
  --sage: #95b8a0;
  --sage-light: #e6f0e9;
  --sky: #4a90d9;
  --sky-light: #e8f2fc;
  --sun: #f4c430;
  --sun-light: #fef8e7;
  --terracotta: #e76f51;
  --terracotta-light: #fdeee9;

  /* Soil & Grid */
  --soil: #c8b49a;
  --soil-inner: #bfa88c;
  --soil-border: rgba(28, 46, 36, 0.12);
  --cell-valid-bg: rgba(45, 106, 79, 0.28);
  --cell-valid-border: #2d6a4f;
  --cell-invalid-bg: rgba(231, 111, 81, 0.28);
  --cell-invalid-border: #e76f51;

  /* Typography */
  --font-family: 'Nunito', ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-base: 16px;
  --font-size-sm: 14px;
  --font-size-xs: 12px;
  --font-size-tiny: 10px;
  --font-size-lg: 18px;
  --font-size-xl: 22px;
  --font-size-2xl: 26px;

  /* Radii */
  --radius-card: 20px;
  --radius-sheet: 24px;
  --radius-control: 16px;
  --radius-pill: 999px;
  --radius-badge: 8px;

  /* Shadows */
  --shadow: 0 2px 12px rgba(28, 46, 36, 0.08);
  --shadow-md: 0 4px 16px rgba(28, 46, 36, 0.12);
  --shadow-lg: 0 10px 25px rgba(28, 46, 36, 0.18);
  --shadow-elevated: 0 14px 28px rgba(28, 46, 36, 0.22), 0 6px 10px rgba(28, 46, 36, 0.12);

  /* Layout */
  --app-max-width: 480px;
  --topbar-height: 48px;
  --bottom-nav-height: 64px;
  --tap-target-min: 44px;
  --transition-fast: 150ms ease;
  --transition-settle: 180ms ease;
}

[data-theme="dark"],
html[data-theme="dark"] {
  /* Dark Theme Palette */
  --bg: #0e1712;
  --surface: #16221b;
  --surface-subtle: #1c2b23;
  --ink: #e9e5dc;
  --muted: #93a39a;
  --border: #25352c;
  --border-focus: #52b788;

  /* Accents */
  --green: #40916c;
  --green-hover: #52b788;
  --green-light: #1b382b;
  --sage: #74a887;
  --sage-light: #1b3024;
  --sky: #5ba2eb;
  --sky-light: #192d3f;
  --sun: #f6ce4a;
  --sun-light: #3d3416;
  --terracotta: #e97f64;
  --terracotta-light: #3a1e17;

  /* Soil & Grid */
  --soil: #2a2118;
  --soil-inner: #241b13;
  --soil-border: rgba(233, 229, 220, 0.1);
  --cell-valid-bg: rgba(64, 145, 108, 0.35);
  --cell-valid-border: #52b788;
  --cell-invalid-bg: rgba(233, 127, 100, 0.35);
  --cell-invalid-border: #e97f64;

  /* Shadows */
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.55);
  --shadow-elevated: 0 14px 28px rgba(0, 0, 0, 0.65), 0 6px 12px rgba(0, 0, 0, 0.4);
}

/* --------------------------------------------------------------------------
   2. Reset & Base Styles
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: var(--font-size-base);
  -webkit-tap-highlight-color: transparent;
  background-color: #070c09; /* Dark neutral gutter on widescreen */
  color: var(--ink);
  font-family: var(--font-family);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  background-color: var(--bg);
  color: var(--ink);
}

/* Max-width 480px centered mobile canvas */
#app-root,
.app-container {
  width: 100%;
  max-width: var(--app-max-width);
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
  padding-bottom: calc(var(--bottom-nav-height) + max(16px, env(safe-area-inset-bottom)));
}

/* Typography Hierarchy */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}

h1 { font-size: var(--font-size-xl); }
h2 { font-size: var(--font-size-lg); }
h3 { font-size: var(--font-size-base); }

p {
  font-size: var(--font-size-base);
  color: var(--ink);
}

a {
  color: var(--green);
  text-decoration: none;
  font-weight: 600;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: var(--font-size-base);
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* --------------------------------------------------------------------------
   3. Topbar (<header id="topbar">)
   -------------------------------------------------------------------------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
  height: var(--topbar-height);
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: var(--tap-target-min) 1fr var(--tap-target-min);
  align-items: center;
  padding: 0 12px;
  /* iOS notch / dynamic island: keep the bar clear of the top safe area */
  padding-top: env(safe-area-inset-top);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#page-title {
  font-size: var(--font-size-lg);
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
  margin: 0;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  justify-content: center;
}

#theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface-subtle);
  color: var(--ink);
  border: 1px solid var(--border);
  transition: transform var(--transition-fast), background-color var(--transition-fast);
}

#theme-toggle:hover {
  transform: scale(1.05);
  background-color: var(--border);
}

#theme-toggle:active {
  transform: scale(0.95);
}

#theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* --------------------------------------------------------------------------
   4. Bottom Navigation (<nav id="bottom-nav">)
   -------------------------------------------------------------------------- */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  height: var(--bottom-nav-height);
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

#bottom-nav a,
#bottom-nav button:not(#camera-btn) {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: var(--tap-target-min);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  gap: 3px;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

#bottom-nav a.active,
#bottom-nav a[aria-current="page"] {
  color: var(--green);
  font-weight: 700;
}

#bottom-nav a:active {
  transform: scale(0.95);
}

#bottom-nav svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Raised Round 56px Green Center Camera Button */
#camera-btn {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background-color: var(--green);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(45, 106, 79, 0.22); /* airy — soft, not dominant */
  border: 3px solid var(--surface);
  transform: translateY(-14px);
  cursor: pointer;
  transition: transform var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
  flex-shrink: 0;
  margin: 0 6px;
}

#camera-btn:hover {
  background-color: var(--green-hover);
  transform: translateY(-16px) scale(1.04);
  box-shadow: 0 6px 12px rgba(45, 106, 79, 0.30);
}

#camera-btn:active {
  transform: translateY(-12px) scale(0.96);
}

#camera-btn svg {
  width: 26px;
  height: 26px;
  stroke: #ffffff;
  stroke-width: 2;
}

/* --------------------------------------------------------------------------
   5. Toast Notification (<div id="toast">)
   -------------------------------------------------------------------------- */
#toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: var(--ink);
  color: var(--surface);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 100;
  transition: opacity 220ms ease, transform 220ms ease, visibility 220ms ease;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}

#toast.show,
#toast.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* --------------------------------------------------------------------------
   6. Buttons & Interactive Controls ("Everything Even" Solid Rule)
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  border: 1.5px solid transparent;
  box-sizing: border-box;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  transition: transform var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.btn:active {
  transform: scale(0.98);
}

/* Primary Solid Button (Solid Green Pill/Radius-12, White 600 Text) */
.btn-primary,
#demo-btn {
  background-color: var(--green);
  color: #ffffff;
  border-color: var(--green);
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(45, 106, 79, 0.22);
}

.btn-primary:hover,
#demo-btn:hover {
  background-color: var(--green-hover);
  border-color: var(--green-hover);
  box-shadow: 0 5px 14px rgba(45, 106, 79, 0.32);
}

.btn-primary:active,
#demo-btn:active {
  transform: scale(0.97);
  transition: transform 0.1s ease; /* quick tactile press */
}

[data-theme="dark"] .btn-primary,
[data-theme="dark"] #demo-btn {
  background-color: var(--green);
  border-color: var(--green);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .btn-primary:hover,
[data-theme="dark"] #demo-btn:hover {
  background-color: var(--green-hover);
  border-color: var(--green-hover);
}

/* Ghost / Outline Button (Transparent, 1.5px border var(--green), green text) */
.btn-ghost {
  background-color: transparent;
  border: 1.5px solid var(--green);
  color: var(--green);
  font-weight: 600;
  box-shadow: none;
}

.btn-ghost:hover {
  background-color: var(--green-light);
  border-color: var(--green);
  color: var(--green);
}

.btn-ghost:active {
  transform: scale(0.98);
}

[data-theme="dark"] .btn-ghost {
  border-color: var(--border-focus);
  color: var(--border-focus);
  background-color: transparent;
}

[data-theme="dark"] .btn-ghost:hover {
  background-color: var(--green-light);
  border-color: var(--border-focus);
  color: var(--border-focus);
}

/* Secondary Button */
.btn-secondary {
  background-color: var(--surface-subtle);
  color: var(--ink);
  border: 1.5px solid var(--border);
  font-weight: 600;
}

.btn-secondary:hover {
  background-color: var(--border);
}

/* Danger Button */
.btn-danger {
  background-color: var(--terracotta);
  color: #ffffff;
  border: 1.5px solid var(--terracotta);
  font-weight: 600;
}

.btn-danger:hover {
  background-color: #d15a3d;
  border-color: #d15a3d;
}

/* Small Button (Height 34px, Padding 0 14px, Font 13px) */
.btn-sm,
.btn.btn-sm,
.btn-primary.btn-sm,
.btn-ghost.btn-sm {
  height: 34px;
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
}


/* Round Equal-Size 44px FAB Buttons (Editor Topbar / Action Bar) */
.btn-fab,
.fab,
.ai-fab,
#undo-btn,
#add-plant-btn,
#ai-btn,
#new-bed {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.btn-fab:hover,
.fab:hover,
.ai-fab:hover,
#undo-btn:hover,
#add-plant-btn:hover,
#ai-btn:hover,
#new-bed:hover {
  transform: scale(1.06);
  background-color: var(--surface-subtle);
  box-shadow: var(--shadow-md);
}

.btn-fab:active,
.fab:active,
.ai-fab:active,
#undo-btn:active,
#add-plant-btn:active,
#ai-btn:active,
#new-bed:active {
  transform: scale(0.97);
  transition: transform 0.1s ease; /* quick tactile press */
}

.ai-fab,
#ai-btn {
  color: var(--green);
}

.ai-fab:hover,
#ai-btn:hover {
  color: var(--green-hover);
}

[data-theme="dark"] .ai-fab,
[data-theme="dark"] #ai-btn {
  color: var(--border-focus);
}

#add-plant-btn {
  background-color: var(--green);
  color: #ffffff;
  border-color: var(--green);
}

#add-plant-btn:hover {
  background-color: var(--green-hover);
}

#undo-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Button Loading State & Spinner */
.btn.loading,
.btn-primary.loading,
#ai-submit-btn.loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.btn.loading::after,
.btn-primary.loading::after,
#ai-submit-btn.loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: btnSpinner 600ms linear infinite;
  vertical-align: middle;
}

@keyframes btnSpinner {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------------------
   7. Form Inputs & Controls
   -------------------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  width: 100%;
}

label,
.field-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.01em;
  display: block;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  height: 42px;
  min-height: 42px;
  padding: 8px 14px;
  background-color: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--ink);
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.15);
}

/* Remove native number-input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
  display: none;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* --------------------------------------------------------------------------
   8. Auth Pages: Login & Signup (<main id="login-page"> / <main id="signup-page">)
   -------------------------------------------------------------------------- */
#login-page,
#signup-page,
.auth-page {
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--topbar-height) - var(--bottom-nav-height));
}

.login-card,
.signup-card,
.auth-card {
  width: 100%;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-brand,
.signup-brand,
.auth-brand {
  text-align: center;
  margin-bottom: 12px;
}

.login-brand .logo-icon,
.signup-brand .logo-icon,
.auth-brand .logo-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  background-color: var(--green-light);
  color: var(--green);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-brand h2,
.signup-brand h2,
.auth-brand h2 {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-brand p,
.signup-brand p,
.auth-brand p {
  color: var(--muted);
  font-size: var(--font-size-sm);
  margin-top: 4px;
}

#login-form,
#signup-form,
#signup,
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

#login-form .btn,
#signup-form .btn,
#signup .btn,
.auth-form .btn,
#login-form .btn-primary,
#signup-form .btn-primary,
#signup .btn-primary,
.auth-form .btn-primary,
#login-form #demo-btn,
#signup-form #demo-btn,
#login-form button[type="submit"],
#signup-form button[type="submit"],
#signup button[type="submit"] {
  width: 100%;
}

.demo-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 10px 0;
  color: var(--muted);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.demo-divider::before,
.demo-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.demo-divider span {
  padding: 0 10px;
}

/* Quiet Skip Link (Login Page, Under Demo Button: Muted Text, 14px 600, Underline on Hover, 8px Padding) */
.skip-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  min-height: 44px;
  margin: 4px auto 0;
  text-align: center;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  transition: color var(--transition-fast), text-decoration var(--transition-fast);
}

.skip-link:hover,
.skip-link:focus-visible {
  color: var(--ink);
  text-decoration: underline;
}

.skip-link:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

[data-theme="dark"] .skip-link {
  color: var(--muted);
}

[data-theme="dark"] .skip-link:hover,
[data-theme="dark"] .skip-link:focus-visible {
  color: var(--ink);
}

[data-theme="dark"] .skip-link:focus-visible {
  outline-color: var(--border-focus);
}

.auth-footer,
.auth-switch {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 4px;
}

.auth-footer a,
.auth-switch a {
  color: var(--green);
  font-weight: 700;
  text-decoration: underline;
}

.auth-footer a:hover,
.auth-switch a:hover {
  color: var(--green-hover);
}

[data-theme="dark"] .auth-footer a,
[data-theme="dark"] .auth-switch a {
  color: var(--border-focus);
}

.flash-error,
.alert-error {
  background-color: var(--terracotta-light);
  color: var(--terracotta);
  border: 1px solid var(--terracotta);
  padding: 10px 14px;
  border-radius: var(--radius-control);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   9. Beds Page (<main id="beds-page">)
   -------------------------------------------------------------------------- */
#beds-page {
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Anonymous User Banner (Top of Beds List) */
.anon-banner {
  background-color: #eef4ef;
  border: 1px solid #cfe3d4;
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.05);
}

.anon-banner-icon,
.anon-banner .banner-icon {
  font-size: 20px;
  line-height: 1;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.anon-banner-icon svg,
.anon-banner svg {
  width: 20px;
  height: 20px;
  stroke: var(--green);
  flex-shrink: 0;
}

.anon-banner-copy {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.4;
  gap: 1px;
}

.anon-banner-copy strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  display: block;
}

.anon-banner-copy span,
.anon-banner-copy p {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  display: block;
}

.anon-banner .btn,
.anon-banner .btn-primary,
.anon-banner .btn-sm {
  flex-shrink: 0;
  margin-left: auto;
  white-space: nowrap;
}

[data-theme="dark"] .anon-banner {
  background-color: #1c2f24;
  border-color: #2a4a38;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .anon-banner-copy strong {
  color: var(--ink);
}

[data-theme="dark"] .anon-banner-copy span,
[data-theme="dark"] .anon-banner-copy p {
  color: var(--muted);
}

[data-theme="dark"] .anon-banner-icon svg,
[data-theme="dark"] .anon-banner svg {
  stroke: var(--border-focus);
}

.beds-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.beds-header h1 {
  font-size: var(--font-size-2xl);
  font-weight: 800;
}

.beds-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bed-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.bed-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--sage);
}

.bed-card:active {
  transform: scale(0.98);
}

.bed-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bed-name {
  font-size: var(--font-size-lg);
  font-weight: 800;
  color: var(--ink);
}

.bed-kind {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: 700;
  background-color: var(--surface-subtle);
  color: var(--muted);
  text-transform: capitalize;
}

.bed-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: var(--font-size-sm);
  color: var(--muted);
  font-weight: 600;
}

.bed-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* New Bed Form Card / Section */
#new-bed-form {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-width: 400px;
  width: 100%;
  margin: 10px auto 0;
}

#new-bed-form .form-group {
  margin-bottom: 14px;
}

#new-bed-form .form-group:last-of-type {
  margin-bottom: 16px;
}

#new-bed-form .btn-primary,
#new-bed-form button[type="submit"] {
  height: 46px;
  min-height: 46px;
  width: 100%;
  border-radius: 12px;
  background-color: var(--green);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.25);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

#new-bed-form .btn-primary:hover,
#new-bed-form button[type="submit"]:hover {
  background-color: var(--green-hover);
  box-shadow: 0 4px 12px rgba(45, 106, 79, 0.35);
}

#new-bed-form .btn-primary:active,
#new-bed-form button[type="submit"]:active {
  transform: scale(0.98);
}

/* --------------------------------------------------------------------------
   Kind Picker (2x2 Grid of Cards)
   -------------------------------------------------------------------------- */
.kind-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.kind-picker input,
.kind-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.kind-option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background-color: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  position: relative;
  user-select: none;
  text-align: center;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), color var(--transition-fast);
}

.kind-option:hover {
  border-color: var(--sage);
  background-color: var(--surface-subtle);
}

.kind-option:active {
  transform: scale(0.98);
}

.kind-option:has(input:checked) {
  border-color: var(--green);
  background-color: #eef4ef;
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.12);
}

.kind-option:has(input:checked) .kind-name,
.kind-option:has(input:checked) {
  color: var(--green);
  font-weight: 700;
}

[data-theme="dark"] .kind-option:has(input:checked) {
  border-color: var(--border-focus);
  background-color: #1c2f24;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  color: var(--ink);
}

[data-theme="dark"] .kind-option:has(input:checked) .kind-name {
  color: var(--ink);
}

.kind-option:has(input:focus-visible),
.kind-option:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Layout Picker (Stacked Layout Cards)
   -------------------------------------------------------------------------- */
.layout-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.layout-picker input,
.layout-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.layout-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background-color: var(--surface);
  cursor: pointer;
  position: relative;
  user-select: none;
  gap: 12px;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.layout-option:hover {
  border-color: var(--sage);
  background-color: var(--surface-subtle);
}

.layout-option:active {
  transform: scale(0.98);
}

.layout-icon {
  font-size: 20px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--green);
  flex-shrink: 0;
  line-height: 1;
}

[data-theme="dark"] .layout-icon {
  color: var(--border-focus);
}

.layout-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.layout-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  display: block;
}

.layout-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
  display: block;
}

.layout-check {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  flex-shrink: 0;
  box-sizing: border-box;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

/* Checked state for layout cards */
.layout-option:has(input:checked) {
  border-color: var(--green);
  background-color: #eef4ef;
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.12);
}

.layout-option:has(input:checked) .layout-title {
  color: var(--green);
  font-weight: 700;
}

.layout-option:has(input:checked) .layout-check {
  border-color: var(--green);
  background-color: var(--green);
}

.layout-option:has(input:checked) .layout-check::after {
  content: '✓';
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  display: block;
}

[data-theme="dark"] .layout-option:has(input:checked) {
  border-color: var(--border-focus);
  background-color: #1c2f24;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .layout-option:has(input:checked) .layout-title {
  color: var(--ink);
}

[data-theme="dark"] .layout-option:has(input:checked) .layout-check {
  border-color: var(--green);
  background-color: var(--green);
}

.layout-option:has(input:focus-visible),
.layout-option:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Soil Picker (Horizontal Chip Row)
   -------------------------------------------------------------------------- */
.soil-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.soil-picker input,
.soil-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.soil-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  background-color: var(--surface);
  color: var(--ink);
  cursor: pointer;
  position: relative;
  user-select: none;
  line-height: 1.2;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.soil-chip:hover {
  border-color: var(--sage);
  background-color: var(--surface-subtle);
}

.soil-chip:active {
  transform: scale(0.96);
}

.soil-chip:has(input:checked) {
  background-color: #2d6a4f;
  color: #ffffff;
  border-color: #2d6a4f;
  box-shadow: 0 2px 6px rgba(45, 106, 79, 0.2);
}

[data-theme="dark"] .soil-chip:has(input:checked) {
  background-color: #2d6a4f;
  color: #ffffff;
  border-color: #2d6a4f;
}

.soil-chip:has(input:focus-visible),
.soil-chip:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Grid Dimensions Fields (#grid-dims)
   -------------------------------------------------------------------------- */
#grid-dims {
  width: 100%;
}

.dims-row,
.grid-dims-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.dims-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.hidden,
#grid-dims.hidden {
  display: none !important;
}

/* --------------------------------------------------------------------------
   10. Editor Page (<main id="editor-page">) — The Showpiece Grid Editor
   -------------------------------------------------------------------------- */
#editor-page {
  padding: 16px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  user-select: none;
  -webkit-user-select: none;
}

.editor-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  box-shadow: var(--shadow);
}

.editor-bed-info {
  display: flex;
  flex-direction: column;
}

.editor-bed-title {
  font-size: var(--font-size-base);
  font-weight: 800;
  line-height: 1.2;
}

.editor-bed-subtitle {
  font-size: var(--font-size-xs);
  color: var(--muted);
  font-weight: 600;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Grid Wrapper & Container */
.grid-viewport {
  width: 100%;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

#grid {
  display: grid;
  position: relative;
  width: 100%;
  max-width: 100%;
  background-color: var(--soil);
  border: 3px solid var(--soil-inner);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
  touch-action: none;
}

/* Free-Placement Bed Canvas */
#grid.layout-free {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 280px;
  background: linear-gradient(150deg, #d9c6a3 0%, #c8b49a 100%);
  border: 3px solid #bfa88c;
  border-radius: 24px;
  box-shadow: inset 0 3px 12px rgba(28, 46, 36, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

[data-theme="dark"] #grid.layout-free {
  background: linear-gradient(150deg, #2a2118 0%, #221a12 100%);
  border-color: #1a130c;
  box-shadow: inset 0 3px 14px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

#grid.layout-free .grid-cell {
  display: none;
}

/* Free-Placement Drop Ring Indicator */
.drop-ring {
  position: absolute;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  border-radius: 50%;
  border: 2px solid var(--green);
  background-color: var(--cell-valid-bg);
  box-shadow: 0 0 14px rgba(45, 106, 79, 0.4), inset 0 0 8px rgba(45, 106, 79, 0.2);
  pointer-events: none;
  z-index: 45;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease, border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.drop-ring.active {
  opacity: 1;
  visibility: visible;
}

.drop-ring.valid {
  border-color: var(--cell-valid-border);
  background-color: var(--cell-valid-bg);
  box-shadow: 0 0 16px rgba(45, 106, 79, 0.45), inset 0 0 10px rgba(45, 106, 79, 0.25);
}

.drop-ring.invalid {
  border-color: var(--cell-invalid-border);
  background-color: var(--cell-invalid-bg);
  box-shadow: 0 0 16px rgba(231, 111, 81, 0.45), inset 0 0 10px rgba(231, 111, 81, 0.25);
}

/* Soil Cells (Grid Mode) */
.grid-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-right: 1px solid var(--soil-border);
  border-bottom: 1px solid var(--soil-border);
  background-color: var(--soil);
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-cell:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.02);
}

/* Ghost Highlights During Drag (Grid Mode) */
.grid-cell.cell-valid {
  background-color: var(--cell-valid-bg) !important;
  box-shadow: inset 0 0 0 2.5px var(--cell-valid-border), inset 0 0 14px rgba(45, 106, 79, 0.4);
}

.grid-cell.cell-invalid {
  background-color: var(--cell-invalid-bg) !important;
  box-shadow: inset 0 0 0 2.5px var(--cell-invalid-border), inset 0 0 14px rgba(231, 111, 81, 0.4);
}

/* Plant Tiles (Glyph + Label) */
.plant-tile {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  z-index: 10;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto;
  will-change: transform, left, top;
}

/* Free Mode Tile Sizing & Exact Center Alignment */
#grid.layout-free .plant-tile {
  width: 58px;
  height: 58px;
  margin-left: -29px;
  margin-top: -29px;
}

#grid.layout-free .plant-tile .plant-tile-inner {
  width: 100%;
  height: 100%;
}

.plant-tile.settle {
  transition: left var(--transition-settle), top var(--transition-settle), transform var(--transition-settle);
}

.plant-tile.ai-glide {
  transition: left 380ms cubic-bezier(0.22, 1, 0.36, 1), top 380ms cubic-bezier(0.22, 1, 0.36, 1) !important;
  will-change: left, top;
}

.plant-tile-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 90%;
  height: 90%;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 2px;
  pointer-events: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

[data-theme="dark"] .plant-tile-inner {
  border-color: rgba(255, 255, 255, 0.08);
}

.plant-tile.is-dragging {
  cursor: grabbing;
  z-index: 90;
}

.plant-tile.is-dragging .plant-tile-inner {
  transform: scale(1.1);
  box-shadow: var(--shadow-elevated);
  border-color: var(--green);
}

.plant-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 65%;
  height: 65%;
  pointer-events: none;
}

.plant-glyph svg {
  width: 100%;
  height: 100%;
  display: block;
}

.plant-label {
  font-size: max(9.5px, var(--font-size-tiny)); /* min 9.5px legibility */
  letter-spacing: 0.01em;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 95%;
  line-height: 1.1;
  margin-top: 2px;
  pointer-events: none;
}

/* Shake Animation for Invalid Return */
@keyframes shakeInvalid {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.plant-tile.shake {
  animation: shakeInvalid 320ms ease-in-out;
}

/* Empty State */
.empty-grid-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 20px;
  gap: 12px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-pill);
  background-color: var(--green-light);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.empty-grid-state h3 {
  font-size: var(--font-size-lg);
  font-weight: 800;
}

.empty-grid-state p {
  color: var(--muted);
  font-size: var(--font-size-sm);
  max-width: 240px;
}

/* --------------------------------------------------------------------------
   11. Bottom Sheets (#catalog-sheet & #plant-sheet)
   -------------------------------------------------------------------------- */
.sheet-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(14, 23, 18, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 80;
  opacity: 0;
  visibility: hidden;
  transition: opacity 250ms ease, visibility 250ms ease;
}

.sheet-backdrop.active,
.sheet-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: var(--app-max-width);
  background-color: var(--surface);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
  z-index: 85;
  transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 80vh;
  max-height: 80dvh;
  overflow-y: auto;
}

.sheet.active,
.sheet.show {
  transform: translateX(-50%) translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: var(--radius-pill);
  background-color: var(--border);
  margin: -4px auto 8px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-title {
  font-size: var(--font-size-lg);
  font-weight: 800;
}

.sheet-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background-color: var(--surface-subtle);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

.sheet-close:hover {
  background-color: var(--border);
  color: var(--ink);
}

/* Catalog Crop Picker (Horizontal Carousel) */
.crop-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 4px 16px;
  margin: 0 -8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.crop-scroll::-webkit-scrollbar {
  height: 6px;
}

.crop-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

.crop-card {
  flex: 0 0 112px;
  background-color: var(--surface-subtle);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.crop-card:hover {
  transform: translateY(-4px);
  border-color: var(--green);
  background-color: var(--surface);
  box-shadow: var(--shadow-md);
}

.crop-card:active {
  transform: scale(0.95);
}

.crop-card-glyph {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crop-card-name {
  font-size: var(--font-size-xs);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
}

.crop-card-badge {
  font-size: var(--font-size-tiny);
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-badge);
  background-color: var(--green-light);
  color: var(--green);
}

/* Plant Details Sheet */
#plant-sheet {
  padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
  gap: 12px;
}

#plant-sheet .sheet-header {
  margin-bottom: -4px;
}

#plant-sheet .sheet-title,
#plant-sheet-title {
  font-size: 18px;
  font-weight: 800;
}

.plant-sheet-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.plant-sheet-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  background-color: var(--surface-subtle);
  border-radius: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
}

.plant-sheet-glyph {
  width: 60px;
  height: 60px;
  max-width: 72px;
  max-height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.plant-sheet-glyph svg,
.plant-sheet-glyph img {
  max-height: 72px;
  max-width: 100%;
  width: 100%;
  height: 100%;
  display: block;
}

.plant-sheet-info h3 {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.plant-sheet-info p {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 1px;
}

.stage-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: capitalize;
  margin-top: 4px;
}

.stage-seedling { background-color: var(--sage-light); color: var(--green); }
.stage-veg { background-color: var(--green-light); color: var(--green); }
.stage-bloom { background-color: var(--sun-light); color: #9c7308; }
.stage-fruit { background-color: var(--terracotta-light); color: var(--terracotta); }

.plant-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.plant-detail-item {
  background-color: var(--surface-subtle);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.plant-detail-item .label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

.plant-detail-item .value {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}

#remove-plant-btn {
  min-height: 42px;
  height: 42px;
  font-size: 14px;
  border-radius: 12px;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   11b. M5 — Plant Tracker (growth-stage stepper, schedule, harvest, notes)
   -------------------------------------------------------------------------- */
.plant-tracker {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Growth-stage stepper: seedling → veg → bloom → fruit */
.stage-stepper {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.stage-step {
  position: relative;
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 4px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--muted);
  background-color: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), transform var(--transition-fast);
}

.stage-step:hover {
  color: var(--ink);
}

.stage-step:active {
  transform: scale(0.95);
}

/* Connecting line between steps 2-4 (1px, spans the 4px gap) */
.stage-step + .stage-step::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  width: 12px;
  height: 1px;
  background-color: var(--border);
  transform: translateY(-50%);
  pointer-events: none;
}

.stage-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: currentColor;
  flex-shrink: 0;
}

/* Current stage: green pill */
.stage-step.active {
  background-color: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

/* Passed stages: sage text */
.stage-step.done {
  color: var(--sage);
}

.stage-step.done .stage-dot {
  background-color: var(--sage);
}

[data-theme="dark"] .stage-step {
  color: var(--muted);
}

[data-theme="dark"] .stage-step:hover {
  color: var(--ink);
}

[data-theme="dark"] .stage-step.active {
  background-color: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

[data-theme="dark"] .stage-step.done {
  color: var(--sage);
}

[data-theme="dark"] .stage-step + .stage-step::before {
  background-color: var(--border);
}

/* Schedule rows (harvest / succession / frost / seed-start) */
.schedule-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.schedule-loading {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  padding: 2px 0;
}

.schedule-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 4px 0;
  line-height: 1.35;
}

.schedule-icon {
  font-size: 14px;
  line-height: 1;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.schedule-text {
  flex: 1;
  min-width: 0;
}

.schedule-label {
  color: var(--ink);
  font-weight: 700;
}

.schedule-note {
  color: var(--green);
  font-weight: 700;
  white-space: nowrap;
}

.schedule-muted {
  color: var(--muted);
}

[data-theme="dark"] .schedule-label {
  color: var(--ink);
}

[data-theme="dark"] .schedule-note {
  color: var(--border-focus);
}

/* Harvest logging */
.harvest-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.harvest-toggle {
  align-self: flex-start;
}

.harvest-form {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
}

.harvest-form[hidden] {
  display: none;
}

.harvest-form input[type="number"] {
  flex: 1;
  min-width: 0;
  width: auto;
  height: 44px;
  min-height: 44px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 12px;
}

.harvest-form .btn-sm {
  flex-shrink: 0;
  height: 44px;
  min-height: 44px;
}

.harvest-history {
  display: flex;
  flex-direction: column;
}

.harvest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  border-top: 1px solid var(--border);
  padding: 6px 0;
}

.harvest-item:first-child {
  border-top: none;
}

.harvest-date {
  color: var(--muted);
}

.harvest-meta {
  color: var(--ink);
  white-space: nowrap;
}

[data-theme="dark"] .harvest-item {
  border-top-color: var(--border);
}

[data-theme="dark"] .harvest-date {
  color: var(--muted);
}

/* Notes */
.notes-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.notes-field {
  width: 100%;
  height: 80px;
  min-height: 80px;
  resize: vertical;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background-color: var(--surface);
  color: var(--ink);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.notes-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.15);
}

[data-theme="dark"] .notes-field {
  background-color: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

[data-theme="dark"] .notes-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(82, 183, 136, 0.2);
}

/* --------------------------------------------------------------------------
   12. More Page (<main id="more-page" class="more-page">)
   -------------------------------------------------------------------------- */
#more-page,
.more-page {
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.more-page .card,
.more-page .more-card,
.more-page .account-card,
.more-page .about-card,
.more-page section {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Account Profile Header / Row */
.account-profile,
.more-profile,
.account-header,
.profile-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Avatar Circle (44px, Green BG, White Initial Letter or Leaf Icon) */
.avatar,
.account-avatar,
.avatar-circle {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background-color: var(--green);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  flex-shrink: 0;
  user-select: none;
  line-height: 1;
}

.avatar.avatar-anon,
.avatar-anon,
.avatar-leaf {
  background-color: var(--sage-light);
  color: var(--green);
  font-size: 22px;
}

[data-theme="dark"] .avatar.avatar-anon,
[data-theme="dark"] .avatar-anon,
[data-theme="dark"] .avatar-leaf {
  background-color: var(--sage-light);
  color: var(--border-focus);
}

.avatar svg,
.account-avatar svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

/* Account Info Details */
.account-info,
.account-details,
.profile-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.account-email,
.account-name,
.account-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
  word-break: break-word;
}

.account-desc,
.account-copy,
.anon-copy {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  font-weight: 500;
}

/* Plan Badge (Small Pill, Sage Background, "Free plan") */
.plan-badge,
.badge-plan {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  background-color: var(--sage-light);
  color: var(--green);
  border: 1px solid var(--sage);
  line-height: 1.2;
}

[data-theme="dark"] .plan-badge,
[data-theme="dark"] .badge-plan {
  background-color: var(--sage-light);
  color: var(--border-focus);
  border-color: #2a4a38;
}

/* More Page Actions Group */
.account-actions,
.more-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.account-actions form,
.more-actions form,
.account-card form,
.more-page form {
  width: 100%;
  margin: 0;
}

.account-actions .btn,
.more-actions .btn,
.account-card form .btn,
.account-card .btn-primary,
.account-card .btn-ghost,
.more-page form .btn {
  width: 100%;
}

/* About Card (Title, Muted Description & Version Line) */
.about-card,
.more-about {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.about-card h3,
.about-card h2,
.about-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.about-card p,
.about-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.about-version,
.version-line {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  opacity: 0.85;
}

/* --------------------------------------------------------------------------
   14. AI Drop UI (Ask AI Sheet & Prompt Chips)
   -------------------------------------------------------------------------- */
.sheet.ai-sheet,
#ai-sheet {
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  gap: 16px;
}

.ai-sheet .sheet-title {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-sheet-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  background-color: var(--surface-subtle);
  color: var(--ink);
  cursor: pointer;
  line-height: 1.2;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.ai-chip:hover,
.ai-chip:active,
.ai-chip:focus-visible {
  border-color: var(--green);
  background-color: var(--sage-light);
  color: var(--green);
  transform: translateY(-1px);
}

[data-theme="dark"] .ai-chip {
  background-color: var(--surface-subtle);
  border-color: var(--border);
  color: var(--ink);
}

[data-theme="dark"] .ai-chip:hover,
[data-theme="dark"] .ai-chip:active,
[data-theme="dark"] .ai-chip:focus-visible {
  border-color: var(--border-focus);
  background-color: var(--sage-light);
  color: var(--border-focus);
}

#ai-input {
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 10px 14px;
  background-color: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--ink);
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#ai-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.15);
}

[data-theme="dark"] #ai-input {
  background-color: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

[data-theme="dark"] #ai-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(82, 183, 136, 0.2);
}

.ai-submit-btn {
  width: 100%;
  height: 46px;
  min-height: 46px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
}

/* --------------------------------------------------------------------------
   15. Accessibility & Prefers Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .plant-tile.ai-glide {
    transition: none !important;
    transition-delay: 0ms !important;
  }

  .btn.loading::after,
  .btn-primary.loading::after,
  #ai-submit-btn.loading::after {
    animation: none !important;
  }

  /* No tactile scale feedback under reduced motion */
  .btn-primary:active,
  #demo-btn:active,
  .btn-fab:active,
  .fab:active,
  .ai-fab:active {
    transform: none;
  }
}

/* Beds page header count */
.beds-count { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }


/* ===== Camera sheet — photo diagnosis (M3) ===== */
.camera-sheet { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.capture-btn {
  display: flex; align-items: center; justify-content: center;
  width: 96px; height: 96px; margin: 12px auto 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #2d6a4f, #40916c);
  color: #fff; cursor: pointer;
  box-shadow: 0 8px 24px rgba(45, 106, 79, .35);
  transition: transform .12s ease, box-shadow .12s ease;
}
.capture-btn:active { transform: scale(.96); }
.camera-hint { text-align: center; font-size: 14px; color: var(--muted); margin: 14px 0 4px; }
.camera-attach-row { margin: 12px 0 4px; display: flex; flex-direction: column; gap: 6px; }
.camera-attach-row[hidden] { display: none; }
.camera-attach-row label { font-size: 13px; font-weight: 600; color: var(--ink); }
.camera-attach-row select {
  width: 100%; height: 44px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 15px; padding: 0 12px;
}
.camera-preview-wrap { position: relative; margin: 8px 0 14px; }
.camera-preview-wrap img {
  width: 100%; max-height: 280px; object-fit: cover;
  border-radius: 16px; display: block;
}
.scan-overlay {
  position: absolute; inset: 0; border-radius: 16px; pointer-events: none; overflow: hidden;
  background: repeating-linear-gradient(180deg, transparent 0 44%, rgba(45, 106, 79, .18) 44% 46%, transparent 46% 100%);
  animation: scan-sweep 1.6s linear infinite;
}
@keyframes scan-sweep { from { background-position: 0 0; } to { background-position: 0 24px; } }
.diagnosis-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; margin: 8px 0 14px;
}
.diagnosis-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.diagnosis-issue { font-size: 18px; font-weight: 800; color: var(--ink); }
.conf-warn { font-size: 12px; font-weight: 700; color: #c05621; background: rgba(244, 196, 48, .18); padding: 4px 10px; border-radius: 999px; }
.confidence-bar { height: 12px; border-radius: 999px; background: var(--border); overflow: hidden; margin-bottom: 12px; }
.confidence-fill { height: 100%; border-radius: 999px; background: var(--green); transition: width .6s ease; }
.confidence-fill.low { background: var(--terracotta); }
.treatment-list { margin: 0 0 6px; padding-left: 20px; }
.treatment-list li { font-size: 14px; color: var(--ink); margin: 6px 0; line-height: 1.45; }
.treatment-empty { font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.stage-chip { display: inline-block; font-size: 12px; font-weight: 700; color: var(--green); background: rgba(45, 106, 79, .12); padding: 4px 10px; border-radius: 999px; margin-top: 6px; }
.camera-result-actions { display: flex; gap: 10px; }
.camera-result-actions .btn { flex: 1; }
@media (prefers-reduced-motion: reduce) {
  .scan-overlay { animation: none; background: rgba(45, 106, 79, .12); }
  .capture-btn { transition: none; }
}

/* --------------------------------------------------------------------------
   16. M4 — Weather Card, Did-You-Water, Location (Weather + Watering UI)
   -------------------------------------------------------------------------- */

/* ----- Weather card (first child of .beds-list) ----- */
.weather-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: opacity var(--transition-fast);
}

.weather-card.loading {
  opacity: 0.55;
}

.weather-loading {
  font-size: var(--font-size-sm);
  color: var(--muted);
  font-weight: 600;
}

/* Row 1: icon + big temp + H/L + location + refresh */
.weather-now {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.weather-icon {
  font-size: 30px;
  line-height: 1;
  flex-shrink: 0;
}

.weather-temp {
  font-size: 28px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
}

.weather-hilo {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.weather-location {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Subtle ↻ refresh — ghost 32px icon button */
.weather-refresh {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background-color: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.weather-refresh:hover {
  background-color: var(--surface-subtle);
  color: var(--ink);
}

.weather-refresh:active {
  transform: scale(0.9);
}

/* Row 2: watering pill + note */
.weather-watering {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.watering-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.water-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.water-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  flex-shrink: 0;
}

.water-pill.yes {
  background-color: var(--green-light);
  color: var(--green);
}

.water-pill.light {
  background-color: #f4c430;
  color: #1c2e24;
}

.water-pill.no {
  background-color: var(--surface-subtle);
  color: var(--muted);
}

.watering-note {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  flex-basis: 100%;
}

/* Row 3: alert chips (tap -> toast with full message) */
.weather-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.alert-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), filter var(--transition-fast);
}

.alert-chip:active {
  transform: scale(0.94);
}

.alert-chip.frost {
  background-color: var(--sky-light);
  color: var(--sky);
}

.alert-chip.heat {
  background-color: var(--terracotta-light);
  color: var(--terracotta);
}

.alert-chip.wind {
  background-color: var(--sun-light);
  color: #9c7308;
}

[data-theme="dark"] .alert-chip.frost {
  color: #7db4ec;
}

[data-theme="dark"] .alert-chip.heat {
  color: #f09a82;
}

[data-theme="dark"] .alert-chip.wind {
  color: var(--sun);
}

/* Compact "needs location" card */
.weather-needs-location {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.weather-needs-location .weather-icon {
  font-size: 22px;
}

.weather-cta {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--ink);
  flex: 1;
  min-width: 0;
}

.weather-set-location {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background-color: var(--green);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

[data-theme="dark"] .weather-set-location {
  background-color: var(--green);
  color: #ffffff;
}

/* Error state */
.weather-error {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--muted);
}

.weather-error .weather-cta {
  font-weight: 600;
  color: var(--muted);
}

/* ----- Did-you-water bar (editor page, above the grid) ----- */
.water-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.water-bar-label {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.water-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 104px;
  min-height: var(--tap-target-min);
  padding: 0 16px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: 700;
  line-height: 1;
  border: 1.5px solid var(--border);
  background-color: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.water-toggle:active {
  transform: scale(0.96);
}

.water-toggle .water-toggle-check {
  font-size: 13px;
  line-height: 1;
}

/* Checked state: green solid fill */
.water-toggle.on {
  background-color: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

/* 7-day history dots below the bar */
.water-dots {
  width: 100%;
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 2px;
}

.water-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #e2dccf;
  flex-shrink: 0;
}

.water-dot.on {
  background-color: var(--green);
}

/* Today's dot gets a 2px green ring */
.water-dot.today {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

[data-theme="dark"] .water-dot {
  background-color: #25352c;
}

[data-theme="dark"] .water-dot.on {
  background-color: var(--green);
}

/* ----- More page location form ----- */
.more-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.more-card-title {
  font-size: var(--font-size-lg);
  font-weight: 800;
  color: var(--ink);
}

#location-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

#location-input {
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 10px 14px;
  background-color: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--ink);
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#location-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.15);
}

#location-form .btn,
#location-form button[type="submit"] {
  width: 100%;
  height: 46px;
  min-height: 46px;
}

.location-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ----- M4 reduced-motion (no pulse animations) ----- */
@media (prefers-reduced-motion: reduce) {
  .weather-refresh,
  .water-toggle,
  .alert-chip {
    transition: none;
  }

  /* M5 plant tracker: disable micro-transitions */
  .stage-step,
  .harvest-form input,
  .harvest-toggle,
  .notes-save-btn,
  .notes-field {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   17. M6 — Memory page (<main id="memory-page">): ask your garden, wiki, events
   The backend renders the wiki + activity server-side; these styles hang off
   the M6 DOM hooks (.memory-ask / .memory-refresh / .wiki-section /
   .memory-events / #memory-answer) that editor.js normalizes onto the page.
   Rules are prefixed with #memory-page so they win over the backend template's
   scoped scaffolding styles (which lack an id).
   -------------------------------------------------------------------------- */

#memory-page,
.memory-page {
  max-width: 480px;
  width: 100%;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Ask-your-garden card (.memory-ask) --- */
#memory-page .memory-ask {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
}

#memory-page .memory-ask h2,
#memory-page .memory-ask-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--ink);
}

#memory-page .memory-ask .memory-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 14px;
  line-height: 1.4;
}

/* Stack the input above a full-width Ask button (the backend's .ask-row
   scaffold renders them side by side; the design contract wants the button
   full width). */
#memory-page .memory-ask .ask-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

#memory-page .memory-ask #memory-question {
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background-color: var(--surface);
  color: var(--ink);
  font-size: 15px;
  box-sizing: border-box;
}

#memory-page .memory-ask #memory-question:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.15);
}

#memory-page .memory-ask .btn-primary {
  width: 100%;
}

/* --- Ask-your-garden answer (#memory-answer) --- */
#memory-answer {
  background-color: #eef4ef;
  border: 1px solid #cfe3d4;
  border-radius: 16px;
  padding: 14px;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.5;
  margin-top: 12px;
  animation: memoryAnswerIn 320ms ease-out both;
}

#memory-answer.answer-in {
  animation: memoryAnswerIn 320ms ease-out both;
}

#memory-answer .asked {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

#memory-answer .reply {
  white-space: pre-wrap;
  word-break: break-word;
}

@keyframes memoryAnswerIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

[data-theme="dark"] #memory-answer {
  background-color: #1c2f24;
  border-color: #2a4a38;
}

/* --- Wiki sections (.wiki-section) --- */
#memory-page .wiki-section {
  margin: 18px 0;
}

#memory-page .wiki-section > h2,
#memory-page .wiki-section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 6px;
}

/* Wiki item cards (details / .wiki-item) */
#memory-page .wiki-section details,
#memory-page .wiki-item {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin: 8px 0;
  overflow: hidden;
}

#memory-page .wiki-section details summary,
#memory-page .wiki-item summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

#memory-page .wiki-section details summary::-webkit-details-marker,
#memory-page .wiki-item summary::-webkit-details-marker {
  display: none;
}

#memory-page .wiki-section details summary::after,
#memory-page .wiki-item summary::after {
  content: '▾';
  color: var(--muted);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

#memory-page .wiki-section details[open] summary::after,
#memory-page .wiki-item[open] summary::after {
  transform: rotate(180deg);
}

#memory-page .wiki-section details .file-preview,
#memory-page .wiki-item .file-preview {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  padding: 0 14px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

#memory-page .wiki-section details .file-meta,
#memory-page .wiki-item .file-meta {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.85;
}

/* --- Recent activity (.memory-events) --- */
#memory-page .memory-events {
  list-style: none;
  margin: 0;
  padding: 0;
}

#memory-page .memory-events li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--ink);
  line-height: 1.45;
}

#memory-page .memory-events li:last-child {
  border-bottom: none;
}

#memory-page .memory-events .activity-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--sage);
  margin-top: 5px;
}

#memory-page .empty-wiki {
  font-size: 14px;
  color: var(--muted);
  padding: 4px 0;
}

/* --- Refresh memory button (.memory-refresh: ghost, full width) --- */
#memory-page .refresh-row form,
#memory-page .memory-refresh {
  width: 100%;
}

#memory-page .memory-refresh {
  border-radius: 12px;
}

/* --- M6 dark-mode variants --- */
[data-theme="dark"] #memory-page .memory-ask {
  box-shadow: var(--shadow);
}

[data-theme="dark"] #memory-page .wiki-section details,
[data-theme="dark"] #memory-page .wiki-item {
  background-color: var(--surface);
  border-color: var(--border);
}

/* --- M6 reduced-motion: no fade-in, no chevron spin --- */
@media (prefers-reduced-motion: reduce) {
  #memory-answer,
  #memory-answer.answer-in {
    animation: none;
  }

  #memory-page .wiki-section details summary::after,
  #memory-page .wiki-item summary::after {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   18. PWA Polish — iOS zoom prevention & safe-area (app.css tail)
   -------------------------------------------------------------------------- */

/* iOS auto-zooms into any form control under 16px; keep every control ≥16px
   on mobile/touch regardless of earlier component-level font-size rules. */
@media (max-width: 480px), (pointer: coarse) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}
