/* 智慧基层 v3.9.0 · 师父 v1.0（内置版）
 * —— 复刻 masterDock 风格，叠加警示气泡 + 首次使用弹窗
 * —— 皮肤 A 墨绿米黄为默认，皮肤 B 紫黛青在 [data-skin="purple"] 切换
 * —— 不改任何现有样式；所有 .teacher-* 选择器为新增
 */

/* ============ 浮窗 A · 辨证+荐方（右抽屉 240×自适应高）============ */
.teacher-panel {
  position: fixed; top: 52px; right: 0; bottom: 0; width: 286px;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #fdf6e8 0%, #fff8ec 100%);
  border-left: 1px solid #eadfc6;
  box-shadow: -10px 0 30px rgba(120, 90, 30, .14);
  transform: translateX(103%);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
  z-index: 71; font-size: 14px;  /* 精品铁律：字号 1.5x */
  font-family: var(--font-sans, system-ui);
  outline: none;  /* 精品铁律：不抢焦点 */
}
.teacher-panel.open { transform: none; }

.teacher-head {
  flex: 0 0 auto; padding: 14px 14px 12px;
  background: linear-gradient(120deg, #fdf6e8, #f6f2ff);
  border-bottom: 1px solid #f0e6d2;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}
.teacher-title { font-size: 15.5px; font-weight: 700; color: #3a2e1f; }
.teacher-sub { font-size: 12.5px; color: #7c6a4e; margin-top: 4px; line-height: 1.6; }

.teacher-x {
  cursor: pointer; width: 32px; height: 32px;  /* 精品铁律：按钮 ≥ 44×44 用 32 + padding */
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; color: #8a7a6a; font-size: 18px; line-height: 1;
  background: transparent; border: none; padding: 0;
  transition: background .15s;
}
.teacher-x:hover { background: #fff4dc; color: #8a5a00; }
.teacher-x:focus-visible { outline: 2px solid #ba7517; outline-offset: 1px; }

.teacher-body {
  flex: 1 1 auto; overflow-y: auto; padding: 10px 14px 14px;
  -webkit-overflow-scrolling: touch;
}
.teacher-empty {
  font-size: 13px; color: #8a7a6a; padding: 16px 8px; line-height: 1.7;
  text-align: center;
}

.teacher-quote {
  background: #fff; border: 1px solid #eadfc6; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px;
  font-size: 13.5px; color: #3a2e1f; line-height: 1.7;
}
.teacher-quote-label {
  display: inline-block; font-size: 11px; color: #9a5b00;
  background: #fdf3df; border: 0.5px solid #eadfc6; border-radius: 4px;
  padding: 1px 6px; margin-bottom: 4px; font-weight: 500;
}
.teacher-quote-source {
  display: block; font-size: 11.5px; color: #8a7a6a;
  margin-top: 4px; font-style: normal;
}

.teacher-formula {
  background: #fff; border: 1px solid #eadfc6; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.teacher-formula-name { font-size: 14px; font-weight: 600; color: #3a2e1f; }
.teacher-formula-source { font-size: 11.5px; color: #8a7a6a; }
.teacher-formula-btn {
  cursor: pointer; background: #fdf3df; color: #8a5a00;
  border: 1px solid #eadfc6; border-radius: 6px;
  padding: 4px 10px; font-size: 12.5px; font-weight: 500;
  transition: background .15s;
}
.teacher-formula-btn:hover { background: #f6e2b8; }
.teacher-formula-btn:focus-visible { outline: 2px solid #ba7517; outline-offset: 1px; }

.teacher-foot {
  flex: 0 0 auto; padding: 10px 14px 12px;
  border-top: 1px solid #f0e6d2;
  font-size: 11.5px; color: #8a7a6a; text-align: center;
}

/* ============ 浮窗 B · 警示气泡（输入框右下，红黄蓝三档）============ */
.teacher-toast {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 320px; max-width: 460px;
  border-radius: 10px; padding: 10px 12px;
  font-size: 13px; line-height: 1.55; z-index: 80;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
  animation: teacher-fade-in .18s ease-out;
}
.teacher-toast.block {
  background: #fdeeee; border: 1px solid #fa5151; color: #791f1f;
}
.teacher-toast.warn {
  background: #fff7e8; border: 1px solid #ff9f1a; color: #633806;
}
.teacher-toast.info {
  background: #e8f9f0; border: 1px solid #07c160; color: #085041;
}
.teacher-toast-head { font-weight: 700; margin-bottom: 4px; font-size: 13.5px; }
.teacher-toast-text { font-size: 12.5px; }
.teacher-toast-src { font-size: 11px; opacity: .75; margin-top: 4px; }
.teacher-toast-actions { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.teacher-toast-btn {
  cursor: pointer; background: rgba(255, 255, 255, .7);
  border: 1px solid currentColor; border-radius: 5px;
  padding: 2px 8px; font-size: 12px; font-weight: 500;
}
.teacher-toast-btn:hover { background: #fff; }

@keyframes teacher-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes teacher-fade-out {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-4px); }
}
.teacher-toast.leaving { animation: teacher-fade-out .2s ease-in forwards; }

/* 浮窗 B 容器：包裹原输入框，让警示气泡能绝对定位 */
.teacher-input-wrap { position: relative; }

/* ============ 浮窗 C · 首次使用弹窗（紫色边框，开方第一次触发）============ */
.teacher-intro {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .35);
  animation: teacher-fade-in .25s ease-out;
}
.teacher-intro-card {
  background: #fff; border: 2px solid #534ab7; border-radius: 14px;
  width: min(520px, 90vw); padding: 0;
  box-shadow: 0 20px 60px rgba(83, 74, 183, .25);
  font-size: 14px; color: #1f2329;
}
.teacher-intro-head {
  background: linear-gradient(120deg, #eeedfe, #cecbf6);
  padding: 14px 18px; border-radius: 12px 12px 0 0;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 16px; font-weight: 700; color: #26215c;
}
.teacher-intro-body { padding: 18px 22px 20px; }
.teacher-intro-body p { margin: 0 0 8px; line-height: 1.85; font-size: 14.5px; }
.teacher-intro-foot {
  padding: 12px 22px 18px;
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
}
.teacher-intro-btn {
  cursor: pointer; background: #534ab7; color: #fff;
  border: none; border-radius: 8px;
  padding: 12px 20px; font-size: 15px; font-weight: 600;
  width: 100%; transition: background .15s;
}
.teacher-intro-btn:hover { background: #3c3489; }
.teacher-intro-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 4px #534ab7; }
.teacher-intro-tip { font-size: 12px; color: #8f959e; text-align: center; }

/* ============ 皮肤 B · 紫黛青（在 [data-skin="purple"] 切换）============ */
[data-skin="purple"] .teacher-panel {
  background: linear-gradient(180deg, #f6f2ff 0%, #eeedfe 100%);
  border-left: 1px solid #cecbf6;
  box-shadow: -10px 0 30px rgba(83, 74, 183, .14);
}
[data-skin="purple"] .teacher-head {
  background: linear-gradient(120deg, #eeedfe, #cecbf6);
  border-bottom: 1px solid #ddd6f4;
}
[data-skin="purple"] .teacher-title { color: #26215c; }
[data-skin="purple"] .teacher-sub { color: #534ab7; }
[data-skin="purple"] .teacher-x:hover { background: #eeedfe; color: #3c3489; }
[data-skin="purple"] .teacher-quote {
  background: #fff; border-color: #cecbf6; color: #26215c;
}
[data-skin="purple"] .teacher-quote-label {
  background: #eeedfe; border-color: #cecbf6; color: #534ab7;
}
[data-skin="purple"] .teacher-quote-source { color: #534ab7; }
[data-skin="purple"] .teacher-formula {
  background: #fff; border-color: #cecbf6;
}
[data-skin="purple"] .teacher-formula-name { color: #26215c; }
[data-skin="purple"] .teacher-formula-source { color: #534ab7; }
[data-skin="purple"] .teacher-formula-btn {
  background: #eeedfe; color: #3c3489; border-color: #cecbf6;
}
[data-skin="purple"] .teacher-formula-btn:hover { background: #cecbf6; }
[data-skin="purple"] .teacher-foot {
  border-top: 1px solid #ddd6f4; color: #534ab7;
}

/* ============ 设置抽屉里"皮肤切换"小控件 ============ */
.teacher-skin-pick {
  display: flex; gap: 8px; margin: 4px 0 8px;
}
.teacher-skin-pick label {
  flex: 1; cursor: pointer; border: 1px solid #e5e8eb; border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; text-align: center;
  transition: border-color .15s;
}
.teacher-skin-pick label:has(input:checked) {
  border-color: #07c160; background: #e8f9f0;
}
.teacher-skin-pick input { margin-right: 4px; vertical-align: middle; }

/* ============ 响应式 ============ */
@media (max-width: 920px) {
  .teacher-panel { width: 86vw; max-width: 320px; }
  .teacher-toast { min-width: 280px; max-width: 80vw; }
}

/* v3.9.1 「去看看」次要按钮（辨证兜底方，无库内 id 时用） */
.teacher-formula-btn.ghost {
  background: #fff; color: #7c6a4e; border-color: #ddd0bb;
}
.teacher-formula-btn.ghost:hover { background: #fdf6e8; }
[data-skin="purple"] .teacher-formula-btn.ghost {
  background: #fff; color: #534ab7; border-color: #cecbf6;
}

/* v3.9.1 采纳后状态：按钮变 ✓ 已采纳，卡片淡出但保留（允许追加第二方） */
.teacher-formula-btn.done,
.teacher-formula-btn:disabled {
  background: #e8f9f0; color: #0f6e56; border-color: #9fe1cb; cursor: default;
}
.teacher-formula.taken { opacity: .72; }
.teacher-formula.taken .teacher-formula-name::after {
  content: ' ✓'; color: #0f6e56; font-weight: 700;
}

/* v3.9.2 主动开口：「师父翻您的旧方子」——放在辨证话术最前面 */
.teacher-habit {
  background: linear-gradient(135deg, #fffdf5 0%, #fdf6e3 100%);
  border: 1px solid #e8d9b5;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.teacher-habit-head {
  font-size: 12px; font-weight: 700; color: #8a6d3b; margin-bottom: 6px;
}
.teacher-habit-row {
  position: relative;
  padding: 6px 0 6px 0;
  border-top: 1px dashed #ead9b0;
}
.teacher-habit-row:first-of-type { border-top: 0; }
.teacher-habit-title { font-size: 13px; font-weight: 600; color: #5a4632; }
.teacher-habit-meta { font-size: 11px; font-weight: 400; color: #a08b6a; margin-left: 4px; }
.teacher-habit-herbs {
  font-size: 12px; color: #6b5a44; line-height: 1.5; margin-top: 2px;
  max-width: 92%;
}
.teacher-habit-btn {
  position: absolute; right: 0; bottom: 6px;
  background: #0a8f5c; color: #fff; border: 0; border-radius: 6px;
  font-size: 12px; padding: 4px 10px; cursor: pointer;
}
.teacher-habit-btn:hover { background: #0b7d50; }
.teacher-habit-btn.done, .teacher-habit-btn:disabled {
  background: #e8f9f0; color: #0f6e56; cursor: default;
}
[data-skin="purple"] .teacher-habit {
  background: linear-gradient(135deg, #fbfaff 0%, #f3f0ff 100%);
  border-color: #d5cdf3;
}
[data-skin="purple"] .teacher-habit-head { color: #534ab7; }
[data-skin="purple"] .teacher-habit-title { color: #3730a3; }
[data-skin="purple"] .teacher-habit-herbs { color: #4f4a6b; }
