:root {
  --bg: #0d1018;
  --bg-soft: #171c28;
  --panel: #ffffff;
  --line: rgba(14, 22, 38, 0.08);
  --text: #142033;
  --muted: #65738a;
  --primary: #2f6df5;
  --primary-soft: #dce7ff;
  --accent: #5ac8fa;
  --glow-a: rgba(82, 129, 255, 0.28);
  --glow-b: rgba(122, 92, 255, 0.22);
  --glow-c: rgba(34, 211, 238, 0.18);
  --success: #0f9f75;
  --danger: #d94b63;
  --shadow: 0 30px 80px rgba(5, 9, 18, 0.26);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, #0f1420 0%, #10141d 48%, #0c1018 100%);
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  inset: auto;
  border-radius: 50%;
  filter: blur(32px);
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.8;
}

.ambient-a {
  width: 320px;
  height: 320px;
  top: 70px;
  left: 10%;
  background: var(--glow-a);
  animation: blinkA 4.8s ease-in-out infinite;
}

.ambient-b {
  width: 240px;
  height: 240px;
  top: 160px;
  right: 12%;
  background: var(--glow-b);
  animation: blinkB 5.6s ease-in-out infinite;
}

.ambient-c {
  width: 260px;
  height: 260px;
  bottom: 120px;
  left: 42%;
  background: var(--glow-c);
  animation: blinkC 6.3s ease-in-out infinite;
}

.shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.board {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  border-radius: 32px;
  padding: 22px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.board-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #edf3ff;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(135deg, #80a9ff, #d8f1ff);
  box-shadow: 0 0 30px rgba(128, 169, 255, 0.35);
}

.brand strong {
  display: block;
  font-size: 20px;
}

