:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1c2421;
  --muted: #66736e;
  --line: #dfe5e2;
  --accent: #1f6f5c;
  --accent-soft: #e2f1ec;
  --warn: #b5541c;
  --warn-soft: #fbeee4;
  --res: #8a3fb0;
  --res-soft: #f3e9f8;
  --via: #9a6a00;
  --via-soft: #fbf3dc;
  --danger: #c0392b;
  --now: #d6336c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111614;
    --card: #1a211e;
    --text: #e6ece9;
    --muted: #93a19b;
    --line: #2b3531;
    --accent: #5cc0a2;
    --accent-soft: #1d3a31;
    --warn: #f0a070;
    --warn-soft: #3a2a1f;
    --res: #c99be3;
    --res-soft: #33253b;
    --via: #e5c060;
    --via-soft: #3a3220;
    --danger: #ff7b6b;
    --now: #ff6b9a;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }
.ok { color: var(--accent); font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 32px 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #08201a; } }
.btn.danger-text { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); }
.dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--now); }
input[type=search], input[type=password], input[type=text], input[type=time], input[type=date], textarea, select {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
}
input:focus-visible, button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ログイン */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 20px; margin: 0; }
.login-card form { display: grid; gap: 10px; margin-top: 12px; }

/* ヘッダー */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar-row { display: flex; align-items: center; gap: 4px; padding: 6px 8px 0 16px; max-width: 760px; margin: 0 auto; }
.title { font-size: 18px; margin: 0; }
.sync-info { flex: 1; font-size: 12px; color: var(--muted); margin-left: 8px; }
.day-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px 10px; max-width: 760px; margin: 0 auto; scrollbar-width: none; }
.day-tabs::-webkit-scrollbar { display: none; }
.day {
  flex: 0 0 auto; display: grid; text-align: center; padding: 4px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); cursor: pointer; line-height: 1.3;
}
.day .md { font-weight: 600; font-size: 14px; }
.day .dl { font-size: 11px; color: var(--muted); }
.day.today { border-color: var(--accent); }
.day.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.day.on .dl { color: rgba(255, 255, 255, .85); }
@media (prefers-color-scheme: dark) { .day.on { color: #08201a; } .day.on .dl { color: #08201a; } }

.main { max-width: 760px; margin: 0 auto; padding: 12px 16px calc(40px + env(safe-area-inset-bottom)); }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.mode { border: 0; background: transparent; border-radius: 8px; min-height: 38px; cursor: pointer; color: var(--muted); }
.mode.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.mine { margin-bottom: 10px; }
.mine .label { font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; cursor: pointer; min-height: 36px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .chip.on { color: #08201a; } }

.search { position: relative; margin-bottom: 12px; }
.results { position: absolute; left: 0; right: 0; top: 48px; z-index: 5; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 60vh; overflow-y: auto; }
.result { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.result:last-child { border-bottom: 0; }
.result:hover { background: var(--accent-soft); }
.rname { font-weight: 600; }
.rgroup { font-size: 12px; color: var(--muted); margin-left: auto; }
.star { border: 0; background: transparent; font-size: 20px; width: 36px; height: 36px; cursor: pointer; color: var(--muted); }
.star.on { color: #e0a800; }
.star.big { font-size: 14px; width: auto; height: auto; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
.star.big.on { border-color: #e0a800; }

.next-banner { background: var(--now); color: #fff; border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.nb-label { font-size: 12px; opacity: .9; }
.nb-title { font-weight: 700; font-size: 16px; }

.person-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 4px 0 10px; }
.pname { font-size: 20px; font-weight: 700; }
.pgroup { font-size: 13px; color: var(--muted); }

/* タイムライン */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.job { display: grid; grid-template-columns: 64px 1fr; gap: 10px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); }
.job.rest { border-left-color: var(--muted); }
.job.active { border-color: var(--now); border-left-color: var(--now); box-shadow: 0 0 0 2px color-mix(in srgb, var(--now) 25%, transparent); }
.job.done, .ev.done { opacity: .5; }
.jtime { font-weight: 700; font-variant-numeric: tabular-nums; }
.jtime span { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.jname { font-weight: 700; font-size: 16px; word-break: break-all; }
.place { font-size: 13px; color: var(--muted); margin-top: 2px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 999px; }
.badge.res { background: var(--res-soft); color: var(--res); }
.badge.via { background: var(--via-soft); color: var(--via); }
.badge.hq { background: var(--accent-soft); color: var(--accent); }
.badge.rest { background: var(--bg); color: var(--muted); }
.mates { margin-top: 6px; font-size: 13px; }
.mates summary { cursor: pointer; color: var(--accent); }
.mates div, .jc-names { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.mate { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 2px 10px; font-size: 13px; cursor: pointer; }
.mate.mine { border-color: #e0a800; font-weight: 600; }

.ev { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 2px 12px 2px 16px; font-size: 13px; }
.etime { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; padding-right: 2px; }
.ebody { border-left: 2px dashed var(--line); padding-left: 10px; }
.eicon { display: inline-block; width: 1.4em; color: var(--accent); }
.ev.leave .eicon, .ev.end .eicon { color: var(--warn); }
.ev.depart .eicon, .ev.direct .eicon { color: var(--res); }
.edesc { color: var(--muted); }
.now-line { position: relative; height: 22px; }
.now-line::before { content: ""; position: absolute; left: 0; right: 0; top: 11px; border-top: 2px solid var(--now); }
.now-line span { position: relative; background: var(--bg); color: var(--now); font-size: 12px; font-weight: 700; padding: 0 6px; margin-left: 8px; }

/* 人割から見る */
.job-filter { margin: -4px 0 10px; font-size: 14px; }
.jobcard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; }
.jc-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.jc-head .jtime { font-size: 13px; }
.jc-head .jname { font-size: 15px; }
.jc-head .count { margin-left: auto; font-size: 12px; color: var(--muted); }

/* ダイアログ */
dialog.sheet { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 48px); background: var(--card); color: var(--text); }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .4); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 4px 20px; position: sticky; top: 0; background: var(--card); }
.sheet-head h2 { font-size: 17px; margin: 0; }
.sheet-body { padding: 4px 20px 20px; }
.status-line { font-size: 15px; }
.hint { background: var(--via-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 8px 0; }
.kinds { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 10px 0; display: grid; gap: 4px; }
.kinds legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.kinds label { display: flex; gap: 8px; align-items: center; min-height: 32px; font-size: 14px; }
.kinds input { width: 18px; height: 18px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.row-btns.col { flex-direction: column; }

.toast {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(520px, calc(100vw - 24px)); background: #1c2421; color: #fff; border-radius: 12px; padding: 12px 16px; z-index: 50;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .3); font-size: 14px;
}
@media (prefers-color-scheme: dark) { .toast { background: #e6ece9; color: #111614; } }
