/* Балкон — спокойная нативная дизайн-система.
   Светлый нейтральный фон, белые карточки, крупные фото растений.
   Цвет только по смыслу: синий — полив, зелёный — основное действие,
   янтарный и красный — состояние растения. */

:root {
  --bg: #f4f5f1;
  --surface: #ffffff;
  --surface-2: #eef0eb;
  --line: #e3e6df;

  --ink: #17231c;
  --ink-2: #5b675f;

  --green: #1e5b3e;
  --green-hover: #174a32;
  --green-tint: #e4efe8;

  --water: #2f6bd0;
  --water-hover: #2559b3;
  --water-tint: #e6eefb;
  --water-ink: #1f4f9f;

  --amber-tint: #fbefd6;
  --amber-ink: #7a4d05;
  --red-tint: #fbe4e0;
  --red-ink: #9a2a1f;

  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(23, 35, 28, 0.05), 0 6px 18px -10px rgba(23, 35, 28, 0.16);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;

  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: #c3c9c1 transparent;
  scrollbar-width: thin;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  caret-color: var(--green);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--green-tint);
}

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

img {
  display: block;
  max-width: 100%;
}

a {
  color: var(--green);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  text-wrap: balance;
}

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

.i {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  vertical-align: -0.2em;
}

.page {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 22px 16px calc(40px + env(safe-area-inset-bottom));
}

.card {
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* Фото или заглушка — общие для миниатюр, карточек и шапки растения */
.thumb,
.plant-card-photo,
.hero-photo {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--surface-2);
}

.thumb img,
.plant-card-photo img,
.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.glass-empty {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #9aa49c;
}

.glass-empty .i {
  width: 36%;
  height: 36%;
  stroke-width: 1.5;
}

/* Плашка состояния */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.pill--attention {
  background: var(--amber-tint);
  color: var(--amber-ink);
}

.pill--critical {
  background: var(--red-tint);
  color: var(--red-ink);
}

.pill--float {
  position: absolute;
  top: 8px;
  left: 8px;
  box-shadow: 0 1px 3px rgba(23, 35, 28, 0.15);
}

/* --- Главная ------------------------------------------------------------------ */

.head {
  padding: 4px 2px 18px;
}

.head h1 {
  font-size: 34px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.head-sub {
  margin-top: 4px;
  color: var(--ink-2);
}

.head-due {
  margin-top: 2px;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-2);
}

.head-due.has-due {
  color: var(--water-ink);
}

/* Список «полить сегодня» */
.tasks {
  margin: 0;
  padding: 4px 0;
  list-style: none;
}

.task {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 12px;
}

.task + .task {
  border-top: 1px solid var(--line);
}

.task-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.task .thumb {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: var(--r-md);
}

.task-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.task-name {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
}

.task-meta {
  font-size: 14px;
  color: var(--ink-2);
}

.task-meta.is-overdue {
  color: var(--red-ink);
  font-weight: 600;
}

.task .pill {
  margin-top: 3px;
}

.task.is-done .thumb img {
  opacity: 0.55;
  transition: opacity 300ms var(--ease-out);
}

.task form {
  margin: 0;
  flex: none;
}

.btn-water {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--water);
  cursor: pointer;
  transition: background-color 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.btn-water:hover {
  background: var(--water-hover);
}

.btn-water:active {
  transform: scale(0.97);
}

.htmx-request .btn-water,
.btn-water.htmx-request {
  opacity: 0.7;
}

.done-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-tint);
  animation: pop 380ms var(--ease-out);
}

.done-mark .i {
  width: 22px;
  height: 22px;
  stroke-width: 3;
}

@keyframes pop {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
}

.empty {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-tint);
}

.empty-icon .i {
  width: 22px;
  height: 22px;
  stroke-width: 2.6;
}

.empty-title {
  font-size: 17px;
  font-weight: 600;
}

.empty-sub {
  margin-top: 2px;
  color: var(--ink-2);
}

/* Растения по комнатам */
.section {
  margin-top: 32px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 2px 12px;
}

.section-head h2 {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.count {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.plant-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 12px;
}

@media (min-width: 560px) {
  .plant-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.plant-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.plant-card-photo {
  aspect-ratio: 4 / 5;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.plant-card-photo img {
  transition: transform 300ms var(--ease-out);
}

.plant-card:hover .plant-card-photo img {
  transform: scale(1.03);
}

.plant-card-name {
  margin: 9px 2px 0;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.25;
  hyphens: auto;
  overflow-wrap: break-word;
}

.plant-card-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 2px 2px 0;
  font-size: 14px;
  color: var(--ink-2);
}

.plant-card-meta.is-due {
  color: var(--water-ink);
  font-weight: 600;
}

.plant-card-meta.is-overdue {
  color: var(--red-ink);
}

.plant-card-meta .i {
  width: 14px;
  height: 14px;
}

.add-plant {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 32px;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
}

.add-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-tint);
}

.add-icon .i {
  width: 22px;
  height: 22px;
  stroke-width: 2.4;
}

.add-plant strong {
  display: block;
  font-size: 16.5px;
  font-weight: 600;
}

.add-plant small {
  display: block;
  margin-top: 1px;
  font-size: 14px;
  color: var(--ink-2);
}

/* --- Страница растения --------------------------------------------------------- */

.hero-photo {
  aspect-ratio: 4 / 5;
  max-height: 62vh;
  width: 100%;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.plant-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

.plant-head h1 {
  font-size: 30px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.species {
  margin-top: 4px;
  color: var(--ink-2);
}

.where {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--ink-2);
}

.btn-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.health {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: var(--green-tint);
}

.health--attention {
  background: var(--amber-tint);
}

.health--critical {
  background: var(--red-tint);
}

.health-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  color: var(--green);
}

