/* ========== My Calm — 기본 변수 & 리셋 ========== */
:root {
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-soft: #ccfbf1;
  --bg: #f1f5f4;
  --bg-soft: #e8eeec;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #d1ddd9;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --shadow: 0 8px 24px rgba(15, 118, 110, 0.08);
  --radius: 20px;
  --radius-sm: 14px;
  --font: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;

  /* 감정 색상 */
  --emotion-calm: #0d9488;
  --emotion-happy: #eab308;
  --emotion-anxious: #8b5cf6;
  --emotion-stress: #f97316;
  --emotion-sad: #3b82f6;
  --emotion-tired: #64748b;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(ellipse at top, #d5f5f0 0%, transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden,
[hidden] {
  display: none !important;
}

/* ========== 앱 컨테이너 ========== */
.app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 1.25rem 1.1rem 2rem;
}

.screen {
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== 헤더 ========== */
.home-header {
  text-align: center;
  padding: 1.5rem 0 1.75rem;
}

.brand {
  margin: 0.75rem 0 0.35rem;
  font-size: 2.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--teal-dark);
}

.greeting {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.home-sub {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.1rem;
}

.screen-header h2 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--teal-dark);
}

.run-header {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.btn-back {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
}

.btn-back:hover,
.btn-back:focus-visible {
  border-color: var(--teal);
  outline: 2px solid var(--teal-soft);
  outline-offset: 2px;
}

/* ========== 감정 오브젝트 ========== */
.emotion-orb {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffffaa, transparent 45%),
    var(--emotion-calm);
  box-shadow: 0 10px 28px rgba(13, 148, 136, 0.35);
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
}

.emotion-orb.small {
  width: 48px;
  height: 48px;
  margin-bottom: 0.85rem;
}

.emotion-orb[data-emotion="calm"] {
  background: radial-gradient(circle at 35% 30%, #ffffffaa, transparent 45%),
    var(--emotion-calm);
  box-shadow: 0 10px 28px rgba(13, 148, 136, 0.35);
}

.emotion-orb[data-emotion="happy"] {
  background: radial-gradient(circle at 35% 30%, #ffffffaa, transparent 45%),
    var(--emotion-happy);
  box-shadow: 0 10px 28px rgba(234, 179, 8, 0.35);
}

.emotion-orb[data-emotion="anxious"] {
  background: radial-gradient(circle at 35% 30%, #ffffffaa, transparent 45%),
    var(--emotion-anxious);
  box-shadow: 0 10px 28px rgba(139, 92, 246, 0.35);
}

.emotion-orb[data-emotion="stress"] {
  background: radial-gradient(circle at 35% 30%, #ffffffaa, transparent 45%),
    var(--emotion-stress);
  box-shadow: 0 10px 28px rgba(249, 115, 22, 0.35);
}

.emotion-orb[data-emotion="sad"] {
  background: radial-gradient(circle at 35% 30%, #ffffffaa, transparent 45%),
    var(--emotion-sad);
  box-shadow: 0 10px 28px rgba(59, 130, 246, 0.35);
}

.emotion-orb[data-emotion="tired"] {
  background: radial-gradient(circle at 35% 30%, #ffffffaa, transparent 45%),
    var(--emotion-tired);
  box-shadow: 0 10px 28px rgba(100, 116, 139, 0.35);
}

/* ========== 카드 ========== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(209, 221, 217, 0.7);
}

.section-label {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0.02em;
}

.quick-section {
  margin: 1.5rem 0 1rem;
}

.quick-grid {
  display: grid;
  gap: 0.75rem;
}

/* ========== 버튼 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 48px;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-weight: 600;
  text-align: center;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease,
    transform 0.15s ease;
}

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

.btn:active {
  transform: scale(0.98);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--teal);
  color: #fff;
}

.btn-primary:hover {
  background: var(--teal-dark);
}

.btn-secondary {
  background: var(--teal-soft);
  color: var(--teal-dark);
  border-color: transparent;
  flex: 1;
}

.btn-secondary:hover {
  background: #b6f0e6;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--teal);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fecaca;
  margin-top: 1rem;
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-card {
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 72px;
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}

.btn-card:hover,
.btn-card:focus-visible {
  border-color: var(--teal);
}

.quick-title {
  font-size: 1.05rem;
  color: var(--text);
}

.quick-desc {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* ========== 감정 선택 ========== */
.emotion-fieldset,
.time-fieldset,
.help-fieldset {
  border: none;
  margin: 0 0 1.15rem;
  padding: 0;
}

.emotion-fieldset legend,
.time-fieldset legend,
.help-fieldset legend {
  font-weight: 600;
  margin-bottom: 0.65rem;
  color: var(--text);
}

.emotion-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}

.emotion-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-height: 72px;
  padding: 0.65rem 0.35rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafcfb;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
}

.emotion-btn:hover,
.emotion-btn:focus-visible {
  border-color: var(--teal);
}

.emotion-btn[aria-pressed="true"] {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.emotion-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.emotion-calm { background: var(--emotion-calm); }
.emotion-happy { background: var(--emotion-happy); }
.emotion-anxious { background: var(--emotion-anxious); }
.emotion-stress { background: var(--emotion-stress); }
.emotion-sad { background: var(--emotion-sad); }
.emotion-tired { background: var(--emotion-tired); }

/* ========== 슬라이더 ========== */
.slider-group {
  margin-bottom: 1.1rem;
}

.slider-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.slider-val {
  color: var(--teal-dark);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 8px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-soft);
  border-radius: 999px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--teal);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.4);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--teal);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.4);
  cursor: pointer;
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 4px;
}

