:root {
  --bg: #f4f6f8; --surface: #ffffff; --ink: #1c2733; --muted: #6b7a89;
  --line: #d8e0e8; --accent: #1f6fb4; --accent-ink: #ffffff;
  --danger: #c0392b; --warn-bg: #fdf3e3; --warn-line: #e8c98a;
  --band-1: #7d8ea0; --band-2: #3f7fbf; --band-3: #3d9970; --band-4: #d08a2d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 15px; line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}
header {
  position: sticky; top: 0; z-index: 20;
  background: #1f3a4d; color: #fff;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
}
.header-row { display: flex; align-items: center; gap: 8px; }
header h1 { font-size: 17px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbtn {
  background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 8px;
  padding: 7px 12px; font-size: 14px; min-height: 38px;
}
.save-status { font-size: 12px; opacity: .85; margin-top: 2px; }
.save-status .dirty { color: #ffd98a; }
main { padding: 12px; max-width: 860px; margin: 0 auto; }

button {
  font: inherit; border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 8px 12px; min-height: 42px; color: var(--ink);
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--danger); }
button.small { min-height: 36px; padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .45; }
input[type="text"], input[type="number"], select, textarea {
  font: inherit; width: 100%; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--ink);
}
textarea { min-height: 96px; }
label.f { display: block; margin: 10px 0; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > .shrink { flex: 0 0 auto; }

.section {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 12px;
}
.section h2 { font-size: 15px; margin: 0 0 8px; }
.note { font-size: 13px; color: var(--muted); }
.warnbox {
  background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 12px; font-size: 14px;
}

.event-row {
  display: flex; gap: 8px; align-items: center; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 8px; min-height: 52px;
}
.event-row .grow { flex: 1; }
.event-row .sub { font-size: 12px; color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 8px; overflow: hidden;
}
.card-head { display: flex; align-items: stretch; gap: 0; }
.band { flex: 0 0 8px; }
.band.d1 { background: var(--band-1); } .band.d2 { background: var(--band-2); }
.band.d3 { background: var(--band-3); } .band.d4 { background: var(--band-4); }
.card-main { flex: 1; padding: 8px 10px; min-width: 0; }
.card-title { font-weight: 600; font-size: 14px; }
.card-summary { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; gap: 4px; padding: 6px 6px 6px 0; align-items: flex-start; }
.card-actions button { min-height: 36px; padding: 4px 9px; font-size: 13px; }
.card-form { border-top: 1px dashed var(--line); padding: 10px 12px; }
.branch { margin: 0 10px 10px 18px; }
.branch-label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 6px 0 6px; }
.add-bar { margin: 2px 0 10px; }
.add-bar button { width: 100%; border-style: dashed; color: var(--accent); }

.modal-back {
  position: fixed; inset: 0; background: rgba(10,20,30,.5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 82vh; overflow: auto;
  border-radius: 14px 14px 0 0; padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
}
.modal h3 { margin: 0 0 10px; font-size: 16px; }
.palette-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.palette-grid button { text-align: left; }
.color-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.color-cell { min-height: 42px; border-radius: 8px; border: 1px solid var(--line); font-size: 12px; padding: 2px; }
.helper-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.helper-bar button { min-height: 38px; font-size: 13px; padding: 5px 10px; }
.error-list { color: var(--danger); font-size: 14px; margin: 6px 0; padding-left: 18px; }
.kv { font-size: 13px; color: var(--muted); }
