/* 現場段取り帳  —  one-hand phone layout, fixed bottom tabs, 44px+ touch targets.
   System fonts only: nothing is fetched from outside, so the app works offline. */
:root{
  --bg:#eef0f2; --surface:#ffffff; --surface2:#f4f6f8; --ink:#17202b; --muted:#566170; --line:#cbd3dc;
  --primary:#1f3a5f; --on-primary:#ffffff;
  --ok:#14713f; --ng:#b92b17; --warn:#8a5300; --info:#1c5a9e;
  --ok-bg:#dff0e5; --ng-bg:#fbe3de; --warn-bg:#faecd0; --info-bg:#dfeaf7;
  --shade:rgba(12,20,30,.55);
  --font:-apple-system,BlinkMacSystemFont,"Hiragino Sans","Hiragino Kaku Gothic ProN","Yu Gothic","Meiryo","Noto Sans JP",sans-serif;
  color-scheme:light;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#0e1319; --surface:#171e27; --surface2:#1e2732; --ink:#e6ebf1; --muted:#9aa6b4; --line:#2f3a47;
    --primary:#7fb0e6; --on-primary:#0b1622;
    --ok:#5cc68f; --ng:#ff8672; --warn:#f0b450; --info:#8cc0f5;
    --ok-bg:#16301f; --ng-bg:#3a1b15; --warn-bg:#352a12; --info-bg:#15283d;
    --shade:rgba(0,0,0,.66);
    color-scheme:dark;
  }
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:16px;line-height:1.5;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;overscroll-behavior-y:none}
button,input,select,textarea{font:inherit;color:inherit}
h1,h2,h3,p{margin:0}
h2{font-size:1.125rem;font-weight:800}
h3{font-size:.8125rem;font-weight:700;color:var(--muted);letter-spacing:.04em}
img{max-width:100%}
[hidden]{display:none!important}
.num{font-variant-numeric:tabular-nums}
.vh{position:absolute;width:1px;height:1px;opacity:0;overflow:hidden;pointer-events:none}
:focus-visible{outline:3px solid var(--info);outline-offset:2px}

.app{max-width:640px;margin:0 auto;min-height:100%;display:flex;flex-direction:column;padding-top:env(safe-area-inset-top,0px)}
.top{position:sticky;top:env(safe-area-inset-top,0px);z-index:5;display:flex;gap:4px;align-items:center;padding:6px 8px 6px 16px;background:var(--bg);border-bottom:1px solid var(--line)}
.site{flex:1;min-width:0;display:flex;align-items:center;gap:8px;min-height:44px;padding:0;border:0;background:none;text-align:left;cursor:pointer}
.site b{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:800;font-size:1.0625rem}
.site i{flex:none;width:0;height:0;border:5px solid transparent;border-top-color:var(--muted);margin-top:5px}
.hbtn{flex:none;width:44px;height:44px;border:0;background:none;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;color:var(--ink)}
.hbtn svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round}
.banner{display:flex;gap:10px;align-items:center;justify-content:space-between;padding:8px 16px;background:var(--info-bg);color:var(--info);font-size:.875rem;font-weight:700}
.banner button{min-height:36px;padding:0 12px;border-radius:8px;border:1.5px solid var(--info);background:none;color:var(--info);font-weight:700}
main{flex:1;display:flex;flex-direction:column;gap:14px;padding:14px 16px;padding-bottom:calc(84px + env(safe-area-inset-bottom,0px));min-width:0}

