/* === style.css - base styles === */
:root {
  --primary: #5b6af0; --primary-light: #7c89f5; --primary-dark: #4a54d4;
  --accent: #ff6b8a; --accent-light: #ff8fa6;
  --success: #34c759; --warning: #ff9f0a;
  --bg: #f0f4ff; --card: #ffffff;
  --text: #1a1a2e; --text-secondary: #6b7280; --text-muted: #9ca3af;
  --border: #e5e7eb;
  --shadow: 0 2px 12px rgba(91,106,240,0.08);
  --shadow-lg: 0 8px 30px rgba(91,106,240,0.12);
  --radius: 16px; --radius-sm: 10px;
  --tab-height: 64px; --header-height: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body, .card, .stat-item, .task-item, .app-header, .tab-bar, .tab-item,
input, select, button, .btn, .toast, .achievement-item, .schedule-item {
  transition: background-color 0.4s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  display: flex; justify-content: center; min-height: 100vh;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}

.app-container {
  width: 100%; max-width: 480px; min-height: 100vh;
  position: relative; padding-bottom: calc(var(--tab-height) + 20px);
}

/* Header */
.app-header {
  padding: 16px 20px 8px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0;
  background: var(--bg); z-index: 10;
}
.app-header h1 {
  font-size: 20px; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--card);
  cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s; margin-left: 8px;
}
.theme-toggle:active { transform: scale(0.9) rotate(30deg); }
.streak-badge {
  display: flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, #fff3cd, #ffe69c);
  padding: 6px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 600; color: #b45309;
}
.streak-badge .flame { font-size: 16px; }
.streak-best-text { font-size: 10px; color: #92400e; margin-left: 2px; }

/* Tab Pages */
.tab-page { display: none; padding: 0 16px; }
.tab-page.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.stat-row { display: flex; gap: 10px; }
.stat-item {
  flex: 1; text-align: center; padding: 12px 8px;
  background: var(--bg); border-radius: var(--radius-sm);
}
.stat-item .value { font-size: 18px; font-weight: 800; color: var(--text); }
.stat-item .label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Task List */
.task-list { list-style: none; }
.task-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--card);
  border-radius: var(--radius-sm); margin-bottom: 8px;
  box-shadow: var(--shadow); transition: all 0.2s; position: relative; overflow: hidden;
}
.task-item.done { opacity: 0.6; background: var(--bg); }
.task-checkbox {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); flex-shrink: 0; cursor: pointer;
  transition: all 0.2s; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.task-item.done .task-checkbox { background: var(--success); border-color: var(--success); }
.task-item.done .task-checkbox::after {
  content: "\2713"; color: white; font-size: 13px; font-weight: 700;
}
.task-info { flex: 1; min-width: 0; }
.task-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.task-item.done .task-name { text-decoration: line-through; color: var(--text-muted); }
.task-meta { display: flex; gap: 8px; font-size: 11px; color: var(--text-secondary); }
.task-delete {
  width: 26px; height: 26px; border-radius: 50%; border: none;
  background: var(--bg); color: var(--text-muted);
  font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.task-delete:active { background: var(--accent); color: white; }

/* Category tags */
.cat-study { background: #e0e7ff; color: #4338ca; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.cat-rest { background: #d1fae5; color: #065f46; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.cat-sport { background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.cat-entertainment { background: #fce7f3; color: #9d174d; padding: 2px 8px; border-radius: 4px; font-weight: 600; }

/* Bottom Tab Bar */
.tab-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; height: var(--tab-height);
  background: var(--card); display: flex; align-items: center; justify-content: space-around;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.06); z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 16px; border: none; background: none; cursor: pointer;
  color: var(--text-muted); font-size: 11px; font-family: var(--font);
  transition: color 0.2s; position: relative;
}
.tab-item .tab-icon { font-size: 22px; transition: transform 0.2s; }
.tab-item.active { color: var(--primary); font-weight: 600; }
.tab-item.active .tab-icon { transform: scale(1.15); }
.tab-item.active::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; background: var(--primary); border-radius: 0 0 3px 3px;
}

/* Dashboard ring */
.dashboard-ring { display: flex; justify-content: center; margin-bottom: 12px; }

