:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --ok: #16a34a;
  --okbg: #dcfce7;
  --wait: #b45309;
  --waitbg: #fef3c7;
  --rej: #dc2626;
  --rejbg: #fee2e2;
  --turn: #2563eb;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif; background: var(--bg); color: var(--ink); }

/* ヘッダ */
.topbar { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.topbar .role { font-weight: 700; font-size: 1.05rem; }
.topbar .role .ic { margin-right: .3rem; }
.topbar .site { color: var(--muted); font-size: .82rem; }
.topbar .spacer { flex: 1; }
.topbar a.nav { font-size: .82rem; color: var(--primary); text-decoration: none; padding: .3rem .6rem; border-radius: 8px; }
.topbar a.nav:hover { background: #eff6ff; }

.wrap { max-width: 860px; margin: 0 auto; padding: 1rem; }

/* ツールバー */
.toolbar { display: flex; align-items: center; gap: .6rem; margin: .2rem 0 1rem; flex-wrap: wrap; }
.mine-count { font-weight: 700; color: var(--primary); }
.toolbar .spacer { flex: 1; }

/* ボタン */
.btn { border: none; border-radius: 9px; padding: .6rem 1rem; font: inherit; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: #fff; color: var(--rej); border: 1px solid var(--rej); }
.btn.lg { padding: .8rem 1.3rem; font-size: 1.05rem; }

/* 申請カード */
.appcard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; margin-bottom: .7rem; cursor: pointer; transition: .12s; }
.appcard:hover { border-color: #cbd5e1; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.appcard.turn { border-left: 4px solid var(--turn); background: #f8fbff; }
.appcard-top { display: flex; align-items: center; gap: .4rem; margin-bottom: .4rem; flex-wrap: wrap; }
.appcard-title { font-weight: 700; }
.appcard-meta { color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.turnflag { color: var(--turn); font-weight: 700; font-size: .8rem; margin-left: auto; }

/* バッジ */
.badge { font-size: .73rem; padding: .18rem .5rem; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.badge.wait { background: var(--waitbg); color: var(--wait); }
.badge.ok { background: var(--okbg); color: var(--ok); }
.badge.rej { background: var(--rejbg); color: var(--rej); }
.badge.wf { background: #e0e7ff; color: #3730a3; }
.badge.wf.simplified { background: #ede9fe; color: #6d28d9; }

.muted { color: var(--muted); }
.small { font-size: .8rem; }

/* モーダル */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; align-items: flex-start; justify-content: center; padding: 4vh 1rem; z-index: 20; overflow-y: auto; }
.modal.show { display: flex; }
.modal-card { background: #fff; border-radius: 16px; max-width: 560px; width: 100%; padding: 1.4rem; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-x { position: absolute; top: .8rem; right: .8rem; border: none; background: #f1f5f9; border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 1rem; }
.detail-head { display: flex; align-items: center; gap: .4rem; margin-bottom: .3rem; flex-wrap: wrap; }
.modal-card h3 { margin: .3rem 0 .8rem; font-size: 1.1rem; }

/* 基本情報 key-value */
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .8rem; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: .8rem; }
.kv.times { grid-template-columns: repeat(3,1fr); margin-top: .7rem; background: #f0fdf4; border-color: #bbf7d0; }
.kv div { font-size: .9rem; }
.kv span { display: block; color: var(--muted); font-size: .72rem; margin-bottom: .1rem; }

.chips-label { font-size: .78rem; color: var(--muted); margin: .9rem 0 .4rem; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; border-radius: 999px; padding: .25rem .6rem; font-size: .82rem; }

.instr { margin-top: .7rem; background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: .6rem .8rem; font-size: .9rem; }
.instr span { display: block; color: var(--wait); font-size: .72rem; font-weight: 700; margin-bottom: .2rem; }
.rejbox { margin-top: .7rem; background: var(--rejbg); border: 1px solid #fecaca; color: var(--rej); border-radius: 10px; padding: .6rem .8rem; font-size: .9rem; }

/* アクション領域 */
.action-area { margin-top: 1rem; }
.action-box { background: #f8fafc; border: 1px dashed var(--line); border-radius: 10px; padding: .9rem; }
.action-btns { display: flex; gap: .6rem; margin-top: .8rem; flex-wrap: wrap; }
.done { background: var(--okbg); color: var(--ok); font-weight: 700; text-align: center; padding: .8rem; border-radius: 10px; }
.chk { display: block; padding: .35rem 0; font-size: .92rem; }
.time-row { display: flex; align-items: center; gap: .6rem; padding: .3rem 0; }
.time-row span { width: 120px; color: var(--muted); font-size: .85rem; }
.time-row input, textarea, .form input, .form select { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: .5rem; }
textarea { width: 100%; }
.ta-label, .hint-merge { font-size: .82rem; color: var(--muted); display: block; margin-bottom: .4rem; }
.hint-merge { background: #ede9fe; color: #6d28d9; padding: .5rem .7rem; border-radius: 8px; }

/* 履歴タイムライン */
.evt { margin-top: 1rem; }
.evt summary { cursor: pointer; color: var(--primary); font-size: .88rem; }
.timeline { list-style: none; padding: .6rem 0 0; margin: 0; }
.timeline li { font-size: .84rem; padding: .35rem 0; border-bottom: 1px dashed var(--line); display: flex; gap: .5rem; flex-wrap: wrap; }
.t-when { color: var(--muted); min-width: 84px; }
.t-what { font-weight: 700; }
.t-who { color: var(--muted); }
.t-extra { color: #6d28d9; width: 100%; padding-left: 84px; }

/* トースト */
.toast { position: fixed; left: 50%; bottom: 1.3rem; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 999px; font-size: .9rem; opacity: 0; transition: .25s; z-index: 40; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* エントリ（index） */
.entry h1 { font-size: 1.5rem; margin-bottom: .3rem; }
.entry .lead { color: var(--muted); line-height: 1.7; }
.role-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1rem; margin: 1.5rem 0; }
.role-card { display: block; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.3rem; transition: .15s; text-align: center; }
.role-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(37,99,235,.12); }
.role-card .ic { font-size: 2.4rem; }
.role-card .t { font-weight: 700; margin: .5rem 0 .2rem; font-size: 1.1rem; }
.role-card .d { color: var(--muted); font-size: .82rem; line-height: 1.5; }
.subnav { display: flex; gap: .8rem; flex-wrap: wrap; margin: 1rem 0; }
.subnav a { text-decoration: none; color: var(--primary); border: 1px solid var(--line); background: #fff; padding: .5rem .9rem; border-radius: 10px; font-size: .9rem; }
.tip { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 12px; padding: 1rem; color: #1e40af; font-size: .88rem; line-height: 1.7; }

/* 申請フォーム */
.form { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem; }
.form h2 { margin-top: 0; font-size: 1.2rem; }
.field { margin-bottom: .9rem; }
.field > label { display: block; font-size: .82rem; color: var(--muted); font-weight: 700; margin-bottom: .3rem; }
.field input[type=text], .field input[type=date], .field input[type=time] { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem; }
.checks label { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: .4rem .7rem; font-size: .88rem; cursor: pointer; }
.checks input { margin-right: .3rem; }
.precheck-note { background: #ede9fe; color: #6d28d9; padding: .5rem .7rem; border-radius: 8px; font-size: .82rem; margin-bottom: .6rem; }
.sec-h { font-weight: 700; font-size: .98rem; margin: 1.3rem 0 .6rem; padding-bottom: .3rem; border-bottom: 2px solid var(--primary); color: var(--ink); }
.sec-h.sub { font-size: .85rem; border-bottom: 1px solid var(--line); color: var(--muted); margin: .9rem 0 .4rem; }
.sec-note { font-weight: 400; font-size: .76rem; color: var(--muted); margin-left: .4rem; }
.sec-note2 { font-size: .76rem; color: var(--muted); margin: .3rem 0; }
.amber { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 8px; padding: .6rem .8rem; font-size: .82rem; line-height: 1.6; margin: 1rem 0; }
.disclaimer { text-align: center; color: var(--muted); font-size: .78rem; padding: 1rem; }

/* ログイン中バー */
.identity-bar { display: flex; align-items: center; gap: .6rem; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: .55rem .9rem; margin: .3rem 0 1rem; flex-wrap: wrap; }
.login-label { font-size: .85rem; font-weight: 700; color: #1e40af; }
.identity-bar select { font: inherit; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 8px; }

/* メンバー追加・一覧 */
.add-row { display: flex; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; }
.add-row input { flex: 1; min-width: 140px; }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; background: #f8fafc; border: 1px solid var(--line); border-radius: 9px; padding: .6rem .8rem; margin-bottom: .5rem; }
.btn.small { padding: .35rem .7rem; font-size: .8rem; }
