/* ===== ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #fafafa;
  color: #222;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
/* コンテンツが短い時はフッターをウィンドウ下部に押し出し、
   コンテンツが長い時は自然に下へ伸びてスクロールに追従させる
   （いわゆる sticky footer パターン）。 */
.page-content { flex: 1 0 auto; }

/* ===== レイアウト ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 1rem;
  border-bottom: 1px solid #eee;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 3.5rem;
}
.header__logo { font-size: 1.1rem; font-weight: bold; }
.header__nav  { display: flex; align-items: center; gap: .5rem; }
.header__user { font-size: .85rem; color: #666; }
.footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.5rem 1rem;
  max-width: 480px;
  margin: 0 auto;
}
.footer__select {
  font-size: .8rem;
  color: #888;
  max-width: 45vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== アプリレイアウト（セットアップ／タイマー／実績の3ペイン） =====
   モバイル：1ペインのみ表示し、下部固定タブバーで切り替える。
   PC（min-width: 900px）：3カラム常時並列表示、タブバーは隠す。 */
.app-pane {
  display: none;
  max-width: 480px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}
.app-pane--active { display: block; }
.app-pane__heading { display: none; }

.app-tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid #eee;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 10;
}
.app-tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  padding: .75rem 0 .65rem;
  background: none;
  border: none;
  font-family: inherit;
  color: #999;
  cursor: pointer;
  position: relative;
}
.app-tabbar__item-icon {
  font-size: 1.25rem;
  line-height: 1;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.app-tabbar__item-icon .tomato-icon { width: 1.15em; height: 1.15em; }
.app-tabbar__item-label { font-size: .68rem; }
.app-tabbar__item--active { color: #e55a4a; }
.app-tabbar__item--active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: #e55a4a;
}

/* 下部固定タブバーとフッター（言語・タイムゾーン設定）が重ならないよう余白を確保 */
@media (max-width: 899.98px) {
  body { padding-bottom: 4.75rem; }
}

@media (min-width: 900px) {
  .app-layout {
    display: grid;
    grid-template-columns: 360px 1fr 360px;
    grid-template-rows: auto auto;
    row-gap: 2.5rem;
    max-width: 1400px;
    margin: 0 auto;
    align-items: start;
  }
  .app-pane {
    display: block;
    max-width: none;
    margin: 0;
    padding: 1.75rem 1.5rem;
  }
  .app-pane__heading {
    display: block;
    font-size: .78rem;
    font-weight: 700;
    color: #aaa;
    letter-spacing: .04em;
    margin-bottom: 1.1rem;
  }
  /* 3列目（休憩アイコン／実績）は同じ列に縦積みし、視覚上は3ペイン
     レイアウトのまま、休憩アイコンだけ独自の見出しで区切って見せる。
     モバイルではこの2つはタブとして完全に独立している。 */
  .app-pane--setup     { grid-column: 1; grid-row: 1 / 3; }
  .app-pane--timer      { grid-column: 2; grid-row: 1 / 3; }
  .app-pane--results    { grid-column: 3; grid-row: 1; padding-bottom: 0; }
  .app-pane--breakicon  { grid-column: 3; grid-row: 2; padding-top: 0; }
  .app-pane--timer { background: #fff; border-left: 1px solid #eee; border-right: 1px solid #eee; }
  .app-pane--timer .running__countdown { font-size: 3.2rem; }
  .app-pane--timer .running__sticky { padding: 0; }
  .app-pane--timer .running__date { font-size: 1.2rem; }
  .app-pane--timer .analog-clock { width: 64px; height: 64px; }
  .app-pane--timer .analog-clock__tick { transform-origin: 50% 29px; }
  .app-pane--timer .analog-clock__hand--hour { height: 16px; }
  .app-pane--timer .analog-clock__hand--minute { height: 23px; }
  .app-tabbar { display: none; }
}

/* ===== フラッシュ（フロート・トースト） ===== */
.flash-stack {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  width: calc(100% - 2rem);
  max-width: 420px;
  pointer-events: none;
}
.flash {
  width: 100%;
  padding: .75rem 1rem;
  font-size: .9rem;
  text-align: center;
  border-radius: .6rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.14);
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: auto;
}
.flash--hide { opacity: 0; transform: translateY(-10px) scale(.98); }
.flash--notice { background: #d4edda; color: #155724; }
.flash--alert  { background: #f8d7da; color: #721c24; }

/* ===== iOSインストール案内バナー ===== */
.ios-banner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: #fff6e5;
  border-bottom: 1px solid #f0dca0;
  font-size: .82rem;
  color: #5a4a1f;
}
.ios-banner[hidden] { display: none; }
.ios-banner__text { flex: 1; line-height: 1.5; }
.ios-banner__icon { font-weight: bold; }
.ios-banner__close {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: #a08a4a;
  cursor: pointer;
  padding: .25rem .5rem;
}

/* ===== 通知許可の案内バナー ===== */
.push-banner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: #fff6e5;
  border-bottom: 1px solid #f0dca0;
  font-size: .82rem;
  color: #5a4a1f;
}
.push-banner[hidden] { display: none; }
.push-banner--denied { background: #f3f3f3; border-bottom-color: #ddd; color: #555; }
.push-banner__text { flex: 1; line-height: 1.5; }
.push-banner__enable {
  flex: 0 0 auto;
  background: #e55a4a;
  color: #fff;
  border: none;
  border-radius: .35rem;
  padding: .4rem .8rem;
  font-size: .8rem;
  cursor: pointer;
}
.push-banner__close {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: #a08a4a;
  cursor: pointer;
  padding: .25rem .5rem;
}
.push-banner--denied .push-banner__close { color: #999; }

/* ===== ボタン ===== */
.btn {
  display: inline-block;
  padding: .6rem 1.2rem;
  border: none;
  border-radius: .5rem;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn--primary   { background: #e55a4a; color: #fff; }
.btn--secondary { background: #eee;    color: #333; }
.btn--ghost     { background: transparent; color: #555; border: 1px solid #ccc; }
.btn--sm        { padding: .35rem .75rem; font-size: .8rem; }
.btn--large     { width: 100%; padding: .9rem; font-size: 1.05rem; margin-top: 1.5rem; text-align: center; }

/* ===== セットアップ画面 ===== */
.setup__title { font-size: 1.3rem; font-weight: bold; margin-bottom: .25rem; }
.setup__meta  { color: #666; font-size: .9rem; margin-bottom: 1.25rem; }
.slots { list-style: none; }
.slot {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 0;
  border-bottom: 1px solid #eee;
  font-size: .95rem;
}
.slot__time  { color: #888; font-size: .82rem; min-width: 7rem; }
.slot__icon  { font-size: 1rem; }
.slot__label { flex: 1; }
.slot__count { color: #aaa; font-size: .82rem; }
.setup__total { margin-top: 1rem; font-size: .95rem; color: #444; }
.setup__done  { margin-top: 1.5rem; text-align: center; color: #555; }

.input {
  padding: .4rem .5rem;
  border: 1px solid #ddd;
  border-radius: .35rem;
  font-size: .85rem;
}
.input--sm         { width: 4rem; }
.input--time       { width: 5rem; }
.input--hour, .input--minute { width: 3.5rem; }

.preset-form { margin-bottom: 1.5rem; padding-bottom: 1.25rem; border-bottom: 1px solid #eee; }
.preset-form__row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
}
.preset-form__label { flex: 0 0 auto; font-size: .85rem; color: #555; }
.preset-form__value { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.time-pair { display: inline-flex; align-items: center; gap: .15rem; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: #555; }

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .3rem;
  margin: 1rem 0;
}
.grid-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
  padding: .5rem .2rem;
  border-radius: .4rem;
  cursor: pointer;
  user-select: none;
  font-size: .7rem;
  color: #888;
}
.grid-cell--pomodoro { background: #fdeceb; }
.grid-cell--blank    { background: #eee; }
.grid-cell--elapsed  { opacity: .45; filter: grayscale(.6); }
.grid-cell__icon { font-size: 1.1rem; }
.preset-grid__total  { font-size: .95rem; color: #444; margin-bottom: .25rem; }
.preset-grid__status { font-size: .8rem; color: #888; min-height: 1.2em; margin-bottom: .5rem; }

.slot--editable { flex-wrap: wrap; gap: .75rem; }
.slot-form { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; flex: 1; }
.slot-form--new { margin-top: .75rem; }

/* ===== サマリーカード ===== */
.summary-card {
  background: #fff;
  border: 1px solid #eee;
  border-radius: .75rem;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  margin-bottom: 1.1rem;
}
.summary-card__count {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  margin-bottom: .85rem;
}
.summary-card__count-icon { font-size: 1.5rem; }
.summary-card__count-num  { font-size: 2rem; font-weight: 700; color: #e55a4a; line-height: 1; }
.summary-card__count-unit { font-size: .9rem; color: #888; }
.summary-card__count-duration { font-size: .8rem; color: #aaa; }
.summary-card__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  padding-top: .8rem;
  border-top: 1px solid #f2f2f2;
}
.summary-stat { text-align: center; }
.summary-stat__label { font-size: .72rem; color: #999; margin-bottom: .2rem; }
.summary-stat__value { font-size: .95rem; font-weight: 600; color: #333; }

/* ===== 始業／終業タイムレンジ ===== */
.time-range {
  display: flex;
  align-items: flex-end;
  gap: .6rem;
  margin-bottom: 1rem;
}
.time-range__field { flex: 1; display: flex; flex-direction: column; gap: .3rem; }
.time-range__label { font-size: .75rem; color: #888; }
.time-range__field .input--time { width: 100%; text-align: center; }
.time-range__sep { color: #ccc; padding-bottom: .5rem; }

/* ===== 実行中画面 ===== */
.running { text-align: center; }
.running__sticky {
  padding-top: .5rem;
  padding-bottom: 1rem;
}
.running .preset-editor { margin-top: 1rem; }
.running__card {
  border-radius: 1rem;
  padding: 1.25rem 1rem 1.5rem;
  border: 1px solid transparent;
}
.running__card--work  { background: #fdf1f0; border-color: #f6d9d6; }
.running__card--blank { background: #f2f3f4; border-color: #e2e4e6; }
.running__state {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: .6rem;
}
.running__state--work  { color: #e55a4a; }
.running__state--blank { color: #888; }
.running__transition {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  font-size: 1.1rem;
  font-weight: bold;
  color: #555;
  margin-bottom: .25rem;
}
.running__arrow { color: #ccc; font-weight: normal; }
.running__countdown {
  font-size: 5rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: #555;
  line-height: 1;
  margin-bottom: .75rem;
  transition: color .3s;
  font-variant-numeric: tabular-nums;
}
.running__countdown--work  { color: #e55a4a; }
.running__countdown--break { color: #8b5a2b; }
.running__countdown--blank { color: #888; }
.running__fraction {
  font-size: .85rem;
  color: #aaa;
  margin-bottom: .9rem;
  font-variant-numeric: tabular-nums;
}
.progress {
  height: 10px;
  background: #eee;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: .25rem;
}
.progress__bar  { height: 100%; background: #e55a4a; transition: width 1s linear, background-color .3s; }
.progress__bar--work  { background: #e55a4a; }
.progress__bar--break { background: #8b5a2b; }
.progress__bar--blank { background: #888; }
.running__message { font-size: .85rem; color: #888; margin: .9rem 0 1.1rem; }
.running__actions {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.running__actions .btn {
  width: 100%;
  border-radius: 999px;
  padding: .85rem 1rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
.running__pause-icon {
  display: inline-flex;
  gap: 3px;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
}
.running__pause-icon span {
  display: block;
  width: 4px;
  height: 14px;
  background: currentColor;
  border-radius: 1px;
}
.running__pause-icon--sm { width: 11px; height: 11px; vertical-align: -1px; }
.running__pause-icon--sm span { width: 3px; height: 11px; }
.running__paused-label { font-size: .9rem; color: #aaa; margin-bottom: .5rem; }
.running__today-actual { text-align: center; margin-top: 1rem; font-size: .95rem; color: #444; }

/* ===== 日付＋アナログ時計 ===== */
.running__topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .9rem;
  margin-bottom: 1rem;
}
.running__date { font-size: 1.55rem; color: #444; font-weight: 700; white-space: nowrap; }
.analog-clock {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #ddd;
  flex-shrink: 0;
}
.analog-clock__tick {
  position: absolute;
  left: 50%; top: 3px;
  width: 2px; height: 8px;
  margin-left: -1px;
  background: #bbb;
  transform-origin: 50% 39px;
}
.analog-clock__tick--major { width: 3px; height: 10px; margin-left: -1.5px; background: #999; }
.analog-clock__hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  transform-origin: 50% 100%;
  background: #333;
  border-radius: 2px;
}
.analog-clock__hand--hour   { width: 4px; height: 22px; margin-left: -2px; }
.analog-clock__hand--minute { width: 3px; height: 32px; margin-left: -1.5px; background: #e55a4a; }
.analog-clock__center {
  position: absolute;
  left: 50%; top: 50%;
  width: 6px; height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #333;
}

/* ===== 「今、一番注力したいこと」欄 ===== */
.focus-text { margin-bottom: 1.25rem; }
.focus-text__display {
  padding: .65rem .8rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #333;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 8rem;
  overflow-y: auto;
  cursor: text;
}
.focus-text__display:empty::before {
  content: attr(data-placeholder);
  color: #bbb;
  white-space: pre-line;
}
.focus-text__input {
  width: 100%;
  resize: none;
  border: 1px solid #eee;
  border-radius: .6rem;
  padding: .65rem .8rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  color: #333;
  background: #fff;
  max-height: 8rem;
  overflow-y: auto;
}
.focus-text__input::placeholder { color: #bbb; }
.focus-text__input:focus { outline: none; border-color: #e55a4a; }

/* ===== 今日の流れ（ミニタイムライン） ===== */
.today-flow { margin-top: 1.25rem; text-align: left; }
.today-flow[hidden] { display: none; }
.today-flow__heading { font-size: .78rem; color: #888; margin-bottom: .4rem; }
.today-flow__track { display: flex; gap: 2px; }
.today-flow__cell { flex: 1; height: 14px; border-radius: 2px; background: #f2a8a0; }
.today-flow__cell--blank { background: #ddd; }
.today-flow__cell--done { background: #e55a4a; }
.today-flow__cell--blank.today-flow__cell--done { background: #b9b9b9; }
.today-flow__cell--current { box-shadow: 0 0 0 2px #333; }
.today-flow__marker {
  display: flex;
  justify-content: space-between;
  font-size: .65rem;
  color: #888;
  margin-top: .3rem;
}
.today-flow__legend {
  display: flex;
  gap: 1rem;
  margin-top: .5rem;
  font-size: .72rem;
  color: #888;
}
.today-flow__legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
  margin-right: .35rem;
  vertical-align: middle;
}

/* ===== 実績ヒートマップ ===== */
.heatmap-section { margin-top: 2rem; }
.heatmap-section__heading { font-size: .8rem; color: #888; margin-bottom: .5rem; }
.heatmap-wrapper { display: flex; justify-content: center; gap: 4px; overflow-x: auto; }
.heatmap-day-labels {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 17px;
  flex-shrink: 0;
}
.heatmap-day-labels__cell {
  height: 16px;
  font-size: .65rem;
  color: #aaa;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.heatmap-grid { display: flex; flex-direction: column; }
.heatmap-months { display: flex; gap: 3px; height: 14px; margin-bottom: 3px; }
.heatmap-months__cell {
  width: 16px;
  flex-shrink: 0;
  overflow: visible;
  white-space: nowrap;
  font-size: .65rem;
  color: #aaa;
}
.heatmap { display: flex; gap: 3px; }
.heatmap__week { display: flex; flex-direction: column; gap: 3px; }
.heatmap__day { width: 16px; height: 16px; border-radius: 3px; background: #ebedf0; flex-shrink: 0; }

/* ===== トマトアイコン（SVG） ===== */
.tomato-icon { width: 1.3em; height: 1.3em; display: inline-block; vertical-align: -.25em; flex-shrink: 0; }

/* ===== 休憩アイコン選択 ===== */
.break-icon-picker { margin-bottom: 1.5rem; }
.break-icon-picker__label { font-size: .78rem; color: #888; margin-bottom: .5rem; }
.break-icon-picker__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr));
  gap: .4rem;
}
.break-icon-picker__tile {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: #fff;
  border: 1px solid #eee;
  border-radius: .5rem;
  cursor: pointer;
}
.break-icon-picker__tile--active { border-color: #e55a4a; background: #fdf1f0; }