/* ========== 시간 / 도움 선택 ========== */
.time-grid,
.help-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.help-grid {
  grid-template-columns: repeat(5, 1fr);
}

.time-option,
.help-option {
  position: relative;
}

.time-option input,
.help-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.time-option span,
.help-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #fafcfb;
  font-weight: 600;
  color: var(--text);
}

.time-option input:checked + span,
.help-option input:checked + span {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.time-option input:focus-visible + span,
.help-option input:focus-visible + span {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

.form-error {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
}

/* ========== 추천 ========== */
#recommendTitle {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  color: var(--teal-dark);
}

.recommend-reason {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
}

.recommend-time {
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.steps-heading {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.step-list {
  margin: 0 0 1.25rem;
  padding-left: 1.25rem;
  color: var(--text);
}

.step-list li {
  margin-bottom: 0.4rem;
}

/* ========== 실행 화면 ========== */
.run-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 0 1.25rem;
}

.run-progress {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.breath-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.breath-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffffcc, transparent 50%),
    var(--teal);
  box-shadow: 0 12px 40px rgba(13, 148, 136, 0.35);
  transform: scale(0.85);
  transition: transform 4s ease-in-out;
}

.breath-circle.inhale {
  transform: scale(1.2);
}

.breath-circle.exhale {
  transform: scale(0.75);
}

.breath-circle.paused {
  transition: none;
}

.breath-hint {
  position: absolute;
  bottom: 0;
  margin: 0;
  font-weight: 600;
  color: var(--teal-dark);
}

.timer {
  margin: 0;
  font-size: 2.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: 0.02em;
}

.run-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.run-controls .btn-ghost {
  width: 100%;
}

/* ========== 결과 ========== */
.after-intro {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.result-list {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
}

.result-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.result-list li:last-child {
  border-bottom: none;
}

.result-label {
  color: var(--text-muted);
  font-weight: 500;
}

.result-value {
  font-weight: 700;
  color: var(--text);
  text-align: right;
}

#btnResultHome {
  margin-bottom: 0.6rem;
}

/* ========== 기록 ========== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.history-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: var(--teal-dark);
}

.history-meta {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.history-meta span {
  display: block;
  margin-top: 0.2rem;
}

.history-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
}

/* ========== 접근성: 모션 감소 ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .breath-circle {
    transform: none !important;
  }

  .screen {
    animation: none;
  }
}
