:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2937;
  --sub: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --danger: #dc2626;
  --nav-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #1a1d24;
    --text: #e5e7eb;
    --sub: #9ca3af;
    --line: #2a2f3a;
    --accent: #60a5fa;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 16px;
  padding-top: env(safe-area-inset-top);
}
header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
}
h1 { margin: 0; font-size: 22px; }
.head-actions button {
  background: none;
  border: none;
  color: var(--sub);
  font-size: 22px;
  padding: 4px 10px;
}
main {
  padding: 0 12px calc(var(--nav-h) + 90px + env(safe-area-inset-bottom));
}
.section-label {
  margin: 16px 4px 6px;
  font-size: 13px;
  color: var(--sub);
}
.card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
}
.check {
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: none;
  color: transparent;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}
.check.done { background: #16a34a; border-color: #16a34a; color: #fff; }
.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 16px; line-height: 1.4; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--sub);
}
.chip.high { background: #fee2e2; color: var(--danger); }
.chip.time { background: #dbeafe; color: #1d4ed8; }
.chip.late { background: #fee2e2; color: var(--danger); }
.event {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 12px;
  margin-bottom: 6px;
  border-left: 4px solid var(--accent);
  background: var(--card);
  border-radius: 8px;
  font-size: 14px;
}
.event .t { color: var(--sub); font-variant-numeric: tabular-nums; min-width: 92px; }
.empty { text-align: center; color: var(--sub); padding: 48px 0; }
nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
  z-index: 6;
}
nav button {
  flex: 1;
  background: none;
  border: none;
  color: var(--sub);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
nav button .ico { font-size: 20px; }
nav button.active { color: var(--accent); font-weight: 600; }
nav .badge { font-size: 11px; }
#fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 30px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  z-index: 7;
}
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
  display: flex;
  align-items: flex-end;
}
.sheet {
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet h2 { margin: 0 0 12px; font-size: 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 4px; }
.row { display: flex; gap: 8px; }
.row .field { flex: 1; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
textarea { min-height: 80px; resize: vertical; }
.btn {
  width: 100%;
  font: inherit;
  font-weight: 600;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  margin-top: 4px;
}
.btn.sub { background: var(--bg); color: var(--text); }
.btn.ok { background: #16a34a; }
.cal-box {
  margin: 14px 0 6px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg);
}
.cal-box h3 { margin: 0 0 8px; font-size: 14px; }
.link { display: block; text-align: center; margin-top: 12px; color: var(--accent); font-size: 14px; }
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 30;
  max-width: 90vw;
}
#toast.show { opacity: 1; }
