/* ===== 考研英语一 · 句析助手 样式 ===== */
:root {
  --blue-900: #1e3a8a;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-100: #dbeafe;
  --teal-800: #0f766e;
  --teal-100: #ccfbf1;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --amber: #f59e0b;
  --green: #16a34a;
  --purple: #9333ea;
  --red: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== 顶栏 ===== */
.appbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(90deg, var(--blue-900), var(--teal-800));
  color: #fff;
  padding: 10px 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .25);
  padding-top: calc(10px + env(safe-area-inset-top));
}
.appbar-inner { display: flex; align-items: center; justify-content: space-between; max-width: 680px; margin: 0 auto; }
.appbar-title { display: flex; align-items: center; gap: 8px; }
.logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f; font-weight: 800; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: inset 0 -1px 2px rgba(0,0,0,.2);
}
.appbar h1 { font-size: 16px; font-weight: 700; letter-spacing: .5px; white-space: nowrap; }
.appbar-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn {
  background: rgba(255,255,255,.16); border: none; color: #fff;
  border-radius: 999px; padding: 5px 10px; font-size: 13px; cursor: pointer;
  backdrop-filter: blur(4px);
}
.icon-btn:active { transform: scale(.95); }

/* ===== 主体 ===== */
main { flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
.pane { display: none; animation: fadeIn .18s ease; }
.pane.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
}
.card-title { font-size: 13px; font-weight: 700; color: var(--blue-900); margin-bottom: 10px; }
.label { font-size: 12px; color: var(--muted); font-weight: 500; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; margin-bottom: 8px; }
.note { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ===== 输入 ===== */
textarea.input-area, textarea#sentenceInput {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; resize: vertical;
  font-family: inherit; color: var(--text); background: #f8fafc;
  transition: border-color .15s, box-shadow .15s;
}
textarea#sentenceInput:focus { outline: none; border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(37,99,235,.15); background: #fff; }
.quick-actions { display: flex; gap: 8px; margin-top: 8px; }

.link-btn {
  background: none; border: none; color: var(--blue-600);
  font-size: 12px; font-weight: 600; cursor: pointer; padding: 2px;
}
.link-btn:active { opacity: .6; }

