/* components.css — 部品のレイアウト。色は変数参照のみ。 */

/* ---- 画面の骨格 ---- */
.screen {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: var(--screen-pad-top) var(--screen-pad-x) 0 var(--screen-pad-x);
  gap: var(--gap-block);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen--task { padding-bottom: var(--sp-6); overflow: hidden; }
.screen__title { font-size: var(--f-size-xl); font-weight: 600; }
.screen__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: nowrap; }
.spacer { margin-top: auto; }

/* ---- ボタン ---- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  height: var(--btn-h);
  padding: 0 var(--sp-5);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--f-size-lg);
  font-weight: 600;
  transition: opacity var(--mo-fast) var(--mo-ease);
}
.btn:active { opacity: 0.75; }
.btn { white-space: nowrap; }
.cta { display: flex; flex-direction: column; gap: 10px; padding-bottom: var(--sp-5); }
@media (max-height: 719px) { .cta { padding-bottom: var(--sp-2); gap: 6px; } }
.btn--primary { background: var(--c-primary); color: var(--c-on-primary); }
.btn--ghost { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border); font-weight: 500; font-size: var(--f-size-md); }
.btn--quiet { background: transparent; color: var(--c-text-muted); border: none; font-size: var(--f-size-sm); font-weight: 400; height: 44px; border-radius: var(--r-full); }
.btn--danger { background: var(--c-surface); color: var(--c-danger); border-color: var(--c-border); font-size: var(--f-size-md); }
.btn--small { height: 44px; font-size: var(--f-size-sm); font-weight: 500; padding: 0 var(--sp-4); border-radius: var(--r-full); }
.btn[disabled] { opacity: 0.4; cursor: default; }

/* ---- カード ---- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}
.card--tight { padding: var(--sp-4); border-radius: var(--r-md); }
.card--list { padding: 0 var(--sp-4); border-radius: var(--r-lg); }
.divider { height: 1px; background: var(--c-divider); }

.muted { color: var(--c-text-muted); font-size: var(--f-size-sm); }
.tiny { color: var(--c-text-muted); font-size: var(--f-size-xs); }
.section-label { color: var(--c-text-muted); font-size: var(--f-size-xs); letter-spacing: 0.06em; }

/* ---- 統計 ---- */
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
.stat { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-3); }
.stat__label { color: var(--c-text-muted); font-size: var(--f-size-xs); margin-bottom: var(--sp-1); }
.stat__value { font-size: var(--f-size-stat); font-weight: 500; }
.stat__unit { font-size: var(--f-size-sm); color: var(--c-text-muted); margin-left: 2px; }

/* 文字を大きくしたら2列に折り返す（REQ-G05） */
@media (max-height: 719px) {
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
}

.headline { display: flex; align-items: baseline; gap: var(--sp-2); }
.headline__value { font-size: var(--f-size-display); line-height: 1.05; font-weight: 300; letter-spacing: -0.02em; }
.headline__unit { font-size: var(--f-size-md); color: var(--c-text-muted); }
.headline__delta { margin-left: auto; font-size: var(--f-size-sm); color: var(--c-success-text); font-weight: 600; }

/* ---- 課題 ---- */
.digit {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--f-size-digit);
  line-height: 1;
  font-weight: 300;
  letter-spacing: -0.03em;
}
.dots { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c-icon-weak); }
.dot--on { background: var(--c-primary); }

.slots { display: flex; justify-content: center; gap: var(--sp-2); flex-wrap: wrap; }
.slot {
  width: 52px; height: 68px;
  border-radius: var(--r-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: center;
  font-size: calc(32px * var(--f-scale));
}
.slot--active { border: 2px solid var(--c-primary); }
.slot__placeholder { width: 22px; height: 2px; background: var(--c-icon-weak); align-self: flex-end; margin-bottom: 14px; }
@media (max-height: 719px) { .slot { width: 46px; height: 58px; font-size: calc(28px * var(--f-scale)); } }

.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
.key {
  height: var(--key-h);
  min-height: 44px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: calc(24px * var(--f-scale));
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
}
.key:active { background: var(--c-chip-bg); }
.key--submit { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-on-primary); font-size: var(--f-size-lg); font-weight: 600; }