.tabs{position:fixed;left:0;right:0;bottom:0;z-index:6;background:var(--surface);border-top:1px solid var(--line);padding-bottom:env(safe-area-inset-bottom,0px)}
.tabs div{max-width:640px;margin:0 auto;display:grid;grid-template-columns:repeat(6,1fr)}
.tabs button{position:relative;display:flex;flex-direction:column;align-items:center;gap:1px;min-height:56px;padding:6px 0 4px;border:0;background:none;color:var(--muted);font-size:.6875rem;font-weight:700;cursor:pointer}
.tabs svg{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linejoin:round;stroke-linecap:round}
.tabs button[aria-current="page"]{color:var(--primary)}
.tabs button[aria-current="page"] svg{stroke-width:2.3}
.tabs .dot{position:absolute;top:4px;left:calc(50% + 8px);min-width:17px;height:17px;padding:0 4px;border-radius:9px;background:var(--ng);color:#fff;font-size:.625rem;line-height:17px;text-align:center}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:46px;padding:0 14px;border:1.5px solid var(--line);border-radius:10px;background:var(--surface);font-weight:700;cursor:pointer;text-align:center;line-height:1.25}
.btn.pri{background:var(--primary);border-color:var(--primary);color:var(--on-primary)}
.btn.danger{color:var(--ng);border-color:var(--ng)}
.btn.sm{min-height:44px;padding:0 12px;font-size:.875rem}
.btn[disabled]{opacity:.45;cursor:default}
.btn[aria-pressed="true"]{background:var(--primary);border-color:var(--primary);color:var(--on-primary)}
.btns{display:flex;gap:8px;flex-wrap:wrap}
.btns>*{flex:1 1 0;min-width:0}
.btns>.fit{flex:0 0 auto}
.link{border:0;background:none;padding:8px 0;color:var(--primary);font-weight:700;text-decoration:underline;cursor:pointer;min-height:44px;text-align:left}

.form{display:flex;flex-direction:column;gap:12px;min-width:0}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.row3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}
.field{display:flex;flex-direction:column;gap:4px;min-width:0}
.field>span,.flabel{font-size:.75rem;font-weight:700;color:var(--muted);letter-spacing:.03em}
.field em{font-style:normal;color:var(--ng);margin-left:6px;font-size:.6875rem}
.field small{color:var(--muted);font-size:.75rem}
input[type=text],input[type=date],input[type=time],input[type=search],input[type=number],select,textarea{width:100%;min-width:0;min-height:46px;padding:8px 10px;border:1.5px solid var(--line);border-radius:8px;background:var(--surface);font-size:16px;-webkit-appearance:none;appearance:none}
select{background-image:linear-gradient(45deg,transparent 50%,var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%,transparent 50%);background-position:calc(100% - 17px) 20px,calc(100% - 12px) 20px;background-size:5px 5px;background-repeat:no-repeat;padding-right:28px}
textarea{min-height:76px;resize:vertical;line-height:1.45}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--primary)}
input.bad,select.bad,textarea.bad{border-color:var(--ng);background:var(--ng-bg)}
.seg{display:flex;border:1.5px solid var(--line);border-radius:8px;overflow:hidden;background:var(--surface)}
.seg button{flex:1;min-width:0;min-height:44px;padding:0 4px;border:0;border-left:1px solid var(--line);background:none;font-weight:700;font-size:.8125rem;cursor:pointer;line-height:1.2}
.seg button:first-child{border-left:0}
.seg button[aria-pressed="true"]{background:var(--primary);color:var(--on-primary)}
details.more{border:1.5px solid var(--line);border-radius:8px;background:var(--surface2)}
details.more>summary{min-height:44px;padding:10px 12px;font-weight:700;font-size:.875rem;cursor:pointer}
details.more>.form{padding:0 12px 12px}
details.more>.filters{padding:0 10px 10px}
details.more>summary span{font-weight:700;color:var(--info);font-size:.8125rem}
.chk{display:flex;align-items:center;gap:8px;min-height:44px;font-size:.875rem;font-weight:700}
.chk input{width:22px;height:22px;accent-color:var(--primary);flex:none}
.note{font-size:.8125rem;color:var(--muted)}
.warnbox{padding:10px 12px;border:1.5px solid var(--warn);border-radius:8px;background:var(--warn-bg);color:var(--warn);font-size:.875rem;font-weight:700}
.ngbox{padding:10px 12px;border:1.5px solid var(--ng);border-radius:8px;background:var(--ng-bg);color:var(--ng);font-size:.875rem;font-weight:700}
.infobox{padding:10px 12px;border:1.5px solid var(--line);border-radius:8px;background:var(--surface2);font-size:.875rem}

