/* ゲンバすけっと アプリ画面（iOS の作法に合わせる） */
:root {
  --bg: #f2f2f7;
  --cell: #ffffff;
  --label: #1c1c1e;
  --label2: #5d5d63;
  --label3: #8e8e93;
  --sep: rgba(60, 60, 67, 0.22);
  --tint: #1d6b46;
  --tint-press: #155636;
  --board: #23412f;
  --chalk: #f4f4ef;
  --yellow: #f2c200;
  --red: #e5372b;
  --orange: #f08a00;
  --fill: rgba(118, 118, 128, 0.12);
  --bar: rgba(249, 249, 249, 0.92);
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #000000;
    --cell: #1c1c1e;
    --label: #f2f2f7;
    --label2: #b4b4ba;
    --label3: #8e8e93;
    --sep: rgba(84, 84, 88, 0.6);
    --tint: #38b27a;
    --tint-press: #2c9364;
    --fill: rgba(118, 118, 128, 0.24);
    --bar: rgba(22, 22, 24, 0.92);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #000000; --cell: #1c1c1e; --label: #f2f2f7; --label2: #b4b4ba; --label3: #8e8e93;
  --sep: rgba(84, 84, 88, 0.6); --tint: #38b27a; --tint-press: #2c9364; --fill: rgba(118, 118, 128, 0.24);
  --bar: rgba(22, 22, 24, 0.92); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'BIZ UDPGothic', 'Noto Sans JP', 'Yu Gothic UI', sans-serif;
  font-size: 17px;
  line-height: 1.45;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--tint); }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* 上の帯と大きな見出し */
.nav {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + 6px) 16px 6px;
  background: var(--bar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  display: flex; align-items: center; gap: 8px; min-height: 52px;
}
.nav .back { border: 0; background: none; color: var(--tint); font-size: 17px; padding: 8px 4px; min-height: 44px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.nav .back::before { content: ''; width: 11px; height: 11px; border-left: 3px solid currentColor; border-bottom: 3px solid currentColor; transform: rotate(45deg); margin-right: 4px; border-radius: 1px; }
.nav .title-s { flex: 1; text-align: center; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav .act { border: 0; background: none; color: var(--tint); font-size: 17px; font-weight: 600; min-height: 44px; min-width: 44px; padding: 0 4px; cursor: pointer; }
.nav .spacer { flex: 1; }
.large-title { font-size: 32px; font-weight: 700; letter-spacing: 0.01em; margin: 4px 16px 10px; line-height: 1.2; }
.sub { color: var(--label2); font-size: 15px; margin: -4px 16px 14px; }

main { padding-bottom: calc(96px + var(--safe-b)); max-width: 760px; margin: 0 auto; }

/* まとまりの一覧（グループ） */
.group-h { color: var(--label2); font-size: 13px; margin: 22px 32px 6px; }
.group-f { color: var(--label2); font-size: 13px; margin: 6px 32px 0; }
.group { background: var(--cell); border-radius: var(--radius); margin: 0 16px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 16px;
  position: relative; background: var(--cell); width: 100%; border: 0; text-align: left; cursor: pointer;
}
.row + .row::before, .swipe + .swipe .row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--sep); transform: scaleY(0.6); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .d { font-size: 14px; color: var(--label2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .v { color: var(--label2); font-size: 16px; flex-shrink: 0; }
.row.link::after { content: ''; width: 8px; height: 8px; border-right: 2px solid var(--label3); border-top: 2px solid var(--label3); transform: rotate(45deg); flex-shrink: 0; margin-left: 2px; }
.row .ic { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: #fff; font-size: 16px; flex-shrink: 0; }
.row .thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--fill); flex-shrink: 0; }
.row.danger { color: var(--red); }
.row.center { justify-content: center; color: var(--tint); }
.pin { color: var(--orange); font-size: 13px; margin-right: 4px; }

/* 左にスワイプで出るボタン（iOS のメールと同じ。削除は赤で一番右） */
.swipe { position: relative; overflow: hidden; }
.swipe .acts { position: absolute; top: 0; right: 0; bottom: 0; display: flex; }
.swipe .acts button { border: 0; color: #fff; font-size: 15px; font-weight: 600; width: 78px; cursor: pointer; }
.swipe .acts .a-pin { background: var(--orange); }
.swipe .acts .a-edit { background: #8e8e93; }
.swipe .acts .a-del { background: var(--red); }
.swipe .row { transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); z-index: 1; }
.swipe.dragging .row { transition: none; }

/* 入力欄 */
.field { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 16px; position: relative; }
.field + .field::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--sep); transform: scaleY(0.6); }
.field label { width: 92px; flex-shrink: 0; font-size: 16px; }
.field input, .field select, .field textarea { flex: 1; min-width: 0; border: 0; background: none; font-size: 17px; padding: 8px 0; outline: none; }
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field.col { flex-direction: column; align-items: stretch; gap: 4px; padding: 10px 16px; }
.field.col label { width: auto; color: var(--label2); font-size: 14px; }
input::placeholder, textarea::placeholder { color: var(--label3); }

/* ボタン */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; border-radius: 12px; border: 0; padding: 0 20px;
  background: var(--tint); color: #fff; font-size: 17px; font-weight: 600; cursor: pointer; width: 100%;
  transition: transform 0.12s, background 0.15s;
}
.btn:active { transform: scale(0.98); background: var(--tint-press); }
.btn.secondary { background: var(--fill); color: var(--tint); }
.btn.danger { background: var(--fill); color: var(--red); }
.btn:disabled { opacity: 0.5; }
.pad { padding: 0 16px; }
.stack > * + * { margin-top: 10px; }

