/*
 * Plants — site-people 의 결을 그대로 따른다.
 *
 * 규칙 셋이 전부다.
 *   1. 선을 쓰지 않는다. 계층은 표면 밝기와 여백으로만 만든다.
 *   2. 만지는 것에만 표면을 준다. 읽기만 하는 것은 바닥 위에 놓인다.
 *   3. 누르면 아래에서 시트가 올라온다.
 *
 * 하나가 더 있다. 초록은 물에만 쓴다 — 오늘 준 물방울, 주기를 넘긴 식물.
 * 장식으로 쓰면 "물 줄 때" 가 묻힌다.
 */

:root {
  color-scheme: light;

  --bg: #faf8f4;        /* 종이 */
  --surface: #eeeae3;   /* 만지는 것 */
  --raised: #ffffff;    /* 떠 있는 것: 시트 */
  --hover: #e4dfd6;

  --text: #23201b;
  --text-dim: #6c6458;  /* surface 위에서도 4.5:1 을 넘기는 가장 흐린 값 */

  --accent: #2e4a6e;    /* 잉크. 주 버튼에만 */
  --accent-hover: #233b59;
  --on-accent: #ffffff;
  --warn: #96591f;
  --danger: #b0503f;
  --scrim: rgba(35, 30, 22, 0.28);

  /*
   * 물. 잎 같은 노랑기 초록이 아니라 물 준 흙에서 올라오는 짙은 초록이다 —
   * 종이 위에서 잉크와 나란히 서도 겨루지 않는 채도. 글자로 쓸 때 bg 와 5:1.
   */
  --leaf: #2f6b45;
  --leaf-soft: #dcebdf;   /* 오늘 준 물방울 칸의 표면 */
  --leaf-hover: #cde2d1;

  --radius: 12px;
  --pill: 999px;
  --app: 560px;
  --tap: 46px;
  --peek: 18px;           /* config.js 의 PEEK 과 같다 */
  --ease: 170ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple SD Gothic Neo',
               'Noto Sans KR', 'Malgun Gothic', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.screen { display: none; }
.screen.is-active { display: block; }

/* ── 폼 ───────────────────────────────────────────────────── */

.input, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: background var(--ease);
}

.input::placeholder, .textarea::placeholder { color: var(--text-dim); opacity: 1; }
.input:focus, .textarea:focus { outline: none; background: var(--raised); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.6; }

.btn {
  min-height: var(--tap);
  padding: 11px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.95rem;
  white-space: nowrap;
  transition: background var(--ease), transform var(--ease);
}

.btn:hover { background: var(--hover); }
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-quiet { background: none; color: var(--text-dim); }
.btn-quiet:hover { background: var(--surface); }
.btn-danger { color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }

.chip {
  min-height: 40px;
  padding: 7px 16px;
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.85rem;
  transition: background var(--ease), color var(--ease);
}

.chip:hover { background: var(--hover); }
.chip.is-active { background: var(--accent); color: var(--on-accent); }

/* ── 홈 ───────────────────────────────────────────────────── */

/*
 * 화면보다 --peek 두 번만큼 낮다. 열면 홈 위가 --peek 만큼 잘린 채 서고,
 * 그러면 아래의 타임라인이 화면 바닥에 같은 만큼 걸쳐 보인다 — 아래에
 * 뭔가 있다는 것은 그렇게 보이는 수밖에 없다.
 *
 * svh 를 쓴다. 폰 브라우저의 주소창이 접히고 펴질 때 vh 는 큰 쪽이라
 * 바닥의 칩이 주소창 뒤로 들어간다.
 */
#home {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--peek) * 2);
  min-height: calc(100svh - var(--peek) * 2);
  width: 100%;
  max-width: var(--app);
  margin: 0 auto;
  padding: max(1.4rem, env(safe-area-inset-top)) 18px 22px;
}

/* 남는 높이를 위가 먹고, 이름표·카드·아래 줄이 한 덩어리로 바닥에 앉는다 */
.home-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.home-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.home-head h1 { margin: 0; font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em; }

.home-links { display: flex; gap: 16px; }
.home-links button { padding: 0; font-size: 0.82rem; color: var(--text-dim); }
.home-links button:hover { color: var(--text); }

/* ── 식물 카드 ────────────────────────────────────────────── */

.plants { display: flex; flex-direction: column; gap: 8px; }

/*
 * 한 줄 카드: [이름 · 주기 ……… 며칠 전] [물방울].
 *
 * 몸통과 물방울은 따로 누르는 두 버튼이다. 둘 사이에 틈을 두지 않고 한
 * 표면으로 이어 붙여 "한 식물" 로 읽히게 하고, 물방울 칸만 한 겹 짙게 둔다.
 * 며칠 전이 물방울 바로 왼쪽에 서는 것은 그 숫자를 보고 누르기 때문이다.
 */
