/* ============================================================
   AI钢琴调律智能体 · 正式网页原型设计系统
   风格：专业、可信、简洁（钢琴与专业教育）
   ============================================================ */
:root {
  color-scheme: light;
  --ink: #1c2a25;
  --muted: #5f6f68;
  --line: #dde5e0;
  --paper: #faf8f3;
  --card: #ffffff;
  --deep: #14332a;
  --deep-2: #1d4a3c;
  --green: #246b55;
  --green-soft: #e8f1ec;
  --gold: #b8893a;
  --gold-soft: #f3e8d2;
  --danger: #a34437;
  --shadow: 0 10px 34px rgba(20, 51, 42, 0.10);
  --shadow-sm: 0 3px 12px rgba(20, 51, 42, 0.07);
  --radius: 14px;
  --serif: "Songti SC", "Noto Serif SC", "SimSun", Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--green); text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 700; line-height: 1.3; }
img { max-width: 100%; }
.hidden { display: none !important; }

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--deep);
  color: #f2ede2;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
}
.nav-bar {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; gap: 22px;
  padding: 0 20px; height: 62px;
}
.brand { display: flex; align-items: center; gap: 11px; flex: 0 0 auto; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--gold); color: var(--deep);
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 21px; font-weight: 700;
}
.brand-text { line-height: 1.15; }
.brand-text .t1 { font-family: var(--serif); font-size: 16px; font-weight: 700; color: #fff; }
.brand-text .t2 { font-size: 11px; color: #b8c9c1; letter-spacing: .08em; }
.nav-links { display: flex; gap: 4px; margin-left: 8px; }
.nav-links a {
  color: #c8d6cf; padding: 8px 13px; border-radius: 8px;
  font-size: 14px; transition: background .15s, color .15s;
}
.nav-links a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-links a.active { background: var(--gold); color: var(--deep); font-weight: 600; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav-btn {
  padding: 8px 15px; border-radius: 9px; font-size: 13px;
  border: 1px solid rgba(255,255,255,.25); color: #f2ede2;
}
.nav-btn.solid { background: var(--gold); color: var(--deep); border-color: var(--gold); font-weight: 600; }
.nav-btn:hover { background: rgba(255,255,255,.1); }
.nav-btn.solid:hover { background: #cda050; }
.hamburger {
  display: none; width: 40px; height: 40px; border-radius: 8px;
  color: #fff; font-size: 22px; align-items: center; justify-content: center;
}
.mobile-menu {
  display: none; flex-direction: column; gap: 2px;
  background: var(--deep); padding: 8px 16px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.mobile-menu a {
  color: #d5e0da; padding: 12px 10px; border-radius: 8px; font-size: 15px;
}
.mobile-menu a.active { background: var(--gold); color: var(--deep); font-weight: 600; }
.mobile-menu.open { display: flex; }

/* ---------- 布局容器 ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 36px 20px 70px; }
.page-narrow { max-width: 860px; }
.page-title { font-size: 30px; margin: 0 0 6px; color: var(--deep); }
.page-sub { color: var(--muted); margin: 0 0 28px; font-size: 15px; }
.section-title { font-size: 21px; margin: 34px 0 16px; color: var(--deep); }

/* ---------- 首页 ---------- */
.hero {
  background: linear-gradient(135deg, var(--deep) 0%, var(--deep-2) 100%);
  color: #f4efe3; border-radius: 20px; padding: 54px 44px;
  position: relative; overflow: hidden;
}
.hero::after {
  content: "♪"; position: absolute; right: 30px; top: -20px;
  font-size: 220px; color: rgba(184,137,58,.12); font-family: var(--serif);
}
.hero h1 { font-size: 38px; margin: 0 0 14px; color: #fff; }
.hero p { font-size: 16px; max-width: 620px; color: #cdd9d2; margin: 0 0 26px; }
.hero-tags { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-tag {
  padding: 6px 14px; border-radius: 999px; font-size: 13px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
}
.entry-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 30px;
}
.entry-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 22px; cursor: pointer; transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 10px;
}
.entry-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.entry-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--green-soft); color: var(--green);
  display: grid; place-items: center; font-size: 24px;
}
.entry-card h3 { margin: 6px 0 0; font-size: 17px; }
.entry-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.entry-card .go { margin-top: auto; color: var(--gold); font-size: 13px; font-weight: 600; }
.stat-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-top: 30px; }
.stat-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-align: center; }
.stat-box .num { font-family: var(--serif); font-size: 30px; color: var(--deep); font-weight: 700; }
.stat-box .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- 卡片通用 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 18px; }

/* ---------- 学习页 ---------- */
.module-card { padding: 24px; }
.module-card .mod-head { display: flex; align-items: center; gap: 13px; margin-bottom: 12px; }
.module-card .mod-badge {
  width: 44px; height: 44px; border-radius: 11px; background: var(--gold-soft);
  color: var(--gold); display: grid; place-items: center; font-size: 22px;
}
.module-card h3 { margin: 0; font-size: 18px; }
.module-card .mod-desc { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.chapter-list { display: flex; flex-direction: column; gap: 6px; }
.chapter-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; border-radius: 8px; background: var(--paper); font-size: 13px;
}
.chapter-item .ch-cat { color: var(--green); font-weight: 600; font-size: 12px; }
.chapter-item .ch-count { color: var(--muted); }

/* ---------- 课程页 ---------- */
.tabs { display: inline-flex; background: var(--green-soft); border-radius: 10px; padding: 4px; margin-bottom: 22px; }
.tabs button { padding: 8px 20px; border-radius: 7px; font-size: 14px; color: var(--green); }
.tabs button.active { background: var(--green); color: #fff; font-weight: 600; }
.course-card { overflow: hidden; display: flex; flex-direction: column; }
.course-cover {
  height: 150px; background: linear-gradient(135deg, var(--deep-2), var(--deep));
  display: grid; place-items: center; color: #f0e6cf; font-size: 40px;
  position: relative;
}
.badge {
  position: absolute; top: 12px; left: 12px;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.badge.free { background: var(--green); color: #fff; }
.badge.preview { background: var(--gold); color: #fff; }
.badge.paid { background: #333; color: #fff; }
.course-body { padding: 18px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.course-body h3 { margin: 0; font-size: 16px; }
.course-body .desc { color: var(--muted); font-size: 13px; line-height: 1.55; }
.course-meta { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.course-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.price { font-family: var(--serif); font-size: 20px; color: var(--gold); font-weight: 700; }
.price.free { color: var(--green); }
.tag-purchased { font-size: 12px; color: var(--green); background: var(--green-soft); padding: 3px 9px; border-radius: 999px; }
.tag-unpurchased { font-size: 12px; color: var(--muted); }
.chapter-tree { margin-top: 14px; display: flex; flex-direction: column; gap: 5px; }
.chapter-tree .ct { padding: 7px 10px; border-radius: 7px; font-size: 13px; background: var(--paper); display: flex; justify-content: space-between; }
.chapter-tree .ct .free-mark { color: var(--gold); font-size: 11px; }

/* ---------- 商城页 ---------- */
.cat-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.cat-chip {
  padding: 7px 15px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); font-size: 13px; color: var(--muted);
}
.cat-chip.active { background: var(--deep); color: #fff; border-color: var(--deep); }
.product-card { overflow: hidden; display: flex; flex-direction: column; }
.product-img {
  height: 130px; background: var(--gold-soft); display: grid; place-items: center;
  font-size: 46px; color: var(--gold);
}
.product-body { padding: 16px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.product-body h3 { margin: 0; font-size: 15px; }
.product-body .use { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.product-body .fit { font-size: 12px; color: var(--green); }
.product-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.buy-link { color: var(--gold); font-size: 13px; font-weight: 600; }

/* ---------- 聊天页 ---------- */
.chat-layout { display: grid; grid-template-columns: 270px minmax(0,1fr); gap: 0; align-items: start; }
.chat-side { position: sticky; top: 82px; padding: 18px; border-right: 1px solid var(--line); }
.mobile-chat-actions { display: none; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--card); }
.chat-side .side-block { margin-bottom: 18px; }
.chat-side .side-title { font-size: 12px; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; font-weight: 700; }
.faq-list { display: flex; flex-direction: column; gap: 6px; }
.faq-q {
  text-align: left; padding: 9px 11px; border-radius: 8px; background: var(--paper);
  font-size: 13px; color: var(--ink); width: 100%;
}
.faq-q:hover { background: var(--green-soft); }
.side-action {
  width: 100%; text-align: left; padding: 9px 11px; border-radius: 8px;
  font-size: 13px; color: var(--green); background: var(--green-soft); margin-bottom: 6px;
}
.side-action:hover { background: #d6e7de; }
.status-row-mini { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; color: var(--muted); }
.status-row-mini strong { color: var(--ink); }
.pill { padding: 2px 9px; border-radius: 999px; font-size: 11px; background: #d9c4a3; }
.pill.ready { background: var(--green); color: #fff; }

.chat-main { display: flex; flex-direction: column; height: calc(100vh - 62px - 40px); min-height: 520px; }
.chat-toolbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px;
  border-bottom: 1px solid var(--line); background: var(--card);
}
.chat-toolbar .ct-title { font-family: var(--serif); font-weight: 700; color: var(--deep); }
.chat-toolbar .spacer { flex: 1; }
.mini-btn {
  padding: 7px 13px; border-radius: 8px; font-size: 13px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
}
.mini-btn:hover { background: var(--paper); }
.mini-btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.messages { flex: 1; overflow-y: auto; padding: 22px clamp(14px,4vw,40px); }
.message { display: flex; gap: 10px; margin-bottom: 18px; align-items: flex-start; }
.message.user { flex-direction: row-reverse; }
.avatar {
  flex: 0 0 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
  background: var(--green);
}
.message.user .avatar { background: var(--gold); color: var(--deep); }
.bubble {
  max-width: min(680px, 88%); padding: 12px 15px;
  border-radius: 4px 14px 14px 14px; background: var(--card);
  box-shadow: var(--shadow-sm); white-space: pre-wrap; line-height: 1.7; font-size: 14.5px;
}
.message.user .bubble { border-radius: 14px 4px 14px 14px; background: var(--green); color: #fff; }
.message-image { max-width: 230px; max-height: 180px; border-radius: 9px; margin-top: 8px; display: block; }
.typing::after { content: "▋"; animation: blink .9s infinite; color: var(--green); }
@keyframes blink { 50% { opacity: 0; } }
.sources-inline { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--muted); }
.sources-inline .src { display: block; }

.composer-wrap { padding: 12px clamp(14px,4vw,40px) 18px; border-top: 1px solid var(--line); background: var(--paper); }
.image-preview { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.image-preview img { width: 64px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.composer {
  display: flex; align-items: flex-end; gap: 9px; padding: 8px;
  border: 1px solid #cdd8d2; border-radius: 14px; background: #fff;
  box-shadow: var(--shadow-sm);
}
.composer textarea {
  flex: 1; border: 0; outline: 0; resize: none; padding: 9px 5px;
  max-height: 130px; line-height: 1.5;
}
.upload-btn, .send-btn { border: 0; border-radius: 10px; padding: 9px 13px; white-space: nowrap; font-size: 14px; }
.upload-btn { background: var(--green-soft); color: var(--green); }
.send-btn { background: var(--green); color: #fff; }
.send-btn:disabled { opacity: .5; }

/* ---------- 个人中心 ---------- */
.profile-layout { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 24px; }
.profile-side { display: flex; flex-direction: column; gap: 4px; }
.profile-side button {
  text-align: left; padding: 11px 14px; border-radius: 9px; font-size: 14px; color: var(--muted);
}
.profile-side button.active { background: var(--green-soft); color: var(--green); font-weight: 600; }
.profile-content { min-height: 300px; }
.form-card { padding: 28px; max-width: 420px; }
.form-card label { display: grid; gap: 6px; margin: 12px 0; font-size: 13px; font-weight: 600; color: #3c4a44; }
.form-card input {
  border: 1px solid #cdd8d2; border-radius: 9px; padding: 11px 12px; outline: 0;
}
.form-card input:focus { border-color: var(--green); }
.btn-primary {
  width: 100%; margin-top: 10px; padding: 12px; border-radius: 10px;
  background: var(--green); color: #fff; font-weight: 600;
}
.link-btn { color: var(--green); font-size: 13px; margin-top: 12px; display: inline-block; }
.info-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.info-row span { color: var(--muted); }

/* ---------- 管理后台 ---------- */
.admin-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 24px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin-table th { background: var(--paper); color: var(--deep); font-weight: 700; }
.admin-table td .ans { color: var(--muted); max-width: 280px; }
.chip-yes { color: var(--danger); font-weight: 600; }
.chip-no { color: var(--muted); }
.cat-tag { background: var(--gold-soft); color: var(--gold); padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.feedback-good { color: var(--green); }
.feedback-bad { color: var(--danger); }
.feedback-neutral { color: var(--muted); }
.faq-rank { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.faq-rank .num { width: 24px; height: 24px; border-radius: 50%; background: var(--deep); color: #fff; display: grid; place-items: center; font-size: 11px; }

/* ---------- 弹窗 ---------- */
dialog {
  width: min(520px, calc(100vw - 30px)); border: 0; border-radius: 16px;
  padding: 0; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(15,35,28,.55); backdrop-filter: blur(3px); }
dialog form { padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.dialog-head h3 { margin: 0 0 5px; font-size: 20px; }
.dialog-head p { margin: 0; color: var(--muted); font-size: 12.5px; }
.icon-close { width: 34px; height: 34px; border-radius: 9px; background: #eef2ef; font-size: 20px; }
dialog label { display: grid; gap: 6px; margin: 12px 0; font-size: 13px; font-weight: 600; color: #3c4a44; }
dialog input, dialog select {
  border: 1px solid #cdd8d2; border-radius: 9px; padding: 11px 12px; outline: 0;
}
.form-msg { min-height: 18px; font-size: 12px; color: var(--danger); }

/* ---------- 页脚 ---------- */
.site-footer { background: var(--deep); color: #9fb3aa; padding: 30px 20px; text-align: center; font-size: 12.5px; margin-top: 40px; }
.site-footer .ft-title { color: #e8e0cc; font-family: var(--serif); margin-bottom: 6px; }

/* ---------- 历史对话抽屉 ---------- */
.history-panel { padding: 18px; max-width: 380px; }
.history-item { padding: 11px; border-radius: 9px; cursor: pointer; border: 1px solid var(--line); margin-bottom: 8px; }
.history-item:hover { background: var(--paper); }
.history-item .h-q { font-size: 13.5px; font-weight: 600; }
.history-item .h-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
  .nav-links { display: none; }
  .hamburger { display: flex; }
  .entry-grid, .stat-row { grid-template-columns: repeat(2,1fr); }
  .grid-3 { grid-template-columns: repeat(2,1fr); }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-side { display: none; }
  .mobile-chat-actions { display: flex; }
  .admin-stats { grid-template-columns: repeat(2,1fr); }
  .profile-layout { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .nav-right { display: none; }
  .hero { padding: 34px 22px; }
  .hero h1 { font-size: 27px; }
  .entry-grid, .grid-3, .grid-2, .stat-row { grid-template-columns: 1fr; }
  .page-title { font-size: 24px; }
  .chat-main { height: calc(100vh - 62px); }
  .bubble { max-width: 95%; }
  .admin-table { font-size: 12px; }
  .admin-table td .ans { max-width: 160px; }
}

/* ---------- 手机菜单底部操作按钮 ---------- */
.mobile-menu-actions { display:flex; gap:10px; padding:14px 18px 18px; border-top:1px solid var(--line); }
.mobile-menu-actions .nav-btn { flex:1; justify-content:center; }

/* ---------- 手机端聊天高度用 dvh，避免键盘弹出遮挡输入框 ---------- */
@media (max-width: 680px) {
  .chat-main { height: 100dvh; height: calc(100dvh - 0px); }
  .composer-wrap { padding-bottom: env(safe-area-inset-bottom, 0); }
  .admin-table { display: block; overflow-x: auto; white-space: nowrap; }
  .admin-table th, .admin-table td { white-space: nowrap; }
  .admin-table td .ans { white-space: normal; max-width: 220px; }
}
