/* ============================================================
   海底撈店經理疑難雜症小百科 — 全站樣式
   設計哲學：Apple HIG 質感 × 海底撈紅色力量
   ============================================================ */

/* ── CSS 變數 ── */
:root {
  --red:        #e60012;
  --red-dark:   #b8000e;
  --red-light:  #ff1a2a;
  --red-glow:   rgba(230, 0, 18, 0.18);
  --red-subtle: rgba(230, 0, 18, 0.06);

  --bg:         #ffffff;
  --bg-soft:    #f7f7fa;
  --bg-border:  #eef0f4;

  --text-main:  #1a1a1e;
  --text-sub:   #5b5f66;
  --text-weak:  #8a8f96;

  --severity-high:   #e60012;
  --severity-mid:    #f5a623;
  --severity-low:    #22c55e;

  --cat-food:    #e60012;
  --cat-comp:    #7c3aed;
  --cat-equip:   #0ea5e9;
  --cat-staff:   #f59e0b;
  --cat-service: #10b981;
  --cat-ops:     #6366f1;

  --shadow-card:  0 1px 3px rgba(0,0,0,.04), 0 8px 32px rgba(0,0,0,.06);
  --shadow-hover: 0 4px 8px rgba(0,0,0,.06), 0 16px 48px rgba(0,0,0,.10);
  --shadow-fab:   0 4px 16px rgba(230,0,18,.30), 0 2px 6px rgba(0,0,0,.12);

  --radius-card: 16px;
  --radius-pill: 999px;
  --radius-btn:  10px;

  --font: -apple-system, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;

  --nav-h: 64px;
  --transition: 0.2s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-main);
  background: var(--bg-soft);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
ul, ol { list-style: none; }
img { max-width: 100%; height: auto; display: block; }

/* ── Typography ── */
h1 { font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
h2 { font-size: clamp(1.4rem, 2.5vw, 2rem); font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
h3 { font-size: clamp(1.1rem, 2vw, 1.4rem); font-weight: 600; line-height: 1.3; }
h4 { font-size: 1rem; font-weight: 600; line-height: 1.4; }
p  { line-height: 1.75; }

/* ── Gradient Text ── */
.gradient-text {
  background: linear-gradient(135deg, var(--red) 0%, #ff4d6d 50%, #ff8c69 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── NAV ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--bg-border);
  display: flex;
  align-items: center;
  padding: 0 clamp(16px, 4vw, 48px);
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
}

.nav-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
  display: block;
}

.nav-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  line-height: 1.3;
}

.nav-title span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-weak);
  margin-top: 1px;
}

.nav-search {
  flex: 1;
  max-width: 400px;
  margin-left: auto;
  position: relative;
}

.nav-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-weak);
  font-size: 16px;
  pointer-events: none;
}

.nav-search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 38px;
  border: 1.5px solid var(--bg-border);
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  -webkit-appearance: none;
}

.nav-search input::placeholder { color: var(--text-weak); }

.nav-search input:focus {
  border-color: var(--red);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--red-glow);
}

/* ── HERO ── */
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(48px, 8vw, 96px) clamp(16px, 4vw, 48px) clamp(40px, 6vw, 72px);
  background: var(--bg);
}

.hero-mesh {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(230,0,18,.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 90% 80%, rgba(230,0,18,.05) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 50% -10%, rgba(255,100,50,.06) 0%, transparent 50%),
    linear-gradient(175deg, #fff 0%, #fff8f8 50%, #fff 100%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  max-width: 860px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--red-subtle);
  border: 1px solid rgba(230,0,18,.15);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.hero-badge i { font-size: 13px; }

.hero h1 {
  margin-bottom: 16px;
}

.hero-sub {
  font-size: clamp(15px, 2vw, 17px);
  color: var(--text-sub);
  max-width: 560px;
  margin-bottom: 36px;
  line-height: 1.7;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.hero-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-sub);
}

.hero-stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--red);
  line-height: 1;
}

.hero-stat-label {
  font-size: 12px;
  color: var(--text-weak);
}

.hero-divider {
  color: var(--bg-border);
  font-size: 18px;
  align-self: center;
}

/* ── FILTER BAR ── */
.filter-section {
  background: var(--bg);
  border-bottom: 1px solid var(--bg-border);
  padding: 16px clamp(16px, 4vw, 48px);
  position: sticky;
  top: var(--nav-h);
  z-index: 90;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.filter-row::-webkit-scrollbar { display: none; }

.filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-weak);
  text-transform: uppercase;
  letter-spacing: .06em;
  flex-shrink: 0;
  padding-right: 4px;
}

.cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--bg-border);
  background: var(--bg);
  color: var(--text-sub);
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

.cat-btn i { font-size: 14px; }

