/* ── CBT 4주 프로그램 — Sage Green Botanical Design System ── */

:root {
  --sage: #7A9E7E;
  --sage-light: #A8C5A0;
  --sage-pale: #E8F0E9;
  --sage-deep: #4E7250;
  --cream: #F7F4EE;
  --cream-dark: #EDE8DF;
  --brown: #8B7355;
  --brown-light: #C4A882;
  --text-dark: #2C3E2D;
  --text-mid: #5A6B5B;
  --text-light: #8A9E8B;
  --accent: #D4845A;
  --accent-light: #F2C4A6;
  --warn: #E8A020;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(74,114,80,0.12);
  --shadow-sm: 0 2px 8px rgba(74,114,80,0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background: var(--cream);
  color: var(--text-dark);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow-x: hidden;
}

button { touch-action: manipulation; -webkit-user-select: none; user-select: none; cursor: pointer; border: none; background: none; font-family: inherit; }

/* ── Botanical Background Motif ── */
.botanical-bg {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.botanical-bg::before {
  content: '';
  position: absolute; top: -60px; right: -40px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(122,158,126,0.15) 0%, transparent 70%);
  border-radius: 50%;
}
.botanical-bg::after {
  content: '';
  position: absolute; bottom: 60px; left: -50px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(168,197,160,0.12) 0%, transparent 70%);
  border-radius: 50%;
}

/* ── Header ── */
.header {
  background: linear-gradient(135deg, var(--sage-deep) 0%, var(--sage) 100%);
  color: white;
  padding: max(52px, env(safe-area-inset-top, 20px) + 32px) 20px 20px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 12px rgba(78,114,80,0.25);
}
.header-inner { display: flex; align-items: center; gap: 12px; max-width: 480px; margin: 0 auto; }
.header-back {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: white; flex-shrink: 0;
  transition: background 0.2s;
}
.header-back:active { background: rgba(255,255,255,0.35); }
.header-title { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; flex: 1; }
.header-subtitle { font-size: 12px; opacity: 0.8; margin-top: 2px; }
.header-leaf { font-size: 22px; flex-shrink: 0; }

/* ── Main Content Wrap ── */
.main { max-width: 480px; margin: 0 auto; padding: 20px 16px calc(env(safe-area-inset-bottom, 0px) + 80px); position: relative; z-index: 1; }

/* ── Stats Card (Home) ── */
.stats-card {
  background: linear-gradient(135deg, var(--sage-deep) 0%, var(--sage) 60%, var(--sage-light) 100%);
  border-radius: var(--radius);
  padding: 24px;
  color: white;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.stats-card::before {
  content: '🌿';
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  font-size: 60px; opacity: 0.2;
}
.stats-label { font-size: 13px; opacity: 0.85; margin-bottom: 6px; }
.stats-days { font-size: 42px; font-weight: 800; line-height: 1; }
.stats-days span { font-size: 16px; font-weight: 500; margin-left: 4px; opacity: 0.85; }
.stats-row { display: flex; gap: 20px; margin-top: 16px; }
.stats-item { flex: 1; }
.stats-item-val { font-size: 22px; font-weight: 700; }
.stats-item-lbl { font-size: 11px; opacity: 0.75; margin-top: 2px; }

/* ── Progress Bar ── */
.progress-section { margin-bottom: 24px; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-mid); margin-bottom: 8px; }
.progress-bar {
  height: 8px; background: var(--cream-dark); border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sage) 0%, var(--sage-light) 100%);
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Week Sections ── */
.week-section { margin-bottom: 28px; }
.week-title {
  font-size: 13px; font-weight: 700; color: var(--sage-deep);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.week-title::after { content: ''; flex: 1; height: 1px; background: var(--sage-pale); }

/* ── Session Card ── */
.session-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}
.session-card:active { transform: scale(0.98); }
.session-card.locked { opacity: 0.55; pointer-events: none; }
.session-card.completed { border-left: 4px solid var(--sage); }
.session-card.available { border-left: 4px solid var(--sage-light); cursor: pointer; }
.session-card.locked { border-left: 4px solid var(--cream-dark); }

