/* FARMAN さぎょうマニュアル */
:root {
  --bg: #F6F4EC;
  --card: #FFFFFF;
  --ink: #1E2A1E;
  --muted: #5B6B5B;
  --line: #E3E0D4;
  --green: #2E7D32;
  --green-deep: #1B5E20;
  --green-soft: #E8F3E8;
  --amber: #F2A20C;
  --amber-soft: #FFF4DB;
  --red: #C62828;
  --red-soft: #FDECEA;
  --blue-soft: #E7F0FA;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(30, 42, 30, .08);
  --fs: 18px;
  --tap: 60px;
}
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
html.big { --fs: 22px; }
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  line-height: 1.7; font-feature-settings: "palt";
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
rt { font-size: .5em; font-weight: 400; color: var(--muted); letter-spacing: 0; }
html.nofuri rt { display: none; }
ruby { ruby-align: center; white-space: nowrap; }

/* ---------- ヘッダー ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--green); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; min-width: 0; }
.brand-name { white-space: nowrap; }
@media (max-width: 360px) { .brand-name { font-size: .95rem; } .brand-small { display: none; } }
.brand-mark { font-size: 1.6rem; line-height: 1; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-small { font-size: .65rem; letter-spacing: .18em; opacity: .85; }
.brand-name { font-size: 1.05rem; font-weight: 700; }
.top-tools { display: flex; gap: 6px; }
.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 52px; min-height: 48px; padding: 4px 6px; border-radius: 12px; flex: 0 0 auto;
  border: 2px solid rgba(255,255,255,.55); background: transparent; color: #fff;
}
.tool[aria-pressed="true"] { background: #fff; color: var(--green-deep); border-color: #fff; }
.tool-ico { font-weight: 700; font-size: 1rem; line-height: 1.1; }
.tool-label { font-size: .6rem; line-height: 1.2; }

/* ---------- レイアウト ---------- */
.app { max-width: 880px; margin: 0 auto; padding: 14px 14px 40px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
.foot { max-width: 880px; margin: 0 auto; padding: 0 14px 30px; }
.foot-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: .8rem; }
.linkish { background: none; border: 0; padding: 10px 6px; color: var(--muted); text-decoration: underline; font-size: .8rem; }
.updated { min-height: 1em; }

.section-title {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 0 10px; font-size: 1.15rem; font-weight: 700;
}
.section-title .ico { font-size: 1.4rem; }
.hint { color: var(--muted); font-size: .9rem; margin: 0 0 10px; }

