/* 持ち物チェック — 色・書体・形のルールは DESIGN.md が正 */

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/barlow-condensed-latin-700.woff2") format("woff2");
}

:root {
  color-scheme: light dark;
  --bg: #F3F6F4;
  --surface: #FFFFFF;
  --ink: #1B2420;
  --ink-2: #5A6962;
  --line: #E1E7E3;
  --line-strong: #86968E;
  --accent: #1F7A5A;
  --on-accent: #FFFFFF;
  --danger: #B3352B;
  --on-danger: #FFFFFF;
  --press: #EEF3F0;
  --track: #E3EAE6;
  --tab-on: #FFFFFF;
  --toast-bg: #1B2420;
  --toast-ink: #F3F6F4;
  --toast-act: #7FD8B3;
  --font-jp: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "Yu Gothic", "Meiryo", sans-serif;
  --font-num: "Barlow Condensed", "Hiragino Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131916;
    --surface: #1B231F;
    --ink: #E8EFEB;
    --ink-2: #A2B1A9;
    --line: #2B3630;
    --line-strong: #5F7067;
    --accent: #5CC79D;
    --on-accent: #0B1F17;
    --danger: #FF8B7E;
    --on-danger: #2A0F0B;
    --press: #222C27;
    --track: #0F1512;
    --tab-on: #2B3730;
    --toast-bg: #E8EFEB;
    --toast-ink: #131916;
    --toast-act: #1F7A5A;
  }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font-jp);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- 全体 ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin-bottom: 8px;
}

.app-name { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0.02em; }

.text-btn {
  min-width: 44px;
  min-height: 44px;
  margin-right: -8px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.text-btn.danger { margin-right: 0; padding-left: 0; color: var(--danger); }

.notice {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  font-size: 14px;
  line-height: 1.6;
}

.notice .nb, .hint .nb { display: block; }

/* ---------- リスト切替 ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--track);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1 0 auto;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.tab:focus-visible { outline-offset: -3px; }
.tab[aria-current="true"] {
  background: var(--tab-on);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.tab-add { color: var(--accent); }

/* ---------- あと◯個（主役の数字） ---------- */
.summary {
  position: relative;
  min-height: 148px;
  padding: 20px 0 4px;
}

.remain { display: flex; align-items: baseline; gap: 8px; margin: 0; }
.remain-pre, .remain-post { font-size: 20px; font-weight: 600; }
.remain-num {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: clamp(84px, 26vw, 112px);
  line-height: 0.85;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 8px;
  margin-top: 16px;
  border-radius: 4px;
  background: var(--track);
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.2s ease-out;
}
.bar-note { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }

.summary-done { padding-top: 28px; }
.done-title { margin: 0; font-size: 30px; font-weight: 600; line-height: 1.25; }
.done-sub { margin: 6px 0 0; font-size: 15px; color: var(--ink-2); }

/* ---------- Signature：日付印 ---------- */
.stamp {
  position: absolute;
  top: 8px;
  right: 0;
  width: 112px;
  height: 112px;
  color: var(--accent);
  transform: rotate(-8deg);
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) { .stamp { mix-blend-mode: normal; } }

.st-ring { fill: none; stroke: currentColor; }
.st-outer { stroke-width: 3.5; }
.st-inner { stroke-width: 1.2; }
.st-rule { stroke: currentColor; stroke-width: 1.3; }
.st-title { fill: currentColor; font-family: var(--font-jp); font-weight: 600; font-size: 20px; letter-spacing: 1px; }
.st-date { fill: currentColor; font-family: var(--font-num); font-weight: 700; font-size: 21px; letter-spacing: 0.5px; }
.st-foot { fill: currentColor; font-family: var(--font-jp); font-weight: 600; font-size: 9px; letter-spacing: 1px; }

.stamp.pop { animation: stamp-in 0.26s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
@keyframes stamp-in {
  0%   { opacity: 0; transform: rotate(-8deg) scale(1.7); }
  55%  { opacity: 1; transform: rotate(-8deg) scale(0.94); }
  100% { opacity: 1; transform: rotate(-8deg) scale(1); }
}

/* ---------- 持ち物の一覧 ---------- */
.hint { margin: 8px 0; font-size: 13px; line-height: 1.6; color: var(--ink-2); }

/* ---------- グループ（見出し＋件数＋面） ---------- */
.groups { margin-top: 20px; }
.group + .group { margin-top: 24px; }
.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 8px;
}
.group-head.is-edit { align-items: center; margin: 0 0 8px; }
.group-name { margin: 0; font-size: 16px; font-weight: 600; }
.group-count {
  margin: 0;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 18px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.group.is-done .group-count { color: var(--accent); }
.group-name-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  font-size: 16px;
  font-weight: 600;
}
.group-del { flex: none; }
.list-empty { padding: 14px 16px; font-size: 14px; color: var(--ink-2); }
.group-tools { margin-top: 12px; }
.text-btn.left { margin: 0 0 0 -8px; }

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
}

