/* ============================================================
   单词本 · Apple 风格设计系统
   ============================================================ */

:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #ececef;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --star: #ffb300;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.04);
  --nav-bg: rgba(251, 251, 253, 0.72);
  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --maxw: 980px;
}

html[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #8e8e93;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
  --nav-bg: rgba(0, 0, 0, 0.68);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}

.backdrop {
  position: fixed;
  inset: 0 0 auto 0;
  height: 420px;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(80% 100% at 50% 0%, var(--accent-soft) 0%, transparent 70%);
  opacity: 0.55;
}

/* ---------------- 导航栏 ---------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
}

.nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: 48px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  font-weight: 590;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand svg { color: var(--accent); }

.nav-links { display: flex; gap: 26px; flex: 1; }
.nav-links a {
  font-size: 12.5px;
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.2s;
  padding: 4px 0;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--text); font-weight: 500; }

.nav-actions { display: flex; gap: 4px; align-items: center; }

.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: none; background: transparent;
  color: var(--text-2);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }

html[data-theme="dark"] .i-sun { display: none; }
html[data-theme="light"] .i-moon { display: none; }
html:not([data-theme]) .i-moon { display: none; }

/* ---------------- 主视图 ---------------- */
.view {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 22px 80px;
  position: relative;
  z-index: 1;
}

.page { animation: rise 0.42s var(--ease) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .page { animation: none; }
  * { transition: none !important; }
}

/* ---------------- 首页 ---------------- */
.hero { padding: 76px 0 44px; text-align: center; }

.hero h1 {
  font-size: clamp(40px, 7vw, 62px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.06;
  margin-bottom: 14px;
}

.hero .sub {
  font-size: 17px;
  color: var(--text-2);
  margin-bottom: 34px;
  letter-spacing: -0.012em;
}

.hero .sub b { color: var(--text); font-weight: 500; }

.searchbox { max-width: 600px; margin: 0 auto; position: relative; }

.searchbox .search-icon {
  position: absolute; left: 20px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}

.searchbox input {
  width: 100%;
  height: 58px;
  padding: 0 108px 0 50px;
  font-size: 17px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s var(--ease), border-color 0.25s, transform 0.25s var(--ease);
  -webkit-appearance: none;
}
.searchbox input::placeholder { color: var(--text-3); }
.searchbox input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-md);
  transform: translateY(-1px);
}

.searchbox .go {
  position: absolute; right: 8px; top: 8px;
  height: 42px; padding: 0 20px;
  border: none; border-radius: 11px;
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}
.searchbox .go:hover { opacity: 0.88; }
.searchbox .go:active { transform: scale(0.97); }

