/* ========================================
   考公学习工作台 — 柔和蓝色层级体系
   ======================================== */

:root {
  /* 背景层级 */
  --bg-page: #F7F9FC;
  --bg-card: #EEF2F8;
  --bg-card-deeper: #E4EAF2;
  --bg-input: #E0E6F0;

  /* 文字层级 */
  --c-primary: #1A3A6E;       /* 深蓝 — 标题、关键数字 */
  --c-secondary: #7B8CA8;      /* 灰蓝 — 描述、辅助信息 */
  --c-tertiary: #A8B5C8;       /* 浅灰蓝 — 更次要 */

  /* 操作层 */
  --c-accent: #4A7FE8;         /* 亮蓝 — 按钮、选中、完成 */
  --c-accent-pressed: #3A6FD8;
  --c-accent-bg: #E8F0FE;      /* 亮蓝浅底 */

  /* 圆角 */
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --r-pill: 100px;

  /* 安全区 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg-page);
  color: var(--c-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', 'Helvetica Neue', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, a {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
  color: inherit;
  text-decoration: none;
}

input, select {
  font-family: inherit;
  outline: none;
}

/* ===== App 容器 ===== */
.app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ===== 顶部 ===== */
.app-header {
  padding: calc(16px + var(--safe-top)) 20px 12px;
}

.app-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--c-primary);
  letter-spacing: -0.3px;
}

.app-page-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== 公共返回按钮 ===== */
.back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--c-primary);
  transition: background 0.15s ease, transform 0.15s ease;
}

.back-btn svg {
  width: 22px;
  height: 22px;
}

.back-btn:active {
  background: var(--bg-card);
  transform: scale(0.92);
}

.app-date {
  font-size: 13px;
  color: var(--c-secondary);
  margin-top: 4px;
}

/* ===== 主内容 ===== */
.content {
  padding: 8px 16px calc(84px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== 卡片基础 ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 20px;
  animation: cardIn 0.4s ease;
}

.card-header {
  margin-bottom: 16px;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--c-primary);
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--c-primary);
  padding: 0 4px;
  margin-bottom: 12px;
}

/* ===== 倒计时卡片 ===== */
.countdown-grid {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
}

