/* ============================================================
   站点外壳样式：页头/页脚/表单/按钮/模态框/Toast/落地页/账号页
   编辑器画布自身的样式在 css/mindmap.css 里。
   配色沿用产品既有的深蓝 + 靛蓝主色，保持视觉一致。
   ============================================================ */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --ink: #2c3e50;
  --ink-soft: #6b7a90;
  --ink-faint: #97a3b4;
  --line: #e3e7ef;
  --line-soft: #eef1f6;
  --brand: #4a6cf7;
  --brand-dark: #3a56d4;
  --brand-soft: #eef1fe;
  --teal: #16a2b8;
  --ok: #2fa36b;
  --warn: #e0a020;
  --err: #e05260;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(28, 40, 60, 0.08);
  --shadow-md: 0 6px 24px rgba(28, 40, 60, 0.12);
  --shadow-lg: 0 16px 48px rgba(28, 40, 60, 0.20);
  --header-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
               "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* 键盘用户跳过导航直达内容 */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  background: var(--brand);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ============================================================
   页头 / 页脚
   ============================================================ */
.site-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 600;
  font-size: 16px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--brand), var(--teal));
  flex: 0 0 auto;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 14px;
}
.site-nav a:not(.btn) { color: var(--ink-soft); }
.site-nav a:not(.btn):hover { color: var(--brand); text-decoration: none; }
.site-nav a[aria-current="page"]:not(.btn) { color: var(--brand); font-weight: 600; }