.session-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.session-card.completed .session-icon { background: var(--sage-pale); }
.session-card.available .session-icon { background: linear-gradient(135deg, var(--sage-pale), var(--cream-dark)); }
.session-card.locked .session-icon { background: var(--cream-dark); }

.session-info { flex: 1; min-width: 0; }
.session-day { font-size: 11px; font-weight: 600; color: var(--text-light); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.5px; }
.session-name { font-size: 15px; font-weight: 700; color: var(--text-dark); }
.session-time { font-size: 12px; color: var(--text-light); margin-top: 3px; }

.session-badge {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.session-card.completed .session-badge { background: var(--sage); color: white; }
.session-card.available .session-badge { background: var(--sage-pale); color: var(--sage-deep); }
.session-card.locked .session-badge { background: var(--cream-dark); color: var(--text-light); }

/* ── Settings Button ── */
.fab {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); right: 20px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--sage-deep); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; box-shadow: 0 6px 20px rgba(78,114,80,0.4);
  z-index: 200; transition: transform 0.2s;
}
.fab:active { transform: scale(0.92); }

/* ── Session Player ── */
.player-header {
  background: linear-gradient(135deg, var(--sage-deep) 0%, var(--sage) 100%);
  color: white;
  padding: max(52px, env(safe-area-inset-top, 20px) + 32px) 20px 0;
  position: sticky; top: 0; z-index: 100;
}
.player-title-row {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 0;
}
.player-day-label { font-size: 12px; opacity: 0.8; margin-bottom: 2px; }
.player-title { font-size: 18px; font-weight: 800; }

/* Step Tab Bar */
.step-tabs {
  display: flex; margin-top: 16px;
}
.step-tab {
  flex: 1; padding: 12px 4px; text-align: center;
  font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.6);
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}
.step-tab.active { color: white; border-bottom-color: white; }
.step-tab.done { color: rgba(255,255,255,0.85); }
.step-tab-icon { font-size: 16px; display: block; margin-bottom: 2px; }

/* ── Step Content Area ── */
.step-content {
  padding: 24px 16px calc(env(safe-area-inset-bottom, 0px) + 90px);
  max-width: 480px; margin: 0 auto;
  animation: stepIn 0.35s cubic-bezier(0.34,1.2,0.64,1);
}
@keyframes stepIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Step header */
.step-header {
  background: linear-gradient(135deg, var(--sage-pale) 0%, var(--cream) 100%);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid rgba(122,158,126,0.2);
}
.step-type-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--sage-deep);
  background: white; border-radius: 99px;
  padding: 4px 10px; margin-bottom: 10px;
}
.step-desc { font-size: 15px; color: var(--text-mid); line-height: 1.65; }
.step-time { font-size: 12px; color: var(--text-light); margin-top: 8px; display: flex; align-items: center; gap: 4px; }

/* Content cards */
.content-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.content-card h3 { font-size: 15px; font-weight: 700; color: var(--sage-deep); margin-bottom: 8px; }
.content-card p { font-size: 14px; line-height: 1.7; color: var(--text-mid); }
.content-card ul { padding-left: 18px; }
.content-card ul li { font-size: 14px; line-height: 1.7; color: var(--text-mid); margin-bottom: 4px; }

.evidence-box {
  background: var(--sage-pale);
  border-left: 4px solid var(--sage);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 16px;
  margin-top: 12px;
}
.evidence-box p { font-size: 13px; color: var(--sage-deep); line-height: 1.6; }

/* ── Worksheet Widgets ── */
.worksheet { margin-bottom: 14px; }
.worksheet-label { font-size: 13px; font-weight: 700; color: var(--text-dark); margin-bottom: 8px; display: block; }
.ws-hint { font-size: 12px; color: var(--text-light); margin-bottom: 10px; }