/* Quote / feedback */
.quote-card {
  background: linear-gradient(135deg, #e0e7ff, #f0e6ff);
  padding: 14px 18px; border-radius: var(--radius-sm);
  font-size: 13px; color: #4338ca; font-weight: 500; text-align: center;
}
[data-theme="dark"] .quote-card { background: linear-gradient(135deg, #1e1b4b, #1a1350); color: #a5b4fc; }

/* Planner input */
.input-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.input-group input, .input-group select {
  padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font);
  background: var(--bg); color: var(--text); outline: none;
}
.input-group input:focus, .input-group select:focus { border-color: var(--primary); }
.input-row { display: flex; gap: 8px; }
.input-row select { flex: 1; }
.input-row input { width: 120px; }

/* Buttons */
.btn { padding: 12px 24px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; border: none; font-family: var(--font); transition: all 0.2s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:active { background: var(--primary-dark); transform: scale(0.97); }
.btn-outline { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:active { background: var(--border); }

/* Timer */
.timer-section { text-align: center; padding: 10px 0; }
.timer-circle { width: 220px; height: 220px; margin: 0 auto 20px; position: relative; }
.timer-circle svg, #timer-ring-svg svg { transform: rotate(-90deg); }
#timer-ring-svg circle:last-of-type { transition: stroke-dashoffset 0.9s linear, stroke 0.3s ease; }
#timer-ring-svg circle:first-of-type { transition: stroke 0.3s ease; }
.timer-display { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
.timer-display .time { font-size: 52px; font-weight: 800; color: var(--text); letter-spacing: -2px; }
.timer-display .phase { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.current-task-label { font-size: 15px; font-weight: 600; margin-bottom: 8px; color: var(--primary-dark); min-height: 24px; }
.timer-controls { display: flex; gap: 12px; justify-content: center; margin-bottom: 20px; }
.btn-timer {
  width: 56px; height: 56px; border-radius: 50%; border: none; font-size: 24px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.btn-timer:active { transform: scale(0.92); }
.btn-play {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; width: 68px; height: 68px; font-size: 28px;
  box-shadow: 0 4px 20px rgba(91,106,240,0.3);
}
.btn-skip { background: var(--bg); color: var(--text-secondary); }

/* Review */
.review-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.review-header h3 { font-size: 16px; font-weight: 600; }
.day-nav { display: flex; gap: 8px; }
.day-nav button {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--card);
  font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text);
}
.day-nav button:active { background: var(--bg); }

/* Achievements */
.achievement-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.achievement-item {
  text-align: center; padding: 16px 8px; background: var(--bg);
  border-radius: var(--radius-sm); transition: all 0.2s;
}
.achievement-item.locked { opacity: 0.35; filter: grayscale(1); }
.achievement-item .icon { font-size: 32px; margin-bottom: 6px; }
.achievement-item .name { font-size: 12px; font-weight: 600; }
.achievement-item .desc { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* Schedule */
.schedule-view { margin-top: 12px; }
.schedule-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 6px; font-size: 13px;
}
.schedule-time { font-weight: 700; font-size: 13px; min-width: 70px; color: var(--primary-dark); }
.schedule-name { flex: 1; }

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 10px; }
.empty-state .text { font-size: 14px; }

/* Toast */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: white; padding: 12px 24px; border-radius: 24px;
  font-size: 14px; font-weight: 500; z-index: 200;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards; white-space: nowrap;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* Celebration */
.celebration { position: fixed; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: 150; }
.confetti {
  position: absolute; width: 10px; height: 10px; border-radius: 2px;
  animation: confettiFall 2s ease-out forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(-100px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Mini inputs */
.mini-label { font-size: 11px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.mini-input {
  width: 100%; padding: 10px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: var(--font);
  background: var(--bg); color: var(--text);
}
.timer-select {
  width: 100%; padding: 10px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: var(--font);
  background: var(--bg); color: var(--text); margin-bottom: 16px;
}

/* ====== DARK MODE ====== */
[data-theme="dark"] {
  --primary: #7c89f5; --primary-light: #9ba4f7; --primary-dark: #5b6af0;
  --accent: #ff8fa6; --accent-light: #ffb3c2;
  --success: #30d158; --warning: #ffb340;
  --bg: #0d0d1a; --card: #1a1a2e;
  --text: #e8e8f0; --text-secondary: #9ca3af; --text-muted: #6b7280;
  --border: #2d2d44;
  --shadow: 0 2px 12px rgba(0,0,0,0.3); --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
}
[data-theme="dark"] .app-header { background: var(--bg); }
[data-theme="dark"] .streak-badge { background: linear-gradient(135deg, #3d2e0a, #5c3d0e); color: #fbbf24; }
[data-theme="dark"] .stat-item { background: #151528; }
[data-theme="dark"] .task-item { background: var(--card); }
[data-theme="dark"] .task-item.done { background: #151528; }
[data-theme="dark"] .btn-outline { background: #151528; }
[data-theme="dark"] .schedule-item { background: var(--card); }

/* Responsive */
@media (min-width: 480px) {
  .app-container { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  .tab-bar { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
