/* 個人物品記憶 P1 MVP 樣式：手機優先、可讀、無外部字型與圖片 */
:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --ink: #14231d;
  --ink-soft: #5b6f68;
  --line: #e2e8e5;
  --brand: #1f6f5c;
  --brand-soft: #e6f2ee;
  --warn: #a8621a;
  --danger: #a3312b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 35, 29, 0.06), 0 8px 20px rgba(20, 35, 29, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "Noto Sans CJK TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* 頂列 */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--brand);
  color: #fff;
}
.appbar__title { display: flex; align-items: center; gap: 10px; }
.appbar__logo { display: flex; align-items: center; color: #fff; }
.appbar__text { display: flex; flex-direction: column; line-height: 1.25; }
.appbar__text strong { font-size: 17px; }
.appbar__text small { font-size: 11px; opacity: 0.85; }
.icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.22); }

/* 內容 */
.view { flex: 1; padding: 14px 16px 90px; }
.view > * + * { margin-top: 14px; }

.hero {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.hero h2 { margin: 0 0 6px; font-size: 19px; }
.hero p { margin: 0 0 12px; color: var(--ink-soft); font-size: 14px; }
.hero__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hero--compact h2 { font-size: 17px; }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 10px; font-size: 16px; }
.section-title { margin: 18px 0 8px; font-size: 15px; color: var(--ink-soft); }

.muted { color: var(--ink-soft); font-size: 13px; margin: 6px 0 10px; }
.empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--ink-soft);
  font-size: 14px;
  text-align: center;
}

/* 按鈕 */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  background: #eef2f0;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--ghost { background: var(--brand-soft); color: var(--brand); border-color: #cfe4dd; }
.btn--danger { background: #fbeceb; color: var(--danger); }
.btn--text { background: transparent; color: var(--ink-soft); padding: 10px 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* 清單卡片 */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card__head h3 { margin: 0; font-size: 16px; }
.card__meta { margin: 4px 0 8px; font-size: 12px; color: var(--ink-soft); }
.card__items { margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.card__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
}

/* 分組清單 */
.groups { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.group h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
}
.count { font-size: 12px; color: var(--ink-soft); font-weight: 400; }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.list .row:last-child { border-bottom: 0; }
.row:hover { background: #fafcfb; }
.row__photo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  background: #eef2f0;
  flex: 0 0 auto;
}
.row__photo--empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #9fb3ac;
  font-size: 18px;
}
.row__body { flex: 1; display: flex; flex-direction: column; }
.row__body strong { font-size: 15px; }
.row__body small { color: var(--ink-soft); font-size: 12px; }
.row__chev { color: #b6c5c0; font-size: 20px; }

/* 搜尋 */
.search { display: block; }
.search input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.search-meta { font-size: 12px; color: var(--ink-soft); margin: 0; }

/* 位置樹 */
.tree, .tree__children { list-style: none; margin: 0; padding: 0; }
.tree__node { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 8px; }
.tree__children { padding: 0 0 6px 0; }
.tree__children .tree__node { margin: 6px 0 6px 14px; box-shadow: none; border: 1px solid var(--line); }
.tree__row { display: flex; align-items: center; gap: 6px; padding: 10px 12px; flex-wrap: wrap; }
.tree__toggle {
  border: 0;
  background: transparent;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  width: 20px;
}
.tree__toggle--none { text-align: center; }
.tree__name { flex: 0 1 auto; font-size: 14px; }
.tree__row .count { margin-left: auto; }

/* 鍵值列 */
.kv { list-style: none; margin: 0; padding: 0; }
.kv li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.kv li:last-child { border-bottom: 0; }
.kv li > span { color: var(--ink-soft); display: flex; flex-direction: column; }
.kv li > span small { font-size: 11px; color: #8fa39c; }
.kv strong { font-weight: 600; text-align: right; }

.switch {
  border: 1px solid var(--line);
  background: #eef2f0;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  min-width: 68px;
}
.switch.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* 底部導覽 */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.tab {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-soft);
  padding: 8px 0;
  cursor: pointer;
  border-radius: 10px;
}
.tab.is-active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }

/* 抽屜／對話層 */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(16, 28, 24, 0.45); }
.sheet__panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 -8px 30px rgba(16, 28, 24, 0.2);
}
.sheet__panel h3 { margin: 0 0 8px; font-size: 17px; }
.sheet__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--ink-soft); }
.field > span, .field > legend { display: block; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.field fieldset, fieldset.field { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 0 0 12px; }

.checklist { list-style: none; margin: 0 0 6px; padding: 0; max-height: 46vh; overflow-y: auto; }
.checklist li { border-bottom: 1px solid var(--line); }
.checklist label { display: flex; align-items: center; gap: 10px; padding: 10px 2px; font-size: 15px; cursor: pointer; }
.checklist label small { margin-left: auto; color: var(--ink-soft); font-size: 12px; }
.checklist--compact label { font-size: 14px; padding: 8px 2px; }

.photo-row { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.photo-btn {
  border: 1px solid #cfe4dd;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.photo-preview {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  background: #eef2f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9fb3ac;
  font-size: 12px;
  overflow: hidden;
}
.photo-preview img, .detail__photo { width: 100%; height: 100%; object-fit: cover; }
.detail__photo { width: 100%; max-height: 240px; border-radius: 12px; margin-bottom: 12px; }

.metrics { margin: 0; padding-left: 20px; font-size: 14px; }
.metrics li { margin-bottom: 8px; }
.metrics li span { display: block; color: var(--ink-soft); font-size: 12px; }

.badge {
  background: #eef2f0;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}
.badge--ok { background: #e4f3ea; color: #1f6f5c; }
.badge--warn { background: #fdf0e3; color: var(--warn); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  background: rgba(20, 35, 29, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 60;
  max-width: 88vw;
  text-align: center;
}

@media (min-width: 700px) {
  .app { max-width: 720px; }
  .tabbar { max-width: 720px; }
  .sheet__panel { max-width: 720px; border-radius: 18px; margin-bottom: 0; }
  .cards { grid-template-columns: 1fr 1fr; }
}

@media print {
  .tabbar, .icon-btn, .hero__actions, .btn, .sheet { display: none !important; }
  .view { padding: 0; }
}