/* OM在席・出退勤　画面の見た目
   レイアウト：1画面だけ。上＝自分の状態と操作、中＝1階・2階の1行、下＝全員の一覧（1人1行） */
:root{
  --bg:#E9F1F1; --surface:#FFFFFF; --sunk:#F3F8F8; --ink:#132C2C; --ink-2:#536867; --line:#D6E3E3;
  --teal:#08707D; --teal-ink:#FFFFFF; --teal-soft:#DDF0F1; --head:#0A7C89; --head-ink:#FFFFFF;
  --in:#1B7347; --in-soft:#E0F2E7; --out:#975000; --out-soft:#FBEDD6; --off:#6A7675; --off-soft:#EDF0F0;
  --danger:#C8251A; --danger-soft:#FCE9E7; --ok:#1B7347; --link:#1559C7; --serve:#9A4A3E; --leave:#A2564F; --leave-soft:#F5ECEA;
  --shadow:0 6px 24px rgba(8,60,66,.14);
  /* iPhone＝ヒラギノ、Android＝Noto Sans JP（端末標準）。見出しも本文も同じ書体 */
  --f-body:system-ui,-apple-system,"Hiragino Sans","Hiragino Kaku Gothic ProN","Noto Sans JP","Noto Sans CJK JP","Yu Gothic UI","Yu Gothic",Meiryo,sans-serif;
  --f-disp:var(--f-body);
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#0B1414; --surface:#122020; --sunk:#0F1B1B; --ink:#E4EFEE; --ink-2:#A3BAB9; --line:#29403F;
  --teal:#4FC2CE; --teal-ink:#05282C; --teal-soft:#123638; --head:#0E4F57; --head-ink:#E9F7F8;
  --in:#74D3A0; --in-soft:#16321F; --out:#F0B25E; --out-soft:#382811; --off:#A2B0AE; --off-soft:#1F2B2A;
  --danger:#FF8A7F; --danger-soft:#3A1A17; --ok:#74D3A0; --link:#7DB0FF; --serve:#A6574A; --leave:#D59A93; --leave-soft:#2E211F;
  --shadow:0 6px 24px rgba(0,0,0,.45); color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#0B1414; --surface:#122020; --sunk:#0F1B1B; --ink:#E4EFEE; --ink-2:#A3BAB9; --line:#29403F;
  --teal:#4FC2CE; --teal-ink:#05282C; --teal-soft:#123638; --head:#0E4F57; --head-ink:#E9F7F8;
  --in:#74D3A0; --in-soft:#16321F; --out:#F0B25E; --out-soft:#382811; --off:#A2B0AE; --off-soft:#1F2B2A;
  --danger:#FF8A7F; --danger-soft:#3A1A17; --ok:#74D3A0; --link:#7DB0FF; --serve:#A6574A; --leave:#D59A93; --leave-soft:#2E211F;
  --shadow:0 6px 24px rgba(0,0,0,.45); color-scheme:dark}

*{box-sizing:border-box}
html{height:100%;height:100dvh;box-sizing:border-box;overflow:hidden}
body{height:100%;margin:0;display:flex;flex-direction:column;overflow:hidden;overscroll-behavior:none;background:var(--bg);color:var(--ink);font-family:var(--f-body);font-size:18px;line-height:1.5;-webkit-text-size-adjust:100%;text-size-adjust:100%;font-variant-numeric:tabular-nums}
button,input,select{font:inherit;color:inherit}
button{cursor:pointer}
:focus-visible{outline:3px solid var(--teal);outline-offset:3px}
.num{font-variant-numeric:tabular-nums}