.health--attention .health-label {
  color: var(--amber-ink);
}

.health--critical .health-label {
  color: var(--red-ink);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
}

.health-note {
  margin-top: 4px;
  line-height: 1.5;
  max-width: 62ch;
}

.water {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 14px 14px 14px 16px;
}

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

.water-when {
  font-size: 17px;
  font-weight: 600;
  text-wrap: balance;
}

.water-when.is-overdue {
  color: var(--red-ink);
}

.water-last {
  margin-top: 1px;
  text-wrap: pretty;
  font-size: 14px;
  color: var(--ink-2);
}

.water form {
  margin: 0;
  flex: none;
}

.btn-soft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--water-ink);
  background: var(--water-tint);
  cursor: pointer;
}

.btn-soft:hover {
  background: #d8e5fa;
}

.block {
  margin-top: 30px;
}

.block h2 {
  margin: 0 2px 10px;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* Задачи */
.todos {
  margin: 0;
  padding: 2px 0;
  list-style: none;
}

.todo + .todo {
  border-top: 1px solid var(--line);
}

.todo form {
  margin: 0;
}

.todo-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.todo-box {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border: 2px solid #b7beb6;
  border-radius: 50%;
  transition: background-color 200ms var(--ease-out), border-color 200ms var(--ease-out);
}

.todo-box .tick {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 26;
  stroke-dashoffset: 26;
}

.todo.is-done .todo-box {
  background: var(--green);
  border-color: var(--green);
}

.todo.is-done .todo-box .tick {
  animation: draw 320ms var(--ease-out) forwards;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

.todo-body {
  min-width: 0;
}

.todo-text {
  display: block;
  line-height: 1.4;
}

.todo.is-done .todo-text {
  color: var(--ink-2);
  text-decoration: line-through;
  text-decoration-color: rgba(91, 103, 95, 0.5);
}

.todo-done {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--green);
}

/* Уход */
.care {
  margin: 0;
  padding: 2px 0;
}

.care-row {
  padding: 13px 16px;
}

.care-row + .care-row {
  border-top: 1px solid var(--line);
}

.care-row dt {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.care-row dd {
  margin: 4px 0 0;
  max-width: 62ch;
}

.caution {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: var(--amber-tint);
  color: var(--ink);
}

.caution > .i {
  margin-top: 2px;
  color: var(--amber-ink);
}

.history {
  margin: 0;
  padding: 2px 0;
  list-style: none;
}

.history li {
  display: flex;
  justify-content: space-between;
  padding: 11px 16px;
  font-size: 15px;
}

.history li + li {
  border-top: 1px solid var(--line);
}

.history-date {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

/* --- Формы ----------------------------------------------------------------- */

.form-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.form-lead {
  margin-top: 8px;
  color: var(--ink-2);
  max-width: 52ch;
}

.form {
  margin-top: 22px;
}

.field {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field > label,
.field > legend {
  display: block;
  margin-bottom: 6px;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
}

.field small {
  font-weight: 400;
  color: var(--ink-2);
}

input:not([type="radio"]):not([type="file"]),
textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  transition: border-color 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input::placeholder,
textarea::placeholder {
  color: #7d877f;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(30, 91, 62, 0.14);
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}

.field-inline span {
  flex: none;
  min-width: 3.4em;
  color: var(--ink-2);
}

.choice {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.choice label {
  position: relative;
  flex: 1;
  min-width: 0;
}

.choice input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.choice span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  text-align: center;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.choice input:checked + span {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(23, 35, 28, 0.12);
}

.choice-good input:checked + span {
  color: var(--green);
}

.choice-attention input:checked + span {
  color: var(--amber-ink);
}

.choice-critical input:checked + span {
  color: var(--red-ink);
}

.choice input:focus-visible + span {
  outline: 2.5px solid var(--green);
  outline-offset: 2px;
}

.photo-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  cursor: pointer;
}

.photo-field input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-preview {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  flex: none;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--ink-2);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview .i {
  width: 26px;
  height: 26px;
}

.photo-cta {
  font-weight: 600;
  color: var(--green);
}

.photo-field:has(input:focus-visible) .photo-preview {
  outline: 2.5px solid var(--green);
  outline-offset: 2px;
}

.more {
  margin: 4px 0 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.more summary {
  padding: 14px 2px;
  font-weight: 600;
  color: var(--green);
  cursor: pointer;
}

.more[open] summary {
  margin-bottom: 4px;
}

.btn-primary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms var(--ease-out);
}

.btn-primary {
  color: #fff;
  background: var(--green);
}

.btn-primary:hover {
  background: var(--green-hover);
}

.btn-danger {
  color: var(--red-ink);
  background: transparent;
  font-size: 15px;
}

.archive {
  margin-top: 20px;
}

.form-error,
.net-error {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--red-tint);
  color: var(--red-ink);
  font-weight: 600;
}

/* --- Вход и ошибки --------------------------------------------------------- */

.page--login {
  display: grid;
  align-content: center;
  min-height: 80vh;
}

.login-card {
  padding: 24px;
}

.login-card h1 {
  font-size: 30px;
  letter-spacing: -0.025em;
}

.login-card p {
  margin-top: 6px;
}

.login-hint {
  color: var(--ink-2);
}

.error-page {
  display: grid;
  gap: 16px;
  justify-items: start;
  padding-top: 30vh;
  font-size: 18px;
}

.btn {
  color: var(--green);
  font-weight: 600;
}

/* --- Движение -------------------------------------------------------------- */

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 160ms;
  animation-timing-function: var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }

  .todo.is-done .todo-box .tick {
    stroke-dashoffset: 0;
  }
}
