:root {
  color-scheme: light dark;
  --bg: #f5f7fa; --surface: #ffffff; --fg: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #1d4ed8; --accent-fg: #fff; --danger: #b91c1c; --ok: #15803d; --warn: #b45309;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1726; --surface: #13233a; --fg: #e5edf7; --muted: #8aa0b8; --line: #22364f;
          --accent: #3b82f6; --danger: #f87171; --ok: #4ade80; --warn: #fbbf24; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif; line-height: 1.6;
       -webkit-text-size-adjust: 100%; padding-bottom: env(safe-area-inset-bottom); }
#app { max-width: 640px; margin: 0 auto; padding: 0 16px 32px; }

h1 { font-size: 1.5rem; margin: .6em 0; } h2 { font-size: 1.25rem; margin: .5em 0; } h3 { font-size: 1rem; margin: 0 0 .5em; }
.brand { font-size: 2rem; letter-spacing: .05em; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.center { display: flex; flex-direction: column; align-items: stretch; text-align: center; padding-top: max(48px, env(safe-area-inset-top)); gap: 8px; }
.center-text { text-align: center; }
.lock-icon { font-size: 2.5rem; margin: 0; }
.error { color: var(--danger); min-height: 1em; margin: 4px 0; }
.warn { color: var(--warn); }

button, input, select, textarea { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--surface); padding: 10px 14px; border-radius: 10px; cursor: pointer; }
button:disabled { opacity: .6; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.danger { color: var(--danger); }
button.ghost { background: none; border: none; color: var(--accent); padding: 8px; }
button.big { padding: 14px; font-size: 1.05rem; }
button.small { padding: 4px 10px; font-size: .85rem; border-radius: 8px; }
button { white-space: nowrap; }
/* iOS は 16px 未満の入力欄をタップすると勝手に拡大するので 16px 固定 */
input, select, textarea { font-size: 16px; min-width: 0; }
.inline > input { flex: 1; }
.stack label > * { min-width: 0; }
html, body { overflow-x: hidden; }
input, select, textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
textarea { resize: vertical; }
input.masked { -webkit-text-security: disc; }
input[type=checkbox] { width: auto; }
.stack { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.inline { display: flex; gap: 6px; align-items: center; }
.inline-label { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 6px; }
.gen { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.gen .len { width: 72px; padding: 6px; }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.actions button { flex: 1; }
details summary { cursor: pointer; color: var(--accent); padding: 8px 0; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px; background: var(--bg);
          padding: max(8px, env(safe-area-inset-top)) 0 8px; border-bottom: 1px solid var(--line); }
.brand-s { font-weight: 700; flex: 1; }
.badge { font-size: .75rem; padding: 3px 10px; border-radius: 999px; background: var(--surface); }
.badge.ok { color: var(--ok); } .badge.dirty, .badge.offline { color: var(--warn); }
.badge.auth, .badge.error { color: var(--danger); }

.searchbar { display: flex; gap: 8px; margin: 12px 0; }
.searchbar .add { width: 52px; font-size: 1.4rem; padding: 0; }
.list { display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.list > p { padding: 16px; margin: 0; }
.row { display: flex; flex-direction: column; align-items: flex-start; text-align: left; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px 14px; }
.row:last-child { border-bottom: none; }
.row-title { font-weight: 600; } .row-sub { color: var(--muted); font-size: .85rem; }

.page { padding-top: 4px; }
.back { margin-left: -8px; }
.field { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 8px 0; }
.field .label { color: var(--muted); font-size: .8rem; }
.field .value { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; word-break: break-all; }
.field .acts { margin-left: auto; display: flex; gap: 6px; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.notes { white-space: pre-wrap; word-break: break-word; }
.history .hist { border-top: 1px solid var(--line); padding: 8px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 12px 0; }
.card p { margin: 4px 0; }
ul.plain { list-style: none; padding: 0; margin: 0; } ul.plain li { padding: 4px 0; }
a { color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
         background: #111827ee; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 20; max-width: 90vw; }
.update { position: fixed; top: 0; left: 0; right: 0; z-index: 30; background: var(--accent); color: #fff;
          padding: max(8px, env(safe-area-inset-top)) 16px 8px; text-align: center; }
.update button { background: #fff; color: var(--accent); }

.kit { padding-top: max(16px, env(safe-area-inset-top)); }
.kit-box { border: 2px solid var(--fg); border-radius: 12px; padding: 16px; display: grid; gap: 4px; }
.kit-box .label { color: var(--muted); font-size: .8rem; margin-top: 8px; }
.kit .sk { font-size: 1.15rem; letter-spacing: .05em; word-break: break-all; }
.write-line { border-bottom: 1px solid var(--muted); height: 2em; }
@media print {
  :root { --bg: #fff; --surface: #fff; --fg: #000; --muted: #444; }
  .no-print, .toast, .update { display: none !important; }
}
