/* ==========================================================================
   LXSARA VISUAL SYSTEM 2.0 — Korean pastel study app (mobile-first)
   米白画布 + 粉/黄/蓝/薰衣草语义色。默认浅色，非 cyber。
   ========================================================================== */

:root {
  /* 画布与表面 */
  --canvas: #FFFDF8;      /* milk */
  --surface: #FFFFFF;     /* 主表面 */
  --ink: #34323A;         /* 主文字 */
  --muted: #77727D;       /* 次级文字 */
  --line: #ECE7E2;        /* 软边框 */

  /* 语义色 */
  --pink: #F4C9D7;        /* blush pink —— 主操作/选中/品牌 */
  --pink-soft: #FBE8EE;   /* soft pink 表面 */
  --pink-deep: #E7A9C0;   /* pink 按压/描边 */
  --pink-ink: #7A4558;    /* pink 上的文字 */

  --yellow: #F6E7A7;      /* butter yellow —— 今日/连胜/成就 */
  --yellow-soft: #FFF5CF; /* soft yellow 表面 */
  --yellow-ink: #7A6A2E;

  --blue: #CFE4F3;        /* powder blue —— 学习/测评/进度/信息 */
  --blue-soft: #EAF4FA;   /* soft blue 表面 */
  --blue-ink: #4A6A80;

  --lavender: #DDD5F3;    /* lavender —— AI Coach / 次级强调 */
  --lavender-soft: #F0EDFA;
  --lavender-ink: #5B4E8A;

  --green: #7BBF9E;       /* 仅正确/成功 */
  --green-soft: #E6F4EC;
  --green-ink: #2F7A55;

  --coral: #E88B94;       /* 仅错误 */
  --coral-soft: #FBE7EA;
  --coral-ink: #A0444E;

  --shadow: 0 2px 14px rgba(80, 62, 104, 0.06);
  --shadow-sm: 0 1px 6px rgba(80, 62, 104, 0.05);
  --r-lg: 20px;
  --r-md: 16px;
  --r-sm: 12px;

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img, svg { display: block; }

#app { min-height: 100vh; }

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶栏（移动端紧凑） ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 58px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(255, 253, 248, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--pink), var(--lavender));
  color: #fff;
  font-weight: 800;
  font-size: 16px;
}
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: 0.3px; }

.top-actions { display: flex; align-items: center; gap: 8px; }
.exam-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 26px 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  min-height: 40px;
  max-width: 140px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2377727D' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.icon-btn {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 18px;
}

/* ---------- 主体布局 ---------- */
.app-body { flex: 1; display: flex; }

.screen { flex: 1; min-width: 0; }

.content {
  padding: 16px 16px 96px; /* 底部为 bottom-nav 留空间 */
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- 侧栏（桌面） ---------- */
.sidebar { display: none; }

/* ---------- 移动端底部导航 ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav button {
  flex: 1;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.bottom-nav .nv { font-size: 20px; line-height: 1; }
.bottom-nav button:active { color: var(--pink-ink); }
.bottom-nav button.active { color: var(--pink-ink); }
.bottom-nav button.active .nv { transform: translateY(-1px); }

/* ---------- footer（build 标记，低调） ---------- */
.footer {
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.55;
  padding: 8px 16px calc(64px + env(safe-area-inset-bottom, 0px));
}

/* ---------- 通用组件 ---------- */
.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--pink-ink);
}
h1 { font-size: 26px; line-height: 1.25; margin: 6px 0 8px; font-weight: 800; letter-spacing: -0.3px; }
h2 { font-size: 18px; line-height: 1.3; margin: 0 0 6px; font-weight: 800; }
h3 { font-size: 15px; margin: 0 0 4px; font-weight: 700; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 13px; }
.pill {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--pink-soft);
  color: var(--pink-ink);
  font-size: 12px;
  font-weight: 700;
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #F6CFDE, #F0BBD2);
  border: 1px solid #EFC3D5;
  color: var(--pink-ink);
  font-weight: 800;
  font-size: 15px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.primary:hover { transform: translateY(-1px); }
.primary:active { transform: translateY(0); }
.primary span { font-size: 18px; }

.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
}
.secondary:disabled { color: var(--muted); opacity: 0.7; }
.secondary.wide { width: 100%; margin-top: 12px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.section-title h2 { margin: 0; }
.section-title b { color: var(--pink-ink); }

.bar { height: 8px; border-radius: 8px; background: var(--line); overflow: hidden; }
.bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--pink), var(--lavender));
  border-radius: inherit;
  transition: width 0.4s ease;
}

/* ---------- 首页 ---------- */
.greeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px 16px;
}
.greet-text { flex: 1; min-width: 0; }
.greet-text .eyebrow { color: var(--blue-ink); }
.greet-text h1 { margin: 4px 0 4px; }
.greet-text .muted b { color: var(--pink-ink); }
.mascot-box { flex: 0 0 auto; }

