/* Earth Works OS の見た目（2026-11-14 見直し）
   白をベースにし、緑は差し色（ボタン・選択中・リンク）だけに使う。ナイトモードは端末の設定に合わせ、「その他」から手動でも選べる。
   四ノ宮：「シンプルに使うなら白ベース（ナイトモード搭載できればなおいい）緑などは差し色で使う程度の方が見やすい」 */
:root {
  color-scheme: light;
  --bg: #ffffff; --surface: #f5f7f5; --card: #ffffff; --line: #e2e6e2; --line-strong: #cfd5cf;
  --ink: #1b1f1c; --muted: #5d655f;
  --accent: #2e7d4f; --accent-ink: #ffffff; --accent-soft: #e8f3ec;
  --warn: #8a5300; --warn-bg: #fff5e3; --bad: #b3261e; --bad-bg: #fdecea; --ok-bg: #e8f3ec; --info-bg: #edf1f6;
  --radius: 14px; --tabbar: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111312; --surface: #1a1d1b; --card: #171a18; --line: #2b302d; --line-strong: #3a413c;
    --ink: #e8eae8; --muted: #a0a8a2;
    --accent: #5bbf86; --accent-ink: #0b130e; --accent-soft: #1b2b21;
    --warn: #f2b866; --warn-bg: #2e2516; --bad: #f28b82; --bad-bg: #3a1f1d; --ok-bg: #1b2b21; --info-bg: #1c2330;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111312; --surface: #1a1d1b; --card: #171a18; --line: #2b302d; --line-strong: #3a413c;
  --ink: #e8eae8; --muted: #a0a8a2;
  --accent: #5bbf86; --accent-ink: #0b130e; --accent-soft: #1b2b21;
  --warn: #f2b866; --warn-bg: #2e2516; --bad: #f28b82; --bad-bg: #3a1f1d; --ok-bg: #1b2b21; --info-bg: #1c2330;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
a { color: var(--accent); text-underline-offset: 2px; }

/* ---------- 画面上部 ---------- */
.top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--bg); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { white-space: nowrap; font-weight: 700; font-size: 17px; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; gap: 8px; }
.brand::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.env { white-space: nowrap; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--warn-bg); color: var(--warn); }
.who { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 0; text-align: right; }
.top { flex-wrap: nowrap; }
#logout { margin-left: auto; }
.who + #logout { margin-left: 0; }
/* 狭い画面では名前と役割を出さない（ホームの見出しに名前が出る）。1行に収めて、ログアウトを画面の中に入れる */
@media (max-width: 480px) { .who { display: none; } .brand { font-size: 16px; } }
.brand { flex: none; }
.env { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
#logout { white-space: nowrap; flex: none; }
#net { margin: 8px 16px 0; }

/* ---------- 下のタブ（主な行き先は5つだけ） ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabbar);
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabs a svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--accent); }

/* ---------- 画面の中の切り替え（タブの中の画面） ---------- */
.subnav { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 16px; padding: 0 16px 2px; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { flex: none; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; color: var(--ink);
  font-size: 14px; white-space: nowrap; background: var(--bg); }
.subnav a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- 本文 ---------- */
.app { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; line-height: 1.35; margin: 4px 0 14px; letter-spacing: .01em; }
h2 { font-size: 17px; line-height: 1.4; margin: 28px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
p { margin: 6px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.back { margin-bottom: 12px; }
details > summary { cursor: pointer; padding: 4px 0; font-weight: 600; }
details.card > summary { margin: -4px 0; }

/* 状態の印 */
.badge { display: inline-block; font-size: 12px; font-weight: 600; line-height: 1.6; padding: 1px 9px; border-radius: 99px; background: var(--info-bg); color: var(--ink); white-space: nowrap; }
.st-draft { background: var(--info-bg); } .st-submitted { background: var(--warn-bg); color: var(--warn); }
.st-approved { background: var(--ok-bg); color: var(--accent); } .st-returned { background: var(--bad-bg); color: var(--bad); }
.st-none { background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); }

/* お知らせ */
.alert { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 15px; border: 1px solid transparent; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.ok { background: var(--ok-bg); color: var(--ink); border-color: var(--accent-soft); }

/* ボタン・入力 */
button, .btn { font: inherit; font-weight: 600; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 9px 16px; cursor: pointer; min-height: 44px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.small { min-height: 34px; padding: 4px 12px; font-size: 14px; }
button:disabled { opacity: .45; cursor: default; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--card); color: var(--ink); min-height: 44px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--accent); }
textarea { min-height: 80px; }
.field { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 一覧 */
.list { padding: 4px 16px; }
.list a.item, .list .item { display: flex; gap: 10px; align-items: center; padding: 12px 0; min-height: 48px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.list > :last-child { border-bottom: 0; }
.menu-group { padding: 0 16px; }
.menu-group a.item { display: flex; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.menu-group a.item:last-child { border-bottom: 0; }
.menu-group a.item::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 20px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 38px; font-weight: 600; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* 日報 */
.alloc { border-left: 4px solid var(--accent); }
.alloc.travel, .alloc.training, .alloc.admin, .alloc.common { border-left-color: var(--line-strong); }
.mat { background: var(--surface); border-radius: 10px; padding: 10px; margin-top: 10px; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.daycell { text-align: center; padding: 6px 0; overflow: hidden; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: 12px; background: var(--card); }
.daycell b { display: block; font-size: 13px; }
.total { font-size: 18px; font-weight: 700; }
.sticky-actions { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); background: var(--bg); padding: 10px 0; display: flex; gap: 8px; border-top: 1px solid var(--line); }
.sticky-actions button { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 12px; max-width: 90vw; z-index: 20; font-size: 15px; }

/* 表 */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { font-size: 12px; font-weight: 600; color: var(--muted); }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }

@media (max-width: 480px) {
  .grid2 { grid-template-columns: 1fr; }
  h1 { font-size: 20px; }
}

/* 写真メモ */
.filebtn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); cursor: pointer; font-weight: 600; flex: 1; text-align: center; }
.filebtn.primary-like { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.filebtn input { position: absolute; width: 1px; height: 1px; opacity: 0; min-height: 0; }
.thumb { display: block; max-width: 100%; max-height: 240px; border-radius: 10px; margin: 6px 0; }
.memo-share { border-left: 4px solid var(--accent); padding: 6px 10px; margin: 8px 0; font-size: 14px; }

/* 作業の進み具合・年ごとの比較 */
.bar { height: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; margin: 6px 0; }
.bar > span { display: block; height: 100%; background: var(--accent); }
td[data-state="unrecorded"] { background: var(--surface); color: var(--muted); }
td[data-state="zero"] { color: var(--warn); }