.plant {
  display: flex;
  align-items: stretch;
  min-height: 56px;
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.plant-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 0 16px;
  text-align: left;
  transition: background var(--ease);
}

.plant-body:hover { background: var(--hover); }
.plant-name { font-size: 0.98rem; font-weight: 600; line-height: 1.3; white-space: nowrap; }
.plant-cycle { font-size: 0.76rem; color: var(--text-dim); white-space: nowrap; }
.plant-when {
  margin-left: auto;
  padding-right: 10px;
  font-size: 0.9rem;
  color: var(--text-dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/*
 * 주기를 넘긴 식물. 경고가 아니라 "이쪽이 목마르다" 정도 — 표면은 그대로
 * 두고 며칠 전만 초록으로 짙게, 그 앞에 점 하나.
 */
.plant.is-due .plant-when { color: var(--leaf); font-weight: 600; }
.plant.is-due .plant-when::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 7px 1px 0;
  border-radius: var(--pill);
  background: var(--leaf);
  vertical-align: middle;
}

/* 오늘 물주기. 엄지 자리라 카드 높이 그대로 56px 정사각에 가깝게 */
.water-btn {
  flex: none;
  width: 56px;
  display: grid;
  place-items: center;
  background: var(--hover);
  transition: background var(--ease);
}

.water-btn:hover { background: #d9d3c8; }
.water-btn svg { width: 20px; height: 20px; stroke: var(--text-dim); fill: none;
                 stroke-width: 1.8; stroke-linejoin: round; transition: transform var(--ease); }
.water-btn:active svg { transform: scale(0.88); }

/* 오늘 준 식물 — 물방울이 차고 칸이 초록으로 */
.water-btn.is-on { background: var(--leaf-soft); }
.water-btn.is-on:hover { background: var(--leaf-hover); }
.water-btn.is-on svg { stroke: var(--leaf); fill: var(--leaf); }

/* 커밋이 가는 동안. 바뀐 모습은 먼저 보여 주고 흐리기만 한다 */
.water-btn.is-busy { opacity: 0.55; }

/* ── 카드 아래 줄 ─────────────────────────────────────────── */

.home-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

/* 식물 들이기. 표면 없이 물러선다 — 자주 누르지 않는다 */
.plant-add {
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.85rem;
  transition: background var(--ease);
}

.plant-add:hover { background: var(--surface); }

/* 기록 남기기 — 지난 날짜 물주기·메모. 이 화면의 주 버튼이라 잉크색 */
.record-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: var(--tap);
  padding: 0 16px 0 12px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background var(--ease), transform var(--ease);
}

.record-btn:hover { background: var(--accent-hover); }
.record-btn:active { transform: scale(0.97); }
.record-btn svg { width: 18px; height: 18px; stroke: var(--on-accent); fill: none;
                  stroke-width: 2; stroke-linecap: round; }

/* ── 타임라인 ─────────────────────────────────────────────── */

#below {
  width: 100%;
  max-width: var(--app);
  margin: 0 auto;
  padding: 6px 18px calc(80px + env(safe-area-inset-bottom));
}

/* 날 사이는 조금, 같은 날 안의 줄 사이는 0 — 거리로 "같은 날" 을 묶는다 */
.timeline { display: flex; flex-direction: column; gap: 4px; }


/* 날짜는 눈금이다. 찾을 때만 보이면 된다 */
.tl-date { font-size: 0.74rem; color: var(--text-dim); line-height: 1.6; }

/*
 * 날짜는 왼쪽 칸, 그날의 기록은 오른쪽 칸에 쌓인다. 기록이 하나뿐인 날은
 * 그래서 한 줄이 되고, 여럿인 날도 날짜가 첫 줄 옆에 선다 — 날짜만 따로
 * 한 줄을 차지하지 않는다. 칸 폭이 고정이라 날이 바뀌어도 내용의 왼쪽 끝이
 * 세로로 맞는다.
 */
.tl-day { display: grid; grid-template-columns: 4.6em 1fr; align-items: start; gap: 0; }
.tl-day .tl-date { grid-column: 1; grid-row: 1; margin: 0; padding-top: 6px; }
.tl-day .tl-row { grid-column: 2; margin: 0 -10px 0 0; width: auto; min-width: 0; }

/*
 * 한 줄. 누르면 고친다. 표면을 깔지 않는다 — 읽는 것이 먼저고, 줄마다
 * 카드를 깔면 타임라인이 버튼 더미가 된다. 손이 올라가면 그때 표면이 선다.
 */