/* 写真を送る画面 */
.shoot {
  margin: 4px 16px 0; border-radius: 18px; background: var(--board); color: var(--chalk);
  padding: 18px; position: relative; overflow: hidden;
}
.shoot .where { font-size: 14px; opacity: 0.8; }
.shoot .site-btn { border: 0; background: none; color: var(--chalk); font-size: 22px; font-weight: 700; padding: 2px 0; display: flex; align-items: center; gap: 8px; cursor: pointer; min-height: 44px; text-align: left; }
.shoot .site-btn::after { content: ''; width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-3px); }
.camera {
  margin-top: 14px; display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 64px; border-radius: 14px; background: var(--yellow); color: #1a1a1a; font-size: 19px; font-weight: 700;
  border: 0; width: 100%; cursor: pointer; transition: transform 0.12s;
}
.camera:active { transform: scale(0.98); }
.camera svg { width: 26px; height: 26px; }
.shoot .alt { display: flex; gap: 10px; margin-top: 10px; }
.shoot .alt button { flex: 1; min-height: 44px; border-radius: 12px; border: 1.5px solid rgba(244, 244, 239, 0.4); background: none; color: var(--chalk); font-size: 15px; cursor: pointer; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; min-height: 36px; padding: 0 14px; border-radius: 18px; border: 0; background: var(--cell); color: var(--label); font-size: 15px; cursor: pointer; }
.chip[aria-pressed='true'] { background: var(--tint); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin: 0 16px; border-radius: var(--radius); overflow: hidden; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(5, 1fr); } }
.grid button { border: 0; padding: 0; aspect-ratio: 1; background: var(--fill); position: relative; cursor: pointer; overflow: hidden; }
.grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .tag { position: absolute; left: 4px; bottom: 4px; background: rgba(0, 0, 0, 0.62); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; max-width: calc(100% - 8px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.date-h { font-size: 15px; font-weight: 600; margin: 18px 20px 8px; color: var(--label2); }

.empty { text-align: center; color: var(--label2); padding: 36px 24px; }
.empty .big { font-size: 44px; }
.empty p { margin: 8px 0 16px; }

/* 進み具合 */
.progress { position: fixed; left: 16px; right: 16px; bottom: calc(92px + var(--safe-b)); z-index: 40; background: var(--label); color: var(--bg); border-radius: 14px; padding: 12px 16px; font-size: 15px; display: flex; align-items: center; gap: 10px; }
.progress .bar { flex: 1; height: 6px; background: rgba(127, 127, 127, 0.4); border-radius: 3px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--yellow); width: 0; transition: width 0.2s; }
.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); z-index: 60; background: rgba(28, 28, 30, 0.92); color: #fff; padding: 11px 18px; border-radius: 22px; font-size: 15px; max-width: calc(100% - 32px); animation: toast 2.6s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 8px); } 8%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* 下のタブ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep); display: flex; padding-bottom: var(--safe-b);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px; color: var(--label3); text-decoration: none; font-size: 11px; min-height: 52px; }
.tabbar a[aria-current='page'] { color: var(--tint); }
.tabbar svg { width: 26px; height: 26px; }