.row { position: relative; display: flex; align-items: center; }
.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 58px;
  height: 1px;
  background: var(--line);
}
.row.is-edit + .row.is-edit::before { left: 56px; }

.row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.row-main:active { background: var(--press); }

.check {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  transition: background-color 0.16s, border-color 0.16s;
}
.check svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--on-accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 14;
  stroke-dashoffset: 14;
  transition: stroke-dashoffset 0.16s ease-out 0.04s;
}
.row-input:checked + .check { border-color: var(--accent); background: var(--accent); }
.row-input:checked + .check svg { stroke-dashoffset: 0; }
.row-input:focus-visible + .check { outline: 3px solid var(--accent); outline-offset: 2px; }

.row-text { flex: 1; min-width: 0; font-size: 18px; line-height: 1.45; overflow-wrap: anywhere; }
.row-input:checked ~ .row-text {
  color: var(--ink-2);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.row.is-edit .row-text { padding: 12px 16px 12px 0; }

.del {
  flex: none;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 0;
  background: none;
  cursor: pointer;
}
.del-mark { position: relative; width: 24px; height: 24px; border-radius: 50%; background: var(--danger); }
.del-mark::after {
  content: "";
  position: absolute;
  top: 11px;
  right: 6px;
  left: 6px;
  height: 2px;
  border-radius: 1px;
  background: var(--on-danger);
}
.del:focus-visible { outline-offset: -4px; }

/* ---------- 空の状態 ---------- */
.empty { padding: 24px 4px; color: var(--ink-2); }
.empty p { margin: 0; }
.empty-title { margin-bottom: 4px !important; color: var(--ink); font-size: 18px; font-weight: 600; }
.empty .btn { margin-top: 16px; }

/* ---------- フォーム・ボタン ---------- */
.add-form { margin-top: 16px; }
.add-row, .inline-form { display: flex; gap: 8px; }
.inline-form { flex-wrap: wrap; margin-top: 12px; }

.add-target { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.add-target label { flex: none; font-size: 14px; color: var(--ink-2); }
.select-wrap { position: relative; flex: 1; min-width: 0; }
.select-wrap select { display: block; width: 100%; padding-right: 40px; appearance: none; -webkit-appearance: none; }
.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 18px;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid var(--ink-2);
  border-bottom: 2px solid var(--ink-2);
  transform: rotate(45deg);
  pointer-events: none;
}
.inline-form .field { flex: 1 1 100%; }
.inline-form .btn { flex: 1 1 0; }

.field {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  font-size: 17px;
}
.field::placeholder { color: var(--ink-2); opacity: 1; }

.btn {
  min-height: 48px;
  padding: 0 20px;
  border: 1.5px solid transparent;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.btn:active:not(:disabled) { filter: brightness(0.94); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-outline { border-color: var(--line-strong); background: transparent; color: var(--ink); }
.btn-danger { border-color: var(--danger); background: transparent; color: var(--danger); }
.btn-block { width: 100%; }

.foot { margin-top: 24px; }
.foot .hint { margin-top: 8px; }
.confirm { margin-top: 8px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.confirm p { margin: 0 0 12px; overflow-wrap: anywhere; }
.confirm-row { display: flex; gap: 8px; }

/* ---------- 通知（元に戻す） ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border-radius: 12px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 15px;
}
.toast.is-in { animation: toast-in 0.18s ease-out; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-act {
  flex: none;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--toast-act);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}
