/* ============================================================
   学习打卡 · 样式
   蓝紫渐变 / 浅色 / 响应式大卡片
   ============================================================ */

:root {
  --brand-1: #6366f1;
  --brand-2: #8b5cf6;
  --brand-3: #a855f7;
  --brand-ink: #5b45d8;

  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 52%, #a855f7 100%);
  --grad-soft: linear-gradient(135deg, #eef1ff 0%, #f7efff 100%);

  --bg: #f3f4fc;
  --card: #ffffff;
  --card-soft: #f8f9ff;

  --text: #1b1d33;
  --text-2: #5b6183;
  --text-3: #8f95b6;

  --line: #e7e9f6;
  --line-strong: #d6d9ef;

  --danger: #e5484d;
  --danger-soft: #fff1f1;

  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow-lg: 0 18px 48px -20px rgba(76, 78, 175, 0.34), 0 4px 14px -6px rgba(76, 78, 175, 0.12);
  --shadow-md: 0 10px 28px -16px rgba(76, 78, 175, 0.4), 0 2px 8px -4px rgba(76, 78, 175, 0.1);
  --shadow-sm: 0 4px 14px -8px rgba(76, 78, 175, 0.45);

  --ring: 0 0 0 3.5px rgba(124, 92, 255, 0.18);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 520px at 6% -10%, #e6e9ff 0%, rgba(230, 233, 255, 0) 62%),
    radial-gradient(820px 500px at 102% -4%, #f4e8ff 0%, rgba(244, 232, 255, 0) 58%),
    radial-gradient(700px 480px at 50% 108%, #eaeaff 0%, rgba(234, 234, 255, 0) 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }

button { font: inherit; color: inherit; }

.hidden { display: none !important; }

/* ---------------- 通用控件 ---------------- */

.logo {
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 8px 20px -8px rgba(124, 92, 255, 0.75);
  flex: none;
}
.logo svg { width: 58%; height: 58%; }
.logo-lg { width: 62px; height: 62px; border-radius: 20px; }
.logo-sm { width: 40px; height: 40px; border-radius: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
  background: transparent;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-ico { width: 19px; height: 19px; }

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 12px 26px -12px rgba(124, 92, 255, 0.95);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 16px 32px -12px rgba(124, 92, 255, 1); }

.btn-ghost {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--brand-2); color: var(--brand-ink); }

.btn-soft {
  background: var(--grad-soft);
  color: var(--brand-ink);
}
.btn-soft:hover:not(:disabled) { box-shadow: var(--shadow-sm); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #ffe4e4; }

.btn-block { width: 100%; }
.btn-lg { padding: 15px 22px; font-size: 17px; border-radius: var(--radius-lg); }
.btn-sm { padding: 7px 13px; font-size: 13.5px; border-radius: var(--radius-sm); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1.5px solid transparent;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.15s ease;
  flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.3); }
.icon-btn:active { transform: scale(0.94); }

.nav-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.18s ease;
  flex: none;
}
.nav-btn svg { width: 18px; height: 18px; }
.nav-btn:hover { border-color: var(--brand-2); color: var(--brand-ink); background: var(--grad-soft); }

.field { display: block; min-width: 0; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 7px;
}
.opt { font-weight: 500; color: var(--text-3); font-size: 12px; }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  font: inherit;
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  outline: none;
}
input::placeholder, textarea::placeholder { color: #b3b8d2; }
input:focus, textarea:focus, select:focus { border-color: var(--brand-2); box-shadow: var(--ring); }
textarea { resize: vertical; min-height: 78px; line-height: 1.65; }
input[type="date"], input[type="time"] { cursor: pointer; }

.form-error {
  margin: 2px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 500;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--grad-soft);
  color: var(--brand-ink);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------------- 登录页 ---------------- */

.login-view {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}
.login-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  pointer-events: none;
}
.login-glow-a { width: 420px; height: 420px; background: #b9b4ff; top: -120px; left: -110px; }
.login-glow-b { width: 460px; height: 460px; background: #e3b8ff; bottom: -150px; right: -130px; }

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  padding: 34px 30px 26px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.8);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-brand { text-align: center; margin-bottom: 4px; }
.login-brand .logo { margin: 0 auto 14px; }
.login-brand h1 { font-size: 25px; }
.login-brand p { margin: 6px 0 0; color: var(--text-3); font-size: 13.5px; }
.login-tip { margin: 2px 0 0; text-align: center; font-size: 12.5px; color: var(--text-3); line-height: 1.6; }

/* ---------------- 顶栏 ---------------- */

.app-view { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 10px 30px -18px rgba(90, 70, 200, 0.9);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar-brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.topbar-brand .logo { background: rgba(255, 255, 255, 0.2); box-shadow: none; }
.topbar-title { font-size: 18px; font-weight: 700; letter-spacing: 0.01em; }
.topbar-sub { font-size: 12.5px; opacity: 0.82; }
.topbar-actions { display: flex; gap: 8px; }

/* ---------------- 主体 ---------------- */

.app-shell {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 34px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.stat-card {
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 12.5px; color: var(--text-3); font-weight: 600; }
.stat-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-value small { font-size: 13px; font-weight: 600; color: var(--text-3); -webkit-text-fill-color: var(--text-3); }

.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.card {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.9);
}
.card-checkin { box-shadow: var(--shadow-lg); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.card-head h2 { font-size: 17px; }
.head-right { display: flex; align-items: center; gap: 8px; flex: none; }

.block { margin-bottom: 18px; }
.block:last-of-type { margin-bottom: 20px; }
.block-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 10px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* 科目 / 监护人 选择块 */
.chip-wrap { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.16s ease;
}
.chip:hover { border-color: #c8c4ff; transform: translateY(-1px); }
.chip .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--chip-color, var(--brand-2));
  flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chip-color, #8b5cf6) 18%, transparent);
}
.chip.active {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 22px -10px rgba(124, 92, 255, 0.95);
}
.chip.active .dot { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35); }

.chip-wrap-sm .chip { padding: 8px 14px; font-size: 14px; border-radius: 12px; font-weight: 500; }

.chip-add {
  border-style: dashed;
  border-color: var(--line-strong);
  color: var(--text-3);
  font-weight: 500;
  background: var(--card-soft);
}
.chip-add:hover { color: var(--brand-ink); border-color: var(--brand-2); background: var(--grad-soft); }
.chip-add svg { width: 15px; height: 15px; }

/* ---------------- 记录列表 ---------------- */

.record-list { display: flex; flex-direction: column; gap: 10px; }

.record {
  display: flex;
  gap: 13px;
  padding: 14px 15px;
  border-radius: var(--radius-lg);
  background: var(--card-soft);
  border: 1px solid var(--line);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.record:hover { border-color: #dcd8ff; box-shadow: var(--shadow-sm); }

.record-bar {
  width: 4px;
  border-radius: 999px;
  background: var(--chip-color, var(--brand-2));
  flex: none;
}
.record-main { flex: 1; min-width: 0; }
.record-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.record-subject { font-size: 15.5px; font-weight: 700; }
.record-time {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand-ink);
  background: var(--grad-soft);
  padding: 2px 9px;
  border-radius: 999px;
}
.record-guardian {
  font-size: 12.5px;
  color: var(--text-2);
  background: #eef0fa;
  padding: 2px 9px;
  border-radius: 999px;
}
.record-remark { font-size: 13.5px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.record-date { font-size: 12.5px; color: var(--text-3); margin-bottom: 3px; }
.record-actions { display: flex; gap: 6px; align-items: flex-start; flex: none; }
.record-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.16s ease;
}
.record-btn svg { width: 15px; height: 15px; }
.record-btn:hover { color: var(--brand-ink); border-color: var(--brand-2); background: var(--grad-soft); }
.record-btn.danger:hover { color: var(--danger); border-color: #ffc9c9; background: var(--danger-soft); }

.empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
  border-radius: var(--radius-lg);
  border: 1.5px dashed var(--line-strong);
  background: var(--card-soft);
}

/* ---------------- 月历 ---------------- */

.cal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.cal-title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
  padding: 4px 0;
}
.cal-weekdays span:first-child,
.cal-weekdays span:last-child { color: #b9a8e8; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  background: var(--card-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  overflow: hidden;
}
.cal-cell:hover { background: #eff0ff; transform: translateY(-1px); }
.cal-cell.muted { opacity: 0.36; }
.cal-cell.has-data { background: linear-gradient(160deg, #eef0ff 0%, #f7ecff 100%); }
.cal-cell.today { border-color: var(--brand-2); }
.cal-cell.selected {
  background: var(--grad);
  border-color: transparent;
  box-shadow: 0 10px 22px -10px rgba(124, 92, 255, 0.95);
}
.cal-num { font-size: 14.5px; font-weight: 600; line-height: 1; }
.cal-cell.selected .cal-num { color: #fff; }
.cal-cell.today:not(.selected) .cal-num { color: var(--brand-ink); }

.cal-dots { display: flex; gap: 3px; align-items: center; justify-content: center; height: 6px; }
.cal-dots .d {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dot-color, var(--brand-2));
}
.cal-cell.selected .cal-dots .d { background: rgba(255, 255, 255, 0.95); }
.cal-more { font-size: 9px; font-weight: 700; color: var(--brand-ink); line-height: 1; }
.cal-cell.selected .cal-more { color: #fff; }

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
}
.legend-item .d {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot-color, var(--brand-2));
  flex: none;
}

.app-footer {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
  padding: 6px 0 2px;
}

/* ---------------- 弹窗 ---------------- */

.modal-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(38, 36, 74, 0.42);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  pointer-events: auto;
  animation: fade-in 0.18s ease;
  overflow-y: auto;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }

.modal {
  width: 100%;
  max-width: 520px;
  margin: auto;
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 0;
}
.modal-head h3 { font-size: 17px; }
.modal-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 11px;
  background: var(--card-soft);
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.16s ease;
}
.modal-close:hover { background: #eef0fa; color: var(--text); }
.modal-close svg { width: 17px; height: 17px; }
.modal-body { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.modal-note { font-size: 12.5px; color: var(--text-3); line-height: 1.6; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--card-soft);
  border: 1px solid var(--line);
}
.tab {
  flex: 1;
  padding: 9px 10px;
  border: none;
  border-radius: 11px;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.16s ease;
}
.tab.active { background: #fff; color: var(--brand-ink); box-shadow: var(--shadow-sm); }

.manage-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.manage-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--card-soft);
  border: 1px solid var(--line);
}
.manage-item .name { flex: 1; font-weight: 600; font-size: 14.5px; min-width: 0; word-break: break-all; }
.manage-add { display: flex; gap: 8px; }
.manage-add input { flex: 1; }

/* ---------------- 提示条 ---------------- */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: rgba(30, 28, 60, 0.94);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  max-width: 100%;
  text-align: center;
  word-break: break-word;
}
.toast.ok { background: linear-gradient(135deg, #5b45d8, #8b5cf6); }
.toast.err { background: linear-gradient(135deg, #d93a3f, #e5484d); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------------- 响应式 ---------------- */

@media (max-width: 980px) {
  .grid-main { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  body { font-size: 14.5px; }
  .app-shell { padding: 16px 14px 28px; gap: 16px; }
  .topbar-inner { padding: 12px 14px; }
  .topbar-title { font-size: 16.5px; }
  .card { padding: 18px; border-radius: var(--radius-lg); }
  .stats-row { gap: 10px; }
  .stat-card { padding: 13px 14px; border-radius: var(--radius-md); }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11.5px; }
  .grid-2 { grid-template-columns: 1fr; gap: 12px; }
  .cal-grid { gap: 4px; }
  .cal-cell { border-radius: 11px; gap: 3px; }
  .cal-num { font-size: 13.5px; }
  .cal-dots .d { width: 4px; height: 4px; }
  .cal-weekdays { gap: 4px; }
  .cal-head { gap: 7px; }
  .cal-title { font-size: 15.5px; }
  .chip { padding: 9px 13px; font-size: 14.5px; }
  .record { padding: 12px 13px; }
  .modal-body { padding: 16px 18px 20px; }
  .modal-head { padding: 18px 18px 0; }
  .toast-root { bottom: 16px; }
}

@media (max-width: 380px) {
  .stat-value { font-size: 19px; }
  .cal-cell { border-radius: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
