:root {
  --ink: #1a473f; --ink-soft: #2c6a5e; --bg: #f6f4ef; --card: #ffffff; --text: #1d1f1e; --muted: #6a6f6c;
  --line: #e1ded6; --warn-bg: #fff4dc; --warn: #8a5a00; --danger: #b3261e; --chip: #e8f0ee; --unsure: #fde9d4;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #7cc4b4; --ink-soft: #9fd6c9; --bg: #121514; --card: #1c201f; --text: #ecefed; --muted: #a2a8a5;
    --line: #2d3331; --warn-bg: #3a2f17; --warn: #f2c66d; --danger: #ff8a80; --chip: #23332f; --unsure: #3d2c1c; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
button { font: inherit; color: inherit; cursor: pointer; border-radius: 12px; border: 1px solid transparent; padding: 10px 14px; background: none; }
button:active { transform: scale(.98); }
.primary { background: var(--ink); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .primary { color: #0d1513; } }
.secondary { background: var(--card); border-color: var(--ink); color: var(--ink); font-weight: 600; }
.ghost { color: var(--ink); }
.danger { color: var(--danger); border-color: var(--danger); width: 100%; margin-top: 24px; }
.link { color: var(--ink); text-decoration: underline; padding: 0; font-weight: 600; }
.big { width: 100%; padding: 15px; font-size: 17px; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; max-width: 720px; margin: 0 auto; }
.title { display: flex; align-items: center; gap: 10px; }
.title img { border-radius: 8px; }
h1 { font-size: 26px; margin: 0; }
.count { color: var(--muted); font-size: 15px; }
main { max-width: 720px; margin: 0 auto; padding: 0 16px 40px; }
.actions { display: grid; gap: 10px; margin: 12px 0; }
.actions.small { display: flex; flex-wrap: wrap; gap: 4px; justify-content: space-between; margin: 0 0 10px; }
.actions.small button { padding: 8px 6px; }
.notice { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 0; font-size: 14px; }
.notice.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.key { display: inline-block; border: 1px solid currentColor; border-radius: 6px; padding: 0 5px; font-size: 13px; }
.search { width: 100%; font: inherit; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.list button { width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); display: grid; gap: 2px; padding: 12px 14px; }
.list .name { font-weight: 700; font-size: 17px; }
.list .sub, .list .tel { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); text-align: center; margin-top: 40px; }

dialog.sheet { border: 0; padding: 0; width: 100%; max-width: 640px; max-height: 100dvh; height: 100dvh; margin: 0 auto; background: var(--bg); color: var(--text); }
dialog.sheet.small { height: auto; margin-top: auto; border-radius: 18px 18px 0 0; }
@media (min-width: 700px) { dialog.sheet { height: 88vh; margin-top: 6vh; border-radius: 18px; } dialog.sheet.small { margin-top: 20vh; height: auto; border-radius: 18px; } }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog form { display: flex; flex-direction: column; height: 100%; }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; border-bottom: 1px solid var(--line); background: var(--card); }
.sheet-head h2 { font-size: 17px; margin: 0; text-align: center; }
.sheet-head > :first-child { justify-self: start; }
.sheet-head > :last-child { justify-self: end; }
.sheet-body { overflow-y: auto; padding: 14px 16px calc(30px + env(safe-area-inset-bottom)); flex: 1; -webkit-overflow-scrolling: touch; }
.field { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 4px 10px; margin-bottom: 10px; }
.field label { font-size: 14px; color: var(--muted); }
.field input { font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); width: 100%; min-width: 0; }
.chips { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--chip); color: var(--ink); padding: 5px 10px; font-size: 14px; border-radius: 999px; }
.chip.unsure { background: var(--unsure); color: var(--warn); }
textarea { width: 100%; font: 14px/1.5 ui-monospace, Menlo, monospace; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
details { margin-top: 16px; }
summary { color: var(--ink); font-weight: 600; padding: 6px 0; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 16px; }
.prose h3 { font-size: 16px; margin: 18px 0 6px; }
.prose ol { padding-left: 1.3em; margin: 0; }
.prose li { margin-bottom: 6px; }
.owner { display: grid; gap: 6px; font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.owner input { font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.version { color: var(--muted); font-size: 13px; margin-top: 24px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; opacity: 0; transition: .25s; pointer-events: none; font-size: 15px; z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.pulse { animation: pulse 1.2s ease-in-out infinite; border-width: 2px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ink) 25%, transparent); } }
@media (max-width: 380px) { .field { grid-template-columns: 1fr; } .chips { grid-column: 1; } }