/* ===== 模式选择 ===== */
.mode-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.mode-label {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px; border-radius: 10px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--bg);
  color: var(--muted); font-size: 12px; font-weight: 500;
  transition: all .15s; user-select: none; text-align: center;
}
.mode-label input { display: none; }
.mode-label .mode-emoji { font-size: 18px; }
.mode-label.active {
  border-color: var(--blue-600); background: var(--blue-100);
  color: var(--blue-700); font-weight: 700;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #fff; border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: transform .08s, filter .15s; font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--blue-600), var(--blue-700));
  border: none; color: #fff; box-shadow: 0 2px 6px rgba(37,99,235,.35);
}
.btn-primary:disabled { opacity: .6; filter: grayscale(.3); }
.btn-block { width: 100%; padding: 12px; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.loading::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.offline-hint { margin-top: 8px; font-size: 12px; color: #92400e; background: #fef3c7; border: 1px solid #fde68a; border-radius: 8px; padding: 6px 10px; }

/* ===== 结果 ===== */
.result-card { animation: fadeIn .2s ease; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid; line-height: 1.4; max-width: 100%;
}
.pill .pill-role { font-size: 11px; font-weight: 800; opacity: .75; letter-spacing: .5px; }
.pill-subject  { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.pill-predicate{ background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.pill-object   { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.pill-predicative { background: #faf5ff; color: #7e22ce; border-color: #e9d5ff; }
.pill-other    { background: #f8fafc; color: #475569; border-color: #e2e8f0; }

/* 从句树 */
.tree, .tree ul { list-style: none; }
.tree { padding-left: 0; }
.tree ul { padding-left: 14px; border-left: 2px solid var(--blue-100); margin: 4px 0 4px 6px; }
.tree li { margin: 6px 0; }
.clause-head {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; cursor: pointer;
}
.clause-head .arrow { flex-shrink: 0; color: var(--muted); font-size: 12px; transition: transform .15s; width: 12px; text-align: center; }
.clause-head.open .arrow { transform: rotate(90deg); }
.clause-type {
  flex-shrink: 0; font-size: 11px; font-weight: 800; color: var(--teal-800);
  background: var(--teal-100); border-radius: 6px; padding: 1px 7px; margin-top: 1px;
}
.clause-body { flex: 1; min-width: 0; }
.clause-text { font-size: 13px; font-weight: 600; }
.clause-intro { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 剥离清单 */
.strip-block { margin-bottom: 10px; }
.strip-block:last-child { margin-bottom: 0; }
.strip-title { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 12px; background: #f8fafc; border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 9px; line-height: 1.5;
}
.tag b { color: var(--blue-700); }
.tag .tag-role { color: var(--muted); font-size: 11px; }

/* 易错点 */
.pitfall { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px; padding: 9px 11px; margin-bottom: 8px; }
.pitfall:last-child { margin-bottom: 0; }
.pitfall .p-title { font-size: 12px; font-weight: 800; color: #9a3412; margin-bottom: 3px; }
.pitfall .p-detail { font-size: 13px; }

/* 写作模板 */
.writing-box { background: #eff6ff; border: 1px dashed #93c5fd; border-radius: 10px; padding: 11px; }
.writing-box .w-template { font-size: 13px; font-weight: 700; color: #1e40af; font-family: Georgia, "Times New Roman", serif; margin-bottom: 6px; }
.writing-box .w-example { font-size: 13px; color: #1e3a8a; }

/* 互动 */
.qa { background: #f0fdfa; border: 1px solid #99f6e4; border-radius: 10px; padding: 11px; }
.qa-question { font-size: 14px; font-weight: 600; color: #134e4a; margin-bottom: 8px; }
.qa-hint { margin-top: 8px; font-size: 13px; color: #115e59; background: #fff; border-radius: 8px; padding: 8px 10px; }

/* 精读 */
.read-item { border-left: 3px solid var(--blue-600); padding: 4px 0 4px 10px; margin-bottom: 10px; }
.read-item .r-clause { font-size: 13px; font-weight: 600; }
.read-item .r-trans { font-size: 13px; color: var(--muted); margin-top: 2px; }
.read-item .r-analysis { font-size: 12px; color: var(--blue-900); background: var(--blue-100); border-radius: 6px; padding: 3px 8px; margin-top: 4px; display: inline-block; }
.translation-box { margin-top: 12px; }
#translationBox { font-size: 14px; color: #334155; background: #f8fafc; border-radius: 8px; padding: 9px 11px; }

/* 词汇 */
.vocab-item {
  display: flex; align-items: flex-start; gap: 8px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; margin-bottom: 8px; background: #fff;
}
.vocab-item .v-main { flex: 1; min-width: 0; }
.vocab-word { font-size: 14px; font-weight: 700; color: var(--blue-900); }
.vocab-pos { font-size: 11px; color: var(--green); font-weight: 700; margin-left: 4px; }
.vocab-band { font-size: 10px; background: #fef3c7; color: #92400e; border-radius: 999px; padding: 0 6px; margin-left: 4px; }
.vocab-mean { font-size: 13px; color: var(--text); margin-top: 1px; }
.vocab-ctx { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 2px; }
.v-add { flex-shrink: 0; }
.v-add.added { color: var(--green); border-color: #bbf7d0; background: #f0fdf4; }

/* 操作条 / 列表 */
.action-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 10px; }
.list { min-height: 60px; }
.list-item {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  margin-bottom: 8px; background: #fff; cursor: pointer; transition: background .12s;
}
.list-item:active { background: var(--bg); }
.list-item .li-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.list-item .li-sentence {
  font-size: 13px; font-weight: 600; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.list-item .li-meta { font-size: 11px; color: var(--muted); margin-top: 5px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge { font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.badge.quick { background: var(--blue-100); color: var(--blue-700); }
.badge.interactive { background: #fae8ff; color: #a21caf; }
.badge.reading { background: var(--teal-100); color: var(--teal-800); }
.li-del { color: var(--red); font-size: 12px; flex-shrink: 0; padding: 4px; }
.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 0; }

.select, .input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
}
.select:focus, .input:focus { outline: none; border-color: var(--blue-600); }

/* ===== 底部标签栏 ===== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  display: flex; background: #fff; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(15,23,42,.06);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 0 7px; background: none; border: none; cursor: pointer;
  font-size: 11px; color: var(--muted); font-family: inherit;
}
.tabbar button .tab-emoji { font-size: 19px; }
.tabbar button.active { color: var(--blue-700); font-weight: 700; }
.tabbar button.active .tab-emoji { transform: translateY(-1px); }

/* ===== 弹窗 ===== */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,23,42,.5);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .15s ease;
}
.sheet {
  background: #fff; width: 100%; max-width: 520px;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: slideUp .2s ease;
  max-height: 86vh; overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.field { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.field .input, .field .select { margin-top: 4px; }
.hint { font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 8px 10px; margin: 4px 0 12px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ===== Toast ===== */
#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(15,23,42,.92); color: #fff; font-size: 13px;
  padding: 9px 16px; border-radius: 999px; z-index: 200;
  max-width: 86vw; text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,.25);
  animation: slideUp .2s ease;
}
#toast.error { background: rgba(153,27,27,.95); }

@media (min-width: 520px) {
  .appbar-inner, main { padding-left: 18px; padding-right: 18px; }
  .sheet { border-radius: 18px; margin-bottom: 24px; }
}
