:root {
  --yellow: #FFD600; --orange: #FF8A00; --pink: #FF5B91; --bg: #FFF9E4;
  --ink: #3b2a00; --ink-soft: #6b5a2e; --card: #fff; --line: #f1e3a8;
  --danger: #e0333f; --ok: #1f9d55; --blue: #2f7de1;
  --radius: 22px; --nav-h: 76px;
  font-size: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Noto Sans JP", "Meiryo", sans-serif; line-height: 1.6; -webkit-text-size-adjust: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.loading { text-align: center; padding: 40vh 0; color: var(--ink-soft); }
.muted { color: var(--ink-soft); font-size: .88rem; }
.hidden { display: none !important; }

/* ---------- ボタン ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; min-height: 52px; padding: 0 1.4em; border: 0; border-radius: 999px;
  background: var(--yellow); color: var(--ink); font-weight: 800; text-decoration: none; cursor: pointer; box-shadow: 0 3px 0 #d9b400; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #d9b400; }
.btn.orange { background: var(--orange); color: #fff; box-shadow: 0 3px 0 #c56a00; }
.btn.pink { background: var(--pink); color: #fff; box-shadow: 0 3px 0 #c93d6c; }
.btn.white { background: #fff; box-shadow: 0 3px 0 var(--line); }
.btn.small { min-height: 40px; padding: 0 1em; font-size: .88rem; }
.btn.danger { background: #fff; color: var(--danger); box-shadow: 0 3px 0 #f3c3c7; }
.btn.block { width: 100%; }
.icon-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; background: #fff; font-size: 1.4rem; cursor: pointer; box-shadow: 0 2px 0 var(--line); }

/* ---------- 全体の枠 ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .6rem; padding: calc(.5rem + env(safe-area-inset-top)) 16px .5rem;
  background: var(--yellow); box-shadow: 0 2px 0 #ecc400; }
.topbar .logo { white-space: nowrap; flex: 0 1 auto; min-width: 0; overflow: hidden; font-weight: 900; font-size: 1.25rem; text-decoration: none; letter-spacing: .02em; display: flex; align-items: center; gap: .4rem; }
.topbar .logo img { width: 36px; height: 36px; border-radius: 10px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .8rem; color: var(--ink-soft); max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
.page-title { font-size: 1.5rem; font-weight: 900; margin: .4rem 0 1rem; display: flex; align-items: center; gap: .5rem; }

.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: #fff; border-top: 3px solid var(--yellow); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; height: var(--nav-h); text-decoration: none; font-size: .72rem; font-weight: 700; color: var(--ink-soft); }
.bottomnav a .ic { font-size: 1.7rem; line-height: 1.1; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; }
.bottomnav a.on { color: var(--ink); }
.bottomnav a.on .ic { background: var(--yellow); }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: 0 3px 0 var(--line); }
.card h2 { font-size: 1.15rem; margin: 0 0 .6rem; display: flex; align-items: center; gap: .4rem; }
.chip { display: inline-block; padding: .1em .75em; border-radius: 999px; background: #FFF1A8; font-size: .8rem; font-weight: 700; margin: 0 .25em .25em 0; }
.chip.orange { background: #FFE0BD; } .chip.pink { background: #FFD6E5; } .chip.red { background: var(--danger); color: #fff; } .chip.gray { background: #eee; color: #666; }
.chip.green { background: #D7F5E3; color: var(--ok); }
.empty { text-align: center; padding: 1.4rem; color: var(--ink-soft); }

/* ---------- TOP ---------- */
.hero { position: relative; border-radius: 28px; overflow: hidden; min-height: 230px; display: flex; flex-direction: column; justify-content: flex-end;
  background: var(--orange) center/cover no-repeat; color: #fff; padding: 22px; margin-bottom: 16px; box-shadow: 0 4px 0 #e2b300; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 25%, rgba(80, 40, 0, .6)); }
.hero > * { position: relative; }
.hero .brand { font-size: 2.4rem; font-weight: 900; line-height: 1.1; text-shadow: 0 3px 0 var(--orange), 0 0 14px rgba(0,0,0,.25); }
.hero .catch { font-weight: 800; font-size: 1.05rem; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.hero .daybadge { position: absolute; top: 16px; right: 16px; background: var(--pink); color: #fff; border-radius: 999px; padding: .35em 1em; font-weight: 900; font-size: 1.05rem; box-shadow: 0 3px 0 #c93d6c; }
.next { background: linear-gradient(135deg, #FFE45C, var(--yellow)); border: 3px solid var(--orange); }
.next .label { display: inline-block; background: var(--orange); color: #fff; font-weight: 900; border-radius: 999px; padding: .1em .9em; font-size: 1.05rem; transform: rotate(-3deg); }
.next .what { font-size: 1.5rem; font-weight: 900; margin: .4rem 0 .1rem; }
.next .when { font-size: 1.15rem; font-weight: 800; }
.notice { border-left: 8px solid var(--pink); }
.notice ul { margin: 0; padding: 0; list-style: none; }
.notice li { padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.notice li:last-child { border: 0; }

/* ---------- メッセージ ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; display: flex; flex-direction: column; }
.msg .name { font-size: .78rem; color: var(--ink-soft); margin: 0 .6rem .1rem; }
.msg .bubble { background: #fff; border-radius: 20px 20px 20px 6px; padding: .6rem .9rem; white-space: pre-wrap; word-break: break-word; box-shadow: 0 2px 0 var(--line); }
.msg .time { font-size: .7rem; color: var(--ink-soft); margin: .1rem .6rem 0; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.mine .bubble { background: var(--yellow); border-radius: 20px 20px 6px 20px; box-shadow: 0 2px 0 #e2b300; }
.msg.pinned .bubble { outline: 3px solid var(--pink); }
.msg .tools { display: flex; gap: .3rem; margin-top: .2rem; }
.composer { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); display: flex; gap: .5rem; align-items: flex-end; padding: 10px 0; background: var(--bg); }
.composer textarea { flex: 1; min-height: 52px; max-height: 160px; border-radius: 26px; border: 3px solid var(--yellow); padding: .7rem 1rem; resize: none; background: #fff; }
.composer .btn { width: 64px; padding: 0; border-radius: 50%; height: 56px; font-size: 1.4rem; }
.tolatest { position: fixed; right: 16px; bottom: calc(var(--nav-h) + 90px + env(safe-area-inset-bottom)); z-index: 15; }

/* ---------- 日程 ---------- */
.days { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: .6rem; }
.days button { flex: 0 0 auto; min-width: 84px; border: 0; border-radius: 20px; background: #fff; padding: .5rem .8rem; font-weight: 800; cursor: pointer; box-shadow: 0 2px 0 var(--line); line-height: 1.3; }
.days button small { display: block; font-weight: 600; font-size: .75rem; color: var(--ink-soft); }
.days button.on { background: var(--yellow); box-shadow: 0 2px 0 #e2b300; }
.days button.today::after { content: "今日"; display: block; font-size: .7rem; color: #fff; background: var(--pink); border-radius: 999px; margin-top: .15rem; }
.prog { display: grid; grid-template-columns: 5.2em 1fr; gap: .8rem; }
.prog .t { font-weight: 900; font-size: 1.1rem; text-align: center; background: #FFF1A8; border-radius: 16px; padding: .4rem 0; align-self: start; }
.prog .t small { display: block; font-size: .78rem; font-weight: 700; color: var(--ink-soft); }
.prog h3 { margin: 0; font-size: 1.15rem; }
.prog.cancel h3 { text-decoration: line-through; color: #999; }
.prog.isnext { outline: 4px solid var(--orange); }
.prog details summary { cursor: pointer; font-size: .85rem; color: var(--blue); font-weight: 700; margin-top: .3rem; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: .5rem 0 0; font-size: .92rem; }
dl.kv dt { color: var(--ink-soft); font-weight: 700; }
dl.kv dd { margin: 0; white-space: pre-wrap; }

/* ---------- 写真・資料・連絡先 ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-grid .ph { aspect-ratio: 1; border-radius: 14px; background: repeating-linear-gradient(45deg, #FFF1A8 0 14px, #FFE77A 14px 28px); display: grid; place-items: center; font-size: 1.8rem; opacity: .7; }
.status-box { display: flex; gap: .8rem; align-items: center; background: #fff; border: 3px dashed var(--orange); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.status-box .big { font-size: 2.2rem; }
.filelist a { display: flex; align-items: center; gap: .8rem; padding: .8rem; border-radius: 18px; background: #FFFBEA; margin-bottom: .5rem; text-decoration: none; font-weight: 700; min-height: 64px; }
.filelist a .ic { font-size: 1.8rem; }
.contacts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.contact { background: #fff; border-radius: var(--radius); padding: 16px 10px; text-align: center; text-decoration: none; box-shadow: 0 3px 0 var(--line); display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.contact .face, .avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 4px solid var(--yellow); background: #FFF1A8; display: grid; place-items: center; font-size: 2.4rem; font-weight: 900; }
.contact .nm { font-weight: 900; font-size: 1.1rem; }
.contact .call { display: inline-flex; align-items: center; gap: .3em; background: var(--ok); color: #fff; border-radius: 999px; padding: .3em 1em; font-weight: 800; }
.contact .nocall { font-size: .78rem; color: var(--ink-soft); }

/* ---------- ログイン ---------- */
.login { max-width: 440px; margin: 0 auto; padding: 16px; }
.login .hero { min-height: 260px; }

/* ---------- フォーム ---------- */
.field { display: block; margin-bottom: .9rem; }
.field > span { display: block; font-weight: 800; font-size: .9rem; margin-bottom: .25rem; }
.field input:not([type=checkbox]) { min-width: 0; }
.field input:not([type=checkbox]), .field select, .field textarea, .input { width: 100%; min-height: 52px; border: 3px solid var(--line); border-radius: 16px; padding: .5rem .8rem; background: #fff; }
.field textarea { min-height: 90px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--yellow); }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .7rem; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem; }
.checks label { display: inline-flex; align-items: center; gap: .3rem; background: #FFFBEA; border: 2px solid var(--line); border-radius: 999px; padding: .35rem .8rem; cursor: pointer; font-weight: 700; font-size: .9rem; }
.checks label:has(input:checked) { background: var(--yellow); border-color: var(--orange); }
.checks input { width: 20px; height: 20px; accent-color: var(--orange); }
.error { color: var(--danger); font-weight: 700; min-height: 1.4em; }
.private { background: #FFF0F5; border-radius: 16px; padding: .8rem; margin-bottom: .9rem; }
.private > b { display: block; color: #b0285a; font-size: .85rem; margin-bottom: .4rem; }

dialog#sheet { border: 0; border-radius: 28px; padding: 22px 18px; width: min(560px, calc(100vw - 16px)); max-height: 92vh; background: var(--bg); color: var(--ink); }
dialog#sheet::backdrop { background: rgba(60, 40, 0, .45); }
.sheet-close { position: absolute; right: 12px; top: 10px; }
.sheet-close button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; font-size: 1.4rem; cursor: pointer; }
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1.2rem; border-radius: 999px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; }

/* ---------- 管理室 ---------- */
.room { min-height: 100vh; }
.room .topbar { background: var(--ink); color: #fff; box-shadow: none; }
.room .topbar .logo { font-size: 1.05rem; }
.topbar .btn.small { white-space: nowrap; flex: 0 0 auto; }
.room .topbar .who { color: #ddd; }
.roomnav { display: flex; gap: .4rem; overflow-x: auto; padding: 10px 16px; background: #fff; border-bottom: 3px solid var(--yellow); position: sticky; top: 56px; z-index: 9; }
.roomnav a { flex: 0 0 auto; text-decoration: none; padding: .45rem .9rem; border-radius: 999px; font-weight: 800; font-size: .9rem; background: #FFFBEA; }
.roomnav a.on { background: var(--yellow); }
.room .main { max-width: 1100px; padding-bottom: 40px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: var(--radius); padding: 14px; text-decoration: none; box-shadow: 0 3px 0 var(--line); display: flex; flex-direction: column; gap: .2rem; }
.stat .k { font-size: .85rem; font-weight: 800; color: var(--ink-soft); }
.stat .v { font-size: 2rem; font-weight: 900; line-height: 1.1; }
.stat .v small { font-size: .9rem; }
.stat.warn { background: #FFE9EC; } .stat.warn .v { color: var(--danger); }
.stat.wide { grid-column: 1 / -1; }
.bar { height: 16px; background: #FFF1A8; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--orange), var(--yellow)); border-radius: 999px; }
.rolegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.rolegrid a span:first-child { white-space: nowrap; }
.rolegrid a { text-decoration: none; background: #FFFBEA; border-radius: 16px; padding: .5rem .7rem; display: flex; justify-content: space-between; font-weight: 700; }
.rolegrid a.short { background: #FFE9EC; color: var(--danger); }
.list-item { display: flex; gap: .8rem; align-items: center; padding: .8rem; background: #fff; border-radius: 18px; margin-bottom: .6rem; box-shadow: 0 2px 0 var(--line); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .avatar { width: 56px; height: 56px; font-size: 1.4rem; border-width: 3px; flex: 0 0 auto; }
.list-item.overdue { background: #FFE9EC; border-left: 8px solid var(--danger); }
.list-item.done { opacity: .6; }
.seg { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.seg button { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: .25rem .7rem; font-weight: 700; font-size: .82rem; cursor: pointer; min-height: 36px; }
.seg button.on { background: var(--yellow); border-color: var(--orange); }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.toolbar .input { flex: 1; min-width: 160px; }
.toolbar select.input { flex: 0 1 auto; width: auto; }

.docwrap { overflow: hidden; background: #8a8a8a; border-radius: 14px; position: relative; }
.docframe { border: 0; display: block; transform-origin: 0 0; background: #8a8a8a; }
.days .btn { flex: 0 0 auto; }
@media (max-width: 480px) { .room .topbar .who { display: none; } }
@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .contacts { grid-template-columns: repeat(3, 1fr); }
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
  .hero { min-height: 300px; }
  .hero .brand { font-size: 3.2rem; }
}
@media (min-width: 1000px) {
  .room-body { display: grid; grid-template-columns: 220px 1fr; }
  .roomnav { flex-direction: column; position: sticky; top: 56px; height: calc(100vh - 56px); border: 0; border-right: 3px solid var(--yellow); padding: 16px; overflow: visible; }
  .roomnav a { padding: .7rem 1rem; font-size: 1rem; }
  .home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .home-wrap .main { max-width: 1100px; }
}