.today-card {
  background: linear-gradient(135deg, var(--yellow-soft), #FFEFC0);
  border: 1px solid #F2E4AC;
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.today-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.today-head .eyebrow { color: var(--yellow-ink); }
.today-head .pill { background: #FBF0BE; color: var(--yellow-ink); }
.today-main {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.today-min strong { font-size: 38px; font-weight: 800; line-height: 1; }
.today-min span { font-size: 12px; color: var(--yellow-ink); margin-left: 3px; }

.task-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.task {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
}
.task-icon {
  width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 20px;
}
.task-body { flex: 1; min-width: 0; }
.task-body strong { display: block; font-size: 14px; }
.task-body small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.task.blue .task-icon { background: var(--blue-soft); }
.task.pink .task-icon { background: var(--pink-soft); }
.task.yellow .task-icon { background: var(--yellow-soft); }
.task.lavender .task-icon { background: var(--lavender-soft); }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.stat-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 6px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-chip b { display: block; font-size: 18px; font-weight: 800; }
.stat-chip span { font-size: 11px; color: var(--muted); }

/* ---------- 卡片 ---------- */
.card-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.mini-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.mini-card h3 { margin-bottom: 6px; }
.mini-card p { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.mini-card.blue { background: var(--blue-soft); border-color: #D7E8F3; }
.mini-card.pink { background: var(--pink-soft); border-color: #F4DAE3; }
.mini-card.yellow { background: var(--yellow-soft); border-color: #F4E9BE; }
.mini-card.lavender { background: var(--lavender-soft); border-color: #E3DDF2; }

.grid2 { display: grid; grid-template-columns: 1fr; gap: 14px; }

/* ---------- 题目 / 答案 ---------- */
.question .eyebrow { color: var(--blue-ink); }
.question h2 { font-size: 19px; line-height: 1.4; margin: 10px 0 16px; }
.answer-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.answer {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1.5px solid var(--line);
  text-align: left;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.answer.correct { background: var(--green-soft); border-color: var(--green); color: var(--green-ink); }
.answer.wrong { background: var(--coral-soft); border-color: var(--coral); color: var(--coral-ink); }
.answer.selected {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: var(--blue-ink);
  box-shadow: inset 3px 0 0 var(--blue);
}
.answer:disabled { cursor: default; }
.answer:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.feedback { min-height: 22px; font-size: 13px; font-weight: 700; margin-top: 14px; }
.feedback.good { color: var(--green-ink); }
.feedback.bad { color: var(--coral-ink); }

.notice {
  background: var(--blue-soft);
  border: 1px solid #D8E8F3;
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--blue-ink);
  margin: 12px 0;
}
.notice strong { display: block; margin-bottom: 4px; }

.empty { color: var(--muted); font-size: 13px; padding: 18px 6px; text-align: center; }

/* ---------- 进度 ---------- */
.statgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
}
.stat b { display: block; font-size: 22px; font-weight: 800; color: var(--pink-ink); }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 12px 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted); }
input, select, textarea {
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  min-height: 46px;
  outline: none;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--pink-deep); }

/* ---------- 吉祥物 ---------- */
.companion { width: 92px; height: auto; }
.companion .halo { fill: var(--lavender-soft); }
.companion .body { fill: var(--pink); }
.companion .hair { fill: var(--lavender); }
.companion .face { fill: #FFFDF8; }
.companion .eye { fill: var(--ink); }
.companion .star { fill: var(--yellow); }

/* ---------- 视图专属面板 ---------- */
.panel.today-panel { background: var(--yellow-soft); border-color: #F2E4AC; }
.panel.today-panel .eyebrow { color: var(--yellow-ink); }
.panel.writing-panel,
.panel.coach-panel { background: var(--lavender-soft); border-color: #E3DDF2; }
.panel.writing-panel .eyebrow,
.panel.coach-panel .eyebrow { color: var(--lavender-ink); }

.answer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}
.answer-actions .primary { flex: 1; }
.answer-actions .primary:disabled { opacity: 0.55; cursor: not-allowed; background: var(--line); color: var(--muted); border-color: var(--line); }


/* ==========================================================================
   桌面端（>= 601px）：同视觉系统，展示侧栏、隐藏底部导航
   ========================================================================== */
@media (min-width: 601px) {
  .content { max-width: 860px; padding: 28px 32px 48px; }

  .bottom-nav { display: none; }
  .footer { padding-bottom: 20px; }

  .sidebar {
    display: block;
    flex: 0 0 232px;
    padding: 24px 14px;
    border-right: 1px solid var(--line);
    position: sticky;
    top: 58px;
    align-self: flex-start;
    height: calc(100vh - 58px);
    overflow-y: auto;
  }
  .side-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin: 18px 10px 8px;
  }
  .sidebar button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    text-align: left;
  }
  .sidebar button:hover { background: var(--pink-soft); }
  .sidebar .nv { width: 20px; text-align: center; }

  .greet-text h1 { font-size: 32px; }
  .mascot-box .companion { width: 110px; }

  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1.5fr 1fr; }
  .answer-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .statgrid { grid-template-columns: repeat(4, 1fr); }

  .topbar { padding: 0 24px; height: 64px; }
  .exam-select { max-width: 180px; }
}

/* 仅在真正可 hover 的指针设备上显示 hover 选中态，避免移动端 sticky hover 造成“预选中”假象；
   已确认/已选中/已判定的答案不参与 hover，保证「选中/正确/错误/悬停/焦点」视觉互不干扰 */
@media (hover: hover) and (pointer: fine) {
  .answer:not(.selected):not(.correct):not(.wrong):not(:disabled):hover { border-color: var(--pink-deep); background: var(--pink-soft); }
}
@media (hover: none), (pointer: coarse) {
  .answer:not(.selected):not(.correct):not(.wrong):not(:disabled):hover { border-color: var(--line); background: var(--surface); }
}
