:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1f23;
  --muted: #6b6f78;
  --line: #e3e1dc;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ec;
  --ok: #1f7a3a;
  --ng: #b3261e;
  --gap-bg: #fffaf0;
  --gap-line: #d9a441;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1f2226;
    --text: #e8e9eb;
    --muted: #9aa0a8;
    --line: #33373d;
    --accent: #5cc3a5;
    --accent-ink: #0d1f1a;
    --accent-soft: #1d3a32;
    --ok: #6fd28d;
    --ng: #ff8a80;
    --gap-bg: #2a2518;
    --gap-line: #b48a36;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { 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", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: 96px; }
button, input, select { font: inherit; color: inherit; }
small { font-size: .8em; }

/* 上のバー */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 1.1rem; margin: 0; }
.bar .sub { margin: 0; color: var(--muted); font-size: .85rem; }
.pad { padding: 12px 16px; }

/* ボタン */
.primary, .ghost, .chip, .icon {
  border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  min-height: 44px; padding: 8px 14px;
}
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.ghost { background: transparent; border-color: var(--line); }
.small { min-height: 44px; padding: 4px 14px; font-size: .95rem; }
.wide { display: block; width: 100%; margin-top: 10px; }
.center { text-align: center; text-decoration: none; line-height: 28px; color: var(--text); }
.icon { min-height: 36px; min-width: 36px; padding: 0; background: transparent; border-color: var(--line); }
button:disabled { opacity: .45; cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { background: var(--surface); border-color: var(--line); min-height: 38px; padding: 4px 14px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }

/* お知らせ */
.mock-note, .shared-note {
  font-size: .85rem; padding: 8px 12px; border-radius: 10px; margin: 0 0 12px;
  background: var(--accent-soft);
}
.hint, .muted { color: var(--muted); }
.hint { font-size: .9rem; margin: 4px 0 8px; }
.ok { color: var(--ok); font-weight: 600; }
.ng { color: var(--ng); font-weight: 600; }
.note { background: var(--gap-bg); border-left: 3px solid var(--gap-line); padding: 6px 10px; border-radius: 6px; }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }

/* 作成フォーム */
.form label, .sheet label { display: block; margin: 10px 0; font-size: .9rem; color: var(--muted); }
.form input, .form select, .sheet input[type="time"], .search {
  display: block; width: 100%; margin-top: 4px; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text);
}
.check { display: flex !important; align-items: center; gap: 8px; color: var(--text) !important; }
.check input { width: 20px; height: 20px; }

/* 地図の場所 */
.map { margin-bottom: 12px; }
.map-inner {
  border: 1px dashed var(--line); border-radius: 12px; padding: 12px; background: var(--surface);
  color: var(--muted); font-size: .85rem; min-height: 120px;
}
.map-inner ol { margin: 8px 0 0; padding-left: 20px; color: var(--text); }

/* タイムライン */
.timeline { list-style: none; margin: 0; padding: 0; }
.node { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: start; padding: 4px 0; }
.time { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; font-size: .95rem; }
.time small { color: var(--muted); font-weight: 400; }
.edge .label { font-weight: 600; }
.card {
  background: var(--surface); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.event.added .card { border-color: var(--accent); }
.card-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card-head strong { flex: 1; }
.lock { font-size: .8rem; background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.meta { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.maplink { display: inline-block; font-size: .85rem; color: var(--accent); }
.card-foot { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; align-items: center; }
.link { background: none; border: 0; padding: 6px 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-size: .85rem; min-height: 32px; }
.edge .link { margin-left: 8px; font-weight: 400; }
.bar-btns { display: flex; gap: 8px; }
.danger { color: var(--ng); border-color: var(--ng); }
.move { margin-left: 66px; padding: 6px 0 6px 12px; border-left: 2px solid var(--line); color: var(--muted); font-size: .85rem; }
.gap {
  margin: 4px 0 4px 66px; padding: 10px 12px; border: 2px dashed var(--gap-line); border-radius: 12px;
  background: var(--gap-bg); display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.gap button { white-space: nowrap; flex-shrink: 0; }
.gap-body { display: grid; gap: 2px; }
.gap-label { font-size: .8rem; color: var(--muted); }
.gap-free { font-size: .9rem; }
.gap-free b { display: block; font-size: 1.35rem; line-height: 1.3; white-space: nowrap; }
.gap-body { min-width: 0; }
.gap-move { font-size: .8rem; color: var(--muted); }
.actions { margin-top: 16px; }

/* 下から出るシート */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-panel {
  position: relative; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  background: var(--bg); border-radius: 16px 16px 0 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(16px); transition: transform .18s ease-out;
}
.sheet.open .sheet-panel { transform: translateY(0); }
.sheet-close { position: absolute; top: 8px; right: 8px; border: 0; background: transparent; font-size: 1.4rem; min-width: 44px; min-height: 44px; cursor: pointer; color: var(--muted); }
.sheet h2 { font-size: 1.05rem; margin: 0 40px 4px 0; }
.pick { list-style: none; padding: 0; margin: 8px 0; }
.pick button {
  width: 100%; text-align: left; padding: 10px 12px; margin: 4px 0; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: flex; justify-content: space-between; gap: 8px;
}
.pick small { color: var(--muted); }
.picked { font-weight: 700; margin: 0 0 4px; }
.label-sm { font-size: .9rem; color: var(--muted); margin: 10px 0 0; }
.wish { display: flex; gap: 8px; margin: 8px 0; }
.wish input { flex: 1; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.stay { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; font-size: .9rem; }
.stay span { min-width: 4.5em; text-align: center; font-weight: 600; }
.cand { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.cand.is-over { opacity: .7; }
.cond { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 6px 0 10px; font-size: .9rem; display: grid; gap: 2px; }
.one-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verdict { margin-top: 6px; font-size: .95rem; line-height: 1.4; }
.verdict b { font-size: 1.15rem; }
.no-hit { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 8px 0; }
.no-hit p { margin: 4px 0; }
.no-hit-title { font-weight: 700; }
.rejected { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.rejected li { padding: 8px 0; border-top: 1px solid var(--line); }
.facts { display: grid; gap: 2px; margin-top: 4px; font-size: .85rem; color: var(--muted); }
.cand .btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.over summary { cursor: pointer; padding: 8px 0; color: var(--muted); }

/* 通知 */
.toast {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 30; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 12px;
  display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px); box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }
.toast button { white-space: nowrap; flex-shrink: 0; background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 8px; padding: 4px 10px; cursor: pointer; }
