/* ============================================================
   Cairn UI — 再利用可能なデザイントークン＆コンポーネント
   使い方: このファイルを読み込み、demo.html のマークアップ例を参照。
   詳しいルールは DESIGN.md を参照。
   ============================================================ */

/* ---------- デザイントークン ---------- */
:root {
  --bg: #f2f2ef;
  --card: #ffffff;
  --fg: #1b1b1d;
  --sub: #a3a3a6;
  --sub2: #c6c6c8;
  --hairline: #e7e7e4;
  --pill: #4a4a4c;
  --toolbar: #3d3d3f;
  --toolbar-hi: #59595c;
  --red: #e5484d;
  --blue: #2f6bff;
  --radius-card: 18px;
  --radius-sheet: 22px;
  --radius-row: 14px;
  --radius-input: 10px;
  --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.07);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-menu: 0 10px 36px rgba(0, 0, 0, 0.16);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --task-fw: 400; /* 本文ウェイト（設定で可変にする場合） */
  /* --accent: #4a7cf7;  テーマ色を使う場合に定義（未定義なら--fgが使われる） */
}

.theme-dark {
  --bg: #161618;
  --card: #232326;
  --fg: #ececee;
  --sub: #86868a;
  --sub2: #5a5a5e;
  --hairline: #313134;
  --toolbar: #2c2c2e;
  --toolbar-hi: #4c4c50;
  --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.35);
}

/* ---------- ベース ---------- */
.cairn,
.cairn * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
.cairn {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
.cairn button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.cairn input, .cairn textarea { font: inherit; color: var(--fg); }

/* ---------- ページヘッダー ---------- */
.c-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 6px;
  min-height: 56px;
}
.c-title {
  font-size: 27px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}
.c-title .chev { font-size: 15px; font-weight: 600; transform: translateY(2px); }
.c-title:active { opacity: 0.55; }

.c-header-pill {
  background: var(--pill);
  border-radius: 999px;
  display: flex;
  padding: 4px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
}
.c-header-pill button {
  width: 42px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
}
.c-header-pill svg { width: 19px; height: 19px; stroke: #fff; }
.c-header-pill button:active { opacity: 0.6; }

/* ブランドタグ（画面最上部中央） */
.c-brand { font-size: 11px; color: var(--sub); text-align: center; }

/* ---------- リスト行 ---------- */
.c-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 20px;
  background: var(--bg);
  transition: transform 0.25s var(--ease), opacity 0.3s;
}
.c-check {
  width: 21px;
  height: 21px;
  border: 1.6px solid var(--sub2);
  border-radius: 5px;
  flex-shrink: 0;
  margin-top: 2px;
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 13px;
  font-weight: 700;
  transition: border-color 0.18s, color 0.18s, background 0.18s, transform 0.18s;
}
.c-check.round { border-radius: 50%; }
.c-row:active .c-check { transform: scale(0.9); }
.c-row-title {
  font-size: 16.5px;
  font-weight: var(--task-fw);
  line-height: 1.4;
  position: relative;
  display: inline-block;
}
/* 完了アニメーション: 取り消し線が伸びる */
.c-row-title::after {
  content: "";
  position: absolute;
  left: 0;
  top: 54%;
  height: 1.5px;
  width: 0;
  background: var(--sub);
  transition: width 0.3s ease;
}
.c-row.done .c-row-title { color: var(--sub); }
.c-row.done .c-row-title::after { width: 100%; }
.c-row.done .c-check {
  background: var(--accent, var(--sub2));
  border-color: var(--accent, var(--sub2));
  color: #fff;
}
.c-row-meta { font-size: 12px; color: var(--sub); margin-top: 3px; display: flex; gap: 8px; }
.c-row-meta .today, .c-row-meta .overdue { color: var(--red); }
.c-row.removing { transform: translateX(-110%); opacity: 0; }

/* ---------- FAB ---------- */
.c-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent, #111);
  color: #fff;
  font-size: 30px;
  font-weight: 200;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}
