/* ぴーチャレ。スマホで、朝と夜に10秒だけ開くもの。
   基準は「片手・1タップ・10秒」。主要操作は親指の届く下半分に置く。 */

:root {
  --paper: #f6f5f0;
  --surface: #ffffff;
  --surface-2: #eeede6;
  --ink: #16233b;
  --muted: #5a6478;
  --faint: #8b93a3;
  --line: #dcdad1;
  --indigo: #2c4a7c;
  --indigo-ink: #ffffff;
  --kihada: #9d7310;
  --shu: #a83b27;
  --moss: #3d6a50;
  --shadow: 0 1px 2px rgba(22, 35, 59, 0.06), 0 6px 20px rgba(22, 35, 59, 0.05);
  --tap: 44px; /* タップ領域の最小 */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #11151d;
    --surface: #181d27;
    --surface-2: #212734;
    --ink: #e7e5dd;
    --muted: #a4abb9;
    --faint: #79808f;
    --line: #2b3241;
    --indigo: #7fa3da;
    --indigo-ink: #0f1420;
    --kihada: #dcac49;
    --shu: #e0765e;
    --moss: #72ac87;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 22px rgba(0, 0, 0, 0.28);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP",
    system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* iPhone のホームバーとノッチを避ける */
#app {
  min-height: 100vh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
.page { max-width: 560px; margin: 0 auto; padding: 0 16px 32px; }
.page.plain { padding-bottom: 48px; }
body.no-nav #app { padding-bottom: 0; }

/* ---- ヘッダ ---- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 17px; letter-spacing: .04em; font-weight: 700; }
.top .who { font-size: 13px; color: var(--muted); }

/* ---- カード ---- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; margin: 14px 0; box-shadow: var(--shadow);
}
.card.tight { padding: 12px 14px; }
.card h2 { margin: 0 0 10px; font-size: 15px; letter-spacing: .02em; }
.sec {
  margin: 22px 0 8px; font-size: 12px; letter-spacing: .1em; color: var(--faint);
  text-transform: uppercase;
}
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }

/* ---- カウントダウン ---- */
.countdowns { display: flex; gap: 10px; }
.count {
  flex: 1; text-align: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 8px;
}
.count .label { display: block; font-size: 12px; color: var(--faint); }
.count .num {
  font-size: 30px; font-weight: 700; color: var(--shu); line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.count .num .unit { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.count.now .num { font-size: 20px; color: var(--kihada); }

/* ---- ボタン ---- */
button, .btn {
  font: inherit; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); padding: 0 14px;
  min-height: var(--tap); cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: .5; cursor: default; }
button.primary {
  background: var(--indigo); color: var(--indigo-ink); border-color: var(--indigo);
  font-weight: 700; letter-spacing: .06em; width: 100%; font-size: 16px;
}
button.ghost { border-color: transparent; background: transparent; color: var(--indigo); padding: 0 8px; }
button.danger { color: var(--shu); border-color: var(--line); }
button.small { min-height: 34px; font-size: 13px; padding: 0 10px; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--kihada); outline-offset: 2px;
}

/* ---- 入力 ---- */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, textarea, select {
  font: inherit; width: 100%; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; min-height: var(--tap);
}
/* iOS は 16px 未満の入力欄で自動ズームする。それを避ける */
input, textarea, select { font-size: 16px; }
textarea { min-height: 76px; resize: vertical; line-height: 1.6; }
.field { margin-bottom: 14px; }
.inline-fields { display: flex; gap: 8px; }
.inline-fields > * { flex: 1; }

/* ---- 区分チップ ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; min-height: 38px;
  background: var(--surface); color: var(--muted); font-size: 14px;
  display: inline-flex; align-items: center; cursor: pointer;
}
.chip[aria-pressed="true"] {
  background: var(--indigo); color: var(--indigo-ink); border-color: var(--indigo); font-weight: 700;
}

/* ---- チームの今日 ---- */
.member { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: none; }
.member .handle { flex: 0 0 auto; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .state { font-size: 13px; color: var(--moss); }
.member .state.no { color: var(--faint); }
.member .meta { margin-left: auto; font-size: 12px; color: var(--muted); text-align: right; }
.member.me .handle { font-weight: 700; }

/* ---- 週グリッド ---- */
.grid-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; }
.grid-row .handle { flex: 0 0 5.5em; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dots { display: flex; gap: 5px; }
.dot { width: 15px; height: 15px; border-radius: 50%; background: var(--moss); }
.dot.off { background: transparent; border: 1px solid var(--faint); }
.dot.future { background: transparent; border: 1px dashed var(--faint); opacity: .5; }
.dot.today { box-shadow: 0 0 0 2px var(--kihada); }
.weekdays { display: flex; gap: 5px; margin-left: calc(5.5em + 8px); }
.weekdays span { width: 15px; text-align: center; font-size: 11px; color: var(--faint); }
.rest-tag { margin-left: auto; font-size: 11px; color: var(--kihada); }

/* ---- 投稿 ---- */
.post { border-top: 1px solid var(--line); padding: 12px 0; }
.post:first-child { border-top: none; }
.post .head { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.post .body { font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.post .stamps { display: flex; gap: 8px; margin-top: 8px; }
.stamp { border: 1px solid var(--line); border-radius: 999px; min-height: 34px; padding: 0 12px; font-size: 13px; }
.stamp[aria-pressed="true"] { border-color: var(--indigo); color: var(--indigo); font-weight: 700; }

/* ---- 棒グラフ ---- */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.bar-row .name { flex: 0 0 5.5em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 10px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
/* inline のままだと height が効かず、塗りが見えない */
.bar-fill { display: block; height: 100%; background: var(--indigo); border-radius: 3px; }
.bar-row .min { flex: 0 0 3.6em; text-align: right; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.total { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.total .unit { font-size: 14px; font-weight: 400; color: var(--muted); margin: 0 1px; }

/* ---- タブ ---- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; flex-direction: column; gap: 2px; min-height: 56px; border: none;
  background: transparent; color: var(--faint); font-size: 11px; border-radius: 0; padding: 6px 0;
}
.tabs button .icon { font-size: 19px; line-height: 1; }
.tabs button[aria-current="page"] { color: var(--indigo); font-weight: 700; }

/* ---- 通知・注意書き ---- */
.note {
  border-left: 3px solid var(--kihada); background: var(--surface);
  padding: 12px 14px; border-radius: 0 8px 8px 0; margin: 14px 0; font-size: 13.5px;
  color: var(--muted); line-height: 1.7;
}
.note.warn { border-left-color: var(--shu); }
.note strong { color: var(--ink); }
.note ol, .note ul { margin: 8px 0 0; padding-left: 1.2em; }
.note li { margin-bottom: 5px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 50;
  background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 999px;
  font-size: 14px; max-width: calc(100% - 32px); text-align: center; box-shadow: var(--shadow);
}
.toast.error { background: var(--shu); color: #fff; }

.pill { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--muted); }
.pill.on { border-color: var(--moss); color: var(--moss); }
.pill.off { border-color: var(--kihada); color: var(--kihada); }

.empty { text-align: center; color: var(--faint); padding: 26px 12px; font-size: 14px; line-height: 1.8; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 3px; overflow-wrap: anywhere; }

.list-item { border-bottom: 1px solid var(--line); padding: 12px 0; }
.list-item:last-child { border-bottom: none; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
