/* Builds 勤怠。2026-11-19。iPhone のホーム画面から使う前提。明るい／暗いは端末の設定に合わせる */
:root {
  --bg: #f2f2f7; --card: #ffffff; --card2: #f7f7fa; --text: #1c1c1e; --sub: #6c6c70; --faint: #aeaeb2;
  --line: rgba(60, 60, 67, .16); --chip: rgba(118, 118, 128, .12);
  --accent: #0a7c5a; --accent-ink: #ffffff; --accent-soft: rgba(10, 124, 90, .12);
  --on: #0a7c5a; --on-soft: rgba(10, 124, 90, .12); --brk: #b25000; --brk-soft: rgba(178, 80, 0, .12); --off: #6c6c70;
  --danger: #d70015; --danger-soft: rgba(215, 0, 21, .1); --warn: #b25000; --warn-soft: rgba(178, 80, 0, .12);
  --bar: rgba(249, 249, 251, .8); --scrim: rgba(0, 0, 0, .32); --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 24px rgba(0, 0, 0, .06);
  --r: 16px; --ease: cubic-bezier(.2, .8, .2, 1);
  --top: env(safe-area-inset-top, 0px); --bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1c1c1e; --card2: #2c2c2e; --text: #f5f5f7; --sub: #98989f; --faint: #636366;
    --line: rgba(84, 84, 88, .55); --chip: rgba(118, 118, 128, .24);
    --accent: #30d18f; --accent-ink: #062b1e; --accent-soft: rgba(48, 209, 143, .16);
    --on: #30d18f; --on-soft: rgba(48, 209, 143, .16); --brk: #ffb340; --brk-soft: rgba(255, 179, 64, .16); --off: #98989f;
    --danger: #ff453a; --danger-soft: rgba(255, 69, 58, .16); --warn: #ffb340; --warn-soft: rgba(255, 179, 64, .16);
    --bar: rgba(22, 22, 24, .8); --scrim: rgba(0, 0, 0, .55); --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none; background: var(--bg); }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", system-ui, sans-serif; }
[hidden] { display: none !important; }
svg { width: 1em; height: 1em; flex: none; }
button, a, [role="button"], .tabbar, .chip, .seg { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; font-size: 17px; color: inherit; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 600; font-size: 16px;
  background: var(--chip); color: var(--text); transition: transform 120ms var(--ease), opacity 120ms; white-space: nowrap; }