/* tags: every state has a glyph and words, never colour alone */
.tag{display:inline-flex;align-items:center;gap:3px;padding:1px 8px;border-radius:11px;font-size:.75rem;font-weight:700;white-space:nowrap;border:1px solid var(--line);background:var(--surface2);color:var(--muted)}
.tag i{font-style:normal;font-weight:900}
.tag.over{background:var(--ng-bg);color:var(--ng);border-color:var(--ng)}
.tag.today,.tag.warn,.tag.re{background:var(--warn-bg);color:var(--warn);border-color:var(--warn)}
.tag.wait,.tag.info{background:var(--info-bg);color:var(--info);border-color:var(--info)}
.tag.ok{background:var(--ok-bg);color:var(--ok);border-color:var(--ok)}
.tags{display:flex;gap:4px;flex-wrap:wrap}

/* lists */
.tool{display:flex;flex-direction:column;gap:8px}
.filters{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.filters select{min-height:44px;font-size:.875rem}
.count{display:flex;justify-content:space-between;align-items:baseline;font-size:.8125rem;color:var(--muted);font-weight:700}
.list{display:flex;flex-direction:column;border-top:1px solid var(--line)}
.grp{padding:10px 0 4px;font-size:.8125rem;font-weight:800;color:var(--muted);border-bottom:1px solid var(--line)}
.item{display:grid;grid-template-columns:auto 1fr;gap:2px 10px;align-items:start;padding:11px 0;border:0;border-bottom:1px solid var(--line);background:none;text-align:left;cursor:pointer;min-width:0;width:100%;min-height:48px}
.item .lead{grid-row:span 2;min-width:44px;max-width:6.5em;overflow-wrap:anywhere;font-weight:800;font-size:.9375rem;line-height:1.3;font-variant-numeric:tabular-nums}
.item .lead small{display:block;font-weight:700;color:var(--muted);font-size:.75rem}
.item .tx{min-width:0;display:flex;flex-direction:column;gap:2px}
.item .tx b{font-weight:700;overflow-wrap:anywhere}
.item .tx small{color:var(--muted);font-size:.8125rem;overflow-wrap:anywhere}
.item .tags{grid-column:2}
.empty{padding:26px 8px;text-align:center;color:var(--muted);font-size:.9375rem}
.empty b{display:block;color:var(--ink);font-size:1.0625rem;font-weight:800;margin-bottom:4px}

/* home */
.sec{display:flex;flex-direction:column;border:1.5px solid var(--line);border-radius:10px;background:var(--surface);overflow:hidden}
.sec>h2{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 12px;font-size:.9375rem;background:var(--surface2);border-bottom:1px solid var(--line)}
.sec>h2 span{font-size:.75rem;color:var(--muted);font-weight:700}
.sec .item{padding:10px 12px}
.sec .item:last-child{border-bottom:0}
.sec .none{padding:10px 12px;color:var(--muted);font-size:.875rem}
.kpis{display:grid;grid-template-columns:repeat(3,1fr);border-bottom:1px solid var(--line)}
.kpis.k2{grid-template-columns:repeat(2,1fr)}
.kpis.k4{grid-template-columns:repeat(4,1fr)}
.kpi{display:flex;flex-direction:column;align-items:flex-start;gap:0;padding:8px 10px;border:0;border-left:1px solid var(--line);background:none;text-align:left;cursor:pointer;min-height:56px}
.kpi:first-child{border-left:0}
.kpi b{font-size:1.375rem;font-weight:800;line-height:1.1;font-variant-numeric:tabular-nums}
.kpi span{font-size:.6875rem;font-weight:700;color:var(--muted);line-height:1.25}
.kpi.hot b{color:var(--ng)}
.kpi.hot span{color:var(--ng)}
.kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 12px;padding:10px 12px;font-size:.875rem;margin:0}
.kv dt{color:var(--muted);font-weight:700;white-space:nowrap}
.kv dd{margin:0;overflow-wrap:anywhere}