.app{flex:1;min-height:0;width:100%;max-width:440px;margin:0 auto;background:var(--surface);display:flex;flex-direction:column;padding-inline:16px;overflow-y:auto;overscroll-behavior:contain}
.bar{flex:none;margin-inline:-16px;background:var(--sunk);color:var(--ink-2);border-bottom:1px solid var(--line);padding:10px 16px;display:flex;align-items:center;gap:10px}
.bar h1{margin:0;font-family:var(--f-disp);font-size:19px;font-weight:700;letter-spacing:.04em;flex:1}
.bar .me-nm{font-size:16px;font-weight:700;color:var(--ink);white-space:nowrap}
.bar .ds{display:none}
@media (max-width:374px){.bar .dl{display:none}.bar .ds{display:inline}}
.bar .pill{font-size:15px;padding:1px 10px}
.bar .gogo{width:52px;height:30px;margin:-4px 0}
.bar .when{flex:1;justify-content:flex-end;display:flex;align-items:baseline;gap:8px;font-size:15px;font-weight:700;white-space:nowrap}
.bar h1{white-space:nowrap}
@media (max-width:360px){.bar{gap:8px}.bar h1{font-size:17px}.bar .when{font-size:13px;gap:6px}.bar .when b{font-size:21px}.bar .adm{padding:4px 8px}}
.bar .when b{font-size:24px;line-height:1;color:var(--ink)}
.bar .adm{background:var(--surface);color:var(--ink-2);border:1.5px solid var(--line);border-radius:10px;padding:4px 10px;font-weight:700;font-size:15px}
main{flex:1 0 auto;display:flex;flex-direction:column;gap:12px;padding-block:12px 16px}
/* ホーム画面：上（自分・階別）は固定、一覧だけが余った高さを使い、足りないときだけ中でスクロール。退勤はいちばん下 */
.app.home{overflow:hidden}
main.home{flex:1 1 auto;min-height:0;padding-bottom:0}
main.home > :not(.listwrap){flex-shrink:0}
.listwrap{flex:0 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;margin-inline:-16px;padding-inline:16px}

