:root {
  --ink: #14261a;
  --green: #1f3d2b;
  --paper: #f4ede1;
  --gold: #c17f3e;
  --sage: #a9c4b4;
  --alert: #d9534f;
  --faint: rgba(20, 38, 26, 0.42);
  --line: rgba(20, 38, 26, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

body {
  height: 100dvh;
}

button,
input,
select {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding:
    max(10px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.brand-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.place-wrap {
  text-align: right;
}

.wx {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  text-align: right;
}

#temp {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

#place-name {
  display: block;
  font-size: 10px;
  color: var(--faint);
  letter-spacing: 0.04em;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-sheet {
  display: grid;
  gap: 10px;
}

.place-sheet[hidden] {
  display: none;
}

.place-sheet input,
.place-sheet select {
  width: 100%;
  border: 0;
  border-radius: 999px;
  background: rgba(169, 196, 180, 0.28);
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
}

.place-results {
  display: grid;
  gap: 2px;
  max-height: 160px;
  overflow: auto;
}

.place-results[hidden] {
  display: none;
}

.place-hit {
  appearance: none;
  background: none;
  border: 0;
  text-align: left;
  padding: 7px 8px;
  border-radius: 10px;
  font-size: 13px;
}

.place-hit:hover,
.place-hit:focus {
  background: rgba(169, 196, 180, 0.35);
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

.panel {
  display: none;
  height: 100%;
}

.panel.is-on {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.thirst {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 10px;
  padding: 8px 4px 8px 2px;
}

.thirst[hidden] {
  display: none;
}

#thirst-label {
  color: var(--alert);
  font-size: 18px;
}

.thirst-actions {
  display: flex;
  gap: 8px;
}

button:not(.tab):not(.wx):not(.place-hit):not(.stem):not(.lib-hit):not(.soil-item):not(.zoom):not(.add-row) {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: var(--paper);
  padding: 8px 16px;
  font-size: 14px;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.bed-wrap {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

.bed {
  height: 100%;
  position: relative;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  background:
    radial-gradient(120% 80% at 50% 110%, rgba(31, 61, 43, 0.08), transparent 55%),
    linear-gradient(180deg, transparent, rgba(169, 196, 180, 0.18));
  border-radius: 28px;
}

.bed-map {
  position: absolute;
  left: 0;
  top: 0;
  width: 132%;
  height: 132%;
  transform-origin: 0 0;
  will-change: transform;
}

.bed-tools {
  position: absolute;
  right: 10px;
  top: 10px;
  display: grid;
  gap: 6px;
  z-index: 2;
}

.zoom {
  appearance: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(244, 237, 225, 0.92);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 20px;
  line-height: 1;
}

.legend {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 1;
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--faint);
  pointer-events: none;
}

#water-all {
  flex: 0 0 auto;
  align-self: center;
  margin: 8px 0 0;
}

.add-fab {
  position: absolute;
  right: 10px;
  bottom: 12px;
  left: auto;
  transform: none;
  z-index: 3;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
}

.add-row {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  border-radius: 14px;
  padding: 8px 4px;
  text-align: left;
  color: var(--green);
  font-size: 16px;
}

.add-row svg {
  width: 36px;
  height: 36px;
  padding: 3px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px currentColor;
}

.add-row b {
  font-weight: 400;
  color: var(--gold);
  font-size: 22px;
}

.add-list {
  display: grid;
  gap: 4px;
}

#plant-search {
  width: 100%;
  border: 0;
  border-radius: 999px;
  background: rgba(169, 196, 180, 0.28);
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  margin-bottom: 8px;
}

#plant-results {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.stem {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 58px;
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  display: grid;
  justify-items: center;
  gap: 2px;
  color: var(--sage);
  touch-action: none;
}

.stem svg {
  width: 46px;
  height: 46px;
  padding: 5px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px currentColor;
}

.stem b {
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.01em;
  color: inherit;
  opacity: 0.8;
  white-space: nowrap;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stem.is-water {
  color: var(--alert);
}

.stem.is-watch {
  color: var(--gold);
}

.stem.is-ok {
  color: var(--sage);
}

.stem.is-lifted {
  z-index: 4;
  filter: drop-shadow(0 6px 10px rgba(20, 38, 26, 0.28));
}

.explore {
  height: 100%;
  overflow: auto;
  padding: 8px 2px 16px;
}

.soils {
  display: grid;
  gap: 18px;
}

.section-label,
.soil h2,
.sheet-label {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

.section-label + .library,
.section-label + .soils {
  margin-top: 0;
}

.explore .section-label:not(:first-child) {
  margin-top: 28px;
}

.soil-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.soil-item {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 64px;
  color: var(--green);
  font-size: 11px;
  text-align: center;
}

.soil-item::after {
  content: "+";
  color: var(--gold);
  font-size: 16px;
  line-height: 1;
}

.soil-item svg {
  width: 40px;
  height: 40px;
  padding: 4px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px currentColor;
}

.library {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 16px;
}

.library li {
  list-style: none;
}

.lib-hit {
  appearance: none;
  background: rgba(169, 196, 180, 0.28);
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--green);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lib-hit::after {
  content: "+";
  color: var(--gold);
  font-size: 18px;
}

.tabs {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding-top: 10px;
}

.tab {
  appearance: none;
  background: none;
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 15px;
  color: var(--faint);
}

.tab.is-on {
  color: var(--ink);
  background: rgba(169, 196, 180, 0.35);
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 38, 26, 0.28);
  z-index: 8;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  background: var(--paper);
  border-radius: 24px 24px 0 0;
  padding: 22px 22px calc(18px + env(safe-area-inset-bottom));
  max-height: 78dvh;
  overflow: auto;
}

.sheet-photo {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 16px;
  margin: 0 0 14px;
  background: rgba(169, 196, 180, 0.28);
}

.sheet h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 400;
}

.latin {
  margin: 4px 0 4px;
  font-style: italic;
  font-size: 14px;
  color: var(--faint);
}

.family {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--faint);
}

.status {
  margin: 0 0 12px;
  font-size: 16px;
}

.status.water {
  color: var(--alert);
}

.status.watch {
  color: var(--gold);
}

.status.ok {
  color: var(--sage);
}

.fact {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--green);
}

.sheet-block {
  margin: 14px 0 0;
}

.sheet-block ul {
  margin: 0;
  padding-left: 18px;
  color: var(--green);
  font-size: 14px;
  line-height: 1.45;
}

.sheet-block li + li {
  margin-top: 6px;
}

.sheet-links {
  list-style: none;
  padding: 0;
}

.sheet-links a {
  color: var(--gold);
}

.flag {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--alert);
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.sheet[hidden],
.backdrop[hidden] {
  display: none;
}
