/* ============ 精读 · Close Reader — 有道词典风格主题 ============ */

:root {
  --bg: #ffffff;
  --bg-soft: #f5f7fa;
  --card: #ffffff;
  --card-border: #e5e8ef;
  --ink: #333333;
  --ink-soft: #666666;
  --ink-faint: #999999;
  --accent: #2e6be6;            /* 有道蓝 */
  --accent-strong: #1f56c8;
  --accent-soft: #eaf1fe;
  --gold: #b98a2f;
  --danger: #e04b4b;
  --danger-soft: #fdeeee;
  --warn: #b07d1f;
  --warn-soft: #fdf6e3;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --shadow-hover: 0 2px 6px rgba(16, 24, 40, 0.06), 0 12px 32px rgba(16, 24, 40, 0.1);
  --serif: Georgia, "Times New Roman", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    linear-gradient(180deg, #f2f6ff 0%, var(--bg) 260px);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
}

.topbar-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 11px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: baseline; gap: 8px; }

.brand-mark { font-size: 22px; }

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent);
  font-family: var(--sans);
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 1px;
}

.badge {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid #f0dcae;
  color: var(--warn);
  background: var(--warn-soft);
}

/* ---------- 布局 ---------- */

.container { max-width: 920px; margin: 0 auto; padding: 26px 20px 60px; }

.hero { text-align: center; margin-bottom: 24px; }

.hero h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 6px;
}

.hero-sub { color: var(--ink-soft); font-size: 14px; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- 输入区（类有道搜索框） ---------- */

.input-card { padding: 16px 18px 14px; margin-bottom: 20px; }

.input-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.input-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 1px;
}

.input-actions { display: flex; gap: 8px; }

#article {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--bg-soft);
  padding: 14px 16px;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

#article:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(46, 107, 230, 0.12);
}

#article::placeholder { color: var(--ink-faint); }

/* ---------- 链接 / PDF 导入栏 ---------- */

.import-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--card-border);
  border-radius: 10px;
  background: var(--bg-soft);
}

.import-bar:not(.hidden) { animation: fadeIn 0.25s ease; }

.import-url {
  flex: 1 1 240px;
  min-width: 0;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: #fff;
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.import-url:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 107, 230, 0.12);
}

.import-url::placeholder { color: var(--ink-faint); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.input-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.hint { font-size: 12.5px; color: var(--ink-faint); }

/* ---------- 按钮 ---------- */

.btn {
  font-family: var(--sans);
  font-size: 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 18px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s, color 0.12s, opacity 0.12s;
  user-select: none;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 9px 26px;
  box-shadow: 0 2px 8px rgba(46, 107, 230, 0.3);
}

.btn-primary:hover:not(:disabled) { background: var(--accent-strong); box-shadow: 0 4px 14px rgba(46, 107, 230, 0.35); transform: translateY(-1px); }

.btn-icon { margin-right: 4px; }

.btn-ghost {
  background: #fff;
  color: var(--ink-soft);
  border-color: var(--card-border);
  font-size: 13px;
}

.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.btn-small { font-size: 12.5px; padding: 5px 12px; }

.btn-mini {
  background: transparent;
  border: none;
  color: var(--ink-faint);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.btn-mini:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- 加载动画 ---------- */

.loading-card { padding: 26px 24px; margin-bottom: 20px; }

.loading-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }

#stageText { font-size: 14.5px; color: var(--ink-soft); }

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #5b8def);
  transition: width 0.4s ease;
}

.loading-hint { margin-top: 12px; font-size: 12.5px; color: var(--ink-faint); }

/* ---------- 错误与警告 ---------- */

.error-card {
  padding: 14px 18px;
  background: var(--danger-soft);
  border-color: #f5c6c6;
  color: var(--danger);
  margin-bottom: 20px;
  font-size: 14px;
}

.warnings {
  background: var(--warn-soft);
  border: 1px solid #f0dcae;
  color: var(--warn);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13.5px;
}

.warnings li { list-style: none; margin: 3px 0; }

.warnings li::before { content: "⚠ "; }

/* ---------- 结果区 ---------- */

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}

.results-head h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--ink);
}

.results-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- 文件方式打开提示 ---------- */

