/*
 * layout.css —— 全站公共骨架
 * 页头、步骤条、页脚、页面容器、两栏骨架、响应式断点。
 * 由 ui.js 的 header()/steps()/footer() 输出对应 HTML。
 */

/* ---- 页面容器 ---- */
.page { max-width: 1200px; margin: 0 auto; padding: var(--space-5) var(--space-6) 96px; }
.page-narrow { max-width: 420px; }

/* ---- 页头 ---- */
.app-header {
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header .bar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px var(--space-6);
  display: flex;
  align-items: center;
  position: relative;
  gap: var(--space-3);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  flex: none;
}
.brand svg { width: 42px; height: 22px; color: var(--green); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand b { font-family: var(--serif); font-size: 20px; letter-spacing: 4px; font-weight: 650; }
.brand small { color: var(--muted); font-size: 10px; letter-spacing: 1.5px; font-weight: 500; }

.back-btn {
  display: none;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 8px 4px;
  color: var(--ink);
  font-size: 15px;
  border: 0;
}
.back-btn svg { width: 20px; height: 20px; }

.nav {
  display: flex;
  gap: var(--space-5);
  align-items: center;
}
.nav a {
  color: var(--ink);
  padding: 8px 2px;
  box-shadow: inset 0 -2px 0 transparent;
}
.nav a.active {
  color: var(--green);
  font-weight: 650;
  box-shadow: inset 0 -2px 0 var(--green);
}

.reader-label { color: var(--muted); font-size: 14px; }

.header-right { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; margin-left: auto; }
.save-pill { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.save-pill svg { width: 18px; height: 18px; }
.login-link { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.user-menu { position: relative; }
.user-icon {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--warm);
  background: var(--card-bg);
  display: grid; place-items: center;
  list-style: none;
}
.user-icon::-webkit-details-marker { display: none; }
.user-icon svg { width: 20px; height: 20px; color: var(--ink); }
.user-menu-list {
  position: absolute; right: 0; top: 52px;
  background: var(--card-bg);
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(41, 46, 42, 0.12);
  padding: 8px;
}
.user-menu-name { padding: 8px 12px; color: var(--muted); font-size: 14px; }
.user-menu-list button, .user-menu-list a {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 10px 12px; border-radius: 8px; color: inherit; font-size: 15px;
}
.user-menu-list button:hover, .user-menu-list a:hover { background: rgba(41, 46, 42, 0.06); }

/* 桌面：三段式，导航绝对居中 */
@media (min-width: 768px) {
  .back-btn { display: none !important; }
  .app-header--back .back-btn { display: inline-flex !important; }
  .nav { position: absolute; left: 50%; transform: translateX(-50%); }
}

/* 手机：左返回、中品牌两行居中、右已保存或留空 */
@media (max-width: 767px) {
  .app-header .bar { padding: 12px 20px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
  .back-btn { display: inline-flex; justify-self: start; }
  .brand { flex-direction: column; gap: 2px; justify-self: center; }
  .brand-text { align-items: center; text-align: center; }
  .nav { display: none; }
  .header-right { justify-self: end; margin-left: 0; }
  .login-link, .user-menu { display: none; }
}

/* ---- 步骤条：圆点在上，标签在下 ---- */
.steps {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  /* 设计稿里三步是紧凑的一组居中，不随内容宽度拉开 */
  max-width: 520px;
  margin: 8px auto 40px;
}
.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 92px;
  flex: none;
}
.step-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid var(--warm);
  color: var(--warm);
  font-size: 13px;
  background: var(--paper);
}
.step-dot svg { width: 16px; height: 16px; }
.step-item.on .step-dot,
.step-item.done .step-dot {
  background: var(--green);
  border-color: var(--green);
  color: var(--paper);
}
.step-label { font-size: 14px; color: var(--warm); text-align: center; white-space: nowrap; }
.step-item.on .step-label { color: var(--green); font-weight: 650; }
.step-item.done .step-label { color: var(--green); }
.step-line {
  flex: 1 1 48px;
  height: 1px;
  background: var(--warm);
  margin-top: 16px;
}
.step-line.done { background: var(--green); }

@media (max-width: 767px) {
  .step-item { min-width: 64px; }
  .step-label { font-size: 12px; white-space: normal; }
  .step-line { flex-basis: 24px; }
}

/* ---- 页脚 ---- */
.site-footer {
  border-top: 1px solid var(--hairline);
  margin-top: var(--space-6);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.footer-left, .footer-right { margin: 0; color: var(--muted); font-size: 13px; }

@media (max-width: 767px) {
  .site-footer { flex-direction: column; align-items: flex-start; gap: 8px; }
  .site-footer--centered { align-items: center; text-align: center; }
  .site-footer--centered .footer-left { display: none; }
  .site-footer--centered .footer-right {
    display: flex; align-items: center; gap: 12px; width: 100%;
  }
  .site-footer--centered .footer-right::before,
  .site-footer--centered .footer-right::after {
    content: ""; flex: 1; height: 1px; background: var(--warm); max-width: 32px;
  }
}

/* ---- 桌面两栏骨架：左 1fr / 右 380px，右栏左侧 1px 分隔线 ---- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-6);
  align-items: stretch;
}
.grid-2 > aside {
  position: relative;
  padding-left: var(--space-6);
}
.grid-2 > aside::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 1px;
  background: var(--hairline-strong);
}

/* ---- 响应式断点 ---- */
@media (max-width: 1023px) {
  .page { padding: var(--space-4) var(--space-4) 96px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 > aside { padding-left: 0; }
  .grid-2 > aside::before { display: none; }
  h1 { font-size: 34px; }
}

@media (max-width: 767px) {
  .page { padding: 20px 20px 96px; }
  h1 { font-size: 30px; }

  /* 手机底部操作：次按钮 45% + 主按钮 55% 并排一行，跳过链接另起一行居中 */
  .btn-row { flex-wrap: wrap; row-gap: 12px; }
  /* 用 flex-grow 比例（45:55）而非百分比，避免 gap 圆整误差导致换行 */
  .btn-row > *:first-child { order: 1; flex: 45 1 0; min-width: 0; }
  .btn-row > *:last-child { order: 2; flex: 55 1 0; min-width: 0; }
  .btn-row > *:not(:first-child):not(:last-child) {
    order: 3; flex: 1 1 100%; text-align: center; margin-top: 2px;
  }
}

/* ---- 离开创作时的保存询问 ---- */
.leave-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(41, 46, 42, 0.36);
  display: grid;
  place-items: center;
  padding: 20px;
}
.leave-dialog {
  width: min(420px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--warm);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.leave-dialog h2 { font-size: 24px; margin-bottom: 8px; }
.leave-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.leave-dialog-actions .btn,
.leave-dialog-actions .btn-ghost { min-width: 96px; }

/* ICP filing footer */
.site-icp{text-align:center;padding:16px 12px calc(16px + env(safe-area-inset-bottom));font-size:12px;line-height:1.5;}
.site-icp a{color:#8a8a8a;text-decoration:none;}
.site-icp a:hover{text-decoration:underline;}