.cat-btn:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-subtle);
  transform: translateY(-1px);
}

.cat-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 2px 8px var(--red-glow);
}

.tag-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.tag-row::-webkit-scrollbar { display: none; }

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  border: 1px solid var(--bg-border);
  background: var(--bg-soft);
  color: var(--text-sub);
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

.tag-pill:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-subtle);
}

.tag-pill.active {
  background: var(--red-subtle);
  border-color: rgba(230,0,18,.3);
  color: var(--red);
  font-weight: 500;
}

/* ── MAIN LAYOUT ── */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px clamp(16px, 4vw, 48px) 80px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.results-count {
  font-size: 13px;
  color: var(--text-weak);
}

.results-count strong {
  color: var(--text-main);
  font-weight: 600;
}

/* ── CARD GRID ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

/* ── CASE CARD ── */
.case-card {
  background: var(--bg);
  border-radius: var(--radius-card);
  border: 1px solid var(--bg-border);
  box-shadow: var(--shadow-card);
  padding: 20px;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.case-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--cat-color, var(--bg-border));
  opacity: 0;
  transition: opacity var(--transition);
}

.case-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(230,0,18,.12);
}

.case-card:hover::before {
  opacity: 1;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.severity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.severity-dot.high { background: var(--severity-high); box-shadow: 0 0 6px rgba(230,0,18,.4); }
.severity-dot.mid  { background: var(--severity-mid);  box-shadow: 0 0 6px rgba(245,166,35,.4); }
.severity-dot.low  { background: var(--severity-low);  box-shadow: 0 0 6px rgba(34,197,94,.4); }

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  background: var(--cat-bg, var(--bg-soft));
  color: var(--cat-color, var(--text-sub));
  border: 1px solid var(--cat-border, var(--bg-border));
}

.severity-label {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-weak);
  font-weight: 500;
  flex-shrink: 0;
}

.card-title {
  font-size: clamp(15px, 1.5vw, 17px);
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-main);
}

.card-summary {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--bg-border);
}

.card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.card-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  color: var(--text-weak);
  border: 1px solid var(--bg-border);
}

.card-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  white-space: nowrap;
  flex-shrink: 0;
  transition: gap var(--transition);
}

.case-card:hover .card-cta { gap: 7px; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-weak);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
  opacity: .4;
}

.empty-state p {
  font-size: 15px;
  margin-top: 8px;
}

/* ── ERROR STATE ── */
.error-state {
  text-align: center;
  padding: 80px 20px;
}

.error-state i {
  font-size: 48px;
  color: var(--red);
  margin-bottom: 16px;
  display: block;
}

/* ============================================================
   CASE DETAIL PAGE
   ============================================================ */

.case-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px) 80px;
}

/* ── Back Button ── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sub);
  transition: color var(--transition), gap var(--transition);
  cursor: pointer;
  text-decoration: none;
  margin: 24px 0 20px;
}

.back-btn:hover {
  color: var(--red);
  gap: 4px;
}

/* ── Case Header ── */
.case-header {
  background: var(--bg);
  border-radius: var(--radius-card);
  border: 1px solid var(--bg-border);
  box-shadow: var(--shadow-card);
  padding: clamp(24px, 4vw, 40px);
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.case-header-mesh {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 80% at 100% 50%, rgba(230,0,18,.04) 0%, transparent 70%);
  pointer-events: none;
}

.case-meta-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.case-title {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.02em;
  margin-bottom: 12px;
}

.case-summary-text {
  font-size: 15px;
  color: var(--text-sub);
  line-height: 1.75;
  margin-bottom: 20px;
}

.case-meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.meta-info {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text-sub);
}

.meta-info i { font-size: 14px; color: var(--text-weak); }

/* ── Two-Column Layout ── */
.case-body {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 28px;
  align-items: start;
}

/* ── Sticky TOC ── */
.toc-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 20px);
  background: var(--bg);
  border-radius: var(--radius-card);
  border: 1px solid var(--bg-border);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

.toc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-weak);
  margin-bottom: 12px;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-sub);
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.toc-link i { font-size: 14px; color: var(--text-weak); flex-shrink: 0; }

.toc-link:hover {
  background: var(--bg-soft);
  color: var(--text-main);
}

.toc-link.active {
  background: var(--red-subtle);
  color: var(--red);
  font-weight: 600;
}

.toc-link.active i { color: var(--red); }

.toc-related {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--bg-border);
}

.toc-related-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-weak);
  margin-bottom: 8px;
}

.toc-related-link {
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-sub);
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
}

.toc-related-link:hover {
  background: var(--bg-soft);
  color: var(--red);
}

/* ── Content Sections ── */
.content-main {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

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

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--bg-border);
}

