:root {
  --navy: #17233f;
  --navy-2: #24345c;
  --orange: #ef7d1a;
  --orange-soft: #fff1e4;
  --gold: #f5a623;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #6b7385;
  --line: #e3e7ef;
  --sun: #d93a3a;
  --sat: #2f6fdb;
  --c-game: #ef7d1a;
  --c-duty: #2f6fdb;
  --c-practice: #2e9d68;
  --c-event: #8e55c7;
  --c-other: #7a8194;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(23, 35, 63, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
a { color: var(--duty, #2f6fdb); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; font-size: 16px; }

/* ---------- 認証 ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(circle at 20% 0%, #24345c 0, #17233f 55%); }
.auth-card { background: #fff; width: 100%; max-width: 420px; border-radius: 18px; padding: 28px 22px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.auth-logo { display: block; width: 96px; height: 96px; margin: 0 auto 10px; }
.auth h1 { text-align: center; font-size: 20px; margin: 0 0 4px; }
.auth .sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 20px; }

/* ---------- フォーム ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 4px; color: #3a4256; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid #cfd5e1; border-radius: 9px; background: #fff; color: var(--text);
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { outline: 2px solid rgba(239,125,26,.35); border-color: var(--orange); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .field { flex: 1 1 140px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 18px; height: 18px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 9px;
  padding: 10px 16px; font-weight: 700; background: var(--navy); color: #fff; min-height: 42px; }
.btn:hover { background: var(--navy-2); }
.btn.primary { background: var(--orange); }
.btn.primary:hover { background: #db6c0c; }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid #cfd5e1; }
.btn.ghost:hover { background: #f1f3f8; }
.btn.danger { background: #fff; color: #c0392b; border: 1px solid #efc3bd; }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.link-btn { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; }
.error { color: #c0392b; font-size: 13px; margin: 8px 0; min-height: 1em; }

/* ---------- レイアウト ---------- */
.shell { display: flex; min-height: 100vh; }
.topbar { display: none; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--navy); color: #fff; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand img { width: 46px; height: 46px; }
.brand-name { font-weight: 800; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--gold); font-weight: 700; letter-spacing: .1em; }
#nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border-radius: 9px; color: #d7dcea;
  background: none; border: 0; text-align: left; font-size: 15px; text-decoration: none; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--orange); color: #fff; font-weight: 700; }
.nav-item .ico { width: 22px; text-align: center; }
.nav-sep { font-size: 11px; color: #8d97b3; padding: 14px 12px 4px; letter-spacing: .08em; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; color: #c5cbe0; }
.me { margin-bottom: 6px; word-break: break-all; }
.me b { color: #fff; }
.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h2 { margin: 0; font-size: 21px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- カレンダー ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-title { font-size: 21px; font-weight: 800; margin: 0 6px; min-width: 130px; text-align: center; }
.seg { display: inline-flex; background: #e6e9f1; border-radius: 9px; padding: 3px; margin-left: auto; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-weight: 700; color: var(--muted); }
.seg button.on { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.cal { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow div { text-align: center; font-size: 12px; font-weight: 700; padding: 7px 0; background: #f7f8fb; border-bottom: 1px solid var(--line); }
.cal-dow div:first-child { color: var(--sun); } .cal-dow div:last-child { color: var(--sat); }
.day { min-height: 108px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; cursor: pointer; position: relative; background: #fff; }
.day:nth-child(7n) { border-right: 0; }
.day.out { background: #fafbfd; }
.day.out .dnum { color: #b9bfcc; }
.day.sel { box-shadow: inset 0 0 0 2px var(--orange); }
.dnum { font-size: 13px; font-weight: 700; display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: 50%; }
.day.sun .dnum { color: var(--sun); } .day.sat .dnum { color: var(--sat); }
.day.today .dnum { background: var(--navy); color: #fff; }
.chip { display: block; width: 100%; text-align: left; border: 0; margin-top: 3px; border-radius: 5px; padding: 2px 5px; font-size: 12px; line-height: 1.35;
  color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--c-other); }
.chip.light { background: transparent; color: var(--text); border-left: 3px solid var(--c-practice); border-radius: 2px; padding-left: 4px; }
.c-game { background: var(--c-game); } .c-duty { background: var(--c-duty); } .c-practice { background: var(--c-practice); }
.c-event { background: var(--c-event); } .c-other { background: var(--c-other); }
.dots { display: none; }

.daylist { margin-top: 14px; }
.daylist h3 { font-size: 15px; margin: 0 0 8px; }
.ev-card { display: flex; gap: 12px; align-items: stretch; background: #fff; border-radius: 11px; box-shadow: var(--shadow); padding: 12px; margin-bottom: 9px;
  cursor: pointer; border: 0; width: 100%; text-align: left; color: var(--text); }
.ev-card:hover { box-shadow: 0 3px 14px rgba(23,35,63,.14); }
.ev-bar { width: 5px; border-radius: 3px; flex-shrink: 0; }
.ev-date { width: 52px; flex-shrink: 0; text-align: center; }
.ev-date .d { font-size: 22px; font-weight: 800; line-height: 1.1; }
.ev-date .w { font-size: 12px; color: var(--muted); }
.ev-main { flex: 1; min-width: 0; }
.ev-title { font-weight: 800; font-size: 15px; }
.ev-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; color: #fff; vertical-align: 1px; }
.tag-row { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 20px; background: #eef1f7; color: #3a4256; font-weight: 700; }
.tag.game { background: var(--orange-soft); color: #b85a08; }
.tag.to, .tag.ref { background: #e5eefc; color: #2457b5; }
.month-sep { font-weight: 800; color: var(--muted); margin: 18px 0 8px; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ---------- 詳細シート ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(15, 22, 40, .45); }
.sheet { position: absolute; right: 0; top: 0; bottom: 0; width: min(520px, 100%); background: var(--bg); overflow-y: auto;
  box-shadow: -10px 0 30px rgba(0,0,0,.2); animation: slideL .22s ease-out; }
.sheet-handle { display: none; }
@keyframes slideL { from { transform: translateX(40px); opacity: .4; } }
@keyframes slideU { from { transform: translateY(60px); opacity: .4; } }
.sh-head { background: var(--navy); color: #fff; padding: 18px 18px 16px; position: relative; }
.sh-head .close { position: absolute; right: 10px; top: 10px; background: rgba(255,255,255,.12); color: #fff; border: 0; width: 34px; height: 34px; border-radius: 50%; font-size: 18px; }
.sh-date { font-size: 14px; color: var(--gold); font-weight: 700; }
.sh-title { font-size: 21px; font-weight: 800; margin: 2px 40px 6px 0; line-height: 1.35; }
.sh-body { padding: 14px; }
.info { background: #fff; border-radius: 11px; box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.info-row { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.info-row:last-child { border-bottom: 0; }
.info-row .k { width: 78px; flex-shrink: 0; font-size: 13px; color: var(--muted); font-weight: 700; padding-top: 1px; }
.info-row .v { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.sec-title { font-size: 14px; font-weight: 800; margin: 18px 4px 8px; display: flex; align-items: center; justify-content: space-between; }
.timeline { background: #fff; border-radius: 11px; box-shadow: var(--shadow); padding: 6px 14px; margin-bottom: 12px; }
.tl { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); align-items: center; }
.tl:last-child { border-bottom: 0; }
.tl .t { width: 48px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tl .l { flex: 1; }
.tl.game .l { font-weight: 800; }
.doc-link { display: flex; align-items: center; gap: 8px; padding: 11px 14px; background: #fff; border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 7px;
  text-decoration: none; color: var(--text); font-size: 14px; border: 0; width: 100%; text-align: left; }
.doc-link .pdf { background: #e74c3c; color: #fff; font-size: 10px; font-weight: 800; padding: 2px 5px; border-radius: 4px; }
.rsvp { background: #fff; border-radius: 11px; box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 12px; }
.rsvp-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.rsvp-row:last-child { border-bottom: 0; }
.rsvp-row .nm { flex: 1; min-width: 90px; font-weight: 700; }
.ox { display: inline-flex; gap: 6px; }
.ox button { width: 46px; height: 40px; border-radius: 9px; border: 1px solid #cfd5e1; background: #fff; font-size: 18px; font-weight: 800; color: #9aa1b1; }
.ox button.on.yes { background: #2e9d68; border-color: #2e9d68; color: #fff; }
.ox button.on.maybe { background: #e0a100; border-color: #e0a100; color: #fff; }
.ox button.on.no { background: #c0392b; border-color: #c0392b; color: #fff; }
.counts { display: flex; gap: 14px; font-weight: 800; font-size: 15px; margin-bottom: 6px; }
.counts .y { color: #2e9d68; } .counts .m { color: #c18a00; } .counts .n { color: #c0392b; } .counts .u { color: var(--muted); }
.who { font-size: 13px; color: #3a4256; margin: 2px 0; }
.who b { display: inline-block; width: 22px; }
.car { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.car-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; }
.car-kids { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 5px; }
.kid { background: var(--orange-soft); color: #9a4b06; font-size: 13px; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
.seat-ng { color: #c0392b; }
.assign-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.assign-row .nm { flex: 1; }
.assign-row select { max-width: 60%; padding: 6px 8px; }
.admin-bar { display: flex; gap: 8px; padding: 0 14px 20px; }

/* ---------- モーダル ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; }
.modal-bg { position: fixed; inset: 0; background: rgba(15,22,40,.5); }
.modal { position: relative; background: #fff; border-radius: 14px; width: 100%; max-width: 640px; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.sched-edit { display: grid; grid-template-columns: 86px 1fr 92px 34px; gap: 6px; margin-bottom: 6px; }
.sched-edit .input { padding: 7px 8px; }
.x-btn { border: 0; background: #f1f3f8; border-radius: 8px; color: #c0392b; font-weight: 800; }

/* ---------- 表 ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { font-size: 12px; color: var(--muted); background: #f7f8fb; white-space: nowrap; }
.tbl tr.off td { color: #a3a9b6; }
.role { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 20px; background: #eef1f7; }
.role.admin { background: var(--orange-soft); color: #b85a08; }
.role.owner { background: var(--navy); color: #fff; }

/* ---------- アップロード ---------- */
.drop { display: block; border: 2px dashed #c3cad8; border-radius: 12px; padding: 26px 14px; text-align: center; background: #fafbfd; cursor: pointer; }
.drop.over { border-color: var(--orange); background: var(--orange-soft); }
.drop .big { font-size: 34px; }
.doc-item { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.doc-item:hover { background: #fafbfd; }
.doc-item .nm { flex: 1; min-width: 0; }
.doc-item .nm div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.st.processing { background: #fff6d6; color: #8a6d00; }
.st.done { background: #e5eefc; color: #2457b5; }
.st.applied { background: #e3f5ec; color: #1f7a4f; }
.st.error { background: #fde8e6; color: #c0392b; }
.cand { border: 1px solid var(--line); border-radius: 11px; padding: 12px; margin-bottom: 10px; }
.cand.off { opacity: .5; }
.cand-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cand-head .check { font-weight: 800; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #e0c97a; border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.invite-box { display: flex; gap: 8px; align-items: center; background: var(--orange-soft); border-radius: 10px; padding: 10px; word-break: break-all; font-size: 13px; }
.kid-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.kid-pick label { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #cfd5e1; border-radius: 20px; padding: 6px 12px; font-size: 14px; background: #fff; }
.kid-pick input:checked + span { font-weight: 800; color: #b85a08; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 30px;
  z-index: 80; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90%; }

/* ---------- スマホ ---------- */
@media (max-width: 860px) {
  .shell { display: block; }
  .topbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30; background: var(--navy); color: #fff;
    padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .icon-btn { background: none; border: 0; color: #fff; font-size: 22px; width: 38px; height: 38px; }
  .topbar-logo { width: 30px; height: 30px; }
  .topbar-title { font-weight: 800; font-size: 16px; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; height: 100%; }
  .sidebar.open { transform: none; }
  .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .main { padding: 14px 12px 50px; }
  .page-head h2 { font-size: 19px; }
  .cal-title { font-size: 18px; min-width: 110px; }
  .day { min-height: 62px; padding: 3px 2px; }
  .dnum { font-size: 12px; width: 22px; height: 22px; }
  .chip { font-size: 10px; padding: 1px 3px; margin-top: 2px; border-radius: 3px; }
  .chip.light { padding-left: 3px; border-left-width: 2px; }
  .sheet { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 88vh; border-radius: 18px 18px 0 0; animation: slideU .22s ease-out;
    padding-bottom: env(safe-area-inset-bottom); }
  .sheet-handle { display: block; width: 44px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.5); position: absolute; left: 50%; top: 7px; transform: translateX(-50%); z-index: 2; }
  .sh-head { border-radius: 18px 18px 0 0; padding-top: 22px; }
  .modal-wrap { padding: 0; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 94vh; overflow-y: auto; padding: 18px 14px; }
  .sched-edit { grid-template-columns: 74px 1fr 34px; }
  .sched-edit .kind { grid-column: 1 / 3; }
  .seg { margin-left: 0; }
  .hide-sp { display: none; }
}
@media (max-width: 380px) {
  .chip { font-size: 9px; }
}
