:root {
  --brown:   #7c5a3a;
  --brown-d: #5f4630;
  --cream:   #fff6e6;
  --cream-2: #f3e3c4;
  --leaf:    #6fae4b;
  --leaf-d:  #5a934a;
  --water:   #5aa9e6;
  --water-d: #3f8fcf;
  --fert:    #8e7cc3;
  --harvest: #e8954a;
  --harvest-d:#cf7a32;
  --note:    #c98b6a;
  --danger:  #e06b5e;
  --card:    #fffdf8;
  --line:    #ecdcbe;
  --shadow:  0 4px 14px rgba(95, 70, 48, 0.16);
  --r:       16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  color: var(--brown-d);
  background:
    radial-gradient(circle at 28% 12%, #fff7e8 0%, transparent 55%),
    linear-gradient(165deg, #f7ecd5 0%, #ecdcb6 100%);
  background-attachment: fixed;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 14px calc(env(safe-area-inset-bottom) + 24px);
}

/* ---- ヘッダー ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 2px 8px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, rgba(247,236,213,0.96) 70%, rgba(247,236,213,0));
}
.logo {
  font-size: 1.3rem;
  margin: 0;
  letter-spacing: .02em;
  color: var(--brown-d);
}
.paw { filter: drop-shadow(0 1px 1px rgba(0,0,0,.12)); }
.icon-btn {
  width: 36px; height: 36px;
  border: none; border-radius: 50%;
  background: #fff; color: var(--brown);
  font-weight: 800; font-size: 1.05rem;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.icon-btn:active { transform: scale(.93); }

.view { animation: fade .25s ease; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- 猫バナー ---- */
.cat-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  margin: 6px 0 18px;
}
.cat-mark { width: 56px; height: 56px; flex: 0 0 56px; }
.cat-mark svg, .empty-cat svg { width: 100%; height: 100%; display: block; }
.speech {
  position: relative;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 12px;
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
}
.speech::before {
  content: "";
  position: absolute;
  left: -7px; top: 18px;
  width: 12px; height: 12px;
  background: var(--cream);
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
}

/* ---- セクション見出し ---- */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 2px 10px;
}
.section-title { font-size: 1.05rem; margin: 0; }
.count-chip {
  background: var(--leaf);
  color: #fff;
  font-size: .8rem;
  font-weight: 800;
  min-width: 24px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 999px;
}
.text-btn {
  background: none; border: none;
  color: var(--leaf-d); font-weight: 700;
  font-size: .9rem; cursor: pointer; padding: 4px;
}

/* ---- 野菜リスト ---- */
.veggie-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.veggie-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s;
}
.veggie-card:active { transform: scale(.985); }
.vc-emoji {
  width: 52px; height: 52px; flex: 0 0 52px;
  display: grid; place-items: center;
  font-size: 30px;
  background: var(--cream);
  border-radius: 14px;
}
.vc-body { flex: 1; min-width: 0; }
.vc-name { font-size: 1.05rem; font-weight: 800; margin: 0 0 2px; }
.vc-variety { font-size: .8rem; color: var(--brown); opacity: .8; }
.vc-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.tag {
  font-size: .72rem; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: var(--cream-2); color: var(--brown-d);
  display: inline-flex; align-items: center; gap: 3px;
}
.tag.warn { background: #fbe3c4; color: #b56a1d; }
.tag.water { background: #dcefff; color: var(--water-d); }
.tag.harvest { background: #fde6cf; color: var(--harvest-d); }
.vc-chev { color: var(--cream-2); font-size: 1.6rem; font-weight: 800; }

/* ---- 空状態 ---- */
.empty { text-align: center; padding: 28px 16px; color: var(--brown); }
.empty-cat { width: 130px; height: 130px; margin: 0 auto 10px; opacity: .95; }
.empty p { line-height: 1.6; font-weight: 600; }

/* ---- FAB ---- */
.fab {
  position: fixed;
  right: max(18px, calc(50% - 260px + 18px));
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  width: 60px; height: 60px;
  border: none; border-radius: 50%;
  background: var(--leaf);
  color: #fff; font-size: 2rem; font-weight: 300;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(90,147,74,0.45);
  cursor: pointer;
  z-index: 6;
}
.fab:active { transform: scale(.92); }

/* ---- 詳細 ---- */
.detail-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 8px; }
.back-btn {
  background: none; border: none;
  color: var(--brown-d); font-weight: 700;
  font-size: 1rem; cursor: pointer; padding: 6px 4px;
}
.veggie-hero {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px; box-shadow: var(--shadow);
}
.hero-emoji {
  width: 68px; height: 68px; flex: 0 0 68px;
  display: grid; place-items: center; font-size: 40px;
  background: var(--cream); border-radius: 18px;
}
.hero-name { margin: 0 0 3px; font-size: 1.35rem; }
.hero-sub { margin: 0; font-size: .85rem; color: var(--brown); opacity: .85; }

.hero-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin: 14px 0;
}
.stat-box {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 6px; text-align: center;
  box-shadow: var(--shadow);
}
.stat-num { font-size: 1.25rem; font-weight: 800; line-height: 1.1; }
.stat-cap { font-size: .72rem; color: var(--brown); opacity: .8; margin-top: 3px; }

/* ---- クイック記録 ---- */
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 18px; }
.qa {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 4px 9px;
  font-size: .78rem; font-weight: 700; color: var(--brown-d);
  cursor: pointer; box-shadow: var(--shadow);
  transition: transform .1s;
}
.qa:active { transform: scale(.93); }
.qa-emoji { font-size: 24px; }

