/* 真我汲 — warm, low-friction access from every page */
.login-overlay.show ~ .emergency-fab,
.login-overlay.show ~ .emergency-overlay {
  display: none !important;
}

.gate-card-emergency {
  position: relative;
  overflow: hidden;
}

.gate-card-emergency::before {
  content: "";
  position: absolute;
  top: -42px;
  right: -42px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(154, 112, 59, .08);
}

.emergency-gate-icon,
.emergency-fab-mark {
  font-family: var(--font-serif);
  font-weight: 700;
}

.emergency-gate-icon {
  color: #7b5d34;
  background: #f4ead8;
}

[data-theme="dark"] .emergency-gate-icon {
  color: #e8c994;
  background: #403422;
}

.emergency-fab {
  position: fixed;
  right: 22px;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 1040;
  display: flex;
  min-height: 48px;
  padding: 7px 15px 7px 8px;
  align-items: center;
  gap: 9px;
  color: #554127;
  background: rgba(255, 250, 239, .94);
  border: 1px solid rgba(135, 99, 53, .22);
  border-radius: 999px;
  box-shadow: 0 9px 28px rgba(77, 55, 29, .16);
  backdrop-filter: blur(16px);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}

.emergency-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(77, 55, 29, .22);
}

.emergency-fab-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #fffaf0;
  background: #8b6a3f;
  border-radius: 50%;
  font-size: 16px;
}

.emergency-fab-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
}

[data-theme="dark"] .emergency-fab {
  color: #eadbc5;
  background: rgba(48, 41, 32, .94);
  border-color: rgba(220, 185, 128, .22);
}

body.emergency-open {
  overflow: hidden;
}

body.emergency-open .emergency-fab {
  opacity: 0;
  pointer-events: none;
}

.emergency-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  padding: 24px;
  place-items: center;
  background: rgba(46, 37, 28, .46);
  backdrop-filter: blur(8px);
}

.emergency-overlay.show {
  display: grid;
}

.emergency-dialog {
  display: flex;
  width: min(100%, 980px);
  max-height: min(88dvh, 780px);
  flex-direction: column;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 100% 0, rgba(154, 112, 59, .1), transparent 290px),
    var(--card);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: 0 30px 90px rgba(40, 29, 19, .28);
}

.emergency-dialog-head {
  display: flex;
  padding: 28px 30px 22px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}

.emergency-eyebrow,
.emergency-strategy-kicker {
  color: #987445;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
}

.emergency-dialog-head h2 {
  margin: 5px 0 6px;
  font-family: var(--font-serif);
  font-size: 27px;
  line-height: 1.2;
}

.emergency-dialog-head p {
  max-width: 650px;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.7;
}

.emergency-mode-tabs {
  display: inline-flex;
  margin-top: 14px;
  padding: 3px;
  gap: 3px;
  background: rgba(154, 112, 59, .08);
  border: 1px solid rgba(154, 112, 59, .13);
  border-radius: 12px;
}