/* 下から出る板（シート） */
.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.38); z-index: 56; animation: fade 0.2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 57; background: var(--bg); border-radius: 14px 14px 0 0;
  max-height: 92dvh; overflow-y: auto; padding-bottom: calc(24px + var(--safe-b)); animation: up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: 760px; margin: 0 auto;
}
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--label3); opacity: 0.5; margin: 6px auto 0; }
.sheet .sheet-nav { display: flex; align-items: center; padding: 4px 8px; min-height: 52px; }
.sheet .sheet-nav b { flex: 1; text-align: center; font-size: 17px; }
.sheet .sheet-nav button { border: 0; background: none; color: var(--tint); font-size: 17px; min-height: 44px; min-width: 64px; cursor: pointer; }
.sheet .sheet-nav .done { font-weight: 600; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* 写真を大きく見る */
.viewer { position: fixed; inset: 0; z-index: 55; background: #000; color: #fff; display: flex; flex-direction: column; }
.viewer .vtop { display: flex; justify-content: space-between; padding: calc(var(--safe-t) + 8px) 12px 8px; }
.viewer .vtop button { border: 0; background: none; color: #fff; font-size: 17px; min-height: 44px; min-width: 44px; cursor: pointer; }
.viewer img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.viewer .vinfo { padding: 12px 16px calc(16px + var(--safe-b)); font-size: 15px; background: #111; }

/* 日報の人の行 */
.worker { display: grid; grid-template-columns: 1fr 1fr 74px 44px; gap: 8px; align-items: center; padding: 8px 12px 8px 16px; position: relative; }
.worker + .worker::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--sep); transform: scaleY(0.6); }
.worker input { border: 0; background: var(--fill); border-radius: 8px; padding: 9px 10px; min-width: 0; font-size: 16px; }
.worker .rm { border: 0; background: none; color: var(--red); font-size: 22px; min-height: 44px; cursor: pointer; }
.seg { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin: 0 16px; }
.seg button { flex: 1; border: 0; background: none; min-height: 34px; border-radius: 7px; font-size: 14px; cursor: pointer; }
.seg button[aria-pressed='true'] { background: var(--cell); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); font-weight: 600; }

/* 出面の表 */
.table-wrap { overflow-x: auto; margin: 0 16px; background: var(--cell); border-radius: var(--radius); }
table.mp { border-collapse: collapse; font-size: 14px; min-width: 100%; }
table.mp th, table.mp td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--sep); }
table.mp th:first-child, table.mp td:first-child { text-align: left; position: sticky; left: 0; background: var(--cell); }
table.mp thead th { color: var(--label2); font-weight: 600; font-size: 12px; }
table.mp tfoot td { font-weight: 700; }
.kpi { display: flex; gap: 10px; margin: 0 16px; }
.kpi div { flex: 1; background: var(--cell); border-radius: var(--radius); padding: 12px 14px; }
.kpi b { display: block; font-size: 26px; line-height: 1.2; }
.kpi span { font-size: 13px; color: var(--label2); }

