/* ============================================================
   二胡课时管理系统 V1.0 全局样式
   风格：米白宣纸底 + 深棕木质 + 暖金点缀，移动端优先
   ============================================================ */

:root {
  --bg: #f4ecdd;
  --bg-deep: #ece1cc;
  --surface: #fdfaf3;
  --surface-2: #f8f1e3;
  --ink: #2c211a;
  --ink-soft: #5a4838;
  --brown: #43301f;
  --brown-deep: #33241a;
  --line: #e4d6bd;
  --line-soft: #eee4d1;
  --gold: #b0833d;
  --gold-deep: #92672c;
  --gold-soft: #ecdcb8;
  --muted: #9a8a75;
  --clay: #a45642;
  --pine: #5f7d5a;
  --shadow: 0 2px 10px rgba(67, 48, 31, 0.07);
  --shadow-lg: 0 10px 32px rgba(67, 48, 31, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(
      1200px 500px at 50% -120px,
      rgba(176, 131, 61, 0.1),
      transparent 60%
    ),
    radial-gradient(
      900px 400px at 100% 0%,
      rgba(67, 48, 31, 0.05),
      transparent 55%
    );
  background-attachment: fixed;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

h1,
h2,
h3,
.serif {
  font-family: var(--serif);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
textarea {
  font-family: inherit;
  font-size: 16px; /* >=16px 避免 iOS 聚焦缩放 */
}

a {
  color: var(--gold-deep);
  text-decoration: none;
}

/* ---------------- 布局 ---------------- */

.page {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.topbar {
  background: linear-gradient(160deg, var(--brown-deep), var(--brown));
  color: #f6ecda;
  padding: 18px 18px 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(176, 131, 61, 0.35);
}

.topbar-inner {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand .logo {
  font-size: 22px;
  line-height: 1;
}

.brand .title {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 2px;
  white-space: nowrap;
}

.brand .sub {
  font-size: 11px;
  color: var(--gold-soft);
  letter-spacing: 1px;
  margin-top: 1px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #f0e4cd;
  border: 1px solid rgba(236, 220, 184, 0.35);
  font-size: 15px;
  transition: background 0.15s;
}

.icon-btn:active {
  background: rgba(236, 220, 184, 0.15);
}

.section-title {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 22px 2px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 1px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--line), transparent);
}

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card + .card {
  margin-top: 12px;
}

/* ---------------- 搜索 ---------------- */

.search {
  position: relative;
  margin-bottom: 14px;
}

.search .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 12px 14px 12px 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}

.search input:focus {
  border-color: var(--gold);
}

/* ---------------- 学生卡片 ---------------- */

.student-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.student-name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 1px;
}

.student-remark {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-row {
  display: flex;
  margin: 12px 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}

.stat {
  flex: 1;
  text-align: center;
  padding: 10px 6px;
}

.stat + .stat {
  border-left: 1px solid var(--line-soft);
}

.stat .num {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.stat .num.hl {
  color: var(--gold-deep);
}

.stat .lbl {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------------- 进度条 ---------------- */

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-deep);
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--gold-deep));
  transition: width 0.35s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 15px;
  letter-spacing: 1px;
  border: 1px solid transparent;
  transition: transform 0.08s, opacity 0.15s, background 0.15s;
  user-select: none;
  white-space: nowrap;
}

.btn:active:not([disabled]) {
  transform: scale(0.97);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #bd8c46, var(--gold-deep));
  color: #fff8ec;
  box-shadow: 0 3px 10px rgba(146, 103, 44, 0.3);
  font-weight: 600;
}

.btn-outline {
  background: transparent;
  border-color: #b89a6f;
  color: var(--brown);
}

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-danger {
  background: linear-gradient(135deg, #b26550, var(--clay));
  color: #fdf2ec;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

.btn-flex {
  flex: 1;
}

/* ---------------- 空状态 ---------------- */

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty .big {
  font-size: 40px;
  margin-bottom: 10px;
  opacity: 0.7;
}

/* ---------------- 表单 ---------------- */

.form-item {
  margin-bottom: 14px;
}

.form-item label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 2px 6px;
  letter-spacing: 1px;
}

.form-item label .req {
  color: var(--clay);
  margin-left: 3px;
}

.form-item input,
.form-item textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

.form-item textarea {
  resize: vertical;
  min-height: 64px;
}

.form-item input:focus,
.form-item textarea:focus {
  border-color: var(--gold);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.form-error {
  color: var(--clay);
  font-size: 13px;
  text-align: center;
  min-height: 18px;
  margin-top: 10px;
}

/* ---------------- 弹层（移动端底部 Sheet） ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 33, 26, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fade 0.18s ease;
}

@media (min-width: 560px) {
  .overlay {
    align-items: center;
  }
}

.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  border-radius: 20px 20px 0 0;
  padding: 0 20px calc(22px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.22s ease;
  max-height: 88vh;
  overflow-y: auto;
}

@media (min-width: 560px) {
  .sheet {
    border-radius: 18px;
    margin: 16px;
  }
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  margin: 0 -20px;
  padding: 20px 56px 12px;
}

.sheet-head h3 {
  margin: 0;
  font-size: 18px;
  text-align: center;
  letter-spacing: 2px;
}

.sheet-close {
  position: absolute;
  right: 14px;
  top: 16px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.sheet h3 {
  margin: 0 0 14px;
  font-size: 18px;
  text-align: center;
  letter-spacing: 2px;
}

.confirm-body {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink-soft);
  margin: 12px 0 4px;
  line-height: 1.9;
}

.confirm-body .row {
  display: flex;
  justify-content: space-between;
}

.confirm-body .row .v {
  font-family: var(--serif);
  color: var(--ink);
}

/* 确认扣课弹层：实际上课时间日期选择 */
.confirm-body .lesson-date-row {
  align-items: center;
  margin-top: 6px;
}

.confirm-body .lesson-date-row input[type='date'] {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px; /* >=16px 避免 iOS 聚焦缩放 */
  max-width: 150px;
}

@keyframes slideUp {
  from {
    transform: translateY(40px);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(51, 36, 26, 0.94);
  color: #f8edd8;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  max-width: 86vw;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

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

.toast.ok {
  background: rgba(72, 101, 66, 0.95);
}

.toast.err {
  background: rgba(140, 70, 52, 0.96);
}

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

.record {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line-soft);
}

.record:last-child {
  border-bottom: none;
}

.record-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: var(--gold-soft);
  color: var(--gold-deep);
}

.record-dot.reverse {
  background: #e3e7d9;
  color: var(--pine);
}

.record-main {
  flex: 1;
  min-width: 0;
}

.record-title {
  font-size: 15px;
  color: var(--ink);
}

.record-title.muted {
  color: var(--muted);
}

.record-time {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.record-change {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--brown);
}

.record-change.reverse {
  color: var(--pine);
}

.record-action {
  flex-shrink: 0;
}

/* ---------------- 链接盒子 ---------------- */

.link-box {
  display: flex;
  gap: 8px;
  align-items: center;
}

.link-box input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 13px;
}

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

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 22px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 34px 26px 28px;
}

