/* 議員本人がスマホで片手操作する前提のレイアウト。
   - 主要な操作は親指の届く下側に置く
   - タップ領域は最低 48px
   - 情報の優先順位は「今日やるべきこと」→「進行中」→「統計」 */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #15181d;
  --ink-sub: #5c646f;
  --line: #dfe3e8;
  --accent: #1b5e9c;
  --accent-ink: #ffffff;
  --danger: #c02626;
  --danger-bg: #fdeceb;
  --warn: #8a5300;
  --warn-bg: #fdf3e0;
  --ok: #1f6b3f;
  --ok-bg: #e8f5ec;
  --radius: 12px;
  --nav-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

/* ---------- ヘッダ ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--accent);
  color: var(--accent-ink);
}
.appbar h1 { margin: 0; font-size: 17px; font-weight: 700; }
.appbar .sub { font-size: 12px; opacity: .85; display: block; font-weight: 400; }
.appbar form { margin: 0; }
.appbar button {
  background: rgba(255,255,255,.18);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  min-height: 40px;
}

main {
  padding: 12px 14px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}

/* ---------- 見出し・カード ---------- */
.section { margin: 0 0 18px; }
.section > h2 {
  font-size: 14px;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-sub);
  letter-spacing: .02em;
}
.section.alert > h2 { color: var(--danger); font-size: 16px; }
.section.warn > h2 { color: var(--warn); font-size: 15px; }

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 13px;
  font-weight: 700;
  font-size: 14px;
  background: var(--line);
  color: var(--ink);
}
.count.is-danger { background: var(--danger); color: #fff; }
.count.is-warn { background: var(--warn); color: #fff; }

.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
}
.card.is-danger { border-left: 5px solid var(--danger); }
.card.is-warn { border-left: 5px solid var(--warn); }
.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--ink-sub);
  margin-bottom: 6px;
}
.card .body {
  font-size: 15px;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .elapsed { font-weight: 700; }
.card.is-danger .elapsed { color: var(--danger); }
.card.is-warn .elapsed { color: var(--warn); }

.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--ink-sub);
  font-size: 14px;
  text-align: center;
}

/* ---------- バッジ ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: #f0f2f5;
  color: var(--ink-sub);
  white-space: nowrap;
}
.badge.received { background: var(--danger-bg); color: var(--danger); border-color: #f3c9c6; }
.badge.reading { background: #eef3fb; color: var(--accent); border-color: #cddcf0; }
.badge.acting { background: var(--warn-bg); color: var(--warn); border-color: #f0dcb4; }
.badge.answered { background: var(--ok-bg); color: var(--ok); border-color: #c3e3cf; }
.badge.closed { background: #eceef1; color: #4a5260; }
.badge.public { background: var(--ok-bg); color: var(--ok); border-color: #c3e3cf; }
.badge.private { background: #eceef1; color: #4a5260; }

/* ---------- 統計 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
}
.stat .n { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat .k { font-size: 11px; color: var(--ink-sub); }

/* ---------- フォーム ---------- */
label { display: block; font-size: 13px; color: var(--ink-sub); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 12px;
  font-size: 16px; /* iOS のズーム防止 */
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  min-height: 48px;
}
textarea { min-height: 120px; resize: vertical; }
input[type=file] { font-size: 14px; padding: 10px 0; width: 100%; }

.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  padding: 14px;
  margin-top: 14px;
  text-align: center;
  text-decoration: none;
}
.btn.secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { min-height: 44px; font-size: 14px; padding: 10px; margin-top: 8px; }

/* 種別をチップで選ばせる（プルダウンより指で速い） */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips label {
  margin: 0;
  padding: 10px 14px;
  min-height: 44px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}
.chips input:checked + label {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .wide { grid-column: 1 / -1; }

/* ---------- 折りたたみ ---------- */
details.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
details.panel > summary {
  padding: 14px;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  list-style: none;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "＋"; margin-left: auto; color: var(--ink-sub); }
details.panel[open] > summary::after { content: "−"; }
details.panel .inner { padding: 0 14px 14px; }
details.panel.danger > summary { color: var(--danger); }

/* ---------- 詳細画面 ---------- */
.voice-body {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  white-space: pre-wrap;
  font-size: 16px;
}
.note {
  font-size: 12px;
  color: var(--ink-sub);
  margin: 6px 0 0;
}

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 14px 18px;
  border-left: 2px solid var(--line);
  margin-left: 6px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline li.response::before { background: var(--ok); }
.timeline .when { font-size: 12px; color: var(--ink-sub); }
.timeline .what { font-size: 15px; white-space: pre-wrap; }
.timeline img { width: 100%; border-radius: 10px; margin-top: 8px; }

/* ---------- フラッシュ ---------- */
.flash {
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}
.flash.info { background: #eef3fb; color: var(--accent); }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--danger-bg); color: var(--danger); }

/* ---------- 下部ナビ（親指の位置） ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  min-height: var(--nav-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--ink-sub);
  font-size: 10px;
}
.tabbar a .ic { font-size: 19px; line-height: 1; }
.tabbar a { padding: 0 2px; text-align: center; }
.tabbar a.on { color: var(--accent); font-weight: 700; }
.tabbar a .dot {
  position: absolute;
  transform: translate(14px, -12px);
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  padding: 0 3px;
}

/* ---------- ログイン ---------- */
.login-wrap { max-width: 360px; margin: 12vh auto 0; padding: 0 20px; }
.login-wrap h1 { font-size: 20px; margin-bottom: 4px; }
.login-wrap p.lead { color: var(--ink-sub); font-size: 13px; margin-top: 0; }

/* ---------- 画面が広くてもスマホの操作体系を崩さない ---------- */
/* PC では中央に寄せるだけ。下部ナビの位置も操作順序も変えない */
@media (min-width: 760px) {
  .tabbar {
    max-width: 720px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
  }
}
