:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #14202b;
  --muted: #55636f;
  --line: #cbd5de;
  --accent: #0b5a8a;
  --accent-text: #ffffff;
  --warn-bg: #fff4d6;
  --warn-line: #b7791f;
  --err-bg: #fde8e8;
  --err-line: #b42318;
  --ok-bg: #e3f6e8;
  --ok-line: #1b7a3a;
  --info-bg: #e6f0fa;
  --info-line: #0b5a8a;
  --tab-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141a;
    --surface: #18222b;
    --text: #e8eef3;
    --muted: #9fb0be;
    --line: #34444f;
    --accent: #5db3e8;
    --accent-text: #05121b;
    --warn-bg: #3a2f10;
    --warn-line: #e0a93b;
    --err-bg: #3d1a18;
    --err-line: #f08a80;
    --ok-bg: #12301c;
    --ok-line: #6fd08a;
    --info-bg: #11283a;
    --info-line: #5db3e8;
  }
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  /* Dynamic Type に追従(iOS)。rem は html 基準なので、ここに指定する。非対応環境は 16px */
  font: -apple-system-body;
  font-family: -apple-system, "Hiragino Sans", system-ui, sans-serif;
}
@supports not (font: -apple-system-body) { html { font-size: 16px; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px);
}

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; margin: 0; font-size: 1.15rem; }
.chip {
  font-size: .8rem; padding: 2px 8px; border: 1px solid var(--warn-line);
  background: var(--warn-bg); border-radius: 999px;
}
.icon-btn {
  min-width: 44px; min-height: 44px; font-size: 1.4rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text);
}

main { padding: 12px; max-width: 640px; margin: 0 auto; outline: none; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
h3 { font-size: 1rem; margin: 14px 0 6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: .9rem; }

.banner {
  border: 1px solid var(--info-line); background: var(--info-bg);
  border-radius: 10px; padding: 10px 12px; margin: 8px 0;
}
.banner.warn { border-color: var(--warn-line); background: var(--warn-bg); }
.banner.err { border-color: var(--err-line); background: var(--err-bg); }
.banner.ok { border-color: var(--ok-line); background: var(--ok-bg); }
.banner strong { display: block; }

.list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }

.appbtn, .btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
  text-decoration: none; font: inherit; text-align: left;
}
.btn { min-height: 44px; justify-content: center; text-align: center; width: auto; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn.danger { border-color: var(--err-line); color: var(--err-line); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.appbtn .mark {
  flex: none; width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center; font-weight: 700;
  border: 2px solid var(--accent); color: var(--accent);
}
.appbtn .label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.appbtn .label small { display: block; color: var(--muted); }
.appbtn .go { flex: none; color: var(--muted); font-weight: 700; }
.appbtn.manual { border-style: dashed; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
}
.card .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.card .name { font-weight: 600; overflow-wrap: anywhere; }

label { display: block; margin: 10px 0 4px; font-weight: 600; }
input[type="text"], input[type="search"], input[type="number"], textarea, select {
  width: 100%; min-height: 44px; padding: 8px 10px; font: inherit;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
textarea { min-height: 120px; font-family: ui-monospace, monospace; font-size: .85rem; }

details { margin: 12px 0; }
summary { min-height: 44px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }

table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  min-height: var(--tab-h); border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: .9rem;
}
/* 色だけに頼らず、下線と太字で現在のタブを示す */
.tabbar button[aria-current="page"] {
  color: var(--accent); font-weight: 700;
  box-shadow: inset 0 3px 0 var(--accent);
}

.toast {
  position: fixed; left: 12px; right: 12px; z-index: 7;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px);
  background: var(--text); color: var(--bg);
  padding: 10px 14px; border-radius: 10px; text-align: center;
}

.notice { padding: 12px; background: var(--err-bg); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