.countdown-ring {
  width: 200px; height: 200px; border-radius: 50%;
  border: 2px solid var(--c-border);
  display: flex; align-items: center; justify-content: center;
  font-size: calc(112px * var(--f-scale)); line-height: 1; font-weight: 300; color: var(--c-primary);
}

/* ---- 結果 ---- */
.verdict { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--f-size-xl); font-weight: 600; }
.verdict--ok { color: var(--c-success-text); }
.verdict--ng { color: var(--c-danger); }
.kv { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) 0; }
.kv__k { color: var(--c-text-muted); font-size: var(--f-size-sm); }
.kv__v { font-size: var(--f-size-md); }
.kv__v--big { font-size: calc(24px * var(--f-scale)); letter-spacing: 0.14em; }

.badge { display: inline-flex; align-items: center; gap: var(--sp-1); border-radius: var(--r-full); padding: 5px 12px; font-size: var(--f-size-sm); font-weight: 600; }
.badge--ok { background: var(--c-chip-bg); color: var(--c-success-text); }

/* ---- 履歴 ---- */
.row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  width: 100%;
  text-align: left;
  min-height: 44px;
}
.row--empty { opacity: 0.6; }
.row__main { flex: 1 1 auto; min-width: 0; }
.row__date { font-size: var(--f-size-md); font-weight: 500; }
.row__value { font-size: var(--f-size-stat); font-weight: 400; }
.chips { display: flex; gap: var(--sp-1); margin-top: var(--sp-1); flex-wrap: wrap; }
.chip { font-size: var(--f-size-xs); color: var(--c-text-muted); background: var(--c-chip-bg); border-radius: var(--r-sm); padding: 3px 8px; }
.list { display: flex; flex-direction: column; gap: var(--sp-2); }

/* ---- 設定 ---- */
.item { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) 0; min-height: 48px; width: 100%; background: none; border: none; text-align: left; }
.item__label { font-size: var(--f-size-md); }
.item__value { font-size: var(--f-size-md); color: var(--c-text-muted); }
.seg { display: flex; background: var(--c-chip-bg); border-radius: var(--r-sm); padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: none; background: transparent; color: var(--c-text-muted); font-size: var(--f-size-sm); padding: 12px 14px; border-radius: 8px; min-height: 44px; }
.seg button[aria-pressed="true"] { background: var(--c-surface); color: var(--c-text); font-weight: 600; box-shadow: var(--sh-1); }
.switch { width: 52px; height: 32px; border-radius: var(--r-full); background: var(--c-border); border: none; padding: 3px; display: flex; align-items: center; }
.switch[aria-checked="true"] { background: var(--c-primary); justify-content: flex-end; }
.switch__knob { width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: var(--sp-2); }
.theme-card { display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); background: none; border: none; padding: 0; }
.theme-card__swatch { width: 100%; height: 48px; border-radius: var(--r-sm); border: 1px solid var(--c-border); display: flex; align-items: flex-end; padding: 6px; }
.theme-card__bar { width: 100%; height: 12px; border-radius: 4px; }
.theme-card[aria-pressed="true"] .theme-card__swatch { border: 2px solid var(--c-primary); }
.theme-card__name { font-size: var(--f-size-xs); color: var(--c-text-muted); }
.theme-card[aria-pressed="true"] .theme-card__name { color: var(--c-text); font-weight: 600; }