.countdown-item {
  flex: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

.exam-name {
  font-size: 12px;
  color: var(--c-secondary);
  font-weight: 500;
}

.countdown-days {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.days-num {
  font-size: 38px;
  font-weight: 800;
  color: var(--c-primary);
  letter-spacing: -1px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.days-unit {
  font-size: 14px;
  color: var(--c-secondary);
  font-weight: 500;
}

.countdown-footer {
  margin-top: 18px;
  padding-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.current-stage {
  font-size: 14px;
  color: var(--c-secondary);
}

.current-stage::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-accent);
  margin-right: 8px;
  vertical-align: middle;
}

/* ===== 按钮 ===== */
.btn {
  border-radius: var(--r-pill);
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

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

.btn-primary {
  background: var(--c-accent);
  color: #fff;
  padding: 13px 28px;
  font-size: 16px;
}

.btn-primary:active {
  background: var(--c-accent-pressed);
}

.btn-secondary {
  background: var(--bg-card-deeper);
  color: var(--c-primary);
  padding: 13px 28px;
  font-size: 16px;
}

.btn-sm {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 17px;
  width: 100%;
  text-align: center;
}

/* ===== 番茄学习卡片 ===== */
.pomodoro-setup {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.duration-group {
  display: flex;
  gap: 10px;
}

.pill {
  flex: 1;
  padding: 10px 0;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  color: var(--c-secondary);
  transition: all 0.2s ease;
  text-align: center;
}

.pill:active {
  transform: scale(0.96);
}

.pill.active {
  background: var(--c-accent);
  color: #fff;
}

.module-select-label {
  font-size: 13px;
  color: var(--c-secondary);
  font-weight: 500;
}

.module-select-group {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.module-select-group::-webkit-scrollbar {
  display: none;
}

.module-pill {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-card-deeper);
  color: var(--c-secondary);
  transition: all 0.2s ease;
}

.module-pill:active {
  transform: scale(0.96);
}

.module-pill.active {
  background: var(--c-accent-bg);
  color: var(--c-accent);
  font-weight: 600;
}

/* 计时器显示 */
.timer-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 0 4px;
  animation: fadeIn 0.3s ease;
}

.timer-ring {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-svg {
  position: absolute;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-track {
  fill: none;
  stroke: var(--bg-card-deeper);
  stroke-width: 6;
}

.timer-progress {
  fill: none;
  stroke: var(--c-accent);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.3s ease;
}

.timer-time {
  font-size: 40px;
  font-weight: 800;
  color: var(--c-primary);
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  z-index: 1;
}

.timer-info {
  font-size: 14px;
  color: var(--c-secondary);
}

/* 操作按钮区 */
.pomodoro-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.pomodoro-actions .btn-lg {
  width: 100%;
}

.pomodoro-actions .btn-secondary {
  width: 100%;
  text-align: center;
}

/* 番茄统计 */
.pomodoro-stats {
  margin-top: 18px;
  padding-top: 16px;
  display: flex;
  align-items: center;
}

.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.stat-divider {
  width: 1px;
  height: 32px;
  background: var(--bg-card-deeper);
}

.stat-label {
  font-size: 12px;
  color: var(--c-secondary);
}

.stat-value {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.stat-num {
  font-size: 24px;
  font-weight: 800;
  color: var(--c-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.stat-unit {
  font-size: 12px;
  color: var(--c-secondary);
}

/* ===== 八大学习模块 ===== */
.modules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.module-card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: cardIn 0.4s ease backwards;
}

.module-card:nth-child(1) { animation-delay: 0.05s; }
.module-card:nth-child(2) { animation-delay: 0.1s; }
.module-card:nth-child(3) { animation-delay: 0.15s; }
.module-card:nth-child(4) { animation-delay: 0.2s; }
.module-card:nth-child(5) { animation-delay: 0.25s; }
.module-card:nth-child(6) { animation-delay: 0.3s; }
.module-card:nth-child(7) { animation-delay: 0.35s; }
.module-card:nth-child(8) { animation-delay: 0.4s; }

.module-card:active {
  transform: scale(0.97);
  transition: transform 0.15s ease;
}

.module-icon {
  width: 28px;
  height: 28px;
  color: var(--c-primary);
}

.module-icon svg {
  width: 100%;
  height: 100%;
}

.module-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--c-primary);
}

.module-desc {
  font-size: 12px;
  color: var(--c-secondary);
  line-height: 1.4;
}

.module-progress {
  height: 5px;
  background: var(--bg-card-deeper);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 2px;
}

.progress-fill {
  height: 100%;
  background: var(--c-accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.module-count {
  font-size: 12px;
  color: var(--c-secondary);
}

.module-count strong {
  color: var(--c-primary);
  font-weight: 700;
}

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 430px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(123, 140, 168, 0.12);
  padding-bottom: var(--safe-bottom);
  display: flex;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 8px;
  transition: all 0.2s ease;
}

.nav-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--c-secondary);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: all 0.2s ease;
}

.nav-label {
  font-size: 10px;
  color: var(--c-secondary);
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-item.active .nav-icon {
  fill: var(--c-primary);
  stroke: var(--c-primary);
  fill-opacity: 0.15;
}

.nav-item.active .nav-label {
  color: var(--c-primary);
  font-weight: 700;
}

.nav-item:active {
  transform: scale(0.92);
}

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 58, 110, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: var(--r-lg);
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 360px;
  animation: modalIn 0.3s ease;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--c-primary);
  margin-bottom: 20px;
  text-align: center;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  color: var(--c-secondary);
  font-weight: 500;
}

.form-input {
  background: var(--bg-page);
  border: none;
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 15px;
  color: var(--c-primary);
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* iOS Safari date input 原生控件容易溢出 */
input[type="date"].form-input {
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px;
}

.form-input:focus {
  background: var(--c-accent-bg);
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions .btn {
  flex: 1;
  text-align: center;
}

/* 弹窗内的 pill 选择器 */
.modal-pill-group {
  display: flex;
  gap: 8px;
}

.modal-pill-group .pill {
  flex: 1;
}

.modal-module-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.modal-module-scroll::-webkit-scrollbar {
  display: none;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(100px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--c-primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 300;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(26, 58, 110, 0.2);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== 动画 ===== */
@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ===== 响应式 ===== */
@media (max-width: 360px) {
  .days-num {
    font-size: 32px;
  }
  .timer-time {
    font-size: 34px;
  }
  .timer-ring {
    width: 140px;
    height: 140px;
  }
  .module-card {
    padding: 14px 12px;
  }
}

/* 大屏居中显示 */
@media (min-width: 431px) {
  body {
    background: var(--bg-page);
  }
  .app {
    box-shadow: 0 0 40px rgba(26, 58, 110, 0.06);
  }
}