/* Textarea */
.ws-textarea {
  width: 100%; min-height: 100px;
  background: white; border: 1.5px solid var(--cream-dark);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 14px; line-height: 1.6; color: var(--text-dark);
  font-family: inherit; resize: vertical;
  transition: border-color 0.2s;
}
.ws-textarea:focus { outline: none; border-color: var(--sage); }
.ws-textarea::placeholder { color: var(--text-light); }

/* Checklist */
.ws-checklist { display: flex; flex-direction: column; gap: 8px; }
.ws-check-item {
  display: flex; align-items: flex-start; gap: 12px;
  background: white; border-radius: var(--radius-sm);
  padding: 12px 14px; cursor: pointer;
  border: 1.5px solid var(--cream-dark);
  transition: all 0.2s;
}
.ws-check-item.checked { background: var(--sage-pale); border-color: var(--sage); }
.ws-check-box {
  width: 20px; height: 20px; border-radius: 6px;
  border: 2px solid var(--cream-dark); flex-shrink: 0;
  background: white; display: flex; align-items: center; justify-content: center;
  font-size: 12px; transition: all 0.2s; margin-top: 1px;
}
.ws-check-item.checked .ws-check-box { background: var(--sage); border-color: var(--sage); color: white; }
.ws-check-text { font-size: 14px; line-height: 1.5; color: var(--text-dark); }

/* Slider */
.ws-slider-wrap { padding: 8px 0; }
.ws-slider {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 99px;
  background: linear-gradient(90deg, var(--sage) var(--val, 50%), var(--cream-dark) var(--val, 50%));
  outline: none;
}
.ws-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px;
  border-radius: 50%; background: var(--sage-deep);
  box-shadow: 0 2px 8px rgba(78,114,80,0.4);
  cursor: pointer;
}
.ws-slider-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-light); margin-top: 6px; }
.ws-slider-val { text-align: center; font-size: 20px; font-weight: 800; color: var(--sage-deep); margin-bottom: 6px; }

/* Dynamic list */
.ws-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.ws-list-item {
  display: flex; align-items: center; gap: 8px;
  background: white; border-radius: var(--radius-sm);
  padding: 10px 12px; border: 1.5px solid var(--cream-dark);
}
.ws-list-item input {
  flex: 1; border: none; outline: none;
  font-size: 14px; color: var(--text-dark); font-family: inherit;
  background: transparent;
}
.ws-list-item input::placeholder { color: var(--text-light); }
.ws-list-del { color: var(--text-light); font-size: 18px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.ws-list-del:active { background: var(--cream-dark); }
.ws-add-btn {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--sage-deep);
  background: var(--sage-pale); border-radius: var(--radius-sm);
  padding: 10px 14px; width: 100%;
}
.ws-add-btn:active { background: rgba(122,158,126,0.2); }

/* Priority drag list */
.ws-priority { display: flex; flex-direction: column; gap: 8px; }
.ws-priority-item {
  display: flex; align-items: center; gap: 10px;
  background: white; border-radius: var(--radius-sm);
  padding: 12px 14px; border: 1.5px solid var(--cream-dark);
}
.ws-priority-rank {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--sage); color: white;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ws-priority-text { flex: 1; font-size: 14px; color: var(--text-dark); }

/* Evidence table */
.ws-evidence-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ws-evidence-table th {
  background: var(--sage-pale); color: var(--sage-deep);
  padding: 8px 10px; text-align: left; font-weight: 700;
  border: 1px solid rgba(122,158,126,0.2);
}
.ws-evidence-table td {
  padding: 0; border: 1px solid var(--cream-dark); vertical-align: top;
}
.ws-evidence-table td textarea {
  width: 100%; border: none; outline: none; background: transparent;
  padding: 8px 10px; font-size: 13px; font-family: inherit;
  resize: none; min-height: 60px; color: var(--text-dark);
}

