:root {
  --primary: #00695c;
  --primary-soft: rgba(0, 105, 92, 0.08);
  --primary-border: rgba(0, 105, 92, 0.3);
  --rest-set: #ffb74d;
  --rest-post: #ffa726;
  --text: #1a1a1a;
  --text-dim: #6b6b6b;
  --bg: #ffffff;
  --track: #e6e6e6;
  --danger: #d32f2f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow-x: hidden;
}

body {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.appbar {
  padding: 16px 16px 12px;
  text-align: center;
  border-bottom: 1px solid #eee;
}
.appbar h1, .appbar h2 { margin: 0; font-size: 18px; font-weight: 600; }

.appbar-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
}
.appbar-form h2 { flex: 1; text-align: center; font-size: 16px; }

.btn-text {
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  padding: 8px;
  cursor: pointer;
}
.btn-text-strong { color: var(--primary); font-weight: 700; }
.btn-text-danger { color: var(--danger); font-weight: 700; }

.list { flex: 1; overflow-y: auto; padding-bottom: 8px; }

.exercise-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
}
.exercise-item .info { flex: 1; min-width: 0; cursor: pointer; }
.exercise-item .name { font-weight: 600; margin: 0 0 2px; }
.exercise-item .detail { font-size: 12px; color: var(--text-dim); margin: 0; }
.exercise-item .delete-btn {
  background: none; border: none; color: var(--danger); font-size: 20px; cursor: pointer; padding: 6px;
}
.exercise-item .drag-handle {
  color: #bbb; font-size: 18px; cursor: grab; padding: 6px; touch-action: none;
}
.exercise-item.dragging { opacity: 0.5; }

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  color: var(--text-dim);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }

.fab {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 26px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  cursor: pointer;
  max-width: 480px;
  z-index: 5;
}

.bottom-bar {
  padding: 8px 16px 16px;
  border-top: 1px solid #eee;
}

.btn {
  border: none;
  border-radius: 26px;
  font-size: 16px;
  font-weight: 700;
  padding: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }
.btn-secondary { background: #e9e9e9; color: #1a1a1a; }
.btn-row { display: flex; gap: 12px; padding: 0 24px; }
.btn-row .btn {
  flex: 1;
  height: 52px;
  padding: 14px 4px;
  font-size: 15px;
}

.form { padding: 4px 0 24px; overflow-y: auto; flex: 1; }
.field { display: block; padding: 12px 16px; }
.field-label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
}
.field input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

.section-header {
  margin: 16px 16px 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.row-picker {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
  padding: 14px 16px;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  background: none;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.row-icon { font-size: 18px; width: 22px; text-align: center; }
.row-label { flex: 1; }
.row-value, .stat-value, .ring-text, .ready-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper-btn {
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: var(--primary-soft); color: var(--primary); font-size: 18px; cursor: pointer;
}
.stepper-value { min-width: 20px; text-align: center; font-weight: 600; }

.hint { padding: 4px 16px 24px; font-size: 12px; color: var(--text-dim); }

.center-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
}

.ready-label { font-size: 20px; font-weight: 600; margin: 0 0 24px; }
.ready-count { font-size: 140px; color: var(--primary); line-height: 1; }

.timer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 8px;
}

.phase-badge {
  padding: 6px 18px;
  border-radius: 20px;
  color: white;
  font-weight: 700;
  font-size: 14px;
  background: var(--primary);
}

.ring-wrap {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 24px auto;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ring { width: 260px; height: 260px; transform: rotate(-90deg); }
.ring-bg, .ring-fg {
  fill: none;
  stroke-width: 12;
}
.ring-bg { stroke: var(--track); }
.ring-fg {
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-dasharray: 741.4;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.95s linear, stroke 0.2s;
}
.ring-text { position: absolute; font-size: 56px; }

.stat-row { display: flex; gap: 12px; width: 100%; padding: 0 24px 20px; }
.stat-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px;
  border-radius: 14px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
}
.stat-label { font-size: 12px; color: var(--primary); font-weight: 600; }
.stat-value { font-size: 16px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.trophy { font-size: 72px; margin-bottom: 16px; }

.ad-slot { min-height: 0; display: flex; justify-content: center; padding-top: 8px; }
.ad-slot ins { display: block; }

.view[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}
.modal[hidden] { display: none; }
.modal-sheet {
  background: white;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border-radius: 16px 16px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid #eee;
}
.modal-title { font-weight: 700; }
.picker-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
}
.picker-select {
  font-size: 20px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  flex: 1;
  max-width: 120px;
}
.picker-sep { font-size: 15px; color: var(--text-dim); }

.modal-sheet-alert { border-radius: 16px; margin: auto; padding: 20px; }
.modal-title-alert { font-weight: 700; font-size: 17px; margin: 0 0 8px; }
.modal-body-alert { color: var(--text-dim); margin: 0 0 16px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal.modal-center { align-items: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  background: rgba(20, 20, 20, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 30;
  max-width: 80%;
  text-align: center;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --text: #f0f0f0;
    --text-dim: #a0a0a0;
    --track: #333;
  }
  .field input, .picker-select { background: #1e1e1e; color: #f0f0f0; border-color: #444; }
  .exercise-item, .appbar, .row-picker { border-color: #2a2a2a; }
  .btn-secondary { background: #2a2a2a; color: #f0f0f0; }
  .modal-sheet { background: #1e1e1e; }
  .modal-header { border-color: #2a2a2a; }
}
