:root {
  --bg: #f6f4ee;
  --panel: #ffffff;
  --ink: #2c2a24;
  --ink-soft: #6b6555;
  --line: #e3ddcc;
  --brand: #4a5d3a;
  --brand-dark: #384728;
  --accent: #a9622f;
  --danger: #b24545;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* iOSはフォーカス時16px未満の入力欄を自動拡大する。全入力要素で回避する */
input, select, textarea, button {
  font-size: 16px;
  font-family: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  line-height: 1.3;
}
button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}
button.primary:active { background: var(--brand-dark); }
button.text-btn {
  border: none;
  background: none;
  color: var(--brand);
  padding: 4px 6px;
  text-decoration: underline;
}
button:disabled { opacity: .55; }
.hidden { display: none !important; }

/* ===== ヘッダー ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-top, 0px));
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; white-space: nowrap; }
.tabnav { display: flex; gap: 6px; flex: 1; }
.tab {
  flex: 1;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 8px 10px;
  color: var(--ink-soft);
  font-size: 14px;
}
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.icon-btn {
  border-radius: 999px;
  padding: 8px 10px;
  background: var(--bg);
}

/* ===== 画面共通 ===== */
#view {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 12px 60px;
}
.loading, .empty-state, .hint {
  color: var(--ink-soft);
  text-align: center;
  padding: 24px 12px;
}
.empty-state .primary { margin-top: 10px; }
.hint { padding: 6px 2px; font-size: 14px; text-align: left; }

h1 { font-size: 20px; margin: 4px 0 10px; }
h2 { font-size: 16px; margin: 0 0 8px; color: var(--brand-dark); }
h3.dlg-sub { font-size: 15px; margin: 16px 0 4px; }

.section { margin: 22px 0; padding-top: 14px; border-top: 1px solid var(--line); }

/* ===== 一覧 ===== */
.list-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.tree-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.tree-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}
.tree-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: var(--bg);
}
.tree-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}
.tree-card-body { padding: 8px 10px 10px; }
.tree-name { font-weight: 600; }
.tree-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* ===== 詳細 ===== */
.back-link { color: var(--brand); text-decoration: none; font-size: 14px; }
.detail-title-row { display: flex; align-items: baseline; gap: 10px; }
.tree-info { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--ink-soft);
}

.photo-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}
.photo-strip .photo-thumb {
  height: 120px;
  width: auto;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
}

.entry-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.form-row { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-size: 13px; color: var(--ink-soft); }
.form-row input, .form-row select, .form-row textarea {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
.req { color: var(--danger); font-size: 11px; }

.entry-timeline { display: flex; flex-direction: column; gap: 10px; }
.entry-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.entry-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.entry-kind { font-weight: 600; }
.entry-date { color: var(--ink-soft); font-size: 12px; }
.entry-note { margin: 6px 0 0; white-space: pre-wrap; font-size: 14px; }
.entry-photos { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.entry-photos img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }

/* ===== 今月やること ===== */
.care-head { margin-bottom: 14px; }
.care-sub { color: var(--ink-soft); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.disclaimer { font-size: 12px; color: var(--ink-soft); background: var(--bg); border-radius: 10px; padding: 8px 10px; margin-top: 10px; }
.care-body { display: flex; flex-direction: column; gap: 12px; }
.care-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.care-group { display: inline-block; font-size: 12px; color: #fff; background: var(--accent); border-radius: 999px; padding: 2px 10px; margin-bottom: 6px; }
.care-item h3 { margin: 0 0 6px; font-size: 15px; }
.care-item p { margin: 0; font-size: 14px; line-height: 1.6; }
.care-sources { margin-top: 8px !important; font-size: 12px !important; color: var(--ink-soft); }
.care-sources a { color: var(--brand); }

.pref-picker { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.pref-picker select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; }

/* ===== ダイアログ ===== */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 18px;
  max-width: 480px;
  width: calc(100% - 32px);
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(20,18,10,.45); }
dialog h2 { margin-top: 0; }
.dlg-note { font-size: 14px; line-height: 1.6; }
.dlg-note.important { background: #fff6e0; border: 1px solid #e8d79a; border-radius: 10px; padding: 10px 12px; }
.dlg-fine { font-size: 12px; color: var(--ink-soft); line-height: 1.6; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dlg-btns-col { display: flex; flex-direction: column; gap: 8px; }

/* ===== トースト ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: #2c2a24;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