.hints {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-top: 18px;
}
.chip {
  padding: 6px 13px;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.chip:hover { background: var(--surface-3); color: var(--text); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 卡片网格 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 8px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s;
}
a.card:hover, .card.clickable:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.card h3 {
  font-size: 16px; font-weight: 590;
  letter-spacing: -0.02em; margin-bottom: 5px;
  display: flex; align-items: center; gap: 8px;
}
.card p { font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.card .big { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; margin-bottom: 2px; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.section-title {
  font-size: 13px; font-weight: 500; color: var(--text-3);
  margin: 40px 0 12px; letter-spacing: 0.01em;
}

/* 每日一词 */
.wotd {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px 28px;
  margin-top: 44px;
  position: relative;
  overflow: hidden;
}
.wotd .tag {
  font-size: 11.5px; font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px; border-radius: 999px;
  display: inline-block; margin-bottom: 16px;
  letter-spacing: 0.02em;
}
.wotd .w {
  font-size: 34px; font-weight: 600;
  letter-spacing: -0.03em; margin-bottom: 4px;
}
.wotd .ph { font-size: 15px; color: var(--text-3); margin-bottom: 14px; font-family: "SF Mono", "SFMono-Regular", Consolas, ui-monospace, monospace; }
.wotd .d { font-size: 15.5px; color: var(--text-2); margin-bottom: 20px; line-height: 1.5; }
.wotd .actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 18px;
  font-size: 14px; font-weight: 500; font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s, color 0.2s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { opacity: 0.88; background: var(--accent); }
.btn.ghost { background: transparent; border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.on { background: var(--accent-soft); color: var(--accent); }
.btn.sm { height: 32px; padding: 0 13px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 38px; padding: 0; }

/* ---------------- 页面头 ---------------- */
.page-head { padding: 52px 0 26px; }
.page-head h1 {
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 600; letter-spacing: -0.032em;
  margin-bottom: 8px;
}
.page-head p { color: var(--text-2); font-size: 15px; }

.crumb {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; color: var(--accent);
  text-decoration: none; margin-bottom: 20px;
  background: none; border: none; cursor: pointer; font-family: inherit;
  padding: 0;
}
.crumb:hover { opacity: 0.7; }
.crumb svg { transition: transform 0.2s; }
.crumb:hover svg { transform: translateX(-2px); }

/* ---------------- 列表 ---------------- */
.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.row {
  display: flex; align-items: center; gap: 16px;
  padding: 15px 22px;
  border-bottom: 0.5px solid var(--border);
  text-decoration: none; color: inherit;
  transition: background 0.18s;
  cursor: pointer;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--surface-2); }

.row .main { flex: 1; min-width: 0; }
.row .w {
  font-size: 16px; font-weight: 500; letter-spacing: -0.02em;
  margin-bottom: 2px; word-break: break-word;
}
.row .w .hl { color: var(--accent); }
.row .ph {
  font-size: 12.5px; color: var(--text-3);
  font-family: "SF Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  margin-bottom: 3px;
}
.row .d {
  font-size: 13.5px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row .side { display: flex; align-items: center; gap: 6px; flex: none; }

.tagpill {
  font-size: 11px; font-weight: 500;
  padding: 3px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}

.star-btn {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border: none; background: transparent;
  color: var(--text-3); border-radius: 8px;
  cursor: pointer; transition: all 0.2s;
}
.star-btn:hover { background: var(--surface-3); color: var(--star); }
.star-btn.on { color: var(--star); }

/* ---------------- 单词详情 ---------------- */
.detail-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 32px;
  margin-bottom: 18px;
}

.detail-hero .word {
  font-size: clamp(34px, 6vw, 46px);
  font-weight: 600; letter-spacing: -0.035em;
  line-height: 1.1; margin-bottom: 10px;
}

.phones { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }

.phone-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 8px 7px 14px;
  background: var(--surface-2);
  border-radius: 11px;
  font-size: 14px;
  font-family: "SF Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  color: var(--text-2);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}
.phone-chip:hover { background: var(--surface-3); color: var(--text); }
.phone-chip .lbl {
  font-family: -apple-system, "Segoe UI", sans-serif;
  font-size: 11px; color: var(--text-3); font-weight: 500;
}
.phone-chip .spk {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--surface);
  display: grid; place-items: center;
  color: var(--accent);
}
.phone-chip.playing .spk { background: var(--accent); color: #fff; }

.detail-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 16px;
}
.block h2 {
  font-size: 12.5px; font-weight: 500; color: var(--text-3);
  margin-bottom: 14px; letter-spacing: 0.02em;
}

.senses { list-style: none; }
.senses li {
  display: flex; gap: 14px;
  font-size: 15.5px; line-height: 1.6;
  padding-bottom: 11px;
}
.senses li:last-child { padding-bottom: 0; }
.senses .num {
  flex: none; width: 20px; height: 20px; margin-top: 2px;
  border-radius: 6px; background: var(--surface-2);
  color: var(--text-3); font-size: 11.5px;
  display: grid; place-items: center; font-weight: 500;
}

.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 7px 14px; font-size: 13.5px; font-family: inherit;
  background: transparent; border: none; border-radius: 9px;
  color: var(--text-2); cursor: pointer; transition: all 0.2s;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.on { background: var(--surface-2); color: var(--text); font-weight: 500; }

textarea.note {
  width: 100%; min-height: 110px;
  padding: 14px 16px;
  font-family: inherit; font-size: 14.5px; line-height: 1.6;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  outline: none; resize: vertical;
  transition: border-color 0.2s, background 0.2s;
}
textarea.note:focus { border-color: var(--accent); background: var(--surface); }

.rel { display: flex; flex-wrap: wrap; gap: 8px; }

.empty {
  text-align: center; padding: 68px 20px;
  color: var(--text-2);
}
.empty h3 { font-size: 17px; font-weight: 500; color: var(--text); margin-bottom: 7px; }
.empty p { font-size: 14px; margin-bottom: 20px; }
.empty .ic { font-size: 30px; margin-bottom: 16px; opacity: 0.35; }

/* ---------------- 统计条 ---------------- */
.bar-row {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 0;
}
.bar-row .name { width: 92px; font-size: 13.5px; flex: none; color: var(--text); }
.bar-row .track {
  flex: 1; height: 8px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden;
}
.bar-row .fill {
  height: 100%; border-radius: 999px; min-width: 3px;
  transition: width 0.9s var(--ease);
}
.bar-row .val {
  width: 62px; text-align: right; flex: none;
  font-size: 13px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 8px;
}
.stat {
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 18px 20px;
}
.stat .lbl { font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.stat .num { font-size: 27px; font-weight: 600; letter-spacing: -0.03em; }

/* ---------------- 设置 ---------------- */
.set-row {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 22px; border-bottom: 0.5px solid var(--border);
}
.set-row:last-child { border-bottom: none; }
.set-row .txt { flex: 1; }
.set-row .txt .t { font-size: 14.5px; margin-bottom: 2px; }
.set-row .txt .s { font-size: 12.5px; color: var(--text-2); }

.seg {
  display: inline-flex; background: var(--surface-2);
  border-radius: 9px; padding: 2px; gap: 2px;
}
.seg button {
  padding: 6px 13px; font-size: 13px; font-family: inherit;
  border: none; background: transparent; border-radius: 7px;
  color: var(--text-2); cursor: pointer; transition: all 0.2s;
}
.seg button.on { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow-sm); }

/* 云同步 */
.set-row.stack { flex-direction: column; align-items: stretch; gap: 12px; }

.sync-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.sync-code {
  flex: 1;
  min-width: 190px;
  font-family: "SF Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 15px;
  letter-spacing: 0.08em;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: 10px;
  color: var(--text);
  user-select: all;
}

.sync-input {
  flex: 1;
  min-width: 190px;
  height: 38px;
  padding: 0 14px;
  font-family: "SF Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.sync-input::placeholder { color: var(--text-3); letter-spacing: 0.08em; }
.sync-input:focus { border-color: var(--accent); background: var(--surface); }

/* ---------------- 加载 / 提示 ---------------- */
.loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 60px 0; color: var(--text-2); font-size: 14px;
}
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 1.8px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress {
  height: 3px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden;
  max-width: 200px; margin: 14px auto 0;
}
.progress i {
  display: block; height: 100%; width: 0;
  background: var(--accent); border-radius: 999px;
  transition: width 0.3s;
}

.toast {
  position: fixed; left: 50%; bottom: 34px;
  transform: translate(-50%, 20px);
  background: rgba(29, 29, 31, 0.92);
  color: #fff; font-size: 13.5px;
  padding: 10px 20px; border-radius: 12px;
  backdrop-filter: blur(12px);
  opacity: 0; pointer-events: none;
  transition: all 0.32s var(--ease);
  z-index: 200;
  max-width: 88vw;
}
html[data-theme="dark"] .toast { background: rgba(245, 245, 247, 0.94); color: #1d1d1f; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 页脚 ---------------- */
.foot {
  text-align: center; padding: 34px 22px 44px;
  font-size: 12.5px; color: var(--text-2);
  border-top: 0.5px solid var(--border);
  position: relative; z-index: 1;
}
.foot-dim { color: var(--text-3); margin-top: 5px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 700px) {
  .nav-inner { gap: 14px; padding: 0 16px; }
  .nav-links { gap: 16px; overflow-x: auto; scrollbar-width: none; }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { font-size: 12px; }
  .brand span { display: none; }
  .view { padding: 0 16px 60px; }
  .hero { padding: 46px 0 30px; }
  .searchbox input { height: 52px; padding-right: 96px; font-size: 16px; }
  .searchbox .go { height: 38px; top: 7px; padding: 0 16px; font-size: 13.5px; }
  .detail-hero { padding: 26px 20px; }
  .block { padding: 20px; }
  .row { padding: 13px 16px; gap: 12px; }
  .row .d { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .grid { grid-template-columns: 1fr; }
  .wotd { padding: 24px 20px; }
  .wotd .w { font-size: 28px; }
  .bar-row .name { width: 74px; font-size: 12.5px; }
  .bar-row .val { width: 54px; font-size: 12px; }
  .set-row { flex-direction: column; align-items: flex-start; gap: 10px; }
}

::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 999px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
