/* ============================================================
 * practice.css — 彧溪斋 · 在线临摹（描红 / 对照）
 * 沿用站内宣纸米白 / 墨黑 / 朱红，微信内置浏览器与触屏友好
 * ============================================================ */
.yxz-practice {
  --px-paper: #f7f1e2;
  --px-paper2: #fbf7ee;
  --px-ink: #1f1b18;
  --px-red: #9e2b25;
  --px-line: #d8cdb4;
  --px-soft: #6f6658;
  font-family: "KaiTi", "STKaiti", "Kaiti SC", "Songti SC", "SimSun", serif;
  color: var(--px-ink);
  background: var(--px-paper2);
  border: 1px solid var(--px-line);
  border-radius: 8px;
  padding: 14px 16px 16px;
  margin: 10px 0 4px;
}

.px-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.px-title { font-size: 17px; letter-spacing: 2px; color: var(--px-red); margin-right: auto; }
.px-title small { display: block; font-size: 11px; letter-spacing: 0; color: var(--px-soft); }
.px-tabs { display: flex; gap: 6px; }
.px-tabs button, .px-seg button, .px-bar button {
  font-family: inherit; font-size: 13px; padding: 6px 12px;
  border: 1px solid var(--px-line); background: #fffdf8; color: var(--px-ink);
  border-radius: 4px; cursor: pointer; line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
.px-tabs button.on, .px-seg button.on { background: var(--px-red); color: #fff; border-color: var(--px-red); }
.px-bar button:active { background: #efe6d2; }

.px-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 0; border-top: 1px dashed var(--px-line); border-bottom: 1px dashed var(--px-line);
}
.px-bar label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--px-soft); white-space: nowrap; }
.px-bar input[type=range] { width: 88px; accent-color: var(--px-red); }
.px-seg { display: flex; gap: 4px; }
.px-seg button { padding: 5px 9px; font-size: 12px; }
.px-colors { display: flex; gap: 5px; align-items: center; }
.px-colors button {
  width: 26px; height: 26px; padding: 0; border-radius: 50%;
  border: 2px solid var(--px-line); background: #222; position: relative;
}
.px-colors button.on { border-color: var(--px-red); box-shadow: 0 0 0 2px rgba(158,43,37,.25); }
.px-colors button[data-color="#a3302a"] { background: #a3302a; }
.px-colors button[data-color="#264a6b"] { background: #264a6b; }
.px-colors button[data-color="eraser"] { background: #fffdf8; color: var(--px-red); font-size: 14px; line-height: 22px; }
.px-actions { display: flex; gap: 6px; margin-left: auto; }

.px-pages { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 0 6px; font-size: 13px; color: var(--px-soft); }
.px-pages button { padding: 3px 10px; font-size: 13px; }

/* 书写舞台：对照模式左右并置，描红模式单栏 */
.px-stage { display: flex; gap: 12px; align-items: flex-start; }
.px-pane {
  position: relative; flex: 1 1 0; min-width: 0;
  background: var(--px-paper); border: 1px solid var(--px-line);
  border-radius: 5px; overflow: hidden;
  box-shadow: inset 0 0 24px rgba(120, 100, 70, .08);
}
.px-pane-label {
  position: absolute; top: 6px; left: 8px; z-index: 3;
  font-size: 11px; letter-spacing: 1px; color: #fff;
  background: rgba(31,27,24,.58); padding: 2px 8px; border-radius: 3px;
  pointer-events: none;
}
.px-ref { background: #26221d; }
.px-ref img { display: block; width: 100%; height: 100%; object-fit: contain; transform-origin: center center; }
.px-ref-scroll { position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
.px-under { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.px-grid-layer { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.px-grid-layer.g-mi {
  background-image:
    linear-gradient(to right, transparent 49.8%, rgba(158,43,37,.30) 49.8%, rgba(158,43,37,.30) 50.2%, transparent 50.2%),
    linear-gradient(to bottom, transparent 49.8%, rgba(158,43,37,.30) 49.8%, rgba(158,43,37,.30) 50.2%, transparent 50.2%),
    linear-gradient(45deg, transparent 49.85%, rgba(158,43,37,.17) 49.85%, rgba(158,43,37,.17) 50.15%, transparent 50.15%),
    linear-gradient(-45deg, transparent 49.85%, rgba(158,43,37,.17) 49.85%, rgba(158,43,37,.17) 50.15%, transparent 50.15%);
  border: 1px solid rgba(158,43,37,.32);
}
.px-grid-layer.g-tian {
  background-image:
    linear-gradient(to right, transparent 49.8%, rgba(158,43,37,.28) 49.8%, rgba(158,43,37,.28) 50.2%, transparent 50.2%),
    linear-gradient(to bottom, transparent 49.8%, rgba(158,43,37,.28) 49.8%, rgba(158,43,37,.28) 50.2%, transparent 50.2%);
  border: 1px solid rgba(158,43,37,.3);
}
.px-canvas {
  position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%;
  touch-action: none; cursor: crosshair; background: transparent;
  -webkit-user-select: none; user-select: none;
}
.px-stage.mode-trace .px-ref { display: none; }
.px-stage.mode-compare .px-under { display: none; }

.px-tip { font-size: 12px; color: var(--px-soft); line-height: 1.8; margin: 10px 0 2px; }
.px-src { font-size: 11px; color: #8a7f6c; line-height: 1.7; margin-top: 6px; }
.px-src a { color: var(--px-red); text-decoration: none; border-bottom: 1px dotted #b8ad99; }
.px-msg { font-size: 12px; color: var(--px-red); min-height: 18px; margin-top: 4px; }

/* 详情弹窗内「临摹」页签标题 */
.px-panel-title { font-size: 15px; color: #9e2b26; letter-spacing: 2px; margin: 4px 0 2px; }
.px-host { width: 100%; }

/* 卡片快捷入口：独立临摹弹层 */
.px-overlay {
  position: fixed; inset: 0; z-index: 390; overflow: auto;
  background: rgba(31,27,24,.62); padding: 18px;
  -webkit-overflow-scrolling: touch;
}
.px-overlay-inner {
  position: relative; max-width: 980px; margin: 0 auto;
  background: #fbf7ee; border: 1px solid #d8cdb4; border-radius: 8px;
  padding: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.px-overlay-close {
  position: absolute; top: 8px; right: 10px; z-index: 5;
  width: 34px; height: 34px; line-height: 28px; font-size: 26px;
  border: 1px solid #d8cdb4; background: #fffdf8; color: #1f1b18;
  border-radius: 50%; cursor: pointer;
}

/* 全屏书写（手机横屏 / 细致临摹） */
.yxz-practice.px-full {
  position: fixed; inset: 0; z-index: 400; overflow: auto;
  border: none; border-radius: 0; padding: 14px 16px 30px;
  background: var(--px-paper);
}
.yxz-practice.px-full .px-stage { max-width: 1100px; margin: 0 auto; }

/* 保存结果预览（微信内长按保存） */
.px-save-mask {
  position: fixed; inset: 0; z-index: 500; background: rgba(31,27,24,.82);
  display: flex; align-items: center; justify-content: center; padding: 18px;
  flex-direction: column; gap: 12px;
}
.px-save-mask img { max-width: 92vw; max-height: 68vh; border: 6px solid #fffdf8; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.px-save-mask p { color: #fffdf8; font-size: 14px; text-align: center; line-height: 1.8; margin: 0; }
.px-save-mask button { font-family: inherit; font-size: 14px; padding: 8px 22px; border: 1px solid #fffdf8; background: transparent; color: #fffdf8; border-radius: 4px; cursor: pointer; }

@media (max-width: 720px) {
  .yxz-practice { padding: 12px 10px 14px; }
  .px-bar { gap: 6px 8px; }
  .px-bar input[type=range] { width: 66px; }
  .px-actions { margin-left: 0; width: 100%; }
  .px-stage.mode-compare { flex-direction: column; }
  .px-stage.mode-compare .px-ref, .px-stage.mode-compare .px-write { width: 100%; flex: none; }
  .px-tabs button, .px-seg button, .px-bar button { font-size: 12px; padding: 5px 9px; }
}
@media print {
  .px-bar, .px-tabs, .px-pages, .px-actions, .px-tip, .px-msg { display: none !important; }
  .px-canvas { display: none; }
}