.file-banner {
  max-width: 920px;
  margin: 14px auto 0;
  padding: 12px 18px;
  background: var(--warn-soft);
  border: 1px solid #f0dcae;
  border-left: 4px solid var(--gold);
  border-radius: 10px;
  color: var(--warn);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.file-banner code {
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
}

.banner-btn { font-size: 13px; padding: 7px 14px; }

/* ---------- 弹窗（昵称 / 反馈 / 历史） ---------- */

.nick-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 40, 60, 0.45);
  /* 不使用毛玻璃：避免内容多时卡顿 */
  animation: overlayFade 0.16s ease;
  padding: 20px;
}

@keyframes overlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.nick-card {
  width: 100%;
  max-width: 420px;
  max-height: 84vh;
  overflow-y: auto;
  padding: 22px 24px;
}

.nick-title { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }

.nick-tip { font-size: 13px; color: var(--ink-soft); line-height: 1.7; margin-bottom: 14px; }

.nick-tip b { color: var(--accent); }

#nickInput, .feedback-nick {
  width: 100%;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  background: var(--bg-soft);
  outline: none;
  font-family: var(--sans);
}

#nickInput:focus, .feedback-nick:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(46, 107, 230, 0.12); }

.auth-error {
  font-size: 12.5px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 8px;
  padding: 7px 12px;
  text-align: left;
  margin-top: 8px;
}

.nick-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.nick-box { display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; }

.nick-name { font-size: 13px; color: var(--accent); font-weight: 600; }

/* 反馈表单 */

.feedback-select {
  width: 100%;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  background: var(--bg-soft);
  outline: none;
  font-family: var(--sans);
  margin-bottom: 10px;
}

.feedback-textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  background: var(--bg-soft);
  outline: none;
  font-family: var(--sans);
  line-height: 1.7;
}

.feedback-textarea:focus, .feedback-select:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(46, 107, 230, 0.12); }

.feedback-nick { margin-top: 10px; }

/* 历史记录 */

.history-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 40, 60, 0.45);
  animation: overlayFade 0.16s ease;
  padding: 20px;
}

.history-card {
  width: 100%;
  max-width: 580px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-title { font-size: 15px; font-weight: 700; color: var(--ink); }

.history-empty {
  color: var(--ink-faint);
  font-size: 13px;
  text-align: center;
  padding: 34px 10px;
}

.history-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--bg-soft);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.history-item:hover { border-color: var(--accent); box-shadow: var(--shadow); }

.history-item-main { min-width: 0; }

.history-item-title {
  font-size: 14px;
  font-family: var(--serif);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

.history-item-actions { display: flex; gap: 4px; flex-shrink: 0; }

.history-foot {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------- 单词查询弹窗 ---------- */

.word-click {
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.12s, color 0.12s;
}

.word-click:hover { background: var(--accent-soft); color: var(--accent-strong); }

.word-panel {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 300;
  width: min(560px, calc(100vw - 32px));
  max-height: 58vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(20, 30, 50, 0.25);
  overflow: hidden;
  animation: fadeUp 0.25s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.word-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.word-panel-title { font-family: var(--serif); font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }

.word-sounds { display: inline-flex; gap: 4px; margin-left: auto; margin-right: 6px; }

.word-panel-head .btn-mini { color: rgba(255, 255, 255, 0.9); }

.word-panel-head .btn-mini:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

.word-panel-body {
  overflow-y: auto;
  padding: 14px 18px 16px;
  font-size: 13.5px;
  line-height: 1.7;
}

.word-phonetic { font-size: 14px; color: var(--accent); margin-bottom: 8px; }

.word-section {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-faint);
  letter-spacing: 1px;
  margin: 10px 0 4px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 3px;
}

.word-explain { margin: 4px 0; color: var(--ink); }

.word-pos {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 0 6px;
  margin-right: 6px;
}

.word-example { margin: 6px 0; }

.word-example-en { font-family: var(--serif); color: var(--ink); }

.word-example-zh { color: var(--ink-soft); font-size: 13px; }

.word-example-src { color: var(--ink-faint); font-size: 11.5px; margin-top: 1px; }

.word-loading, .word-nothing, .word-error { color: var(--ink-soft); padding: 8px 0; }

.word-error { color: var(--danger); }

.word-panel-foot {
  border-top: 1px solid var(--card-border);
  padding: 9px 16px;
  text-align: center;
  background: var(--bg-soft);
}

.word-panel-foot a {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
}

.word-panel-foot a:hover { text-decoration: underline; }

/* ---------- 句子卡片 ---------- */

.sentence-list { display: flex; flex-direction: column; gap: 16px; }

.sentence-card { padding: 18px 22px 14px; transition: box-shadow 0.2s, border-color 0.2s; animation: cardFadeUp 0.5s ease both; }

@keyframes cardFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.sentence-card:hover { border-color: #cdd8ee; box-shadow: var(--shadow-hover); }

.s-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.s-index {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 12px;
}

.s-card-actions { display: inline-flex; gap: 4px; }

.s-en {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.8;
  color: var(--ink);
  margin-bottom: 6px;
}

.s-zh {
  font-size: 14.5px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 8px 14px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 12px;
}

.s-error {
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 10px;
}

/* 主干 */

.s-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--accent-soft);
  border: 1px solid #d6e4fb;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.s-main-label {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: 6px;
  padding: 2px 10px;
  margin-top: 1px;
}

.s-main-text { font-size: 14px; color: var(--ink); line-height: 1.7; }

/* 区块标题 */

.section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 8px;
}

