/* ===== Fonts ===== */
/* 崇羲篆体 / 教育部國字隸書 改由 js/app.js 用 fetch+FontFace 带进度加载（避免双下载 + 显示百分比） */
@font-face {
  font-family: 'LXGWSeal';
  src: url('../fonts/LXGWSeal-Regular.ttf') format('truetype');
  font-display: swap;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  color: #1a1a1a;
  background: #f5f0e8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
#app-header {
  background: linear-gradient(135deg, #8B0000, #A52A2A);
  color: #fff;
  text-align: center;
  padding: 20px 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
#app-header .title-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 2px;
}
#style-select {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-align: center;
  text-align-last: center;
  padding: 0 22px 0 8px;
  cursor: pointer;
  font-family: inherit;
  outline: none;
}
#style-select:focus { text-shadow: 0 0 8px rgba(255,255,255,.6); }
#style-select option { color: #222; font-size: 1rem; letter-spacing: normal; font-weight: 400; }
#app-header .caret {
  position: absolute;
  right: 4px; top: 50%;
  transform: translateY(-50%);
  color: #fff; opacity: .9;
  font-size: .95rem;
  pointer-events: none;
}
.subtitle {
  font-size: .78rem;
  opacity: .85;
  letter-spacing: .08em;
}
#app-header .header-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}
#app-header .version {
  font-size: .72rem;
  background: rgba(255,255,255,.22);
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 10px;
  padding: 1px 8px;
  letter-spacing: .04em;
  opacity: .95;
  white-space: nowrap;
}

/* ===== Sticky top: input box (always visible) ===== */
#top-sticky {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #f5f0e8;
}

/* ===== Main content ===== */
#main-content {
  padding: 14px 12px 24px;
  flex: 1;
}

/* ===== Cards & Form ===== */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card label {
  display: block;
  font-size: .82rem;
  color: #666;
  margin-bottom: 4px;
  font-weight: 500;
}
.row2 { display: flex; gap: 10px; }
.flex1 { flex: 1; }

textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 1rem;
  outline: none;
  transition: border-color .2s;
  background: #fafafa;
  font-family: inherit;
}
textarea:focus, input:focus, select:focus {
  border-color: #8B0000;
  background: #fff;
}
input[type="color"] {
  width: 100%;
  height: 40px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 3px;
  cursor: pointer;
  background: #fafafa;
}

/* ===== Buttons ===== */
.btn-primary {
  display: block;
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #8B0000, #A52A2A);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .05em;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .2s, transform .1s;
}
.btn-primary:active { opacity: .85; transform: scale(.98); }

/* 输入框右上角的“生成高清图”按钮 */
.shared-input { position: relative; }
.shared-input > label { padding-right: 96px; } /* 给右上角按钮留位，避免文字重叠 */
#input-text { margin-top: 20px; } /* 输入框下移 20px，避免与右上角按钮重叠 */
.btn-generate-corner {
  position: absolute;
  top: 8px;
  right: 8px;
  width: auto;
  margin: 0;
  padding: 6px 14px;
  font-size: .82rem;
  font-weight: 600;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}

.btn-secondary {
  display: inline-block;
  padding: 10px 18px;
  background: #fff;
  color: #8B0000;
  border: 2px solid #8B0000;
  border-radius: 8px;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .2s;
}
.btn-secondary:active { background: #fde8e8; }
.btn-sm { padding: 8px 14px; font-size: .88rem; }

#action-bar {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}

/* ===== Canvas Preview ===== */
#preview-area {
  text-align: center;
  margin-top: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* 缩放/平移舞台：transform 作用于此，画布绘制结果拷贝到内部 <img> 展示与交互 */
#seal-stage {
  display: inline-block;
  transform-origin: 0 0;
  touch-action: pan-y;          /* 未放大时允许页面纵向滚动；放大后由 JS 改为 none 自行接管 */
  will-change: transform;
  transition: transform .08s ease-out;
  cursor: grab;
}
#seal-stage.dragging { transition: none; }
#seal-stage.selected {
  outline: 3px solid #8B0000;
  outline-offset: 4px;
  box-shadow: 0 0 0 6px rgba(139,0,0,.15), 0 2px 8px rgba(0,0,0,.1);
  border-radius: 6px;
  cursor: grabbing;
}
#seal-img {
  display: block;
  max-width: 100%;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  background: #fff;
  -webkit-touch-callout: none;   /* 关闭系统长按菜单，改用自定义长按下载，避免重复触发 */
  -webkit-user-select: none;
  user-select: none;
  pointer-events: auto;
}
#seal-canvas { display: none; }

/* ===== Font loading status ===== */
.font-loading {
  text-align: center;
  font-size: .82rem;
  color: #999;
  margin-top: 8px;
  padding: 6px;
}
.font-loading.ready { color: #2e7d32; }

.hint {
  font-size: .8rem;
  color: #999;
  line-height: 1.5;
  margin-bottom: 10px;
}

/* ===== 隶书替代字标注 ===== */
.legend {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fff7e6;
  border: 1px solid #f0d9a8;
  border-radius: 8px;
  font-size: .82rem;
  color: #8a6d3b;
  line-height: 1.6;
  text-align: center;
}
.legend b { color: #b45309; }
.legend .sub-chars {
  display: inline-block;
  margin-top: 4px;
  letter-spacing: .12em;
  font-size: 1rem;
  color: #a16207;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 16px 12px 20px;
  font-size: .74rem;
  color: #aaa;
  line-height: 1.6;
  border-top: 1px solid #e0d5c7;
  margin-top: auto;
  background: #f5f0e8;
}
footer a { color: #8B0000; text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ===== Responsive ===== */
@media (min-width: 768px) {
  body { max-width: 640px; margin: 0 auto; box-shadow: 0 0 20px rgba(0,0,0,.08); }
}

/* 崇羲/隶书字体改由 app.js 用 fetch+FontFace 加载，此处不再重复声明 */

/* ===== 高清字库加载弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-card {
  background: #fffdf8;
  border-radius: 16px;
  padding: 28px 26px;
  width: 300px;
  max-width: 86vw;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
  text-align: center;
  font-family: inherit;
}
.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #5a2a16;
  margin-bottom: 6px;
}
.modal-sub {
  font-size: .78rem;
  color: #8a6a55;
  margin-bottom: 18px;
  line-height: 1.5;
}
.progress-track {
  height: 10px;
  background: #ece2d4;
  border-radius: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c0392b, #e67e22);
  transition: width .2s ease;
}
.modal-pct {
  margin-top: 10px;
  font-size: .9rem;
  color: #5a2a16;
  font-variant-numeric: tabular-nums;
}
.modal-speed {
  margin-top: 4px;
  min-height: 18px;
  font-size: .82rem;
  color: #9a8c7a;
  font-variant-numeric: tabular-nums;
}
.btn-ghost {
  margin-top: 16px;
  background: transparent;
  border: 1px solid #d8c8b4;
  color: #8a6a55;
  border-radius: 10px;
  padding: 8px 18px;
  font-size: .85rem;
  cursor: pointer;
}
.btn-ghost:hover { background: #f3ece0; }