/* ---------- 月えらび ---------- */
.months { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.months::-webkit-scrollbar { display: none; }
.month {
  flex: 0 0 auto; min-width: 54px; min-height: 48px; padding: 4px 10px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--card); font-weight: 700; font-size: 1rem;
}
.month.now { border-color: var(--green); color: var(--green-deep); }
.month[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------- カードグリッド ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; border: 2px solid transparent; min-height: var(--tap);
}
.card:active { border-color: var(--green); }
.card-img { aspect-ratio: 4 / 3; background: var(--green-soft); display: flex; align-items: center; justify-content: center; font-size: 3.2rem; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.card-crop { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.card-title { font-weight: 700; font-size: 1.02rem; line-height: 1.45; overflow-wrap: anywhere; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.crop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.crop-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 14px 10px 12px; min-height: 104px;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow); font-weight: 700; font-size: 1rem;
  border: 2px solid transparent; text-align: center;
}
.crop-btn:active { border-color: var(--green); }
.crop-btn .emoji { font-size: 2rem; line-height: 1.1; }
.crop-btn .name { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.crop-btn .count {
  position: absolute; top: 8px; right: 10px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px;
  background: var(--green-soft); color: var(--green-deep); font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.empty { background: var(--card); border-radius: var(--radius); padding: 24px; text-align: center; color: var(--muted); }

/* ---------- タグ・バッジ ---------- */
.tag { display: inline-flex; align-items: center; gap: 3px; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--green-soft); color: var(--green-deep); white-space: nowrap; }
.tag.warn { background: var(--amber-soft); color: #8A5A00; }
.tag.danger { background: var(--red-soft); color: var(--red); }
.tag.info { background: var(--blue-soft); color: #234B7A; }
.tag.now { background: var(--green); color: #fff; }

/* ---------- 作業ページ ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 14px 0 8px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-weight: 700; margin-bottom: 12px; border: 0; }
.task-head { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px; }
.task-crop { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
.task-crop .emoji { font-size: 1.5rem; }
.task-title { font-size: 1.6rem; font-weight: 700; line-height: 1.35; margin: 4px 0 8px; }
.task-work { font-size: .85rem; color: var(--muted); }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.hero { border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; box-shadow: var(--shadow); background: #000; }
.hero img { width: 100%; max-height: 62vh; object-fit: contain; background: #111; }
.hero-strip { display: flex; gap: 8px; overflow-x: auto; padding: 8px; background: var(--card); }
.hero-strip img { width: 110px; height: 82px; object-fit: cover; border-radius: 10px; flex: 0 0 auto; border: 3px solid transparent; cursor: pointer; }
.hero-strip img.on { border-color: var(--green); }

.block { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 16px; margin-bottom: 14px; }
.block-title { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; font-weight: 700; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 3px solid var(--green-soft); }
.block-title .ico { font-size: 1.5rem; }
.block.caution .block-title { border-color: var(--amber-soft); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.step { display: grid; grid-template-columns: 52px 1fr; gap: 10px 12px; padding: 12px; border-radius: 14px; background: #FAFAF6; border: 1px solid var(--line); }
.step-num { width: 52px; height: 52px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 700; font-size: 1.4rem; display: flex; align-items: center; justify-content: center; }
.step-text { font-size: 1.15rem; line-height: 1.75; align-self: center; }
.step-photos { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr; gap: 8px; }
.step-photos img { width: 100%; border-radius: 12px; max-height: 60vh; object-fit: cover; }
.step-photos figcaption { font-size: .85rem; color: var(--muted); margin-top: 4px; }
@media (min-width: 640px) { .step-photos.multi { grid-template-columns: 1fr 1fr; } }

.cautions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.caution-item { display: flex; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--amber-soft); border-left: 6px solid var(--amber); font-size: 1.05rem; }
.caution-item .ico { flex: 0 0 auto; font-size: 1.3rem; }

.items { display: flex; flex-wrap: wrap; gap: 10px; }
.item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 96px; padding: 10px 8px; border-radius: 14px; background: #FAFAF6; border: 1px solid var(--line); text-align: center; }
.item .ico { font-size: 2rem; line-height: 1.1; }
.item .label { font-size: .9rem; font-weight: 700; }

.note { background: var(--blue-soft); border-radius: 14px; padding: 12px 14px; font-size: 1rem; display: flex; gap: 10px; }
.note .ico { font-size: 1.3rem; }

.video-wrap { position: relative; padding-top: 56.25%; border-radius: 12px; overflow: hidden; background: #000; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* スタッフ向け */
.staff-toggle { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; border: 0; width: 100%; text-align: left; font-weight: 700; }
.staff-toggle .sw { width: 52px; height: 30px; border-radius: 999px; background: #CFCFC4; position: relative; flex: 0 0 auto; transition: background .2s; }
.staff-toggle .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; }
.staff-toggle[aria-pressed="true"] .sw { background: var(--green); }
.staff-toggle[aria-pressed="true"] .sw::after { left: 25px; }
.staff-box { border: 2px dashed #B8C7B8; background: #F4F8F4; }
.kv { display: grid; grid-template-columns: 7.5em 1fr; gap: 6px 12px; font-size: .95rem; margin: 0; }
.kv dt { color: var(--muted); font-weight: 700; }
.kv dd { margin: 0; white-space: pre-wrap; }
.orig { white-space: pre-wrap; font-size: .95rem; line-height: 1.7; color: #33402F; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 8px 18px; border-radius: 14px; border: 2px solid var(--green); background: var(--card); color: var(--green-deep); font-weight: 700; font-size: 1rem; }
.btn.primary { background: var(--green); color: #fff; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 40px; padding: 4px 12px; font-size: .85rem; }

/* ---------- スタッフ画面（アップロード） ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; }
.field input[type="text"], .field input[type="password"], .field select, .field input[type="number"] {
  width: 100%; min-height: 52px; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font: inherit;
}
.field input:focus, .field select:focus { outline: 3px solid #A5D6A7; border-color: var(--green); }
.camera { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 120px; border: 3px dashed #A5D6A7; border-radius: var(--radius); background: var(--green-soft); cursor: pointer; text-align: center; padding: 16px; }
.camera .ico { font-size: 2.4rem; }
.camera input { display: none; }
.preview { position: relative; }
.preview img { border-radius: 14px; max-height: 50vh; object-fit: contain; margin: 0 auto; }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--green); width: 0; transition: width .3s; }
.photo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-list > .hint { grid-column: 1 / -1; }
.photo-item { background: #FAFAF6; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.photo-item img { aspect-ratio: 4/3; object-fit: cover; width: 100%; }
.photo-item .pi-body { padding: 6px 8px; font-size: .78rem; display: flex; flex-direction: column; gap: 4px; }
.photo-item .pi-name { word-break: break-all; color: var(--muted); }
.step-choice { display: flex; flex-wrap: wrap; gap: 8px; }
.step-choice button { min-width: 52px; min-height: 52px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-weight: 700; font-size: 1.1rem; }
.step-choice button[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.step-choice .wide { padding: 0 14px; font-size: .95rem; }
.steps-mini { list-style: none; padding: 0; margin: 8px 0 0; font-size: .85rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.steps-mini li b { color: var(--green-deep); margin-right: 6px; }

/* ---------- QR ---------- */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.qr-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; break-inside: avoid; }
.qr-card canvas, .qr-card img { margin: 0 auto 8px; }
.qr-card .t { font-weight: 700; font-size: .95rem; }
.qr-card .c { font-size: .8rem; color: var(--muted); }

/* ---------- トースト ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1E2A1E; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 50; font-size: .95rem; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }

/* ---------- 印刷 ---------- */
@media print {
  @page { margin: 12mm; }
  html { --fs: 12.5pt; }
  body { background: #fff; }
  .top, .foot, .back, .actions, .staff-toggle, .months, .toast, .hero-strip, .no-print { display: none !important; }
  .app { max-width: none; padding: 0; }
  .task-head, .block, .hero { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; margin-bottom: 8pt; }
  .hero img { max-height: 70mm; }
  .step { break-inside: avoid; }
  .step-photos img { max-height: 70mm; }
  .card, .crop-btn, .qr-card { box-shadow: none; border: 1px solid #ccc; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
