:root {
  --bg: #f4f1e8;
  --panel: #fffdf7;
  --ink: #223027;
  --muted: #6c746d;
  --line: #ded8c8;
  --line-strong: #9cb47f;
  --row-a: #f5f9ed;
  --row-b: #e5f0d8;
  --month: #f6f2e7;
  --grows: #3f8a60;
  --blooms: #e2b72c;
  --harvest: #8a6b52;
  --accent: #336d7d;
  --danger: #b75b55;
  --flower-color: #d7a72a;
  --radius: 8px;
  --name-col: 220px;
  --month-min: 54px;
  --chart-min-width: 868px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid rgba(222, 216, 200, 0.88);
  background: rgba(255, 253, 247, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grows);
  color: white;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.version,
.muted,
.note,
.eyebrow {
  color: var(--muted);
}

.brand small,
.version {
  font-size: 12px;
}

.app-layout {
  padding: 14px clamp(16px, 4vw, 42px) 34px;
}

.top-control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  min-width: 0;
  margin-bottom: 8px;
}

.panel,
.calendar-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(49, 58, 42, 0.07);
}

.panel {
  padding: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

h3 {
  margin: 16px 0 8px;
  font-size: 13px;
}

.filters-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: end;
  min-width: 0;
  min-height: 76px;
  padding: 10px 12px;
}

.filters-panel h2 {
  margin-bottom: 4px;
}

.filters-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(260px, 1.45fr) minmax(160px, 0.65fr);
  gap: 10px;
  align-items: end;
  min-width: 0;
}