.nav-user {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
  font-size: 13px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 用在「未设置恢复码」这类需要引起注意但不算错误的状态上 */
.text-warn { color: #b5761f; font-weight: 600; }

.linklike {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--ink-soft);
  cursor: pointer;
}
.linklike:hover { color: var(--err); }

.site-main { flex: 1 1 auto; display: flex; flex-direction: column; }

.site-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 16px 20px;
  font-size: 12px;
  color: var(--ink-faint);
}
.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  align-items: center;
  justify-content: space-between;
}
.footer-links, .footer-meta { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.site-footer a { color: var(--ink-faint); }
.site-footer a:hover { color: var(--brand); }

/* ============================================================
   按钮 / 表单控件
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-outline { border-color: var(--line); background: var(--surface); color: var(--ink-soft); }
.btn-outline:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c9424f; }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--line-soft); color: var(--ink); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 26px; font-size: 15px; }
.btn-block { width: 100%; }

.field { margin-bottom: 16px; }
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}
.field-hint { margin-top: 5px; font-size: 12px; color: var(--ink-faint); }
.field-error { margin-top: 5px; font-size: 12px; color: var(--err); min-height: 0; }

.input, .textarea, .select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input[aria-invalid="true"] { border-color: var(--err); }

/* 恢复码等一次性代码用等宽字体，逐字符对齐才好核对有没有抄错 */
.input-mono {
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.checkbox-row input[type="checkbox"] { margin-top: 3px; flex: 0 0 auto; }
.checkbox-sub {
  margin: 8px 0 0 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ============================================================
   卡片 / 通用容器
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 24px; }
.card-title { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.card-sub { margin: 0 0 18px; font-size: 13px; color: var(--ink-faint); }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 420px; }
.section { padding: 32px 0; }

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error { background: #fdeef0; border-color: #f6d3d8; color: #b03341; }
.alert-ok { background: #eaf6f0; border-color: #cfe8db; color: #217a4d; }
.alert-info { background: var(--brand-soft); border-color: #d8dffc; color: var(--brand-dark); }

/* 条款重新确认横幅。位于 header 与 main 之间，
   flex:0 0 auto 是必需的：编辑器页 body 是 overflow:hidden 的满屏 flex，
   否则横幅会被 main 挤没。 */
.consent-banner {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: #fff7e6;
  border-bottom: 1px solid #f5d99a;
  color: #8a5b00;
  font-size: 13px;
}
.consent-banner-text { flex: 1 1 260px; }
.consent-banner .btn { flex: 0 0 auto; }

/* ============================================================
   落地页
   ============================================================ */
.hero {
  padding: 72px 20px 56px;
  text-align: center;
  background: linear-gradient(180deg, #fff 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
}
.hero h1 {
  margin: 0 0 14px;
  font-size: 34px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.hero p {
  margin: 0 auto 28px;
  max-width: 560px;
  font-size: 16px;
  color: var(--ink-soft);
}
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  padding: 44px 0 56px;
}
.feature {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.feature h3 { margin: 0 0 8px; font-size: 15px; }
.feature p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.feature-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--brand-soft);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}

/* ============================================================
   登录 / 注册
   ============================================================ */
.auth-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-switch {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-faint);
}
.auth-sep { margin: 0 6px; color: var(--line); }

/* ============================================================
   一次性恢复码
   ============================================================ */
.recovery-box { padding: 0 20px; }
.recovery-warn {
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-soft);
  background: #fff8e6;
  border-left: 3px solid #e8a33d;
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 4px 0 16px;
}
.recovery-code {
  margin: 0 0 12px;
  padding: 16px 12px;
  text-align: center;
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px dashed var(--brand);
  border-radius: var(--radius-sm);
  /* 允许整段选中复制，即便剪贴板 API 不可用 */
  user-select: all;
  word-break: break-all;
}
.recovery-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.recovery-hint { font-size: 12px; color: var(--ink-faint); }

/* ============================================================
   账号页
   ============================================================ */
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  align-items: start;
  padding: 28px 20px 44px;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--ink-faint); margin: 0; }
.kv dd { margin: 0; color: var(--ink); font-weight: 500; text-align: right; word-break: break-all; }

.meter { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; margin-top: 6px; }
.meter-fill { height: 100%; background: var(--brand); border-radius: 3px; transition: width 0.25s; }
.meter-fill.warn { background: var(--warn); }
.meter-fill.over { background: var(--err); }

.session-list { list-style: none; margin: 0; padding: 0; }
.session-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.session-list li:last-child { border-bottom: 0; }
.session-meta { min-width: 0; }
.session-ua { color: var(--ink-faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  margin-left: 6px;
}

.danger-zone { border-color: #f2d4d8; }
.danger-zone .card-title { color: var(--err); }

/* ============================================================
   法律条款页
   ============================================================ */
.legal {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 56px;
  width: 100%;
}
.legal h1 { font-size: 24px; margin: 0 0 6px; }
.legal .legal-meta { color: var(--ink-faint); font-size: 13px; margin-bottom: 28px; }
.legal h2 { font-size: 17px; margin: 30px 0 10px; padding-top: 4px; }
.legal h3 { font-size: 14px; margin: 20px 0 8px; }
.legal p, .legal li { font-size: 14px; color: #3d4c5e; }
.legal ul, .legal ol { padding-left: 22px; }
.legal table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 13px; }
.legal th, .legal td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.legal th { background: var(--line-soft); font-weight: 600; }
.legal .callout {
  background: var(--brand-soft);
  border-left: 3px solid var(--brand);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 18px 0;
}

/* ============================================================
   模态框（替代原生 alert / confirm / prompt）
   ============================================================ */
.modal-root[hidden] { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 42, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9000;
  animation: fade-in 0.14s ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  animation: pop-in 0.16s ease;
}
.modal-wide { max-width: 640px; }
.modal-head { padding: 18px 20px 0; }
.modal-title { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body { padding: 12px 20px 4px; font-size: 13px; color: var(--ink-soft); white-space: pre-wrap; }
.modal-foot {
  padding: 16px 20px 18px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ============================================================
   Toast
   ============================================================ */
.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  background: #2c3e50;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  max-width: 340px;
  animation: toast-in 0.18s ease;
  border-left: 3px solid var(--brand);
}
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--err); }
.toast-info { border-left-color: var(--brand); }
.toast.leaving { animation: toast-out 0.18s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ============================================================
   错误页
   ============================================================ */
.error-page { text-align: center; padding: 80px 20px; flex: 1 1 auto; }
.error-code { font-size: 64px; font-weight: 700; color: var(--line); line-height: 1; margin-bottom: 12px; }
.error-page h1 { font-size: 20px; margin: 0 0 8px; }
.error-page p { color: var(--ink-soft); margin: 0 0 24px; }

/* ============================================================
   编辑器外壳
   ============================================================ */
body.editor-body { overflow: hidden; }
body.editor-body .site-main { min-height: 0; }
body.editor-body .site-footer { display: none; }

.editor-shell { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }

.editor-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.editor-toolbar .spacer { flex: 1 1 auto; }
.search-box { position: relative; }
.search-box .input { width: 190px; padding-right: 26px; }
.search-count {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--ink-faint);
  pointer-events: none;
}
.search-count.search-none { color: var(--err); }
.quota-chip {
  font-size: 12px;
  color: var(--ink-faint);
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  white-space: nowrap;
}
.quota-chip.warn { color: var(--warn); border-color: #f0ddb4; }
.quota-chip.over { color: var(--err); border-color: #f2ccd2; }

/* 让 mindmap.css 里的 .mm-layout 填满工具栏以下的剩余高度 */
.editor-host { flex: 1 1 auto; min-height: 0; display: flex; }
/* min-width:0 是关键：flex 子项默认 min-width:auto，导图一宽就会把整页撑出
   横向滚动条，而不是让画布自己滚。 */
.editor-host > .mm-layout { flex: 1 1 auto; min-height: 0; min-width: 0; }

@media (max-width: 720px) {
  .hero { padding: 48px 16px 36px; }
  .hero h1 { font-size: 26px; }
  .site-header-inner { padding: 0 12px; }
  .site-nav { gap: 12px; }
  .brand-name { display: none; }
  .account-grid { padding: 18px 12px 32px; }
  .search-box .input { width: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