.brand p {
  margin: 4px 0 0;
  color: rgba(237, 243, 255, 0.72);
  font-size: 14px;
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab,
.primary-button,
.ghost-button,
.upload-button {
  border: none;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.tab {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #eef4ff;
  font-weight: 700;
}

.tab.is-active {
  background: #ffffff;
  color: var(--text);
}

.tab:hover,
.primary-button:hover,
.ghost-button:hover,
.upload-button:hover {
  transform: translateY(-1px);
}

.board-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
}

.content,
.sidebar {
  min-width: 0;
}

.page {
  display: none;
  background: var(--panel);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.page.is-active {
  display: block;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head.compact {
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 12px 0 10px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.page-tag,
.mini-tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.auth-state {
  min-width: 86px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.auth-state.is-ok {
  color: var(--success);
}

.chart-card,
.checkin-card,
.pomodoro-card,
.profile-card,
.info-card,
.placeholder-card {
  border: 1px solid var(--line);
  border-radius: 24px;
}

.chart-card,
.checkin-card,
.pomodoro-card {
  background: #fbfcff;
}

.chart-card {
  padding: 20px;
  margin-bottom: 18px;
}

.chart-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.chart-title h2,
.checkin-top h2,
.pomodoro-card h2,
.profile-card h3,
.info-card h3 {
  margin: 0 0 6px;
}

.chart-title p,
.checkin-top p,
.profile-card p,
.info-card p,
.placeholder-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.chart-legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.chart-legend span {
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: var(--primary);
}

.chart-wrap {
  position: relative;
  min-height: 240px;
}

#progressChart {
  width: 100%;
  height: 240px;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.empty-state.is-hidden {
  display: none;
}

.checkin-card {
  padding: 22px;
}

.checkin-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.date-box {
  min-width: 170px;
}

.date-box label,
.mood-select span,
.notes-box span,
.timer-controls span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(18, 32, 51, 0.12);
  border-radius: 16px;
  min-height: 48px;
  padding: 0 14px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 120px;
  padding: 14px;
  resize: vertical;
}

.subject-groups {
  display: grid;
  gap: 18px;
}

.subject-group {
  padding: 18px;
  border-radius: 22px;
  background: #fff;
  border: 1px solid rgba(18, 32, 51, 0.08);
}

.subject-group h3 {
  margin: 0 0 14px;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.subject-item {
  display: grid;
  gap: 8px;
}

.subject-item span {
  font-size: 14px;
  font-weight: 700;
}

.checkin-bottom {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}

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

.summary-pill {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}

.primary-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #2f6df5, #4c96ff);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 18px 30px rgba(47, 109, 245, 0.22);
}

.ghost-button,
.upload-button {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  border: 1px solid rgba(18, 32, 51, 0.10);
  font-weight: 700;
}

.pomodoro-card {
  padding: 24px;
  display: grid;
  gap: 20px;
}

.timer-face {
  position: relative;
  min-height: 340px;
  display: grid;
  place-items: center;
  text-align: center;
  overflow: hidden;
  border-radius: 26px;
  background:
    radial-gradient(circle at top, rgba(90, 200, 250, 0.18), transparent 38%),
    linear-gradient(180deg, #fff, #f6f8ff);
}

.timer-label {
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timer-value {
  font-size: clamp(56px, 10vw, 110px);
  line-height: 1;
  font-weight: 900;
}

.timer-ring {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  border: 16px solid rgba(47, 109, 245, 0.10);
}

.timer-ring-fill {
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  border: 16px solid transparent;
  border-top-color: var(--primary);
  transform: rotate(-90deg);
}

.timer-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.sidebar {
  display: grid;
  gap: 16px;
}

.profile-card,
.info-card {
  background: rgba(255, 255, 255, 0.94);
  padding: 20px;
  box-shadow: var(--shadow);
}

.profile-card {
  text-align: center;
}

.avatar-shell {
  width: 132px;
  height: 132px;
  margin: 0 auto 16px;
  border-radius: 32px;
  overflow: hidden;
  background: linear-gradient(135deg, #d6e4ff, #f3f7ff);
  display: grid;
  place-items: center;
  position: relative;
}

.avatar-shell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.avatar-shell.has-image img {
  display: block;
}

.avatar-shell.has-image span {
  display: none;
}

#avatarFallback {
  font-size: 52px;
  font-weight: 900;
  color: var(--primary);
}

.profile-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-info strong {
  display: block;
  font-size: 30px;
  margin: 6px 0 8px;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  position: relative;
}

.upload-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.mini-stat {
  display: grid;
  gap: 6px;
  padding-top: 10px;
}

.mini-stat + .mini-stat {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px dashed rgba(18, 32, 51, 0.08);
}

.mini-stat strong {
  font-size: 34px;
}

.mini-stat span {
  color: var(--muted);
}

.placeholder-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.placeholder-card {
  background: #fbfcff;
  padding: 20px;
}

.placeholder-card strong {
  display: block;
  font-size: 20px;
  margin-bottom: 10px;
}

.pin-modal {
  width: min(420px, calc(100% - 24px));
  border: none;
  padding: 0;
  background: transparent;
}

.pin-modal::backdrop {
  background: rgba(4, 8, 15, 0.55);
  backdrop-filter: blur(8px);
}

.pin-panel {
  background: #fff;
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.pin-head h2 {
  margin: 12px 0 10px;
}

.pin-head p {
  margin: 0 0 16px;
  color: var(--muted);
}

.pin-input {
  text-align: center;
  letter-spacing: 0.35em;
  font-size: 28px;
  font-weight: 800;
}

.pin-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 14px;
}

.pin-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}

@keyframes blinkA {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.12); }
}

@keyframes blinkB {
  0%, 100% { opacity: 0.2; transform: scale(0.92); }
  50% { opacity: 0.8; transform: scale(1.08); }
}

@keyframes blinkC {
  0%, 100% { opacity: 0.18; transform: translateY(0); }
  50% { opacity: 0.65; transform: translateY(-12px); }
}

@media (max-width: 1080px) {
  .board-body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .board-top,
  .page-head,
  .checkin-top,
  .form-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .checkin-bottom,
  .placeholder-grid,
  .sidebar,
  .timer-controls {
    grid-template-columns: 1fr;
  }

  .shell {
    width: min(100% - 18px, 1320px);
    padding: 20px 0 28px;
  }

  .page {
    padding: 20px;
  }
}
