:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #23282b;
  --ink-soft: #6a7378;
  --line: #e4e0d8;
  --accent: #2f6f5e;
  --accent-soft: #e6f0ec;
  --warn: #b4552f;
  --shadow: 0 1px 2px rgba(35, 40, 43, .06), 0 8px 24px rgba(35, 40, 43, .06);
  --radius: 16px;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
  overscroll-behavior-y: contain;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 12px;
  background: rgba(246, 244, 239, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-size: 19px; font-weight: 650; letter-spacing: .01em; }
.topbar-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; min-height: 18px; }

main { padding: 16px 16px 8px; max-width: 760px; margin: 0 auto; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px;
}

.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.mt8 { margin-top: 8px; }
.mt14 { margin-top: 10px; }

button {
  font: inherit; color: inherit; cursor: pointer;
  border: 1px solid var(--line); background: #fff;
  border-radius: 12px; padding: 11px 15px;
  transition: transform .08s ease, background .15s ease;
}
button:active { transform: scale(.975); }
button:disabled { opacity: .45; cursor: default; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-danger { color: var(--warn); }
.btn-block { display: block; width: 100%; }
.btn-big { padding: 16px; font-size: 17px; border-radius: 14px; }

input, textarea, select {
  font: inherit; color: inherit; width: 100%;
  padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }

/* ---------- review ---------- */
.review-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; }
.prompt {
  min-height: 148px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 10px;
  padding: 16px 8px;
}
.prompt-q { font-size: 15px; color: var(--ink-soft); }
.prompt-main { font-size: 26px; font-weight: 650; line-height: 1.25; }
.prompt-tag { font-size: 14px; color: var(--ink-soft); }

.play-btn {
  width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); border: none; color: #fff;
  font-size: 30px; box-shadow: 0 10px 28px rgba(47, 111, 94, .28);
}
.play-btn.playing { background: #24574a; }

.clip-bar {
  height: 6px; border-radius: 3px; background: var(--line);
  overflow: hidden; margin: 14px 0 4px;
}
.clip-bar > i { display: block; height: 100%; width: 0; background: var(--accent); }

.ratings {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  position: sticky; bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--card); padding-top: 6px;
}
.ratings button {
  padding: 10px 4px; font-size: 13px; line-height: 1.25;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.ratings button b { display: block; font-size: 14.5px; font-weight: 650; }
.ratings button small { font-size: 11.5px; color: var(--ink-soft); }
.play-btn:disabled { opacity: .32; }
.play-btn { touch-action: manipulation; }
.r0 { border-color: #e7cfc4; } .r1 { border-color: #e6dcc4; }
.r2 { border-color: #cfe0d6; } .r3 { border-color: #c9d8e4; }

/* ---------- library ---------- */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; background: #fff; border-radius: 14px;
  margin-bottom: 9px; box-shadow: var(--shadow); cursor: pointer;
}
.list-item:active { background: #faf9f6; }
.li-title { font-weight: 600; }
.li-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.chip {
  display: inline-block; font-size: 11.5px; padding: 2px 8px;
  border-radius: 999px; background: var(--accent-soft); color: #24574a; margin-right: 5px;
}
.due-badge { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: #eef0f1; color: var(--ink-soft); white-space: nowrap; }
.due-badge.now { background: var(--accent-soft); color: #24574a; font-weight: 600; }

.empty { text-align: center; padding: 46px 18px; color: var(--ink-soft); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ---------- misc ---------- */
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { border: none; border-radius: 0; flex: 1; background: #fff; font-size: 14px; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: #fff; border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.stat .n { font-size: 25px; font-weight: 650; }
.stat .l { font-size: 12.5px; color: var(--ink-soft); }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 96px; margin-top: 14px; }
.bars > div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; justify-content: flex-end; }
.bars .b { width: 100%; background: var(--accent-soft); border-radius: 6px 6px 0 0; min-height: 3px; }
.bars .d { font-size: 11px; color: var(--ink-soft); }

input[type=range] { padding: 0; border: none; background: transparent; }

.sheet {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  overflow-y: auto; padding: calc(env(safe-area-inset-top) + 12px) 16px 40px;
}
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; max-width: 760px; margin-inline: auto; }
.sheet-head h2 { font-size: 18px; margin: 0; }
.sheet-body { max-width: 760px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: rgba(252, 251, 248, .95);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none; border-radius: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 8px; font-size: 11.5px; color: var(--ink-soft);
}
.tab .tab-ico { font-size: 18px; line-height: 1; }
.tab.on { color: var(--accent); font-weight: 650; }

/* 批量选择时吸在底部导航上方的操作条 */
.select-bar {
  position: fixed; left: 0; right: 0;
  bottom: calc(62px + env(safe-area-inset-bottom));
  z-index: 25;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: rgba(252, 251, 248, .97);
  border-top: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(12px);
}
.select-bar .grow { flex: 1; }

.pick-box {
  width: 22px; height: 22px; flex: none; border-radius: 6px;
  border: 1.5px solid var(--line); display: grid; place-items: center;
  font-size: 14px; color: #fff; background: #fff;
}
.pick-box.on { background: var(--accent); border-color: var(--accent); }
.list-item.picked { background: var(--accent-soft); }

/*
 * 文件选择按钮：把真正的 <input type="file"> 铺在按钮上面。
 * iOS 上动态创建再 .click() 有时不弹选择器，这样用户点是直接点在输入框上，
 * 由系统原生触发，最可靠。
 */
.file-btn {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 16px; border-radius: 14px;
  background: var(--accent); color: #fff;
  font-size: 17px; font-weight: 600; cursor: pointer;
  text-align: center;
}
.file-btn input[type="file"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; font-size: 100px;
}
.file-btn.small {
  display: inline-flex; width: auto; padding: 11px 15px;
  border-radius: 12px; font-size: 16px; font-weight: 400;
  background: #fff; color: var(--ink); border: 1px solid var(--line);
}

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(35, 40, 43, .93); color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 60;
  max-width: 88vw;
}

@media (min-width: 700px) {
  .prompt { min-height: 240px; }
  .prompt-main { font-size: 32px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