/* ---- テーマエディタ ---- */
.color-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; min-height: 48px; }
.color-row__swatch { width: 40px; height: 40px; border-radius: var(--r-sm); border: 1px solid var(--c-border); padding: 0; background: none; }
.color-row__name { flex: 1 1 auto; font-size: var(--f-size-md); }
.color-row__hex { font-size: var(--f-size-sm); color: var(--c-text-muted); font-variant-numeric: tabular-nums; }
.notice { display: flex; align-items: center; gap: var(--sp-2); border-radius: var(--r-md); padding: 10px 14px; font-size: var(--f-size-sm); }
.notice--ok { background: var(--c-chip-bg); color: var(--c-success-text); }
.notice--warn { background: var(--c-chip-bg); color: var(--c-danger); }
.notice__tag { margin-left: auto; font-weight: 700; font-size: var(--f-size-xs); }

/* ---- タブバー ---- */
.tabbar {
  flex: 0 0 auto;
  height: var(--tabbar-h);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: none; border: none; color: var(--c-text-muted); min-height: 44px; }
.tab[aria-current="page"] { color: var(--c-primary); }
.tab__label { font-size: var(--f-size-xs); }
.tab[aria-current="page"] .tab__label { font-weight: 600; }

/* ---- 補助 ---- */
.icon-btn { width: 44px; height: 44px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: none; border: none; color: var(--c-text-muted); border-radius: var(--r-full); }
/* v1.4: タイトル（アプリ名＋版番号）と、取扱説明ボタン */
.app-title { display: flex; align-items: baseline; gap: 4px; flex: 1 1 auto; min-width: 0; }
.app-title__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-title__ver { flex: 0 0 auto; white-space: nowrap; color: var(--c-text-muted); font-weight: 500; font-size: var(--f-size-xs); }
.manual-btn {
  flex: 0 0 auto;
  min-width: 44px; min-height: 44px;
  padding: 0 var(--sp-2);
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--c-text-muted);
  font-size: var(--f-size-sm); font-weight: 600;
  border-radius: var(--r-md);
  white-space: nowrap;
}
.manual-btn:active { background: var(--c-chip-bg); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px); transform: translateX(-50%);
  background: var(--c-text); color: var(--c-bg);
  padding: 10px 18px; border-radius: var(--r-full); font-size: var(--f-size-sm);
  box-shadow: var(--sh-2); z-index: 40; max-width: 90%;
}
.banner {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--c-chip-bg); border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: var(--sp-3);
  font-size: var(--f-size-sm);
}
.banner__close { margin-left: auto; background: none; border: none; color: var(--c-text-muted); width: 44px; height: 44px; }
.chart { display: block; width: 100%; }
.chart__labels { display: flex; justify-content: space-between; margin-top: var(--sp-1); font-size: var(--f-size-xs); color: var(--c-text-muted); font-variant-numeric: tabular-nums; }

.faq { display: flex; flex-direction: column; gap: var(--sp-2); }
.faq__q { font-size: var(--f-size-md); font-weight: 600; margin-bottom: var(--sp-1); }
.faq__a { font-size: var(--f-size-sm); color: var(--c-text-muted); line-height: 1.7; white-space: pre-line; }
.steps { margin: var(--sp-2) 0 0 0; padding-left: 1.2em; font-size: var(--f-size-sm); color: var(--c-text-muted); line-height: 1.8; }

/* ==================== WM節約ジョブ管理 専用（v1.1差分仕様） ==================== */

.add-job-wrap { flex: 0 0 auto; display: flex; flex-direction: column; gap: var(--sp-1); }
.add-job { display: flex; align-items: center; gap: var(--sp-2); flex: 0 0 auto; }
.add-input, .note-input {
  flex: 1 1 auto;
  min-height: 44px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  padding: 0 var(--sp-3);
  font-size: var(--f-size-md);
}

.now-card {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--c-surface);
  border: 2px solid var(--c-primary);
  border-radius: var(--r-lg);
  padding: var(--sp-2) var(--sp-3);
  min-height: 44px;
  flex: 0 0 auto;
}
.now-card__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* v1.2: 中断中のカードを8件見せるため、実行中のカードも高くしすぎない。
   題名は最大2行まで。3行目以降は「…」で切る。 */