/* ---- 記録リスト ---- */
.log-list { list-style: none; margin: 0; padding: 0 0 10px; position: relative; }
.log-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 4px 0;
}
.log-rail { display: flex; flex-direction: column; align-items: center; flex: 0 0 40px; }
.log-dot {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 19px;
  color: #fff; box-shadow: var(--shadow); z-index: 1;
}
.log-dot.water { background: var(--water); }
.log-dot.fertilizer { background: var(--fert); }
.log-dot.harvest { background: var(--harvest); }
.log-dot.note { background: var(--note); }
.log-dot.sow { background: var(--leaf); }
.log-line { width: 2px; flex: 1; background: var(--line); margin: 2px 0; min-height: 8px; }
.log-item:last-child .log-line { display: none; }
.log-body {
  flex: 1; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 9px 12px; margin-bottom: 8px;
  box-shadow: var(--shadow); min-width: 0;
}
.log-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.log-type { font-weight: 800; font-size: .95rem; }
.log-date { font-size: .76rem; color: var(--brown); opacity: .85; white-space: nowrap; }
.log-note { font-size: .88rem; margin: 4px 0 0; line-height: 1.45; color: var(--brown-d); white-space: pre-wrap; word-break: break-word; }
.log-del {
  background: none; border: none; color: var(--cream-2);
  font-size: 1.05rem; cursor: pointer; padding: 0 0 0 6px; line-height: 1;
}
.log-del:active { color: var(--danger); }
.empty-logs { text-align: center; color: var(--brown); opacity: .8; padding: 24px; font-weight: 600; }

/* ---- 入力 ---- */
.field-label { display: block; font-size: .82rem; font-weight: 700; color: var(--brown); margin: 12px 2px 5px; }
.input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 11px 12px; font-size: 1rem; font-family: inherit;
  color: var(--brown-d); background: #fff; outline: none;
  -webkit-user-select: text; user-select: text;
}
.input:focus { border-color: var(--leaf); }
.textarea { resize: none; line-height: 1.45; }

.emoji-picker, .type-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.emoji-opt {
  width: 44px; height: 44px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff;
  font-size: 24px; cursor: pointer; display: grid; place-items: center;
}
.emoji-opt.active { border-color: var(--leaf); background: #eef7e6; transform: scale(1.05); }
.type-opt {
  display: flex; align-items: center; gap: 5px;
  border: 1.5px solid var(--line); background: #fff;
  border-radius: 999px; padding: 8px 13px; font-size: .9rem; font-weight: 700;
  cursor: pointer; color: var(--brown-d);
}
.type-opt.active { border-color: var(--leaf); background: #eef7e6; }

/* ---- モーダル ---- */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(75,55,38,0.42); }
.modal-card {
  position: relative; width: 100%; max-width: 520px;
  background: var(--cream); border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(env(safe-area-inset-bottom) + 20px);
  box-shadow: 0 -8px 30px rgba(0,0,0,0.2);
  max-height: 90dvh; overflow-y: auto;
  animation: slideUp .26s ease;
}
.modal-card h2 { margin: 0 0 4px; font-size: 1.2rem; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

.btn {
  border: none; border-radius: 12px;
  padding: 12px 16px; font-size: 1rem; font-weight: 800;
  font-family: inherit; cursor: pointer;
  background: #fff; color: var(--brown-d);
  box-shadow: var(--shadow);
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--leaf); color: #fff; }

.howto { padding-left: 1.1em; line-height: 1.7; font-size: .92rem; }
.howto li { margin-bottom: 6px; }

/* ---- シート（メニュー） ---- */
.sheet {
  position: relative; width: 100%; max-width: 520px;
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 14px);
  display: flex; flex-direction: column; gap: 9px;
  animation: slideUp .24s ease;
}
.sheet-btn {
  border: none; border-radius: 14px; padding: 15px;
  font-size: 1rem; font-weight: 700; font-family: inherit;
  background: var(--cream); color: var(--brown-d);
  box-shadow: var(--shadow); cursor: pointer;
}
.sheet-btn.danger { color: var(--danger); }
.sheet-btn.cancel { background: #fff; }

/* ---- トースト ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px);
  transform: translateX(-50%) translateY(10px);
  background: var(--brown-d); color: #fff;
  padding: 11px 18px; border-radius: 999px;
  font-size: .9rem; font-weight: 700;
  box-shadow: 0 6px 20px rgba(0,0,0,0.28);
  z-index: 40; opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
