/* App shell, pages, cards, dialogs, toasts. */

body { display: flex; flex-direction: column; min-height: 100%; }

/* ----------------------------------------------------------------- header */

.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  height: var(--header-h); padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}

.brand {
  display: flex; align-items: center; gap: 10px; flex: none;
  color: var(--text); text-decoration: none; font-weight: 680; font-size: 1.05rem;
}
.brand-mark { width: 28px; height: 28px; }

.app-nav {
  display: flex; gap: 2px; min-width: 0; height: 100%;
  overflow-x: auto; scrollbar-width: none;
}
.app-nav::-webkit-scrollbar { display: none; }

.nav-link {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 0 12px; color: var(--muted); text-decoration: none; font-weight: 550; white-space: nowrap;
}
.nav-link:hover { color: var(--text); }
.nav-link[aria-current="page"] { color: var(--text); }
.nav-link[aria-current="page"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--accent);
}
.nav-link.is-soon { opacity: 0.55; }
.nav-soon {
  font-size: 0.68rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 1px 5px; border-radius: 4px; background: var(--surface-2); color: var(--muted);
}

/* ------------------------------------------------------------------ pages */

.app-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.app-main:focus { outline: none; }

.page { width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  margin-bottom: 24px;
}
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 16px; }
.panel h2 { margin-bottom: 14px; }
.panel .field + .field, .panel .field + .check, .panel .check + .check { margin-top: 14px; }

/* ---------------------------------------------------------- garden cards */

.garden-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.garden-card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.garden-card:hover { border-color: var(--border-strong); }

.garden-thumb {
  display: block; aspect-ratio: 16 / 9; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.garden-thumb svg { display: block; width: 100%; height: 100%; }

.garden-card-body { display: grid; gap: 4px; padding: 14px 16px 6px; }
.garden-card-body h2 { font-size: 1.05rem; overflow-wrap: anywhere; }
.garden-card-body h2 a { color: inherit; text-decoration: none; }
.garden-card-body h2 a:hover { text-decoration: underline; }

.garden-card-actions {
  display: flex; align-items: center; gap: 4px; margin-top: auto; padding: 10px 12px 12px;
}
.garden-card-actions .spacer { flex: 1; }
.garden-card-actions .btn-ghost { color: var(--muted); }
.garden-card-actions .btn-ghost:hover { color: var(--text); }
.garden-card-actions .btn-ghost.danger:hover { color: var(--danger); background: var(--danger-soft); }

.empty {
  display: grid; justify-items: center; gap: 12px; text-align: center;
  padding: 64px 24px; border: 2px dashed var(--border); border-radius: var(--radius);
}
.empty > svg { width: 56px; height: 56px; color: var(--accent); }
.empty p { max-width: 420px; }

/* ---------------------------------------------------------------- planner */

.planner-placeholder {
  flex: 1; display: grid; place-items: center; padding: 32px;
  background:
    linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 40px 40px,
    var(--bg);
}
.planner-placeholder .panel { max-width: 460px; text-align: center; display: grid; gap: 10px; }

/* ---------------------------------------------------------------- dialogs */

dialog.modal {
  width: min(460px, calc(100vw - 32px)); padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgb(10 15 10 / 0.45); }
dialog.modal form { display: grid; gap: 16px; padding: 22px; }
dialog.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ----------------------------------------------------------------- toasts */

.toasts {
  position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg);
  animation: toast-in 0.18s ease-out;
}
.toast.error { background: var(--danger); color: var(--surface); }
.toast button {
  border: 0; background: transparent; color: inherit; font: inherit; font-weight: 650;
  text-decoration: underline; cursor: pointer; padding: 0;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

/* ---------------------------------------------------------------- narrow */

@media (max-width: 700px) {
  .brand span { display: none; }
  .page { padding: 20px 16px 48px; }
}

/* ------------------------------------------------------------------ menus */

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 330px;
  display: grid; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
.menu[hidden] { display: none; }
.menu-item {
  display: flex; justify-content: space-between; gap: 16px; align-items: baseline;
  padding: 8px 10px; border: 0; border-radius: 4px; background: transparent; color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-hint { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

/* ------------------------------------------------------------------ print */

#print-root { display: none; }

@media print {
  /* Only when a plan has been prepared for printing (planner Print / Ctrl+P). */
  body:has(#print-root) > *:not(#print-root) { display: none !important; }
  body:has(#print-root) { background: #fff; display: block; min-height: 0; }
  #print-root { display: block; }
  #print-root svg { display: block; width: 100%; height: auto; max-height: calc(100vh - 2mm); }
}