.now-card__title {
  font-size: var(--f-size-lg); font-weight: 700; word-break: break-word;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
/* v1.2: 再開メモの内容は実行中のカードにだけ出す */
.now-card__next {
  font-size: var(--f-size-sm); color: var(--c-text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* v1.2: 「時間」「メモ」「終了」を横に並べる */
.now-card__actions { flex: 0 0 auto; display: flex; align-items: center; gap: var(--sp-1); }

/* v1.2: 8件見えるようにするため、行の間隔と余白を詰めた。
   「終了」ボタンは44pxを保つ必要があるので、これが高さの下限になる。 */
.job-list { display: flex; flex-direction: column; gap: var(--sp-1); flex: 0 0 auto; }
.job-card {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 0 var(--sp-3);
  min-height: 44px;
  cursor: pointer;
}
.job-card__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.job-card__title {
  font-size: var(--f-size-md); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* v1.2: v1.1の「…」を文字の「時間」ボタンに変更。「メモ」も同じ見た目 */
.card-time-btn, .card-memo-btn {
  flex: 0 0 auto;
  min-width: 44px; min-height: 44px;
  padding: 0 6px;
  border-radius: var(--r-full);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-muted);
  font-size: var(--f-size-sm);
}
.card-time-btn:active, .card-memo-btn:active { background: var(--c-chip-bg); }
.card-times { display: flex; gap: var(--sp-3); margin-top: var(--sp-1); min-height: 1em; }

.done-btn {
  flex: 0 0 auto;
  min-width: 44px; min-height: 44px;
  padding: 0 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: var(--f-size-sm);
  font-weight: 600;
}
.done-btn:active { background: var(--c-chip-bg); }

.note-open {
  background: var(--c-chip-bg);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 0 0 auto;
}
.note-open__row { display: flex; align-items: center; gap: var(--sp-2); }
/* v1.2: 「記録」を廃止し、その位置（入力欄の右）に「閉じる」を置いた */
.note-open__close { flex: 0 0 auto; min-width: 56px; min-height: 44px; padding: 0 var(--sp-3); background: none; border: 1px solid var(--c-border); border-radius: var(--r-full); color: var(--c-text-muted); font-size: var(--f-size-sm); }

.done-section { flex: 0 0 auto; }
.done-section__head {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 44px;
  background: none; border: none;
  color: var(--c-text-muted); font-size: var(--f-size-sm);
}
.done-section__list { display: flex; flex-direction: column; gap: var(--sp-1); margin-top: var(--sp-2); }
.done-row {
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--c-chip-bg);
}
.done-row__title { flex: 1 1 auto; min-width: 0; color: var(--c-text-muted); text-decoration: line-through; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.done-row__btn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-full);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  font-size: var(--f-size-xs);
  color: var(--c-text);
}

.undo-bar {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(var(--btn-h) + 24px);
  z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  background: var(--c-text);
  color: var(--c-bg);
  padding: 10px 16px;
  border-radius: var(--r-md);
  box-shadow: var(--sh-2);
  font-size: var(--f-size-sm);
}
.undo-bar__btn { background: none; border: none; color: var(--c-bg); font-weight: 600; min-height: 44px; padding: 0 var(--sp-2); }

/* v1.3: 休憩ボタンの右に「アプリを閉じる」を置くため、横並びにした */
.break-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--screen-pad-x);
  padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
}
.break-button {
  width: 100%;
  min-height: 44px;
  height: var(--btn-h);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: var(--f-size-md);
  font-weight: 600;
}
.break-button[disabled] { opacity: 0.4; }
/* v1.3: 休憩中は黒地＋青枠。薄くしない（休憩中だと分からなかったため） */
.break-button--resting,
.break-button--resting[disabled] {
  opacity: 1;
  background: #111318;
  color: #ffffff;
  border: 2px solid var(--c-primary);
  font-weight: 700;
}
.empty-list { color: var(--c-text-muted); font-size: var(--f-size-sm); padding: var(--sp-4) 0; text-align: center; }