.tl-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 -10px;
  width: calc(100% + 20px);
  padding: 4px 10px;
  border-radius: var(--radius);
  text-align: left;
  font-size: 0.94rem;
  transition: background var(--ease);
}

.tl-row:hover { background: var(--surface); }
/* "물 줌" 과 물방울 — 이 줄이 물 준 것임을 초록이 말한다 */
.tl-did { color: var(--leaf); font-weight: 600; white-space: nowrap; }
.tl-did svg { width: 15px; height: 15px; vertical-align: -2px; fill: var(--leaf); stroke: var(--leaf);
              stroke-width: 1.6; stroke-linejoin: round; }

/* 달 머리말. 이 구역에서 가장 큰 글자지만 줄 하나 크기 — 표지가 아니라 책갈피다 */
.tl-month { margin: 14px 0 4px; font-size: 0.86rem; font-weight: 600; }
.tl-month:first-child, .tl-filter + .tl-month { margin-top: 0; }
.tl-text { white-space: pre-wrap; word-break: break-word; }

/* 식물 태그. 타임라인 줄 머리에 서므로 흐리게 숨지 않고 본문만큼 읽힌다 */
.tag {
  display: inline-block;
  padding: 0 8px;
  border-radius: var(--pill);
  background: var(--surface);
  font-size: 0.78rem;
  line-height: 1.75;
  color: var(--text);
  white-space: nowrap;
  vertical-align: 1px;
}

/* 거르는 중이라는 표시. 누르면 풀린다 */
.tl-filter {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px 6px 14px;
  border-radius: var(--pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.8rem;
}

.tl-filter svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2;
                 stroke-linecap: round; }

.empty { padding: 30px 0; color: var(--text-dim); font-size: 0.9rem; text-align: center; }

/* ── 시트 ─────────────────────────────────────────────────── */

.sheet-back {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--scrim);
  animation: fade-in 170ms ease-out;
}

.sheet {
  width: 100%;
  max-width: var(--app);
  max-height: 88vh;
  overflow-y: auto;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  background: var(--raised);
  border-radius: 22px 22px 0 0;
  animation: sheet-up 230ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.sheet::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  margin: 0 auto 16px;
  background: var(--surface);
  border-radius: var(--pill);
}

.sheet-title { margin: 0 0 14px; font-size: 1rem; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.field-label { font-size: 0.78rem; color: var(--text-dim); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* 물주기 · 메모 두 칸. 시트 맨 위에서 무엇을 남길지 먼저 고른다 */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--surface);
}

.seg-btn { min-height: 38px; border-radius: 9px; font-size: 0.9rem; color: var(--text-dim);
           transition: background var(--ease), color var(--ease); }
.seg-btn.is-active { background: var(--raised); color: var(--text); font-weight: 600; }

.quote {
  margin: 0;
  padding: 12px 14px;
  max-height: 40vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
}

.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.stack .btn { min-height: 50px; }

/* 보관한 식물 한 줄 — 이름과 꺼내기 */
.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.row-name { font-size: 0.92rem; }

.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; min-height: 50px; }

/* 시트 안의 입력은 시트(raised)보다 짙어야 눌려 보인다. 포커스는 종이색으로 */
.sheet .input, .sheet .textarea { background: var(--surface); }
.sheet .input:focus, .sheet .textarea:focus { background: var(--bg); }

@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(26px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .sheet-back, .sheet { animation: none; }
  * { transition: none !important; }
}

@media (max-width: 380px) {
  #home, #below { padding-left: 12px; padding-right: 12px; }
  .plant-body { padding-left: 13px; }
}

/* ── 잠금 · 설정 ──────────────────────────────────────────── */

/* 여기도 손이 닿는 곳에서 끝난다 */
.center { min-height: 100vh; align-content: end; justify-items: center;
          padding: 24px 24px max(24px, 12vh); }
.center.is-active { display: grid; }

.gate { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }
.gate h1 { margin: 0 0 6px; font-size: 1.6rem; font-weight: 600; text-align: center; }
.gate .hint { margin: 0; font-size: 0.78rem; line-height: 1.55; color: var(--text-dim); }
.gate .link { text-align: center; font-size: 0.78rem; color: var(--text-dim); }

/* ── 알림 ─────────────────────────────────────────────────── */

.msg { margin: 0; font-size: 0.83rem; color: var(--warn); }
.msg.is-info { color: var(--text-dim); }

.banner { margin: 10px 0 0; color: var(--warn); font-size: 0.82rem; line-height: 1.5; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  max-width: calc(100% - 32px);
  padding: 11px 20px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--pill);
  font-size: 0.85rem;
}