/* LINE のまね */
.chat { background: #8cabd9; margin: 0 16px; border-radius: var(--radius); padding: 12px; min-height: 260px; display: flex; flex-direction: column; gap: 8px; }
.chat .b { max-width: 80%; padding: 8px 12px; border-radius: 16px; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.chat .me { align-self: flex-end; background: #85e249; color: #111; }
.chat .bot { align-self: flex-start; background: #fff; color: #111; }
.chat img { max-width: 140px; border-radius: 12px; align-self: flex-end; }
.chat-in { display: flex; gap: 8px; margin: 8px 16px 0; }
.chat-in textarea { flex: 1; border-radius: 12px; border: 0; background: var(--cell); padding: 10px; min-height: 44px; font-size: 16px; }
.chat-in button { border: 0; border-radius: 12px; background: var(--tint); color: #fff; min-width: 64px; font-weight: 600; cursor: pointer; }

.code { font-size: 40px; font-weight: 700; letter-spacing: 0.2em; text-align: center; padding: 16px; background: var(--cell); border-radius: var(--radius); margin: 0 16px; font-variant-numeric: tabular-nums; }
.note { margin: 12px 16px; padding: 12px 14px; border-radius: var(--radius); background: rgba(242, 194, 0, 0.18); font-size: 15px; }
.meter { height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--tint); }

/* ログイン・招待の画面 */
.auth { max-width: 440px; margin: 0 auto; padding: calc(var(--safe-t) + 40px) 0 40px; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0 16px 18px; font-weight: 700; font-size: 20px; }
.brand .mark { width: 40px; height: 40px; border-radius: 10px; background: var(--board); color: var(--chalk); display: grid; place-items: center; font-size: 22px; }
.brand .mark-img { width: 40px; height: 40px; border-radius: 10px; display: block; }

/* 画面ツアー */
.tour-veil { position: fixed; inset: 0; z-index: 90; pointer-events: auto; }
.tour-hole { position: fixed; z-index: 91; border-radius: 12px; box-shadow: 0 0 0 4px var(--yellow), 0 0 0 9999px rgba(0, 0, 0, 0.62); pointer-events: none; transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
.tour-tip { position: fixed; z-index: 92; left: 16px; right: 16px; max-width: 420px; margin: 0 auto; background: var(--cell); color: var(--label); border-radius: 16px; padding: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); transition: top 0.3s; }
.tour-tip h3 { margin: 0 0 4px; font-size: 17px; }
.tour-tip p { margin: 0 0 12px; font-size: 16px; color: var(--label2); }
.tour-tip .tb { display: flex; gap: 8px; align-items: center; }
.tour-tip .tb span { flex: 1; font-size: 13px; color: var(--label3); }
.tour-tip .tb button { border: 0; border-radius: 10px; min-height: 44px; padding: 0 14px; font-size: 16px; cursor: pointer; background: var(--fill); color: var(--label); }
.tour-tip .tb .next { background: var(--tint); color: #fff; font-weight: 600; }

/* 写真台帳・日報の印刷 */
.print-only { display: none; }
.ledger-page { background: #fff; color: #111; width: 100%; max-width: 760px; margin: 12px auto; padding: 14mm 12mm; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12); font-family: 'BIZ UDPGothic', 'Hiragino Sans', 'Noto Sans JP', sans-serif; }
.ledger-page h1 { font-size: 18px; margin: 0 0 6px; text-align: center; letter-spacing: 0.3em; }
.ledger-page .meta { display: flex; justify-content: space-between; font-size: 12px; border-bottom: 2px solid #111; padding-bottom: 4px; margin-bottom: 8px; }
.ledger-row { display: grid; grid-template-columns: 58% 1fr; border: 1px solid #111; margin-bottom: 4mm; height: 72mm; }
.ledger-row img { width: 100%; height: 100%; object-fit: contain; background: #f3f3f3; display: block; }
.ledger-row table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ledger-row th { width: 34%; background: #f0f0f0; font-weight: 600; text-align: left; }
.ledger-row th, .ledger-row td { border-left: 1px solid #111; border-bottom: 1px solid #111; padding: 5px 6px; vertical-align: top; word-break: break-all; }
.ledger-row tr:last-child td, .ledger-row tr:last-child th { border-bottom: 0; height: 100%; }
.ledger-row table { height: 100%; }
.report-sheet table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 10px; }
.report-sheet th, .report-sheet td { border: 1px solid #111; padding: 6px 8px; text-align: left; }
.report-sheet th { background: #f0f0f0; width: 22%; }
.report-sheet .photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.report-sheet .photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
@media print {
  @page { size: A4 portrait; margin: 0; }
  body { background: #fff; }
  .nav, .tabbar, .no-print, .large-title, .sub { display: none !important; }
  main { padding: 0; max-width: none; }
  .ledger-page { box-shadow: none; margin: 0; max-width: none; height: 297mm; page-break-after: always; }
  .ledger-page:last-child { page-break-after: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* 安全書類は A4 横 */
.safety-page { max-width: 1100px; }
@media print { .safety-page { height: auto; min-height: 210mm; } }
@page safety { size: A4 landscape; }
.safety-page { page: safety; }
main:has(.safety-page) { max-width: 1140px; }

/* 雨の日の段取り */
.wx-strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 2px; scrollbar-width: none; }
.wx-strip::-webkit-scrollbar { display: none; }
.wx { flex: 0 0 auto; min-width: 46px; display: grid; justify-items: center; gap: 1px; padding: 6px 4px; border-radius: 12px; background: var(--cell); font-size: 12px; color: var(--label2); }
.wx .wi { font-size: 20px; line-height: 1.2; }
.wx .wd { font-weight: 600; color: var(--label); }
.wx.rain { background: rgba(10,122,255,.12); color: #0a64d6; }
.wx.rain .wp { font-weight: 700; }
.rain-card { margin: 4px 16px 12px; padding: 12px 14px; border-radius: 16px; background: rgba(10,122,255,.1); }
.rain-h { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.rain-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid rgba(10,122,255,.15); }
.rain-row:first-of-type { border-top: 0; }
.rain-site { flex: 1; min-width: 0; display: grid; text-align: left; background: none; border: 0; padding: 4px 0; color: inherit; font: inherit; min-height: 44px; }
.rain-site span { font-size: 13px; color: var(--label2); }
.rain-line { flex: 0 0 auto; background: #06c755; color: #fff; text-decoration: none; font-weight: 600; font-size: 13px; padding: 10px 12px; border-radius: 10px; }
.rain-f { margin: 6px 0 0; font-size: 12px; color: var(--label2); }