.filters-grid > div {
  min-width: 0;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.stacked-label {
  margin-top: 16px;
}

select {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
}

.search-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.search-box input,
.search-box button {
  min-width: 0;
  border: 0;
  background: transparent;
}

.search-box input {
  min-height: 34px;
  padding: 7px 10px;
  outline: 0;
}

.search-box button {
  color: var(--muted);
  font-size: 20px;
}

.chip-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.chip {
  flex: 0 0 auto;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.db-actions,
.form-actions {
  display: flex;
  gap: 8px;
}

.db-panel {
  display: grid;
  align-content: start;
  gap: 10px;
}

.plain-button {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.admin-toggle {
  min-height: 76px;
  padding-inline: 18px;
  box-shadow: 0 12px 28px rgba(49, 58, 42, 0.07);
}

.plain-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.plain-button.danger {
  border-color: rgba(183, 91, 85, 0.38);
  color: var(--danger);
}

.small {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.4;
}

.detail-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
  display: none;
  width: min(360px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  overflow: auto;
  gap: 10px;
  box-shadow: 0 18px 44px rgba(34, 48, 39, 0.18);
}

.admin-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 5;
  display: grid;
  width: min(360px, calc(100% - 28px));
  gap: 12px;
  box-shadow: 0 18px 44px rgba(34, 48, 39, 0.18);
}

.admin-panel[hidden] {
  display: none;
}

.detail-panel.is-open {
  display: grid;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-header .eyebrow {
  margin: 0;
}

.detail-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--muted);
  font-size: 21px;
  line-height: 1;
}

.detail-panel h2 {
  font-size: 20px;
}

.detail-row {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.45;
}

.herb-illustration {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid rgba(222, 216, 200, 0.8);
  border-radius: var(--radius);
  background: #fbf5e8;
}

.part-summary {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.edit-form {
  display: grid;
  gap: 12px;
}

.edit-form input,
.edit-form textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  resize: vertical;
}

.color-field {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.edit-form input[type="color"] {
  width: 46px;
  height: 40px;
  padding: 3px;
}

.color-preview {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.color-preview .herb-swatch {
  width: 14px;
  height: 14px;
}

.month-checks,
.part-month-row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 3px;
}

.month-toggle {
  display: grid;
  place-items: center;
  min-height: 25px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.month-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.month-toggle:has(input:checked) {
  border-color: var(--accent);
  background: rgba(51, 109, 125, 0.12);
  color: var(--ink);
}

.harvest-editor {
  display: grid;
  gap: 8px;
}

.harvest-edit-row {
  display: grid;
  gap: 5px;
}

.harvest-edit-row strong {
  font-size: 12px;
}

.detail-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.workspace {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.workspace-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 14px;
  font-size: 13px;
  font-weight: 900;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.swatch {
  width: 34px;
  height: 7px;
  border-radius: 999px;
}

.swatch.grows {
  background: var(--grows);
}

.swatch.blooms {
  background: var(--blooms);
}

.swatch.harvest {
  background: var(--harvest);
}

.calendar-card {
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.calendar-stage {
  position: relative;
  width: 100%;
  min-width: 0;
}

.calendar-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.calendar-header,
.chart-row {
  display: grid;
  grid-template-columns: var(--name-col) repeat(12, minmax(var(--month-min), 1fr));
  width: max(100%, var(--chart-min-width));
}

.calendar-header {
  min-height: 104px;
  border-bottom: 3px solid var(--line-strong);
  background: var(--month);
}

.corner-cell {
  display: flex;
  align-items: end;
  padding: 12px 14px;
  border-right: 3px solid var(--line-strong);
  color: #386928;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-style: italic;
  font-weight: 900;
}

.month-head {
  display: contents;
}

.month-label {
  display: flex;
  align-items: end;
  justify-content: center;
  min-height: 104px;
  padding: 10px 0;
  border-right: 1px dotted var(--line-strong);
  font-size: 12px;
  font-weight: 900;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.month-label.filtered {
  background: rgba(226, 183, 44, 0.18);
}

.chart-row {
  min-height: 34px;
  border-bottom: 1px solid rgba(156, 180, 127, 0.36);
}

.chart-row:nth-child(odd) {
  background: var(--row-a);
}

.chart-row:nth-child(even) {
  background: var(--row-b);
}

.chart-row.selected {
  background: #d9e8ec;
}

.herb-name {
  display: grid;
  align-content: center;
  gap: 3px;
  min-width: 0;
  padding: 5px 10px 5px 12px;
  border: 0;
  border-right: 3px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.14;
}

.herb-title {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
}

.herb-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.herb-swatch {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(34, 48, 39, 0.18);
  border-radius: 50%;
  background: var(--flower-color);
}

.herb-name:focus-visible,
.chip:focus-visible,
.search-box input:focus-visible,
.search-box button:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(51, 109, 125, 0.32);
  outline-offset: 2px;
}

.month-track {
  position: relative;
  display: grid;
  grid-column: 2 / -1;
  grid-template-columns: repeat(12, minmax(var(--month-min), 1fr));
  grid-template-rows: repeat(3, 1fr);
  min-height: 34px;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc((100% / 12) - 1px),
    rgba(156, 180, 127, 0.38) calc((100% / 12) - 1px),
    rgba(156, 180, 127, 0.38) calc(100% / 12)
  );
}

.filter-band {
  grid-row: 1 / -1;
  z-index: 0;
  background: rgba(226, 183, 44, 0.16);
}

.phase {
  position: relative;
  z-index: 1;
  height: 7px;
  align-self: center;
  justify-self: stretch;
  border-radius: 999px;
}

.phase.grows {
  grid-row: 1;
  background: var(--grows);
}

.phase.blooms {
  grid-row: 2;
  background: var(--blooms);
}

.phase.harvest {
  grid-row: 3;
  background: var(--harvest);
}

.empty {
  padding: 26px;
  color: var(--muted);
}

.note {
  max-width: 780px;
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 920px) {
  :root {
    --name-col: 170px;
    --month-min: 44px;
    --chart-min-width: 698px;
  }

  .top-control-grid {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .filters-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  }

  .filters-grid > div:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  :root {
    --name-col: 150px;
    --month-min: 38px;
    --chart-min-width: 606px;
  }

  .app-topbar {
    padding-inline: 12px;
  }

  .brand small {
    display: none;
  }

  .app-layout {
    padding: 14px 12px 26px;
  }

  .workspace-heading {
    display: grid;
    align-items: start;
  }

  .legend {
    justify-content: start;
  }

  .corner-cell {
    font-size: 22px;
  }

  .herb-name {
    font-size: 12px;
  }

  .filters-grid {
    grid-template-columns: 1fr;
  }

  .top-control-grid,
  .filters-panel {
    grid-template-columns: 1fr;
  }

  .admin-toggle {
    min-height: 42px;
  }

  .admin-panel {
    position: static;
    width: 100%;
    margin-top: 12px;
  }

  .detail-panel {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: 12px;
  }
}
