/* 業務管理アプリ iPhone 版：画面の見た目
   ・iPhone の画面（幅 320〜430px）で横にはみ出さない（長い文字は折り返す）
   ・入力欄の文字は 16px 以上（iPhone が入力時に拡大しないように）
   ・画面の端（ホームバー・切り欠き）を避ける（safe-area） */
:root {
  --bg: #f2f3f5; --card: #ffffff; --text: #1a1a1a; --muted: #5f6368; --line: #d9dce1; --accent: #1f5fbf;
  --accent-text: #ffffff; --danger: #c62828; --head: #ffffff; --tab: #ffffff; --chip: #e8eef8; --chip-text: #1f4e8c;
  --input: #ffffff; --sel: #dce8fb; --shadow: 0 1px 2px rgba(0,0,0,.08);
  --done-bg: #D9D9D9; --done-fg: #7F7F7F; --minutes-bg: #EAF1FB; --minutes-mark: #5B7DB1;
  --sun: #E00000; --sat: #0040E0; --today: #F4B084; --holiday-bg: #404040; --holiday-fg: #E8E8E8; --lock: #EDEDED;
  --fixed-bg: #FFF2CC; --fixed-fg: #7F6000; --alert-bg: #FFC7CE; --alert-fg: #9C0006; --ng: #FF0000; --link: #0050C8;
  --sat-bg: #eef3ff; --sun-bg: #fff0f0;
  color-scheme: light;
}
:root.dark {
  --bg: #121212; --card: #1e1e1e; --text: #e8e8e8; --muted: #a8a8a8; --line: #3a3a3a; --accent: #5b9bff;
  --accent-text: #0b0b0b; --danger: #ff7070; --head: #1b1b1b; --tab: #1b1b1b; --chip: #24324a; --chip-text: #bcd3ff;
  --input: #262626; --sel: #24324a; --shadow: none;
  --done-bg: #3A3A3A; --done-fg: #9A9A9A; --minutes-bg: #22303F; --minutes-mark: #8FAFE0;
  --sun: #FF7070; --sat: #7FB2FF; --today: #8A4E26; --holiday-bg: #0A0A0A; --holiday-fg: #8C8C8C; --lock: #262626;
  --fixed-bg: #4A3F14; --fixed-fg: #FFD966; --alert-bg: #5C1F28; --alert-fg: #FFB3BC; --ng: #B00020; --link: #7CC0FF;
  --sat-bg: #1d2433; --sun-bg: #331d1d;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; }
#app { min-height: 100dvh; display: flex; flex-direction: column; }
#top { position: sticky; top: 0; z-index: 20; background: var(--head); border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left)); }
#top-row { display: flex; align-items: center; gap: 4px; min-height: 44px; }
#title { flex: 1; font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
button.icon { width: 40px; height: 40px; border: none; background: none; font-size: 22px; border-radius: 10px; flex: none; }
button.icon:disabled { opacity: .3; }
button.icon:active { background: var(--sel); }
#btn-back { font-size: 30px; line-height: 1; }
.chip { border: none; background: var(--chip); color: var(--chip-text); border-radius: 999px; padding: 3px 10px; font-size: 13px;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.err { background: var(--alert-bg); color: var(--alert-fg); }
.chip.warn { background: #ffe3c2; color: #6b3a00; }
:root.dark .chip.warn { background: #4a3a10; color: #ffd98a; }
#view { flex: 1; padding: 8px max(8px, env(safe-area-inset-right)) calc(78px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); outline: none; }
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--tab); border-top: 1px solid var(--line);
  padding: 2px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#tabs button { flex: 1; border: none; background: none; padding: 4px 0 6px; display: flex; flex-direction: column; align-items: center;
  font-size: 11px; color: var(--muted); min-width: 0; }
#tabs button .ti { font-size: 20px; line-height: 26px; }
#tabs button.on { color: var(--accent); font-weight: 600; }

/* 道具の並び */
.bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 2px 0 8px; }
.bar .grow { flex: 1 1 140px; min-width: 0; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 12px; min-height: 36px; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 9px; min-height: 30px; font-size: 13px; }
.btn:disabled { opacity: .4; }
.btn.on { background: var(--sel); border-color: var(--accent); }
input.search, input.text, select.sel, textarea.ta { width: 100%; border: 1px solid var(--line); background: var(--input); border-radius: 10px;
  padding: 8px 10px; min-height: 40px; }
textarea.ta { min-height: 88px; resize: vertical; line-height: 1.45; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: none; background: var(--card); padding: 6px 10px; min-height: 34px; font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.note { color: var(--muted); font-size: 13px; margin: 4px 2px 10px; }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }
.more { display: block; width: 100%; margin: 8px 0; }

/* カード */
.card { background: var(--card); border-radius: 12px; padding: 10px 12px; margin: 0 0 8px; box-shadow: var(--shadow); border: 1px solid var(--line);
  overflow-wrap: anywhere; word-break: break-word; }
.card.tap:active { background: var(--sel); }
.card .row { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.card .row .grow { flex: 1 1 auto; min-width: 0; }
.card .k { color: var(--muted); font-size: 12px; }
.card .t { font-weight: 600; }
.card .body { margin-top: 4px; white-space: pre-wrap; }
.card .sub { color: var(--muted); font-size: 13px; }
.card.done { opacity: .75; }
.badge { display: inline-block; border-radius: 6px; padding: 0 6px; font-size: 13px; line-height: 20px; white-space: nowrap; border: 1px solid transparent; }
.badge.outline { border-color: var(--line); }
.group-head { margin: 14px 4px 6px; font-size: 13px; color: var(--muted); font-weight: 600; display: flex; gap: 6px; flex-wrap: wrap; }
.sep { border-top: 2px solid var(--muted); margin: 10px 0; opacity: .4; }
.rich { white-space: pre-wrap; overflow-wrap: anywhere; }
.rich .mb { background: var(--minutes-bg); }
.rich .mm { color: var(--minutes-mark); font-weight: 700; }
.rich .dn { background: var(--done-bg); color: var(--done-fg); text-decoration: line-through; }
.lines .ln { display: block; }
.lines .ln.dn { color: var(--done-fg); text-decoration: line-through; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 14px; margin-top: 6px; }
.kv > div:nth-child(odd) { color: var(--muted); font-size: 12px; padding-top: 2px; white-space: nowrap; }
.kv > div { min-width: 0; overflow-wrap: anywhere; }

/* 日誌 */
.day.today { border: 2px solid var(--today); }
.day.holiday { background: var(--holiday-bg); color: var(--holiday-fg); }
.day.holiday .k, .day.holiday .sub { color: var(--holiday-fg); }
.day .date.sat { color: var(--sat); }
.day .date.sun { color: var(--sun); }
.day .sec { margin-top: 6px; }
.day .sec:first-of-type { margin-top: 4px; }
.auto { color: var(--muted); font-style: italic; }

/* 時間シート */
.tb { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.tb td { border-bottom: 1px solid var(--line); padding: 7px 4px; vertical-align: top; overflow-wrap: anywhere; }
.tb td.tm { width: 52px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tb td.tm.fixed { background: var(--fixed-bg); color: var(--fixed-fg); font-weight: 600; }
.tb td.mn { width: 50px; text-align: right; font-variant-numeric: tabular-nums; }
.tb tr.dn td.tk { color: var(--done-fg); text-decoration: line-through; }
.tb tr:active td { background: var(--sel); }
.locked { background: var(--lock); }

/* 工程表 */
.ktask .no { color: var(--muted); font-size: 12px; min-width: 2.4em; }
.ktask .dates { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 4px; font-size: 14px; }
.ktask .dates .cell { padding: 0 4px; border-radius: 4px; }
.kgroup { background: var(--chip); color: var(--chip-text); }
.gantt-wrap { position: relative; border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; }
.gantt-scroll { overflow: auto; -webkit-overflow-scrolling: touch; max-height: calc(100dvh - 220px); }
.gantt-wrap canvas { display: block; }
.msg { padding: 8px 10px; border-radius: 10px; margin: 6px 0; font-size: 14px; white-space: pre-wrap; }
.msg.err { background: var(--alert-bg); color: var(--alert-fg); }
.msg.ok { background: var(--chip); color: var(--chip-text); }
.tip { font-size: 12px; color: var(--muted); white-space: pre-wrap; margin: 2px 2px 8px; }

/* 下から出る画面（編集） */
#sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; }
#sheet[hidden] { display: none; }
#sheet-panel { background: var(--bg); width: 100%; height: 100dvh; display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top); }
#sheet-head { display: flex; align-items: center; gap: 6px; padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
  background: var(--head); border-bottom: 1px solid var(--line); min-height: 50px; }
#sheet-title { flex: 1; text-align: center; font-size: 16px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
button.text { border: none; background: none; color: var(--accent); font-size: 16px; padding: 8px 6px; min-width: 64px; }
button.text.strong { font-weight: 700; }
button.text[hidden] { display: none; }
#sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 10px max(12px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.field { margin: 0 0 12px; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin: 0 2px 4px; }
.field .hint { font-size: 12px; color: var(--muted); margin: 4px 2px 0; white-space: pre-wrap; }
.field .inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.field .inline > .grow { flex: 1 1 150px; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.check input { width: 22px; height: 22px; }
.attrbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.attrbar .btn { padding: 4px 10px; min-height: 32px; font-size: 13px; }
.preview { background: var(--card); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; min-height: 40px; }
.linechk { display: flex; gap: 8px; align-items: flex-start; padding: 6px 2px; border-bottom: 1px solid var(--line); }
.linechk input { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.linechk span { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.linechk.dn span { color: var(--done-fg); text-decoration: line-through; }
.danger-zone { margin-top: 22px; display: flex; gap: 8px; flex-wrap: wrap; }
.list-item { display: flex; gap: 8px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.list-item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.menu-list .card { display: flex; align-items: center; gap: 10px; }
.menu-list .card .ic { font-size: 20px; width: 28px; text-align: center; }
.menu-list .card .grow { flex: 1; min-width: 0; }
.menu-list .card .sub { display: block; }
#toast { position: fixed; left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 60; background: #333; color: #fff;
  border-radius: 12px; padding: 10px 14px; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.25); white-space: pre-wrap; }
#toast.err { background: #b3261e; }
#toast[hidden] { display: none; }
.loading { text-align: center; padding: 30px; color: var(--muted); }
pre.code { white-space: pre-wrap; font-size: 12px; background: var(--card); padding: 8px; border-radius: 8px; overflow-wrap: anywhere; }