.btn:active { transform: scale(.97); opacity: .85; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.brk { background: var(--brk-soft); color: var(--brk); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.plain { background: none; color: var(--accent); padding: 0 8px; }
.btn.big { min-height: 56px; font-size: 18px; border-radius: 16px; width: 100%; }
.btn.huge { min-height: 76px; font-size: 22px; border-radius: 20px; width: 100%; letter-spacing: .04em; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn svg { font-size: 20px; }
@media (hover: hover) and (pointer: fine) { .btn:hover { filter: brightness(1.04); } }

/* ---------- 最初の画面 */
.screen.center { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: calc(var(--top) + 32px) 24px calc(var(--bottom) + 32px); gap: 14px; max-width: 460px; margin: 0 auto; }
.hero-icon { width: 76px; height: 76px; border-radius: 20px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 40px; margin-bottom: 6px; }
.screen h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; font-weight: 700; }
.lead { color: var(--sub); font-size: 16px; }
.steps { text-align: left; padding-left: 1.4em; margin: 8px 0 0; font-size: 16px; line-height: 1.9; }
.inline-icon { display: inline-flex; vertical-align: -3px; color: var(--accent); font-size: 20px; }
.login-form { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.code-input { width: 100%; text-align: center; font: 600 28px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .12em; padding: 16px 12px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--card); text-transform: uppercase; outline: none; }
.code-input:focus { border-color: var(--accent); }
.msg { min-height: 1.4em; color: var(--danger); font-size: 15px; }

/* ---------- 本体 */
.top { position: sticky; top: 0; z-index: 5; padding: calc(var(--top) + 10px) 16px 8px; background: var(--bg); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 640px; margin: 0 auto; }
#title { font-size: 32px; line-height: 1.1; letter-spacing: -.025em; font-weight: 700; }
.me-chip { max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--sub); font-size: 15px; font-weight: 600; background: var(--chip); padding: 6px 12px; border-radius: 999px; }
main { max-width: 640px; margin: 0 auto; padding: 4px 16px calc(var(--bottom) + 96px); }
.tab { display: flex; flex-direction: column; gap: 14px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; gap: 4px;
  padding: 6px 12px calc(var(--bottom) + 6px); background: var(--bar); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border-top: .5px solid var(--line); }
.tabbar button { flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--faint); font-size: 11px; font-weight: 600; }
.tabbar button svg { font-size: 26px; }
.tabbar button.on { color: var(--accent); }

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.section-title { font-size: 13px; font-weight: 600; color: var(--sub); text-transform: none; padding: 6px 4px 0; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.empty { color: var(--sub); text-align: center; padding: 28px 16px; font-size: 15px; }

/* ---------- 打刻 */
.clock { text-align: center; padding: 6px 0 2px; }
.clock .date { color: var(--sub); font-size: 15px; font-weight: 600; }
.clock .time { font-size: 56px; line-height: 1.05; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

.status { padding: 18px; display: flex; flex-direction: column; gap: 6px; border-left: 6px solid var(--off); }
.status.on { border-left-color: var(--on); }
.status.break { border-left-color: var(--brk); }
.status .label { font-size: 13px; font-weight: 700; letter-spacing: .02em; color: var(--off); }
.status.on .label { color: var(--on); }
.status.break .label { color: var(--brk); }
.status .where { font-size: 22px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; overflow-wrap: anywhere; }
.status .since { color: var(--sub); font-size: 15px; font-variant-numeric: tabular-nums; }

.site-pick { display: flex; align-items: center; gap: 12px; padding: 14px 16px; width: 100%; text-align: left; min-height: 60px; }
.site-pick:active { background: var(--card2); }
.site-pick .k { color: var(--sub); font-size: 13px; font-weight: 600; }
.site-pick .v { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.site-pick .grow { flex: 1; min-width: 0; }
.site-pick .chev { color: var(--faint); font-size: 18px; }
.hint { font-size: 13px; color: var(--sub); display: flex; align-items: center; gap: 6px; padding: 0 4px; }
.hint svg { font-size: 15px; }
.hint.warn { color: var(--warn); }

.actions { display: flex; flex-direction: column; gap: 10px; }
.actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.queue { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 14px; font-weight: 600; }

/* ---------- 一覧 */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 52px; width: 100%; text-align: left; }
.item + .item { border-top: .5px solid var(--line); }
button.item:active { background: var(--card2); }
.item .grow { flex: 1; min-width: 0; }
.item .t1 { font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.item .t2 { color: var(--sub); font-size: 14px; overflow-wrap: anywhere; }
.item .right { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.item .right .t2 { font-weight: 400; }
.item.void .t1, .item.void .right { text-decoration: line-through; color: var(--faint); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--off); flex: none; align-self: flex-start; margin-top: 7px; } /* 名前が 2 行になっても 1 行目の横に置く */
.dot.on { background: var(--on); }
.dot.break { background: var(--brk); }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--chip); color: var(--sub); margin-left: 6px; vertical-align: 1px; white-space: nowrap; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.ok { background: var(--on-soft); color: var(--on); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 16px 4px; font-size: 14px; font-weight: 700; color: var(--sub); }
.total { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.total .card { padding: 14px 16px; }
.total .k { color: var(--sub); font-size: 13px; font-weight: 600; }
.total .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ---------- 管理 */
.seg { display: flex; background: var(--chip); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { flex: 1; min-height: 34px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--sub); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.month-nav .m { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 34px; padding: 0 14px; border-radius: 999px; background: var(--chip); font-size: 14px; font-weight: 600; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 16px; align-items: center; }
.bar-row + .bar-row { border-top: .5px solid var(--line); }
.bar-row .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .h { font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-row .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--chip); overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.warn-text { color: var(--warn); }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- シート（下から出る） */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; }
.scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity 240ms var(--ease); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--bg);
  border-radius: 20px 20px 0 0; padding: 8px 16px calc(var(--bottom) + 20px); transform: translateY(100%); transition: transform 320ms var(--ease); max-width: 640px; margin: 0 auto; }
.sheet-wrap.open .scrim { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--faint); margin: 0 auto 12px; opacity: .6; }
#sheet-body { display: flex; flex-direction: column; gap: 14px; }
#sheet-body h2 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
#sheet-body .sub { color: var(--sub); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--sub); }
.field input, .field select, .field textarea { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); outline: none; min-height: 48px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 72px; resize: vertical; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--card); border-radius: 12px; min-height: 52px; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--accent); }
.code-box { font: 700 34px/1.1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .1em; text-align: center; padding: 18px; background: var(--card); border-radius: 14px; -webkit-user-select: all; user-select: all; }
.hist { font-size: 13px; color: var(--sub); background: var(--card); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.site-row .dist { color: var(--sub); font-size: 13px; font-weight: 600; white-space: nowrap; }
.site-row.sel .t1 { color: var(--accent); }
.site-row .check { color: var(--accent); font-size: 20px; }

#toast { position: fixed; left: 50%; bottom: calc(var(--bottom) + 84px); transform: translate(-50%, 20px); z-index: 40; opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px; background: #1c1c1e; color: #fff; font-size: 15px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25); transition: opacity 200ms var(--ease), transform 260ms var(--ease); }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { color: #6ee7b7; font-weight: 700; white-space: nowrap; min-height: 32px; }
#toast.err { background: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .sheet, .scrim, #toast, .btn { transition: opacity 160ms ease !important; }
  .sheet { transform: none !important; opacity: 0; }
  .sheet-wrap.open .sheet { opacity: 1; }
}
