:root {
  --bg: #FFF8EF;
  --surface: #FFFFFF;
  --text: #3B2A20;
  --text-sub: #6B5A4E;
  --primary: #8A4B2A;
  --primary-press: #6F3B20;
  --accent: #F2C27B;
  --line: #E8DCCD;
  --danger: #B3261E;
  --radius: 12px;
  --bar-h: 88px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0; line-height: 1.4; }
h2 { font-size: 18px; margin: 0 0 8px; }
p { margin: 0 0 8px; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.pad { padding: 16px; }
.sub { color: var(--text-sub); font-size: 14px; }

/* 画面 */
.screen {
  min-height: 100vh; min-height: 100dvh;
  max-width: 560px; margin: 0 auto;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom));
}
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: calc(4px + env(safe-area-inset-top)) 8px 4px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; text-align: center; }
.topbar-space { width: 44px; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  min-width: 44px; height: 44px; border: 0; background: transparent;
  font-size: 28px; line-height: 1; border-radius: var(--radius); cursor: pointer; color: var(--text);
}
.icon-btn:active { background: var(--line); }

/* 下部の主ボタン */
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  max-width: 560px; margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 80%, rgba(255, 248, 239, 0));
  display: flex; flex-direction: column; gap: 4px;
}
.btn-primary {
  width: 100%; height: 56px; border: 0; border-radius: var(--radius);
  background: var(--primary); color: #fff; font-size: 17px; font-weight: 700; cursor: pointer;
}
.btn-primary:active { background: var(--primary-press); }
.btn-primary:disabled { background: #B9A99C; color: #3B2A20; }
.btn-secondary {
  display: block; width: 100%; min-height: 48px; margin-top: 8px;
  border: 2px solid var(--primary); border-radius: var(--radius);
  background: var(--surface); color: var(--primary); font-weight: 700; cursor: pointer;
}
.btn-link {
  min-height: 44px; border: 0; background: transparent; color: var(--primary);
  text-decoration: underline; cursor: pointer; font-size: 15px;
}
.btn-small {
  min-height: 44px; padding: 0 14px; border-radius: var(--radius);
  border: 0; background: var(--primary); color: #fff; font-weight: 700; cursor: pointer; font-size: 15px;
}
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-aux {
  flex: 1 1 0; min-height: 48px; padding: 6px 8px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 700; cursor: pointer; line-height: 1.3;
}
.btn-aux small { display: block; font-size: 12px; color: var(--text-sub); font-weight: 400; }
.btn-aux:disabled { color: var(--text-sub); background: #F6EFE6; }

/* ようこそ */
.welcome { padding: 48px 24px 16px; text-align: center; }
.welcome-illust { margin: 0 auto 16px; }
.app-name { color: var(--primary); font-weight: 700; font-size: 18px; margin-bottom: 4px; }
.welcome h1 { font-size: 24px; margin-bottom: 24px; }
.welcome-points { text-align: left; padding-left: 1.4em; margin: 0 auto; max-width: 420px; }
.welcome-points li { margin-bottom: 12px; }

/* フォーム */
.form .field { display: block; margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field-label { display: block; font-weight: 700; margin-bottom: 6px; padding: 0; }
.req { font-size: 12px; color: #fff; background: var(--primary); border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
input[type="text"], input[type="date"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid #B9A99C; border-radius: var(--radius); background: var(--surface);
  font-size: 16px; /* iOSの自動ズームを防ぐ */
}
textarea { resize: vertical; }
.field-error { color: var(--danger); font-size: 14px; margin: 4px 0 0; min-height: 0; }
.field-error:empty { display: none; }

.avatar-pick { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 16px; cursor: pointer; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; overflow: hidden; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--text); font-weight: 700; font-size: 18px;
  border: 2px solid transparent;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 112px; height: 112px; font-size: 16px; border: 2px dashed #B9A99C; background: var(--surface); }
.avatar-lg.has-img { border-style: solid; border-color: var(--line); }

/* ホーム */
.dog-switch { flex: 1; display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px; }
.dog-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 56px; border: 0; background: transparent; cursor: pointer; padding: 0 2px;
  font-size: 12px; color: var(--text);
}
.dog-chip .avatar { width: 44px; height: 44px; }
.dog-chip[aria-current="true"] .avatar { border-color: var(--primary); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary); }
.dog-chip[aria-current="true"] { font-weight: 700; }
.dog-chip-name { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dog-chip.add .avatar { background: var(--surface); border: 2px dashed #B9A99C; font-size: 22px; }

.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); padding: 16px; margin-bottom: 16px; }
.card-title { font-size: 17px; }
.next-card { display: flex; align-items: center; gap: 12px; }
.next-text { flex: 1; margin: 0; font-weight: 700; }
.next-text small { display: block; font-weight: 400; color: var(--text-sub); font-size: 14px; }
.banner {
  background: #FDEBD0; border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px;
}
.banner p { margin: 0 0 8px; }
.banner-actions { display: flex; gap: 8px; }
.aux-row { display: flex; gap: 8px; margin: 0 0 16px; }
.section-title { font-size: 16px; color: var(--text-sub); margin: 8px 0; }
.rec-list { list-style: none; padding: 0; margin: 0; }
.rec-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px; margin-bottom: 8px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--text);
}
.thumb {
  width: 64px; height: 64px; border-radius: 10px; overflow: hidden; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); font-weight: 700; font-size: 22px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.initial { border-radius: 50%; }