.emergency-mode-tabs button {
  min-height: 34px;
  padding: 7px 14px;
  color: var(--text2);
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.emergency-mode-tabs button[aria-selected="true"] {
  color: #684d2e;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(82, 59, 32, .09);
}

[data-theme="dark"] .emergency-mode-tabs button[aria-selected="true"] {
  color: #efd8b4;
}

.emergency-close {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--text2);
  background: rgba(var(--accent-rgb), .06);
  border: 0;
  border-radius: 50%;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.emergency-close:hover {
  color: var(--text);
  background: rgba(var(--accent-rgb), .11);
}

.emergency-layout {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: 310px minmax(0, 1fr);
}

.emergency-scenarios {
  padding: 20px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: rgba(var(--accent-rgb), .025);
}

.emergency-scenario-title {
  margin: 0 4px 12px;
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
}

.emergency-scenario {
  display: flex;
  width: 100%;
  min-height: 46px;
  margin-bottom: 7px;
  padding: 7px 11px;
  align-items: center;
  gap: 11px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 13px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}

.emergency-scenario:hover {
  background: var(--card);
  border-color: var(--border);
}

.emergency-scenario.active {
  color: #684d2e;
  background: #f5ecdd;
  border-color: #dec9a8;
}

[data-theme="dark"] .emergency-scenario.active {
  color: #efd8b4;
  background: #3d3325;
  border-color: #5d4b34;
}

.emergency-scenario-mark {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  color: #84623a;
  background: rgba(154, 112, 59, .1);
  border-radius: 10px;
  font-family: var(--font-serif);
  font-weight: 700;
}

.emergency-scenario.active .emergency-scenario-mark {
  color: #fffaf0;
  background: #8b6a3f;
}

.emergency-strategy {
  min-height: 0;
  padding: 30px 34px;
  overflow-y: auto;
}

.emergency-empty {
  display: flex;
  min-height: 100%;
  max-width: 500px;
  margin: auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.emergency-empty-mark {
  display: grid;
  width: 68px;
  height: 68px;
  margin-bottom: 18px;
  place-items: center;
  color: #8b6a3f;
  background: #f4ead8;
  border-radius: 22px;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
}

[data-theme="dark"] .emergency-empty-mark {
  background: #403422;
}

.emergency-empty h3 {
  margin-bottom: 8px;
  font-family: var(--font-serif);
  font-size: 22px;
}

.emergency-empty > p {
  color: var(--text2);
  font-size: 13px;
}

.emergency-empty blockquote {
  margin-top: 28px;
  padding: 16px 20px;
  color: #755936;
  background: rgba(154, 112, 59, .07);
  border-left: 3px solid #b69363;
  border-radius: 4px 14px 14px 4px;
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.9;
  text-align: left;
}

[data-theme="dark"] .emergency-empty blockquote {
  color: #e5c99f;
}

.emergency-strategy-head {
  display: flex;
  margin-bottom: 18px;
  align-items: center;
  gap: 14px;
}

.emergency-strategy-mark {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  color: #fffaf0;
  background: #8b6a3f;
  border-radius: 15px;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(117, 84, 43, .15);
}

.emergency-strategy-head h3 {
  margin-top: 3px;
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1.35;
}

.emergency-lead {
  margin-bottom: 22px;
  color: var(--text2);
  font-size: 14px;
  line-height: 1.8;
}

.emergency-steps {
  padding: 0;
  list-style: none;
  counter-reset: emergency-step;
}

.emergency-steps li {
  display: grid;
  margin-bottom: 17px;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 12px;
  counter-increment: emergency-step;
}

.emergency-steps li::before {
  content: counter(emergency-step);
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: #84623a;
  background: #f4ead8;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

[data-theme="dark"] .emergency-steps li::before {
  color: #e8c994;
  background: #403422;
}

.emergency-steps strong {
  display: block;
  margin: 2px 0 4px;
  font-size: 14px;
}

.emergency-steps p {
  color: var(--text2);
  font-size: 13px;
  line-height: 1.78;
}

.emergency-action-label {
  margin: 0 0 10px;
  color: #987445;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
}

.emergency-actions {
  display: grid;
  padding: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  list-style: none;
}

.emergency-actions li {
  position: relative;
  min-height: 46px;
  padding: 12px 12px 12px 31px;
  color: var(--text);
  background: rgba(var(--accent-rgb), .045);
  border: 1px solid var(--border);
  border-radius: 13px;
  font-size: 13px;
  line-height: 1.55;
}

.emergency-actions li::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 14px;
  width: 7px;
  height: 7px;
  background: #a57b47;
  border-radius: 50%;
}

.emergency-prompts {
  display: grid;
  margin-bottom: 20px;
  gap: 8px;
}

.emergency-prompts > div {
  display: grid;
  padding: 11px 13px;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  background: rgba(154, 112, 59, .06);
  border-radius: 12px;
}

.emergency-prompts span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: #84623a;
  border: 1px solid #c9af89;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
}

.emergency-prompts p {
  font-size: 13px;
  line-height: 1.65;
}

.emergency-guide-section {
  margin: 0 0 22px;
}

.emergency-guide-section h4 {
  margin: 0 0 10px;
  color: #80613a;
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.5;
}

[data-theme="dark"] .emergency-guide-section h4 {
  color: #e5c99f;
}

.emergency-guide-section .emergency-actions,
.emergency-guide-section .emergency-prompts {
  margin-bottom: 0;
}

.emergency-section-text {
  margin: -3px 0 10px;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.7;
}

.emergency-detail-quote {
  margin-top: 22px;
  padding: 14px 17px;
  color: #755936;
  background: rgba(154, 112, 59, .07);
  border-left: 3px solid #b69363;
  border-radius: 4px 14px 14px 4px;
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.8;
}

[data-theme="dark"] .emergency-detail-quote {
  color: #e5c99f;
}

.emergency-note {
  display: flex;
  margin-top: 24px;
  padding: 14px 16px;
  gap: 10px;
  color: #6e5332;
  background: #f6efe3;
  border-radius: 14px;
}

[data-theme="dark"] .emergency-note {
  color: #e5c99f;
  background: #352d22;
}

.emergency-note span {
  color: #a57b47;
}

.emergency-note p {
  font-family: var(--font-serif);
  font-size: 13px;
  line-height: 1.7;
}

.emergency-dialog-foot {
  display: flex;
  padding: 13px 30px;
  justify-content: space-between;
  gap: 20px;
  color: var(--text2);
  background: rgba(var(--accent-rgb), .025);
  border-top: 1px solid var(--border);
  font-size: 10px;
}

.emergency-mobile-back {
  display: none;
}

@media (min-width: 769px) {
  .gate-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .emergency-dialog {
    max-height: 92dvh;
  }

  .emergency-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .emergency-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .emergency-fab {
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    z-index: 1045;
    min-height: 44px;
    padding: 5px;
  }

  .emergency-fab-mark {
    width: 34px;
    height: 34px;
  }

  .emergency-fab-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .emergency-overlay {
    padding: 0;
    align-items: end;
  }

  .emergency-dialog {
    width: 100%;
    height: min(94dvh, 820px);
    max-height: none;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 26px 26px 0 0;
  }

  .emergency-dialog-head {
    padding: 20px 18px 16px;
  }

  .emergency-dialog-head h2 {
    font-size: 23px;
  }

  .emergency-dialog-head p {
    font-size: 12px;
  }

  .emergency-eyebrow {
    display: none;
  }

  .emergency-mode-tabs {
    display: flex;
    width: 100%;
    margin-top: 12px;
  }

  .emergency-mode-tabs button {
    flex: 1;
  }

  .emergency-layout {
    display: block;
    position: relative;
    overflow: hidden;
  }

  .emergency-scenarios,
  .emergency-strategy {
    position: absolute;
    inset: 0;
    padding: 16px;
    overflow-y: auto;
    border-right: 0;
    background: var(--card);
    -webkit-overflow-scrolling: touch;
  }

  .emergency-strategy {
    z-index: 2;
    display: none;
    padding: 16px 18px 30px;
  }

  .emergency-strategy.has-selection {
    display: block;
  }

  .emergency-scenario-title {
    margin-bottom: 10px;
  }

  .emergency-scenario {
    min-height: 50px;
    margin-bottom: 8px;
    padding: 8px 11px;
    background: rgba(var(--accent-rgb), .025);
    border-color: var(--border);
    font-size: 14px;
  }

  .emergency-mobile-back {
    display: inline-flex;
    min-height: 38px;
    margin-bottom: 18px;
    padding: 7px 11px;
    align-items: center;
    color: #80613a;
    background: rgba(154, 112, 59, .08);
    border: 0;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
  }

  .emergency-strategy-head {
    margin-bottom: 14px;
  }

  .emergency-strategy-head h3 {
    font-size: 20px;
  }

  .emergency-dialog-foot {
    padding: 10px 18px max(10px, env(safe-area-inset-bottom));
  }

  .emergency-dialog-foot span:last-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .emergency-fab,
  .emergency-scenario {
    transition: none;
  }
}
