/* =========================================================
   然然的小宇宙 — 全局视觉系统
   风格：苹果原生 + 低饱和个人手账感
   ========================================================= */

:root{
  /* 背景：柔和白 / 极浅暖粉 */
  --bg: #fbf7f5;
  --bg-2: #ffffff;
  --bg-soft: #f4eeea;

  /* 文字：克制近黑，非纯黑 */
  --ink: #3b3531;
  --ink-soft: #8c837c;
  --ink-faint: #b6ada6;

  /* 描边 / 阴影 */
  --line: rgba(60,50,45,0.10);
  --line-strong: rgba(60,50,45,0.16);
  --shadow: 0 1px 2px rgba(60,50,45,0.04), 0 10px 30px rgba(60,50,45,0.05);
  --shadow-sm: 0 1px 2px rgba(60,50,45,0.05);

  /* 圆角 */
  --radius: 22px;
  --radius-sm: 16px;
  --radius-xs: 12px;

  /* 生活领域低饱和配色 */
  --c-home: #e7d6cf;
  --c-literacy: #d8c4a0;   /* 赭石 / 米黄 · 书香 */
  --c-english: #a9bccd;    /* 雾蓝 */
  --c-checkin: #b3cdbe;    /* 薄荷绿 */
  --c-works: #dabfa6;      /* 陶土橙 */
  --c-fun: #e2bcc4;        /* 樱粉 */
  --c-growth: #c5bad6;     /* 丁香紫 */

  /* 动作色（低饱和） */
  --accent: #c98b7a;
  --green: #8fb98f;        /* 答对啦 */
  --red: #d98e88;          /* 我还不认识你 */
  --blue: #8aa9c9;         /* 再来一次 */

  /* 安全区 */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

*{ box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html,body{ margin:0; padding:0; height:100%; }

body{
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 17px;
  line-height: 1.55;
  letter-spacing: .2px;
}

#app{ display:flex; min-height:100vh; min-height:100dvh; }

/* ===================== 侧边栏 ===================== */
#sidebar{
  width: 250px; flex: 0 0 250px;
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  padding: calc(22px + var(--safe-t)) 14px calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: rgba(255,255,255,0.62);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
  z-index: 20;
}

.brand{ display:flex; align-items:center; gap:11px; padding: 2px 10px 16px; }
.brand .avatar{
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-soft); border: 1px solid var(--line);
  display:flex; align-items:center; justify-content:center;
  font-size: 22px; overflow:hidden; flex:0 0 44px;
}
.brand .avatar img{ width:100%; height:100%; object-fit:cover; }
.brand .title{ font-size: 17px; font-weight: 600; letter-spacing: .5px; line-height:1.2; }
.brand .sub{ font-size: 11px; color: var(--ink-soft); margin-top:2px; }

.nav{ display:flex; flex-direction:column; gap:5px; flex:1; }
.nav-btn{
  position: relative;
  display:flex; align-items:center; gap:13px;
  min-height: 50px; padding: 0 14px;
  border:none; background: transparent; border-radius: 15px;
  color: var(--ink); font-size: 16px; cursor:pointer; text-align:left;
  font-family: inherit;
  transition: background .18s ease, color .18s ease;
}
.nav-btn .ic{ width:25px; height:25px; color: var(--ink-faint); flex:0 0 25px; transition: color .18s ease; }
.nav-btn:hover{ background: rgba(255,255,255,0.6); }
.nav-btn.active{ background:#fff; box-shadow: var(--shadow-sm); font-weight:600; }
.nav-btn.active::before{
  content:""; position:absolute; left:0; top:50%; transform:translateY(-50%);
  width:4px; height:24px; border-radius:4px; background: var(--tab-color, var(--accent));
}
.nav-btn.active .ic{ color: var(--tab-color, var(--accent)); }

.settings-btn{
  display:flex; align-items:center; gap:13px;
  min-height:50px; padding:0 14px; margin-top:6px;
  border:none; background:transparent; border-radius:15px;
  color: var(--ink-soft); font-size:15px; cursor:pointer; font-family:inherit;
}
.settings-btn .ic{ width:24px; height:24px; }
.settings-btn:hover{ background: rgba(255,255,255,0.6); }

/* ===================== 主区域 ===================== */
#main{
  flex:1; min-width:0;
  padding: calc(26px + var(--safe-t)) 30px calc(34px + var(--safe-b)) calc(30px + var(--safe-r));
  max-width: 1180px;
}