.c-fab:active { transform: scale(0.88); }
.theme-dark .c-fab { background: var(--accent, #fff); color: var(--accent-contrast, #111); }

/* ---------- 下部ツールバー ---------- */
.c-toolbar {
  background: var(--toolbar);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  box-shadow: var(--shadow-float);
}
.c-toolbar button {
  width: 58px;
  height: 48px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  position: relative;
  transition: background 0.25s ease;
}
.c-toolbar svg { width: 21px; height: 21px; stroke: #fff; opacity: 0.95; }
.c-toolbar button.active { background: var(--toolbar-hi); }
.c-toolbar .dot {
  position: absolute;
  top: 8px;
  right: 11px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
}

/* ---------- ボタン ---------- */
.c-btn-primary {
  display: block;
  width: 100%;
  background: var(--fg);
  color: var(--bg);
  border-radius: 999px;
  padding: 15px;
  font-size: 15.5px;
  font-weight: 700;
  text-align: center;
  transition: transform 0.12s;
}
.c-btn-primary:active { transform: scale(0.97); }
.c-btn-ghost {
  display: block;
  width: 100%;
  border-radius: 999px;
  padding: 13px;
  font-size: 14.5px;
  color: var(--sub);
  text-align: center;
}
.c-btn-danger { color: var(--red); }

/* ---------- トグル ---------- */
.c-toggle {
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--sub2);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
  display: inline-block;
}
.c-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s var(--ease);
}
.c-toggle.on { background: var(--accent, var(--fg)); }
.c-toggle.on::after { transform: translateX(18px); }

/* ---------- セグメント ---------- */
.c-seg {
  background: rgba(0, 0, 0, 0.055);
  border-radius: 999px;
  padding: 3px;
  display: inline-flex;
}
.theme-dark .c-seg { background: rgba(255, 255, 255, 0.08); }
.c-seg button {
  font-size: 12.5px;
  padding: 6px 16px;
  border-radius: 999px;
  color: var(--sub);
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.c-seg button.on {
  background: var(--card);
  color: var(--fg);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* ---------- 設定カード＆行 ---------- */
.c-card {
  background: var(--card);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.c-set-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  font-size: 15px;
  text-align: left;
  position: relative;
}
.c-set-row + .c-set-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 46px;
  right: 0;
  border-top: 1px solid var(--hairline);
}
.c-set-row .grow { flex: 1; }
.c-set-row .val { color: var(--sub); font-size: 13.5px; }
.c-set-row .chev-r { color: var(--sub2); font-size: 15px; }
.c-set-row .ic svg { width: 18px; height: 18px; stroke: var(--fg); }

/* ---------- ボトムシート ---------- */
.c-sheet {
  background: var(--card);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  padding: 14px 20px 24px;
  animation: c-sheet-up 0.3s var(--ease);
}
.c-sheet .grab {
  width: 44px;
  height: 4px;
  background: var(--sub2);
  border-radius: 4px;
  margin: 0 auto 12px;
}
.c-sheet h2 { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 14px; }
@keyframes c-sheet-up { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- メニュー ---------- */
.c-menu {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow-menu);
  padding: 5px;
  min-width: 220px;
  animation: c-pop 0.18s var(--ease);
  transform-origin: top right;
}
@keyframes c-pop { from { transform: scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }
.c-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  font-size: 14.5px;
  border-radius: 9px;
  text-align: left;
}
.c-menu button:active { background: var(--bg); }
.c-menu .danger { color: var(--red); }
.c-menu .sep { border-top: 1px solid var(--hairline); margin: 4px 10px; }

/* ---------- ダイアログ・トースト ---------- */
.c-dialog {
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  padding: 22px 20px 16px;
  max-width: 330px;
  animation: c-pop 0.2s var(--ease);
}
.c-dialog .msg { font-size: 14.5px; line-height: 1.65; margin-bottom: 16px; }
.c-dialog .a-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  font-size: 14.5px;
  margin-top: 8px;
  background: var(--bg);
  text-align: center;
}
.c-dialog .a-btn.primary { background: var(--fg); color: var(--bg); font-weight: 700; }
.c-dialog .a-btn.warn { color: var(--red); background: rgba(229, 72, 77, 0.08); }

.c-toast {
  background: rgba(20, 20, 22, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 999px;
  display: inline-block;
  animation: c-pop 0.2s ease;
}

/* ---------- 入力 ---------- */
.c-input {
  width: 100%;
  background: var(--bg);
  border: none;
  border-radius: var(--radius-input);
  padding: 12px 14px;
  outline: none;
}

/* ---------- タイマーリング ---------- */
.c-ring-track { fill: none; stroke: var(--hairline); stroke-width: 2; }
.c-ring-prog {
  fill: none;
  stroke: var(--accent, var(--fg));
  stroke-width: 2;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 1s linear;
}
.c-ring-time {
  font-size: clamp(44px, 14vw, 60px);
  font-weight: 300;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