.login-logo {
  text-align: center;
  font-size: 44px;
  line-height: 1;
}

.login-title {
  text-align: center;
  font-size: 23px;
  letter-spacing: 6px;
  margin: 12px 0 4px;
  color: var(--brown);
}

.login-sub {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 3px;
  margin-bottom: 26px;
}

.login-deco {
  width: 48px;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
  margin: 0 auto 22px;
}

/* ---------------- 学生公开页 ---------------- */

.public-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 26px 16px 44px;
}

.public-head {
  text-align: center;
  margin-bottom: 18px;
}

.public-head .brand-line {
  font-size: 14px;
  letter-spacing: 3px;
  color: var(--ink-soft);
}

.public-head .deco {
  width: 40px;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
  margin: 10px auto 0;
}

.hero-card {
  background: linear-gradient(165deg, var(--brown-deep), var(--brown));
  color: #f7edd9;
  border-radius: 20px;
  padding: 26px 22px 22px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  top: -60px;
  right: -50px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(236, 220, 184, 0.16), transparent 70%);
  pointer-events: none;
}

.hero-name {
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 4px;
}

.hero-ring {
  margin: 16px auto 6px;
  width: 158px;
  height: 158px;
  position: relative;
}

.hero-ring svg {
  transform: rotate(-90deg);
}

.hero-ring .ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.hero-ring .ring-num {
  font-family: var(--serif);
  font-size: 46px;
  font-weight: 700;
  color: #f2d9a6;
  line-height: 1.1;
}

.hero-ring .ring-lbl {
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--gold-soft);
  margin-top: 4px;
}

.hero-progress-meta {
  font-size: 12px;
  color: rgba(236, 220, 184, 0.75);
  letter-spacing: 1px;
}

.public-stats {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.public-stat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  padding: 14px 6px;
}

.public-stat .num {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
}

.public-stat .lbl {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.public-records .card {
  padding: 6px 16px;
}

.public-record {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}

.public-record:last-child {
  border-bottom: none;
}

.public-record .date {
  font-size: 13px;
  color: var(--gold-deep);
  font-weight: 600;
  width: 64px;
  flex-shrink: 0;
}

.public-record .what {
  flex: 1;
  font-size: 14px;
  color: var(--ink-soft);
}

.public-record .change {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--brown);
}

.public-record .change.reverse {
  color: var(--pine);
}

/* ---------------- 错误页（学生链接失效等） ---------------- */

.state-page {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  color: var(--ink-soft);
}

.state-page .emoji {
  font-size: 52px;
  margin-bottom: 14px;
  opacity: 0.8;
}

.state-page .msg {
  font-size: 16px;
  line-height: 1.8;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 12px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-deep);
  letter-spacing: 1px;
}

.badge.empty {
  background: #efe2e0;
  color: var(--clay);
}

.loading {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
  font-size: 14px;
  letter-spacing: 2px;
}

/* ---------------- 窄屏手机适配（≤400px：375/390/412 等） ---------------- */

@media (max-width: 400px) {
  .topbar {
    padding: 14px 12px 12px;
  }

  .topbar-inner {
    gap: 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand .logo {
    font-size: 19px;
  }

  .brand .title {
    font-size: 16px;
    letter-spacing: 1px;
  }

  .brand .sub {
    font-size: 10px;
    letter-spacing: 0;
  }

  .topbar-actions {
    gap: 6px;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .topbar-actions .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* 超窄屏（≤340px，如 iPhone SE 一代） */
@media (max-width: 340px) {
  .brand .sub {
    display: none;
  }

  .topbar-inner {
    gap: 6px;
  }

  .brand {
    gap: 6px;
  }

  .brand .logo {
    font-size: 18px;
  }

  .topbar-actions {
    gap: 4px;
  }

  .icon-btn {
    width: 30px;
    height: 30px;
  }

  .topbar-actions .btn-sm {
    padding: 6px 8px;
  }
}