.section-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.section-icon.red    { background: var(--red-subtle);           color: var(--red); }
.section-icon.purple { background: rgba(124,58,237,.08);        color: #7c3aed; }
.section-icon.green  { background: rgba(16,185,129,.08);        color: #10b981; }
.section-icon.amber  { background: rgba(245,158,11,.08);        color: #d97706; }
.section-icon.blue   { background: rgba(14,165,233,.08);        color: #0284c7; }

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.section-body {
  padding: 20px 24px 24px;
}

/* ── Scenario Card ── */
.scenario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.scenario-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-radius: 10px;
  border: 1px solid var(--bg-border);
}

.scenario-item i {
  font-size: 16px;
  color: var(--red);
  margin-top: 1px;
  flex-shrink: 0;
}

.scenario-item-label {
  font-size: 11px;
  color: var(--text-weak);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 2px;
}

.scenario-item-value {
  font-size: 13px;
  color: var(--text-main);
  font-weight: 500;
}

.scenario-desc {
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.8;
  padding: 16px;
  background: var(--bg-soft);
  border-radius: 10px;
  border: 1px solid var(--bg-border);
  border-left: 3px solid var(--red);
}

/* ── SOP Timeline ── */
.sop-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.sop-item {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0 16px;
  position: relative;
}

.sop-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 20px;
  top: 48px;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--bg-border), transparent);
  transform: translateX(-50%);
}

.sop-step-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--red-glow);
  position: relative;
  z-index: 1;
  margin-top: 4px;
}

.sop-content {
  padding: 0 0 28px 0;
}

.sop-action {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
  margin-top: 8px;
}

.sop-detail {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.75;
  margin-bottom: 10px;
}

.sop-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(245,166,35,.08);
  border: 1px solid rgba(245,166,35,.2);
  border-radius: 8px;
  border-left: 3px solid var(--severity-mid);
}

.sop-warning i {
  font-size: 14px;
  color: var(--severity-mid);
  flex-shrink: 0;
  margin-top: 1px;
}

.sop-warning span {
  font-size: 12px;
  color: #92400e;
  line-height: 1.6;
}

/* ── Key Dialog ── */
.dialog-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialog-bubble {
  max-width: 80%;
  word-break: break-word;
  min-width: 0;
}

.dialog-bubble.manager { align-self: flex-start; }
.dialog-bubble.other   { align-self: flex-end; }

.dialog-who {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-weak);
  letter-spacing: .04em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.dialog-bubble.other .dialog-who { text-align: right; }

.dialog-text {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
}

.dialog-bubble.manager .dialog-text {
  background: var(--red-subtle);
  border: 1px solid rgba(230,0,18,.15);
  border-bottom-left-radius: 4px;
  color: var(--text-main);
}

.dialog-bubble.other .dialog-text {
  background: var(--bg-soft);
  border: 1px solid var(--bg-border);
  border-bottom-right-radius: 4px;
  color: var(--text-main);
}

.dialog-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Prevention Checklist ── */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border-radius: 10px;
  border: 1px solid var(--bg-border);
  transition: background var(--transition), border-color var(--transition);
  cursor: pointer;
}

.check-item:hover {
  background: rgba(16,185,129,.05);
  border-color: rgba(16,185,129,.2);
}

.check-item.checked {
  background: rgba(16,185,129,.06);
  border-color: rgba(16,185,129,.2);
}

.check-box {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--bg-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  margin-top: 1px;
}

.check-item.checked .check-box {
  background: #10b981;
  border-color: #10b981;
}

.check-box i {
  font-size: 12px;
  color: #fff;
  opacity: 0;
  transition: opacity var(--transition);
}

.check-item.checked .check-box i { opacity: 1; }

.check-text {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.65;
}

.check-item.checked .check-text {
  color: var(--text-weak);
  text-decoration: line-through;
}

/* ── Common Mistakes ── */
.mistake-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mistake-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(230,0,18,.04);
  border: 1px solid rgba(230,0,18,.12);
  border-radius: 10px;
  border-left: 3px solid var(--red);
}

.mistake-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  margin-top: 1px;
}

.mistake-text {
  font-size: 13px;
  color: #7f1d1d;
  line-height: 1.65;
}

/* ── Related Cases ── */
.related-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.related-card {
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--bg-border);
  border-radius: 10px;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  display: block;
}

.related-card:hover {
  background: var(--bg);
  border-color: rgba(230,0,18,.2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.related-card-cat {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-weak);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}

.related-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
}

/* ============================================================
   AI CHAT WIDGET — 全站共用浮動按鈕
   ============================================================ */

.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
}

.chat-fab-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red) 0%, #ff4d6d 100%);
  box-shadow: var(--shadow-fab);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  color: #fff;
  font-size: 24px;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
}

.chat-fab-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(230,0,18,.4), 0 3px 8px rgba(0,0,0,.15);
}