/* ===================== 卡片 ===================== */
.card{
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card.tight{ padding: 16px; }

.grid{ display:grid; gap:18px; }
.cols-2{ grid-template-columns: repeat(2, 1fr); }
.cols-3{ grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px){ .cols-2, .cols-3{ grid-template-columns: 1fr; } }

/* ===================== 文字 ===================== */
h1,h2,h3{ margin:0; font-weight:600; letter-spacing:.3px; }
.muted{ color: var(--ink-soft); }
.faint{ color: var(--ink-faint); }

/* ===================== 按钮 ===================== */
.btn{
  min-height: 48px; padding: 0 20px;
  border-radius: 15px; border: 1px solid var(--line);
  background:#fff; color: var(--ink); font-size: 16px; cursor:pointer;
  font-family: inherit; display:inline-flex; align-items:center; justify-content:center; gap:8px;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active{ transform: scale(0.97); }
.btn.block{ width:100%; }
.btn.green{ background: var(--green); border-color: transparent; color:#fff; }
.btn.red{ background: var(--red); border-color: transparent; color:#fff; }
.btn.blue{ background: var(--blue); border-color: transparent; color:#fff; }
.btn.ghost{ background: transparent; }
.btn .ic{ width:22px; height:22px; }

/* ===================== 首页模块 ===================== */
.hello{ display:flex; align-items:center; gap:18px; margin-bottom: 22px; }
.hello .ava{
  width:64px; height:64px; border-radius:50%; overflow:hidden; flex:0 0 64px;
  background: var(--bg-soft); border:1px solid var(--line);
  display:flex; align-items:center; justify-content:center; font-size:30px;
}
.hello .ava img{ width:100%; height:100%; object-fit:cover; }
.hello h1{ font-size: 26px; }
.hello .tag{ color: var(--ink-soft); font-size: 13px; margin-top:6px; letter-spacing:.5px; }

.stat-row{ display:flex; gap:14px; flex-wrap:wrap; }
.stat{
  flex:1; min-width: 140px;
  background: var(--bg-2); border:1px solid var(--line); border-radius: var(--radius-sm);
  padding:16px 18px; box-shadow: var(--shadow-sm);
}
.stat .num{ font-size: 30px; font-weight: 600; letter-spacing:.5px; }
.stat .lbl{ color: var(--ink-soft); font-size: 13px; margin-top:4px; }

.continue{
  display:flex; align-items:center; gap:18px; cursor:pointer;
  border-left: 4px solid var(--c-literacy);
}
.continue .big{ font-size: 40px; }
.continue .meta{ flex:1; }
.continue .meta .t{ font-size:18px; font-weight:600; }
.continue .bar{ height:8px; border-radius:8px; background: var(--bg-soft); margin-top:8px; overflow:hidden; }
.continue .bar > i{ display:block; height:100%; background: var(--c-literacy); border-radius:8px; }

.empty-state{
  border:1px dashed var(--line-strong); border-radius: var(--radius-sm);
  padding: 22px; color: var(--ink-soft); text-align:center; background: rgba(255,255,255,0.5);
}
.empty-state .big{ font-size: 30px; margin-bottom:8px; }

.thumb-row{ display:flex; gap:12px; overflow-x:auto; padding-bottom:4px; }
.thumb{
  flex:0 0 120px; height:120px; border-radius: var(--radius-xs);
  border:1px solid var(--line); background: var(--bg-soft);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px;
  color: var(--ink-soft); font-size:12px; text-align:center; padding:10px;
}
.thumb .dot{ width:46px; height:46px; border-radius:14px; }

.moment{
  border-left:3px solid var(--c-fun); padding:10px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.6); color: var(--ink);
}
.moment .when{ font-size:11px; color: var(--ink-faint); margin-top:4px; }

.tip{
  border-left:3px solid var(--accent); background: rgba(255,255,255,0.6);
  padding:12px 16px; border-radius:10px; color: var(--ink); font-size:14px;
}

/* ===================== 识文断字 ===================== */
.shelf{ display:grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap:16px; }
.book{
  position:relative; border-radius: var(--radius-sm); padding:18px;
  border:1px solid var(--line); background: var(--bg-2); box-shadow: var(--shadow-sm);
  cursor:pointer; min-height:130px; display:flex; flex-direction:column; justify-content:space-between;
  transition: transform .1s ease;
}
.book:active{ transform: scale(0.98); }
.book .cover{
  width:46px; height:60px; border-radius:8px; background: var(--c-literacy);
  display:flex; align-items:center; justify-content:center; font-size:13px; color:#fff; font-weight:600;
}
.book.locked .cover{ background: var(--bg-soft); color: var(--ink-faint); }
.book .name{ font-size:18px; font-weight:600; margin-top:10px; }
.book .author{ font-size:12px; color: var(--ink-soft); margin-top:2px; }
.book .soon{ font-size:11px; color: var(--ink-faint); margin-top:8px; }

.detail-head{ display:flex; align-items:center; gap:14px; margin-bottom:18px; }
.detail-head .back{
  width:44px; height:44px; border-radius:12px; border:1px solid var(--line);
  background:#fff; cursor:pointer; display:flex; align-items:center; justify-content:center;
}
.detail-head h2{ font-size:22px; }

.module{ margin-bottom:18px; }
.module h3{ font-size:17px; margin-bottom:12px; display:flex; align-items:center; gap:9px; }
.module h3 .ic{ width:22px; height:22px; color: var(--accent); }

/* 字卡 */
.char-stage{
  display:flex; flex-direction:column; align-items:center; gap:18px;
  padding: 30px 20px; border-radius: var(--radius); background: var(--bg-2);
  border:1px solid var(--line); box-shadow: var(--shadow-sm);
}
.big-char{
  font-size: 120px; line-height:1; font-weight:500; color: var(--ink);
  min-height: 130px; display:flex; align-items:center; justify-content:center;
}
.big-char.zhuan{ color: var(--ink-faint); font-size: 96px; }
.char-meta{ color: var(--ink-soft); font-size:13px; }
.char-actions{ display:flex; gap:12px; flex-wrap:wrap; justify-content:center; }

.seg{ display:inline-flex; background: var(--bg-soft); border-radius:12px; padding:4px; gap:4px; }
.seg button{
  min-height:40px; padding:0 16px; border:none; background:transparent; border-radius:9px;
  color: var(--ink-soft); font-size:14px; cursor:pointer; font-family:inherit;
}
.seg button.on{ background:#fff; color: var(--ink); box-shadow: var(--shadow-sm); font-weight:600; }

.select-row{ display:flex; gap:10px; align-items:center; margin-bottom:14px; }
.select-row input{
  min-height:46px; width:120px; border-radius:12px; border:1px solid var(--line);
  padding:0 14px; font-size:18px; font-family:inherit; background:#fff; color:var(--ink);
  text-align:center;
}

/* 模仿写字 */
.write-wrap{ display:grid; grid-template-columns: 160px 1fr; gap:18px; align-items:stretch; }
@media (max-width: 720px){ .write-wrap{ grid-template-columns: 1fr; } }
.write-show{
  border-radius: var(--radius-sm); border:1px solid var(--line); background: var(--bg-2);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; padding:18px;
}
.write-show .ch{ font-size:80px; font-weight:500; }
.write-show .ch.zhuan{ color: var(--ink-faint); }
.write-show .ph{ font-size:12px; color: var(--ink-faint); text-align:center; }
.canvas-box{
  border-radius: var(--radius-sm); border:1px solid var(--line); background:
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(60,50,45,0.04) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(60,50,45,0.04) 40px),
    #fff;
  position:relative; overflow:hidden;
}
#writeCanvas{ width:100%; height:320px; display:block; touch-action:none; cursor:crosshair; }

/* 诵读接龙 */
.relay-line{
  font-size: 34px; font-weight:500; letter-spacing: 6px; text-align:center;
  padding: 26px 16px; border-radius: var(--radius-sm); background: var(--bg-2);
  border:1px solid var(--line); box-shadow: var(--shadow-sm); min-height: 90px;
  display:flex; align-items:center; justify-content:center;
}
.relay-line.next{ color: var(--accent); background: rgba(201,139,122,0.08); }
.relay-controls{ display:flex; gap:12px; flex-wrap:wrap; margin-top:14px; justify-content:center; }

/* 视频占位 */
.video-ph{
  border-radius: var(--radius-sm); border:1px dashed var(--line-strong);
  background: rgba(255,255,255,0.5); padding: 30px; text-align:center; color: var(--ink-soft);
}
.video-ph .ic{ width:40px; height:40px; color: var(--ink-faint); margin-bottom:10px; }

/* 看全文 */
.kai{ font-family: "Kaiti SC","STKaiti","KaiTi","楷体",serif; }

.full-text{
  max-height: 380px; overflow-y: auto;
  margin-top: 12px; padding: 20px 22px;
  background: rgba(255,255,255,0.55); border:1px solid var(--line);
  border-radius: var(--radius-sm);
}
.full-row{
  display:flex; justify-content:center; align-items:center; gap: 36px;
  font-size: 32px; line-height: 2.1; color: var(--ink);
  letter-spacing: 4px;
}
.full-ph{ display:inline-block; }
.zhuan-row{ gap: 28px !important; letter-spacing: 0 !important; line-height: 2.4 !important; }
.zhuan-glyph{
  width: 40px; height: 40px; object-fit: contain; vertical-align: middle;
  margin: 0 3px;
}
.zhuan-missing{
  display:inline-block; width: 40px; text-align:center; opacity: 0.45;
  color: var(--ink-faint); font-size: 22px; margin: 0 3px;
}

/* ===================== 空壳板块 ===================== */
.coming{
  border:1px dashed var(--line-strong); border-radius: var(--radius);
  padding: 60px 30px; text-align:center; color: var(--ink-soft);
  background: rgba(255,255,255,0.4);
}
.coming .ic{ width:54px; height:54px; color: var(--ink-faint); margin-bottom:14px; }
.coming h2{ font-size:22px; color: var(--ink); margin-bottom:8px; }
.coming p{ font-size:14px; max-width: 420px; margin: 0 auto; }

/* ===================== 设置 ===================== */
.set-row{ display:flex; align-items:center; gap:14px; padding:16px 0; border-bottom:1px solid var(--line); }
.set-row:last-child{ border-bottom:none; }
.set-row .label{ flex:1; }
.set-row .label .t{ font-weight:600; }
.set-row .label .d{ font-size:13px; color: var(--ink-soft); }
.avatar-edit{ display:flex; align-items:center; gap:14px; }
.avatar-edit .preview{
  width:64px; height:64px; border-radius:50%; overflow:hidden; background: var(--bg-soft);
  border:1px solid var(--line); display:flex; align-items:center; justify-content:center; font-size:28px;
}
.avatar-edit .preview img{ width:100%; height:100%; object-fit:cover; }

/* ===================== 窄屏：侧边栏变底部 Tab ===================== */
@media (max-width: 820px){
  #app{ flex-direction: column; }
  #sidebar{
    width:auto; flex:none; height:auto;
    position: fixed; left:0; right:0; bottom:0;
    flex-direction: row; align-items:center; gap:4px;
    border-right:none; border-top:1px solid var(--line);
    padding: calc(6px + var(--safe-b)) 8px calc(6px + var(--safe-b)) calc(8px + var(--safe-l));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;       /* IE 10+ */
  }
  #sidebar::-webkit-scrollbar{ display:none; } /* Chrome/Safari */
  .brand, .nav-spacer{ display:none; }
  .nav{ flex-direction: row; gap:4px; flex:1; justify-content: space-between; min-width: min-content; }
  .nav-btn{ flex-direction:column; gap:3px; min-height:48px; padding:6px 10px; font-size:11px; flex:1 1 auto; }
  .nav-btn .ic{ width:22px; height:22px; }
  .settings-btn{ margin-top:0; flex-direction:column; min-height:48px; padding:6px 10px; font-size:11px; flex:0 0 auto; }
  .settings-btn .label{ display:none; }
  #main{ margin-left:0; padding: 22px 18px calc(110px + var(--safe-b)) 18px; max-width:none; }
}

.nav{ gap:2px; }
  .nav-btn{ min-height:46px; padding:5px 6px; flex:0 0 46px; }
  .nav-btn span{ display:none; }
  .nav-btn .ic{ width:24px; height:24px; }
  .settings-btn{ min-height:46px; padding:5px 6px; flex:0 0 46px; }
  #main{ padding: 18px 14px calc(92px + var(--safe-b)) 14px; }
}

.nav-btn{ flex:0 0 auto; }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce){
  *{ transition: none !important; }
}