/* attachments */
.strip{display:flex;gap:6px;overflow-x:auto;padding-bottom:2px;min-height:20px}
.th{position:relative;flex:none;width:76px;height:76px;padding:0;border:1px solid var(--line);background:var(--surface2);overflow:hidden;border-radius:4px;cursor:pointer}
.th img{display:block;width:100%;height:100%;object-fit:cover}
.th .pg{position:absolute;left:0;bottom:0;padding:0 5px;background:var(--shade);color:#fff;font-size:.625rem;font-weight:700}
.th .x{position:absolute;top:0;right:0;width:26px;height:26px;background:var(--shade);color:#fff;font-weight:900;font-size:.875rem;line-height:26px;text-align:center}
.th[aria-pressed="true"]{outline:4px solid var(--info);outline-offset:-4px}
.grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}
.grid .th{width:auto;height:auto;aspect-ratio:1}
.cmp{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.cmp figure{margin:0;display:flex;flex-direction:column;gap:4px;min-width:0}
.cmp figcaption{font-size:.75rem;font-weight:700;color:var(--muted)}
.cmp img{width:100%;aspect-ratio:4/3;object-fit:cover;border:1px solid var(--line);background:var(--surface2);border-radius:4px}
.chips{display:flex;flex-direction:column;gap:6px}
.chip{display:flex;align-items:center;gap:6px;min-height:44px;padding:4px 4px 4px 10px;border:1.5px solid var(--line);border-radius:8px;background:var(--surface);font-size:.875rem}
.chip span{flex:1;min-width:0;overflow-wrap:anywhere}
.chip button{flex:none;min-width:44px;height:44px;padding:0 6px;border:0;background:none;font-weight:900;cursor:pointer;color:var(--muted)}
.chip.gone{border-style:dashed;color:var(--muted)}

/* sub-items inside a sheet */
.sub{display:flex;flex-direction:column;border-top:1px solid var(--line)}
.sub .item{padding:10px 0}
.hist{display:flex;flex-direction:column;gap:6px;font-size:.8125rem}
.hist div{padding:6px 10px;border-left:3px solid var(--line);background:var(--surface2)}
.hist b{font-variant-numeric:tabular-nums}
.money{display:grid;grid-template-columns:1fr auto;gap:2px 12px;padding:10px 12px;font-size:.875rem}
.money dt{color:var(--muted);font-weight:700}
.money dd{margin:0;text-align:right;font-weight:800;font-variant-numeric:tabular-nums}
.money small{display:block;font-weight:500;color:var(--muted);font-size:.75rem}

/* day timeline */
.daybar{display:flex;gap:6px;align-items:center}
.daybar input{flex:1}
.tl{border:1.5px solid var(--line);border-radius:8px;background:var(--surface);overflow-x:auto}
.tl-in{min-width:520px;padding:6px 8px 8px}
.tl-row{display:grid;grid-template-columns:86px 1fr;align-items:center;gap:6px;min-height:30px}
.tl-row>span{font-size:.6875rem;font-weight:700;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tl{--n:14}
.tl-lane{position:relative;height:calc(24px*var(--t,1));background:repeating-linear-gradient(90deg,var(--surface2) 0,var(--surface2) calc(100%/var(--n) - 1px),var(--line) calc(100%/var(--n) - 1px),var(--line) calc(100%/var(--n)))}
.tl-bar{position:absolute;top:calc(2px + 24px*var(--k,0));height:20px;border-radius:3px;background:var(--info);color:#fff;font-size:.625rem;font-weight:700;line-height:20px;padding:0 3px;overflow:hidden;white-space:nowrap;border:0}
.tl-bar.tent{background:repeating-linear-gradient(135deg,var(--info) 0 6px,#6f9bcb 6px 12px)}
.tl-bar.clash{background:var(--ng)}
.tl-hrs{display:grid;grid-template-columns:86px 1fr;gap:6px}
.tl-hrs div{display:grid;grid-template-columns:repeat(var(--n),1fr);font-size:.625rem;color:var(--muted);font-variant-numeric:tabular-nums}

/* sheets */
.sheet{position:fixed;inset:0;z-index:20;background:var(--bg);display:flex;flex-direction:column}
.sheet>header{flex:none;display:flex;align-items:center;gap:8px;padding:calc(env(safe-area-inset-top,0px) + 6px) 8px 6px 16px;border-bottom:1px solid var(--line);background:var(--bg)}
.sheet>header h2{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sheet>header button{min-height:44px;padding:0 12px;border:0;background:none;font-weight:700;color:var(--primary);cursor:pointer}
.sheet>.body{flex:1;overflow:auto;-webkit-overflow-scrolling:touch}
.sheet>.body>div{max-width:640px;margin:0 auto;padding:14px 16px 24px;display:flex;flex-direction:column;gap:14px;min-width:0}
.sheet>footer{flex:none;padding:8px 16px calc(env(safe-area-inset-bottom,0px) + 8px);border-top:1px solid var(--line);background:var(--surface)}
.sheet>footer .btns{max-width:608px;margin:0 auto}
.viewer{flex:1;overflow:auto;background:#20262e;-webkit-overflow-scrolling:touch;touch-action:pan-x pan-y}
.viewer canvas,.viewer img{display:block;max-width:none;margin:0 auto;background:#fff}
.annwrap{position:relative;margin:0 auto;background:#fff}
.viewer .annwrap img{display:block;width:100%;height:100%}
.viewer .annwrap canvas{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;background:transparent}
.annbox canvas{display:block;width:100%;height:auto;touch-action:none;border:1px solid var(--line);background:#fff}
.vbar{flex:none;display:flex;gap:6px;align-items:center;justify-content:center;padding:6px 8px calc(env(safe-area-inset-bottom,0px) + 6px);background:var(--surface);border-top:1px solid var(--line)}
.vbar button{min-width:46px;min-height:46px;padding:0 6px;border:1.5px solid var(--line);border-radius:8px;background:var(--surface);font-weight:800}
.vbar span{min-width:76px;text-align:center;font-weight:700;font-variant-numeric:tabular-nums;font-size:.875rem}
.ask{position:fixed;inset:0;z-index:40;background:var(--shade);display:flex;align-items:flex-end;justify-content:center}
.ask>div{width:100%;max-width:640px;max-height:86vh;overflow:auto;background:var(--surface);border-radius:16px 16px 0 0;padding:20px 16px calc(env(safe-area-inset-bottom,0px) + 16px);display:flex;flex-direction:column;gap:12px}
.ask p{font-weight:700;overflow-wrap:anywhere}
.ask small{color:var(--muted);font-weight:500;white-space:pre-line}
.ask .opts{display:flex;flex-direction:column;gap:8px}
#toast{position:fixed;left:16px;right:16px;bottom:calc(70px + env(safe-area-inset-bottom,0px));z-index:50;display:flex;justify-content:center;pointer-events:none}
#toast div{pointer-events:auto;display:flex;gap:12px;align-items:center;max-width:520px;padding:10px 16px;border-radius:10px;background:var(--ink);color:var(--bg);font-weight:700;font-size:.9375rem;box-shadow:0 4px 16px var(--shade)}
#toast div.err{background:var(--ng);color:#fff}
#toast button{border:0;background:none;color:inherit;font-weight:800;text-decoration:underline;min-height:36px;padding:0 4px}
#busy{position:fixed;inset:0;z-index:60;background:var(--shade);display:flex;align-items:center;justify-content:center;padding:24px}
#busy div{background:var(--surface);border-radius:12px;padding:20px 24px;font-weight:700;text-align:center;min-width:220px}
#busy small{display:block;margin-top:4px;color:var(--muted);font-weight:500;font-variant-numeric:tabular-nums}
.meter{height:8px;border-radius:4px;background:var(--surface2);border:1px solid var(--line);overflow:hidden}
.meter i{display:block;height:100%;background:var(--primary)}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