.chat-fab-btn.pulse::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--red);
  animation: fabPulse 2s ease-out infinite;
}

@keyframes fabPulse {
  0%   { transform: scale(1); opacity: .6; }
  100% { transform: scale(1.5); opacity: 0; }
}

.chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 420px;
  height: 640px;
  background: var(--bg);
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.08);
  border: 1px solid var(--bg-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999;
  transform: scale(.92) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
  transform-origin: bottom right;
}

.chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.chat-header {
  background: linear-gradient(135deg, var(--red) 0%, #c8000c 100%);
  padding: 16px 18px 14px;
  flex-shrink: 0;
}

.chat-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
}

.chat-header-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.chat-header-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: rgba(255,255,255,.75);
}

.chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
}

.chat-close-btn {
  background: rgba(255,255,255,.2);
  border: none;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 16px;
  transition: background var(--transition);
}

.chat-close-btn:hover { background: rgba(255,255,255,.3); }

.chat-demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-pill);
  font-size: 11px;
  color: rgba(255,255,255,.85);
}

.chat-demo-badge i { font-size: 12px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--bg-border); border-radius: 2px; }

.chat-msg {
  max-width: 85%;
  word-break: break-word;
  min-width: 0;
}

.chat-msg.ai  { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; }

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.65;
}

.chat-msg.ai .chat-msg-bubble {
  background: var(--bg-soft);
  border: 1px solid var(--bg-border);
  border-bottom-left-radius: 4px;
  color: var(--text-main);
}

.chat-msg.user .chat-msg-bubble {
  background: var(--red);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--bg-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-weak);
  animation: typingDot .9s ease-in-out infinite;
}

.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-presets {
  padding: 0 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-preset-btn {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  border: 1.5px solid var(--bg-border);
  background: var(--bg);
  color: var(--text-sub);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  line-height: 1.4;
}

.chat-preset-btn:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-subtle);
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--bg-border);
  background: var(--bg);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  border: 1.5px solid var(--bg-border);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-main);
  background: var(--bg-soft);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  /* 防止中文輸入法觸發 keydown enter */
  ime-mode: auto;
}

.chat-input::placeholder { color: var(--text-weak); }

.chat-input:focus {
  border-color: var(--red);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--red-glow);
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-size: 16px;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
}

.chat-send-btn:hover { background: var(--red-dark); transform: scale(1.05); }
.chat-send-btn:active { transform: scale(.96); }

/* ============================================================
   SKELETON LOADING
   ============================================================ */

@keyframes skeletonPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

.skeleton {
  background: var(--bg-border);
  border-radius: 6px;
  animation: skeletonPulse 1.4s ease-in-out infinite;
}

.skeleton-card {
  background: var(--bg);
  border-radius: var(--radius-card);
  border: 1px solid var(--bg-border);
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-border) 25%, var(--bg-soft) 50%, var(--bg-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-100 { width: 100%; }
.skeleton-line.h-20 { height: 20px; }
.skeleton-line.h-12 { height: 12px; }

/* ============================================================
   RESPONSIVE — 手機版
   ============================================================ */

@media (max-width: 900px) {
  :root { --nav-h: 56px; }

  /* Nav */
  .nav {
    padding: 0 16px;
    gap: 10px;
  }

  .nav-title span { display: none; }
  .nav-logo { height: 30px; }

  .nav-search {
    max-width: none;
    margin-left: 0;
  }

  /* Hero */
  .hero {
    padding: 36px 16px 32px;
  }

  .hero-stats {
    gap: 6px 16px;
  }

  .hero-divider { display: none; }

  /* Filter */
  .filter-section {
    padding: 12px 16px;
    top: var(--nav-h);
  }

  /* Cards */
  .card-grid {
    grid-template-columns: 1fr;
  }

  /* Case Detail */
  .case-page {
    padding: 0 16px 80px;
  }

  .case-body {
    grid-template-columns: 1fr;
  }

  .toc-sidebar {
    display: none;
  }

  .scenario-grid {
    grid-template-columns: 1fr;
  }

  .related-grid {
    grid-template-columns: 1fr;
  }

  .sop-item {
    grid-template-columns: 36px 1fr;
  }

  /* Chat */
  .chat-window {
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(100vh - 40px);
    border-radius: 20px 20px 0 0;
    transform-origin: bottom center;
  }

  .chat-fab {
    bottom: 20px;
    right: 20px;
  }

  .dialog-bubble {
    max-width: 90%;
  }
}

@media (max-width: 480px) {
  h1 { font-size: 1.8rem; }

  .case-header {
    padding: 20px 16px;
  }

  .section-body {
    padding: 16px;
  }

  .section-header {
    padding: 16px 16px 12px;
  }
}