.rec-main { flex: 1; min-width: 0; }
.rec-date { font-weight: 700; }
.rec-cut { display: block; }
.rec-meta { display: block; color: var(--text-sub); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--text-sub); padding: 24px 8px; }
.empty img { margin: 0 auto 12px; }
.empty-text { color: var(--text-sub); text-align: center; padding: 24px 0; }

/* 記録 */
.photo-pair { display: flex; gap: 12px; margin-bottom: 8px; }
.photo-slot { flex: 1; cursor: pointer; text-align: center; }
.photo-box {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 4 / 3; width: 100%; border-radius: var(--radius); overflow: hidden;
  border: 2px dashed #B9A99C; background: var(--surface); font-size: 32px; color: var(--text-sub);
}
.photo-box.has-img { border-style: solid; border-color: var(--line); }
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-cap { display: block; font-size: 14px; color: var(--text-sub); margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 14px; border-radius: 22px; cursor: pointer;
  border: 1px solid #B9A99C; background: var(--surface); color: var(--text); font-size: 15px;
}
.chip[aria-pressed="true"], .chip[aria-checked="true"] { background: var(--accent); border-color: var(--accent); font-weight: 700; }
#cut-other { margin-top: 8px; }
.segment { display: flex; border: 1px solid #B9A99C; border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.segment button {
  flex: 1; min-height: 44px; border: 0; background: transparent; cursor: pointer; font-size: 15px; color: var(--text);
}
.segment button + button { border-left: 1px solid #B9A99C; }
.segment button[aria-checked="true"] { background: var(--accent); font-weight: 700; }
.summary-row {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  min-height: 48px; padding: 8px 12px; margin-bottom: 12px; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; color: var(--text);
}
.edit-mark { color: var(--primary); font-weight: 700; font-size: 14px; flex: none; margin-left: 8px; }
.meta-fields { margin-bottom: 8px; }
.memo-wrap summary { min-height: 44px; display: flex; align-items: center; color: var(--primary); font-weight: 700; cursor: pointer; }
.memo-wrap textarea { margin-top: 4px; }

/* 詳細 */
.swiper { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; margin-bottom: 16px; border-radius: var(--radius); }
.swiper figure { flex: 0 0 100%; scroll-snap-align: center; margin: 0; }
.swiper img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); background: var(--line); }
.swiper figcaption { text-align: center; font-size: 14px; color: var(--text-sub); }
.kv { display: grid; grid-template-columns: 6em 1fr; gap: 6px 12px; margin: 0 0 12px; }
.kv dt { color: var(--text-sub); }
.kv dd { margin: 0; font-weight: 700; word-break: break-word; }
.memo-text { white-space: pre-wrap; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); padding: 12px; }
.memo-text:empty { display: none; }

/* 比較 */
.cmp-selects { display: flex; gap: 8px; margin-top: 16px; }
.cmp-selects .field { flex: 1; min-width: 0; margin-bottom: 8px; }
.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cmp-col img, .cmp-col .noimg {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--radius); background: var(--line);
}
.cmp-col .noimg { display: flex; align-items: center; justify-content: center; color: var(--text-sub); font-size: 14px; }
.cmp-col p { margin: 4px 0 0; font-size: 14px; }
.cmp-col .cmp-head { font-weight: 700; font-size: 15px; }

/* トリマーさんに見せる */
.screen-card { background: #FFFFFF; padding-bottom: 24px; max-width: none; }
.card-top { display: flex; justify-content: flex-end; padding: calc(8px + env(safe-area-inset-top)) 12px 0; }
.trim-card { max-width: 560px; margin: 0 auto; padding: 8px 20px 24px; }
.tc-dog { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.tc-dog .avatar { width: 88px; height: 88px; font-size: 30px; }
.tc-name { font-size: 28px; font-weight: 700; line-height: 1.3; }
.tc-breed { font-size: 18px; color: var(--text-sub); }
.tc-label { font-size: 16px; color: var(--text-sub); font-weight: 700; margin: 16px 0 4px; }
.tc-prev { font-size: 20px; font-weight: 700; }
.tc-photo { width: 100%; max-height: 50vh; object-fit: contain; border-radius: var(--radius); margin-top: 8px; background: #F6EFE6; }
.tc-wish { font-size: 32px; font-weight: 700; color: var(--primary); line-height: 1.3; }
.tc-memo { font-size: 24px; font-weight: 700; margin-top: 8px; white-space: pre-wrap; word-break: break-word; }

/* 設定 */
.dog-admin { list-style: none; padding: 0; margin: 0 0 8px; }
.dog-admin li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dog-admin .da-name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }

/* シート（dialog） */
dialog.sheet {
  border: 0; border-radius: 16px 16px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  width: 100%; max-width: 560px; margin: auto auto 0; background: var(--surface); color: var(--text);
}
dialog.sheet::backdrop { background: rgba(59, 42, 32, 0.45); }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.wish-choices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.wish-choices .chip { min-height: 56px; font-size: 18px; border-radius: var(--radius); }

/* トースト */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 20; background: var(--text); color: #fff; padding: 12px 20px; border-radius: 24px;
  max-width: calc(100% - 32px); font-size: 15px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