/* 自分 */
.now{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.now .date{font-size:17px;color:var(--ink-2)}
.now .clock{font-family:var(--f-disp);font-size:34px;font-weight:700;color:var(--teal);line-height:1}
.mystat{display:flex;align-items:center;gap:10px;flex-wrap:nowrap;min-height:40px}
.mystat .chip{flex:none}
.mystat .sm{font-size:16px;color:var(--ink-2);flex:1 1 8em;min-width:0}
.mystat .grow{flex:1}
.chip{border:1.5px solid var(--line);background:var(--surface);color:var(--ink-2);border-radius:999px;padding:5px 12px;font-size:14px;font-weight:700;min-height:36px}
.chip[aria-pressed="true"]{border-color:var(--teal);color:var(--teal);background:var(--teal-soft)}

.pill{display:inline-flex;align-items:center;gap:6px;border-radius:999px;padding:2px 12px;font-weight:700;font-size:18px;white-space:nowrap}
.pill.big{font-size:20px;padding:4px 14px}
.st-in{background:var(--in-soft);color:var(--in)}
.st-out{background:var(--out-soft);color:var(--out)}
.st-off{background:var(--off-soft);color:var(--off)}
.tag{font-size:14px;font-weight:700;border-radius:999px;padding:2px 10px;background:var(--serve);color:#fff;white-space:nowrap}
.chip.serve[aria-pressed="true"]{border-color:var(--serve);background:var(--serve);color:#fff}
.plc{background:none;border:0;padding:0;color:var(--link);text-decoration:underline;text-underline-offset:3px;font:inherit;font-weight:700;cursor:pointer}
/* 外出情報：理由（余れば…）｜🚃の枠（常に確保）｜区切り｜戻り（固定幅）。行ごとに列がそろう */
.oi{display:grid;grid-template-columns:minmax(0,1fr) 1.3em auto 5.4em;align-items:center;column-gap:4px;min-width:0;width:100%;font-size:15px;color:var(--ink)}
.oi .rs,.oi .plc{display:block;min-width:0;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:left;font-weight:700}
.oi .tr{text-align:center;font-size:14px;line-height:1}
.oi .sep{color:var(--ink-2);opacity:.45;font-weight:700}
.oi .bk{font-size:13px;color:var(--ink-2);white-space:nowrap}
.mystat .oi{flex:1 1 0;font-size:16px}
.mystat .oi .bk{font-size:14px}
.office .board li{grid-template-columns:4.2em 96px minmax(0,1fr)}
.office .oi{font-size:22px;grid-template-columns:minmax(0,1fr) 1.3em auto 5.4em}
.office .oi .bk{font-size:18px}
.office .board .gogo{width:96px;height:52px}
.opt{display:flex;gap:8px;align-items:center}
.opt input{flex:1;min-width:0;min-height:50px;border-radius:12px;border:2px solid var(--line);background:var(--surface);padding:6px 12px;font-size:18px}
.glab{grid-column:1/-1;font-size:14px;font-weight:700;color:var(--ink-2);margin-top:2px}

/* 社長：金属枠の赤い発射ボタン */
.launchwrap{display:flex;justify-content:center;padding-block:4px}
.launch{width:150px;height:150px;border-radius:50%;border:0;padding:12px;cursor:pointer;
  background:conic-gradient(from 200deg,#868b92,#f5f7f9,#979da4,#e9ecef,#7b8188,#f5f7f9,#868b92);
  box-shadow:0 10px 20px rgba(0,0,0,.35),inset 0 2px 3px rgba(255,255,255,.85),inset 0 -3px 6px rgba(0,0,0,.35)}
.launch span{display:flex;align-items:center;justify-content:center;width:100%;height:100%;border-radius:50%;
  background:radial-gradient(circle at 34% 28%,#ffb3ab 0,#ff3b2e 20%,#d0120a 55%,#7c0500 100%);
  color:#fff;font-weight:900;font-size:22px;line-height:1.2;text-align:center;text-shadow:0 2px 2px rgba(0,0,0,.45);
  box-shadow:inset 0 5px 9px rgba(255,255,255,.35),inset 0 -7px 12px rgba(0,0,0,.5),0 3px 0 #5a0000;transition:transform .08s}
.launch:active span{transform:translateY(3px) scale(.98);box-shadow:inset 0 2px 4px rgba(255,255,255,.25),inset 0 -2px 6px rgba(0,0,0,.55)}
.launch[disabled]{opacity:.7}

/* 社長が在社のときだけ：GOGOランプ風（動かさない） */
.gogo{height:40px;width:72px;flex:none;overflow:visible;margin:-6px 0}
.mystat .gogo{height:46px;width:82px}
.office .gogo{height:60px;width:108px}

/* 出勤・退勤の一口メモ（どこかを触ると消える） */
.cheer{position:fixed;left:50%;transform:translateX(-50%);top:calc(14px + env(safe-area-inset-top,0px));z-index:45;width:calc(100% - 32px);max-width:408px;
  background:var(--surface);border:2px solid var(--teal);border-radius:20px;padding:14px 16px;box-shadow:var(--shadow);display:flex;align-items:center;gap:12px;animation:pop .25s ease}
.cheer .em{font-size:40px;line-height:1;flex:none}
.cheer .tx{display:flex;flex-direction:column;gap:2px;min-width:0}
.cheer b{font-size:20px;line-height:1.35}
.cheer small{font-size:14px;color:var(--ink-2)}
@keyframes pop{from{transform:translate(-50%,-8px);opacity:0}to{transform:translate(-50%,0);opacity:1}}

.btn{display:flex;align-items:center;justify-content:center;gap:10px;width:100%;min-height:60px;border-radius:16px;border:0;font-size:22px;font-weight:700;padding:8px 16px;font-family:var(--f-body)}
.btn.primary{background:var(--teal);color:var(--teal-ink)}
/* 「戻りました」は押したあとの状態（在社）と同じ緑 */
.btn.in{background:var(--in);color:var(--surface)}
.btn.stack .now{font-size:15px;font-weight:700;opacity:1;margin-top:2px}
.subacts{display:flex;justify-content:flex-end;margin-top:-4px}
.btn.out{background:var(--out);color:var(--surface)}
.btn.soft{background:var(--teal-soft);color:var(--teal);border:2px solid var(--teal)}
.btn.plain{background:var(--sunk);color:var(--ink);border:2px solid var(--line);font-size:19px;min-height:54px}
.btn.small{min-height:50px;font-size:18px}
.btn.stack{flex-direction:column;gap:0;line-height:1.25}
.btn.stack small{font-size:15px;font-weight:400;opacity:.9}
.btn[disabled]{opacity:.55;cursor:wait}
.link{background:none;border:0;color:var(--teal);font-weight:700;text-decoration:underline;text-underline-offset:4px;padding:2px 4px;font-size:16px;align-self:center}

/* スワイプ */
.swipe{position:relative;height:66px;border-radius:33px;background:var(--teal-soft);border:2px solid var(--teal);overflow:hidden;touch-action:none;user-select:none;-webkit-user-select:none;margin-inline:6px}
/* 退勤だけは落ち着いた赤（エラーや接客中の赤とは分ける） */
.swipe.red{background:var(--leave-soft);border-color:var(--leave)}
.swipe.red .fill{background:var(--leave)}
.swipe.red .lbl{color:var(--leave)}
.swipe.red .knob,.swipe.red .hint{background:var(--leave);color:var(--surface)}
.btn.danger{background:var(--leave);color:var(--surface)}
.chip.undo{border-color:var(--danger);color:var(--danger);flex:none}
/* 退勤：スクロールしなくても見える画面のいちばん下に留める（内容が短ければ一覧の下） */
.bottomact{flex:none;margin-top:auto;margin-inline:-16px;padding:12px 22px 14px;background:var(--surface)}
.swipe .fill{position:absolute;inset:0 auto 0 0;width:calc(62px + var(--p,0) * (100% - 62px));background:var(--teal);opacity:.22;border-radius:33px}
.swipe .lbl{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-left:60px;font-size:20px;font-weight:700;color:var(--teal);pointer-events:none}
.swipe .lbl .arrows{letter-spacing:-2px;margin-left:8px;animation:nudge 1.6s ease-in-out infinite}
.swipe .knob{position:absolute;top:5px;left:5px;width:52px;height:52px;border-radius:50%;background:var(--teal);color:var(--teal-ink);border:0;font-size:15px;font-weight:700;display:flex;align-items:center;justify-content:center;touch-action:none;box-shadow:var(--shadow);transition:transform .25s ease}
.swipe.drag .knob{transition:none}
.swipe .hint{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:var(--teal);color:var(--teal-ink);font-weight:700;font-size:17px}
.swipe.showhint .hint{display:flex}
@keyframes nudge{0%,100%{transform:translateX(0)}50%{transform:translateX(6px)}}

.notice{border-radius:14px;padding:10px 14px;display:flex;flex-direction:column;gap:8px;font-size:16px}
.notice.err{background:var(--danger-soft);color:var(--danger);border:2px solid var(--danger)}
.notice.warn{background:var(--out-soft);color:var(--ink);border:2px solid var(--out)}
.notice.undo{background:var(--sunk);border:1.5px dashed var(--line);flex-direction:row;align-items:center;gap:10px;padding:8px 12px}
.notice.undo .grow{flex:1;min-width:0;color:var(--ink-2);font-size:15px}
.notice.undo button{border:2px solid var(--danger);color:var(--danger);background:var(--surface);border-radius:12px;padding:6px 12px;font-weight:700;font-size:16px;white-space:nowrap}
.row-btns{display:flex;flex-wrap:wrap;gap:8px}
.row-btns .btn{flex:1 1 30%;min-height:48px;font-size:18px}

/* 1階・2階 */
.floors{display:grid;grid-template-columns:1fr 1fr;border:2px solid var(--line);border-radius:14px;overflow:hidden}
.floors > div{padding:6px 12px;display:flex;align-items:baseline;gap:8px;font-weight:700;font-size:18px;white-space:nowrap}
.floors > div + div{border-left:2px solid var(--line)}
.floors .fn{font-size:15px;color:var(--ink-2)}
.floors .empty{background:var(--danger-soft);color:var(--danger)}

/* 一覧 */
.board{list-style:none;margin:0;padding:0;border-top:2px solid var(--line)}
.board li{display:grid;grid-template-columns:3.4em 64px minmax(0,1fr);column-gap:8px;align-items:center;min-height:50px;padding:6px 2px;border-bottom:1px solid var(--line)}
.board li > :nth-child(2){justify-self:start}
.board li > :nth-child(3){justify-self:stretch;min-width:0}
.board li > .tag{justify-self:start}
.board .gogo{width:64px;height:36px}
.board li.mine{background:var(--sunk);margin-inline:-8px;padding-inline:10px}
.board .nm{font-weight:700;font-size:20px;white-space:nowrap}
.board .sm{font-size:15px;color:var(--ink-2);min-width:0;flex:1 1 8em}
.board .sm.wrap{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.office .board .sm.wrap{font-size:18px}
/* 不在の人は行ごと薄く（社長のひとことは読める濃さに） */
.board li.off > *{opacity:.45}
.board li.off > .sm.wrap{opacity:.7}
/* 一覧の行は押すと、その人の在席を代わりに変えられる */
.board li[data-a]{cursor:pointer;-webkit-tap-highlight-color:transparent}
.board li[data-a]:active{background:var(--teal-soft)}
.board li.flash{animation:flash 2.2s ease}
@keyframes flash{0%{background:var(--teal-soft)}100%{background:transparent}}

/* 管理 */
.card{border:2px solid var(--line);border-radius:16px;padding:14px;display:flex;flex-direction:column;gap:10px}
.sec h2{font-family:var(--f-disp);font-size:20px;margin:0 0 8px;display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.sec h2 span{font-family:var(--f-body);font-size:14px;color:var(--ink-2);font-weight:400}
.muted{color:var(--ink-2);font-size:15px}
.field{display:flex;flex-direction:column;gap:6px}
.field label{font-weight:700;font-size:17px}
.field input{min-height:54px;border-radius:12px;border:2px solid var(--line);background:var(--surface);padding:8px 12px;font-size:20px;width:100%}
.seg{display:flex;flex-wrap:wrap;gap:6px}
.seg button{flex:1 1 auto;min-height:48px;border-radius:12px;border:2px solid var(--line);background:var(--surface);font-weight:700;font-size:17px;padding:4px 10px}
.seg.eq{display:grid;grid-template-columns:repeat(5,minmax(0,1fr))}
.seg.eq button{padding:4px 2px;font-size:16px}
.seg button[aria-pressed="true"]{background:var(--teal);color:var(--teal-ink);border-color:var(--teal)}
.list{list-style:none;margin:0;padding:0}
.list li{display:flex;align-items:center;gap:10px;padding:10px 2px;border-top:1px solid var(--line)}
.list li:first-child{border-top:0}
.list .grow{flex:1;min-width:0}
.mk{border-radius:999px;padding:1px 8px;font-size:13px;font-weight:700;white-space:nowrap}
.mk.self{background:var(--out-soft);color:var(--out)}
.mk.fix{background:var(--teal-soft);color:var(--teal)}
.mini{border:2px solid var(--teal);color:var(--teal);background:var(--surface);border-radius:12px;padding:6px 10px;font-weight:700;font-size:15px;white-space:nowrap}
.mini.dg{border-color:var(--danger);color:var(--danger)}
.list li.pin{background:var(--teal-soft)}
pre.csv{margin:0;background:var(--sunk);border:1px solid var(--line);border-radius:12px;padding:12px;font-size:13px;line-height:1.5;max-height:200px;overflow:auto;white-space:pre}

/* シート */
.back{position:fixed;inset:0;background:rgba(5,25,27,.5);z-index:20;display:flex;align-items:flex-end;justify-content:center}
.sheet{width:100%;max-width:440px;background:var(--surface);border-radius:24px 24px 0 0;padding:18px 16px calc(18px + env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;gap:10px;max-height:92dvh;overflow:auto}
.sheet h2{margin:0;font-family:var(--f-disp);font-size:22px}
.sheet .step .note{font-size:13px;white-space:nowrap}
.sheet .step{font-size:15px;color:var(--ink-2)}
.choices{display:grid;grid-template-columns:1fr;gap:8px}
.choices.two{grid-template-columns:1fr 1fr}
.choices .btn{min-height:60px;font-size:20px}
.olist{display:flex;flex-direction:column;gap:8px}
.orow{display:flex;align-items:center;gap:14px;width:100%;min-height:64px;border:2px solid var(--line);background:var(--sunk);border-radius:16px;padding:8px 14px;text-align:left;color:var(--ink)}
.orow:active{background:var(--teal-soft);border-color:var(--teal)}
.orow .oic{width:28px;height:28px;flex:none;color:var(--teal)}
.orow .ot{display:flex;flex-direction:column;min-width:0}
.orow b{font-size:20px;line-height:1.3}
.orow small{font-size:14px;color:var(--ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.times{display:grid;grid-template-columns:1fr 1fr;gap:10px}

/* 初回設定 */
.setup{display:flex;flex-direction:column;gap:16px;padding-block:24px}
.setup h2{font-family:var(--f-disp);font-size:24px;margin:0;white-space:nowrap}
.dots{display:flex;justify-content:center;gap:14px}
.dots span{width:48px;height:58px;border-radius:14px;border:2px solid var(--line);display:flex;align-items:center;justify-content:center;font-size:30px;font-weight:700}
.dots span.f{border-color:var(--teal);background:var(--teal-soft);color:var(--teal)}
.dots.bad{animation:shake .4s}
@keyframes shake{25%{transform:translateX(-8px)}75%{transform:translateX(8px)}}
.pad{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.pad button{min-height:64px;border-radius:16px;border:2px solid var(--line);background:var(--sunk);font-size:28px;font-weight:700;font-family:var(--f-disp)}
.names{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.names .btn{font-size:24px;min-height:72px}

.toast{position:fixed;left:50%;transform:translateX(-50%);top:calc(12px + env(safe-area-inset-top,0px));z-index:40;width:calc(100% - 32px);max-width:408px;background:var(--ok);color:var(--surface);border-radius:16px;padding:14px 16px;font-weight:700;font-size:19px;box-shadow:var(--shadow);display:flex;align-items:center;gap:10px}

/* 事務所掲示モード */
.office{position:fixed;inset:0;z-index:30;background:var(--surface);overflow:auto;padding:20px max(16px,4vw)}
.office .top{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap;margin-bottom:14px}
.office .top .clock{font-family:var(--f-disp);font-size:clamp(40px,7vw,64px);color:var(--teal);line-height:1}
.office .wrap{max-width:720px;display:flex;flex-direction:column;gap:14px}
.office .board .nm{font-size:30px}
.office .board li{min-height:72px}
.office .board .pill{font-size:24px}
.office .board .sm{font-size:20px}
.office .floors > div{font-size:24px;padding:12px 16px}

@media (prefers-reduced-motion: reduce){*{animation:none!important;transition:none!important}}

/* 読み込み中・オフライン */
.loading{margin:auto;color:var(--ink-2);font-size:18px;padding:40px 0;text-align:center}
.offline{flex:none;background:var(--out-soft);color:var(--ink);text-align:center;font-size:14px;padding:4px 8px}