/* Task decomposer */
.ws-task-main {
  background: var(--sage-pale); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 10px;
  font-size: 14px; font-weight: 700; color: var(--sage-deep);
}
.ws-task-steps { display: flex; flex-direction: column; gap: 6px; }
.ws-task-step {
  display: flex; align-items: center; gap: 10px;
  background: white; border-radius: 8px; padding: 10px 12px;
  border: 1.5px solid var(--cream-dark);
}
.ws-task-step-num { font-size: 12px; font-weight: 700; color: var(--sage); width: 20px; flex-shrink: 0; }
.ws-task-step input { flex: 1; border: none; outline: none; font-size: 13px; font-family: inherit; background: transparent; color: var(--text-dark); }
.ws-task-step input::placeholder { color: var(--text-light); }

/* ── Bottom Action Bar ── */
.action-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: white;
  padding: 12px 20px calc(env(safe-area-inset-bottom, 0px) + 12px);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  z-index: 200;
}
.action-bar-inner { max-width: 480px; margin: 0 auto; display: flex; gap: 10px; }
.btn-primary {
  flex: 1; padding: 15px;
  background: linear-gradient(135deg, var(--sage-deep) 0%, var(--sage) 100%);
  color: white; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 700; letter-spacing: -0.3px;
  box-shadow: 0 4px 15px rgba(78,114,80,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:active { transform: scale(0.97); box-shadow: 0 2px 8px rgba(78,114,80,0.25); }
.btn-secondary {
  padding: 15px 18px;
  background: var(--sage-pale); color: var(--sage-deep);
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  transition: background 0.15s;
}
.btn-secondary:active { background: rgba(122,158,126,0.2); }

/* ── Timer ── */
.timer-circle {
  width: 160px; height: 160px; border-radius: 50%;
  background: conic-gradient(var(--sage) var(--pct, 0%), var(--cream-dark) var(--pct, 0%));
  display: flex; align-items: center; justify-content: center;
  margin: 20px auto;
  position: relative;
}
.timer-inner {
  width: 130px; height: 130px; border-radius: 50%;
  background: var(--cream);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.timer-time { font-size: 30px; font-weight: 800; color: var(--text-dark); }
.timer-label { font-size: 12px; color: var(--text-light); margin-top: 2px; }

/* ── Modal / Overlay ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 500; display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-sheet {
  background: var(--cream); border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(env(safe-area-inset-bottom, 0px) + 28px);
  width: 100%; max-width: 480px;
  transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.34,1.2,0.64,1);
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-handle { width: 40px; height: 4px; border-radius: 99px; background: var(--cream-dark); margin: 0 auto 20px; }
.modal-title { font-size: 18px; font-weight: 800; color: var(--text-dark); margin-bottom: 16px; }

/* Reset button */
.btn-danger {
  width: 100%; padding: 14px;
  background: #FFF0F0; color: #D94040;
  border: 1.5px solid #FFCDD2;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  margin-top: 8px;
}
.btn-danger:active { background: #FFE0E0; }

/* ── Completion Screen ── */
.complete-wrap { text-align: center; padding: 40px 20px; }
.complete-icon { font-size: 64px; margin-bottom: 16px; }
.complete-title { font-size: 24px; font-weight: 800; color: var(--sage-deep); margin-bottom: 8px; }
.complete-desc { font-size: 15px; color: var(--text-mid); line-height: 1.65; }
.complete-points {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--sage-pale); border-radius: 99px;
  padding: 8px 18px; margin: 20px auto;
  font-size: 14px; font-weight: 700; color: var(--sage-deep);
}

/* ── Info chips ── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  background: var(--cream-dark); color: var(--text-mid);
  border-radius: 99px; padding: 4px 10px; margin: 2px;
}
.chip-green { background: var(--sage-pale); color: var(--sage-deep); }

/* ── Auto-save indicator ── */
.autosave { font-size: 11px; color: var(--text-light); text-align: right; padding: 0 4px 4px; }

/* ── Utility ── */
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.mt24 { margin-top: 24px; }
.hidden { display: none !important; }