/* 意群表 */

.s-chunks { margin-top: 4px; }

.s-guide { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--card-border); }

.guide-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-steps li {
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.7;
  padding-left: 2px;
}

.guide-steps li::marker {
  color: var(--accent);
  font-weight: 700;
}

/* 表格 */

.table-scroll { overflow-x: auto; }

.word-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.word-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--ink-faint);
  text-transform: uppercase;
  padding: 6px 10px;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
  background: var(--bg-soft);
}

.word-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f2f7;
  vertical-align: top;
}

.word-table tr:last-child td { border-bottom: none; }

.word-table tr:hover td { background: var(--accent-soft); }

.w-word { font-weight: 700; font-family: var(--serif); font-size: 14.5px; color: var(--ink); white-space: nowrap; }

.w-pos { white-space: nowrap; color: var(--ink-soft); }

.w-pos b { font-weight: 600; color: var(--ink); }

.w-pos-name { font-size: 12px; color: var(--ink-faint); margin-left: 4px; }

.w-comp { min-width: 200px; }

.comp-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 6px;
  margin-right: 8px;
  white-space: nowrap;
}

.comp-meaning { font-size: 12px; color: var(--ink-soft); line-height: 1.5; }

.w-gloss { color: var(--ink-soft); min-width: 90px; }

.word-table.grammar-table .w-word,
.word-table.grammar-table .w-pos,
.word-table.grammar-table .w-gloss { white-space: normal; }

/* 成分配色（有道风格扁平色） */
.c-subject    { background: #e3edfd; color: #1d4ed8; }
.c-predicate  { background: #fde8e8; color: #b91c1c; }
.c-object     { background: #e4f4e8; color: #15803d; }
.c-attributive{ background: #f1e9fd; color: #6d28d9; }
.c-adverbial  { background: #ffedd9; color: #c2410c; }
.c-complement { background: #dcf4f1; color: #0f766e; }
.c-predicative{ background: #fde8f3; color: #be185d; }
.c-appositive { background: #fdf0da; color: #92400e; }

/* 超纲词 */

.s-beyond {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--card-border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.s-beyond-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gold);
  white-space: nowrap;
}

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

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 4px 13px;
  font-size: 13.5px;
  transition: border-color 0.15s;
}

.chip:hover { border-color: var(--accent); }

.chip b { color: var(--accent-strong); font-family: var(--serif); }

.chip i { font-style: normal; color: var(--ink-soft); font-size: 12.5px; }

/* ---------- 页脚与提示 ---------- */

.footer {
  text-align: center;
  padding: 26px 20px 30px;
  font-size: 12.5px;
  color: var(--ink-faint);
}

.version-text {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 40, 60, 0.92);
  color: #fff;
  font-size: 13.5px;
  padding: 10px 22px;
  border-radius: 999px;
  z-index: 400;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  animation: toastFade 0.25s ease;
}

@keyframes toastFade {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 响应式 ---------- */

@media (max-width: 640px) {
  .container { padding: 18px 12px 50px; }
  .hero h1 { font-size: 24px; }
  .s-en { font-size: 16px; }
  .sentence-card { padding: 14px 14px 12px; }
  .results-head { flex-direction: column; align-items: flex-start; }
  .word-table { font-size: 12.5px; }
  .comp-meaning { display: none; }
}
