/* ============ 浅时光数码银盐冲印 - 在线照片裁剪 前台样式 ============ */
:root {
  --primary: #2d8bff;
  --primary-dark: #1b6de0;
  --accent: #ff8a3d;
  --bg: #2c4068;
  --card: #37527f;
  --text: #f1f5fc;
  --muted: #b6c6e3;
  --border: #4a6595;
  --danger: #ff7a80;
  --radius: 14px;
  --shadow: 0 2px 14px rgba(0, 0, 0, .25);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", -apple-system, system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: linear-gradient(180deg, #40598a 0%, #2b3f63 100%);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: linear-gradient(135deg, #0e5fd8 0%, #1677ff 55%, #38a0ff 100%);
  color: #fff;
  padding: 18px 22px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 14px rgba(14, 95, 216, .25);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.shop-info h1 { font-size: 22px; font-weight: 700; letter-spacing: 1px; }
.shop-info p { font-size: 13px; opacity: .85; margin-top: 2px; }
.shop-links { display: flex; align-items: center; gap: 10px; }
.shop-links-label { font-size: 13px; opacity: .9; white-space: nowrap; }
.shop-link {
  color: #fff;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 20px;
  padding: 5px 14px;
  white-space: nowrap;
}
.shop-link:hover { background: rgba(255,255,255,.16); }
.admin-link {
  color: #fff;
  font-size: 13px;
  opacity: .9;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 20px;
  padding: 5px 14px;
  white-space: nowrap;
  transition: background .2s;
}
.admin-link:hover { background: rgba(255,255,255,.15); }

/* ---------- 上传区 ---------- */
.upload-zone { padding: 26px 16px 10px; }
.upload-box {
  max-width: 520px;
  margin: 0 auto;
  background: var(--card);
  border: 2px dashed #2e4564;
  border-radius: 18px;
  padding: 46px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, transform .15s;
}
.upload-box:hover, .upload-box.dragover { border-color: var(--primary); transform: translateY(-1px); }
.upload-icon { font-size: 44px; line-height: 1; }
.upload-title { font-size: 17px; font-weight: 600; margin-top: 12px; }
.upload-tip { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- 工作区 ---------- */
.work-zone {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 18px;
  align-items: start;
}
.stage-wrap { min-width: 0; }
.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 10px;
}
.stage-hint { font-size: 12px; color: var(--muted); }

.stage {
  position: relative;
  background: #3a5280;
  border-radius: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
  min-height: 220px;
  min-width: 180px;
  margin: 0 auto;
  touch-action: none;
  user-select: none;
}
.stage img {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  object-fit: contain;
  z-index: 1;
}
.stage.ready img { opacity: 1; }

/* 裁剪框 */
.crop-box {
  position: absolute;
  z-index: 3;
  border: 2px solid rgba(255,255,255,.95);
  /* 遮罩范围收敛到画布尺寸即可（原来 9999px 每次拖动都要重绘超大区域，手机上容易卡顿） */
  box-shadow: 0 0 0 1600px rgba(0,0,0,.5);
  cursor: move;
  touch-action: none;
  display: none;
}
.crop-box.active { display: block; }
.stage.full { background: #ffffff; }
.crop-box.full {
  border-color: transparent;
  box-shadow: none;
  cursor: default;
}
.crop-box.full::after { display: none; }
.crop-box.full .crop-rule { display: none; }
.crop-box::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 1px dashed rgba(255,255,255,.55);
  pointer-events: none;
}
.crop-rule {
  position: absolute;
  background: rgba(255,255,255,.35);
  pointer-events: none;
}
.rule-h { left: 0; right: 0; height: 1px; }
.rule-v { top: 0; bottom: 0; width: 1px; }
.crop-rule:nth-of-type(1) { top: 33.333%; }
.crop-rule:nth-of-type(2) { top: 66.666%; }
.crop-rule:nth-of-type(3) { left: 33.333%; }
.crop-rule:nth-of-type(4) { left: 66.666%; }
.crop-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  background: var(--primary);
  border-radius: 4px;
  touch-action: none;
  z-index: 5;
}
.crop-handle.nw { top: -11px; left: -11px; cursor: nwse-resize; }
.crop-handle.ne { top: -11px; right: -11px; cursor: nesw-resize; }
.crop-handle.sw { bottom: -11px; left: -11px; cursor: nesw-resize; }
.crop-handle.se { bottom: -11px; right: -11px; cursor: nwse-resize; }

/* 尺寸角标 */
.size-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(0,0,0,.62);
  color: #fff;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  pointer-events: none;
  z-index: 8;
  display: none;
}

/* 文字层 */
.text-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}
.text-item {
  position: absolute;
  pointer-events: auto;
  cursor: move;
  touch-action: none;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.75);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.25;
  padding: 4px 6px;
  border: 1px solid transparent;
  transform-origin: top left;
  user-select: none;
}
.text-item .text-inner { pointer-events: none; }
/* 时间文字：强制一行，字号由程序按裁剪框宽度自动定 */
.text-item.no-wrap { white-space: nowrap; word-break: normal; }
.text-item.selected {
  border: 1px dashed #fff;
  background: rgba(255,255,255,.08);
}
.text-item.dragging { opacity: .85; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 78px; }
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.panel-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.panel-sub { font-size: 11px; font-weight: 400; color: var(--muted); }

/* 尺寸列表 */
.size-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.size-item {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  background: var(--card);
  transition: border-color .15s, background .15s, transform .1s;
}
.size-item:hover { border-color: var(--primary); }
.size-item.active {
  border-color: var(--primary);
  background: #21406e;
  transform: translateY(-1px);
}
.size-item .size-name { font-size: 13px; font-weight: 600; }
.size-item .size-ratio { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* 按钮 */
.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: var(--card);
  color: var(--text);
  border: 1.5px solid var(--border);
  font-size: 13px;
  padding: 6px 12px;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #3a2530; color: var(--danger); font-size: 13px; }
.btn-danger:hover { background: #452d3a; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 16px; font-size: 15px; font-weight: 600; border-radius: 12px; }

/* 文字控件 */
.text-controls { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.ctrl-label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.ctrl-textarea {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 14px;
  resize: vertical;
  min-height: 60px;
}
.ctrl-textarea:focus { outline: none; border-color: var(--primary); }
.ctrl-textarea::placeholder { color: var(--muted); }
.ctrl-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ctrl-row-btns { justify-content: flex-end; margin-top: 2px; }
.ctrl-range { flex: 1; min-width: 80px; accent-color: var(--primary); }
.ctrl-val { font-size: 12px; color: var(--muted); min-width: 28px; text-align: right; }
.ctrl-select {
  flex: 1;
  min-width: 0;
  background: var(--card);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 14px;
}
.color-row { display: flex; align-items: center; gap: 8px; flex: 1; }
input[type="color"] {
  width: 40px;
  height: 32px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  padding: 2px;
  cursor: pointer;
}
.swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,.28);
  cursor: pointer;
}
.align-grid {
  position: relative;
  width: 118px;
  height: 118px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  margin: 0 auto;
  background: rgba(255,255,255,.03);
}
.align-btn {
  position: absolute;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font);
  padding: 5px 8px;
  border-radius: 6px;
  line-height: 1;
}
.align-btn:hover { color: var(--text); background: rgba(45,139,255,.14); }
.align-btn.active { color: #fff; background: #2d5fa3; font-weight: 600; }
.align-btn[data-align="tl"] { top: 8px; left: 10px; }
.align-btn[data-align="tr"] { top: 8px; right: 10px; }
.align-btn[data-align="c"]  { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.align-btn[data-align="bl"] { bottom: 8px; left: 10px; }
.align-btn[data-align="br"] { bottom: 8px; right: 10px; }

/* 导出 */
.export-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.export-row .ctrl-select { flex: 1; }

.modal-sm { max-width: 380px; }
.field-label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 5px; }
.field {
  width: 100%;
  background: #24395e;
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 14px;
}
.field:focus { outline: none; border-color: var(--primary); }
.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; min-width: 0; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10,14,20,.72);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal-box {
  background: var(--card);
  color: var(--text);
  border-radius: 18px;
  max-width: 520px;
  width: 100%;
  max-height: 92vh;
  overflow: auto;
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 2;
}
.modal-close {
  border: none;
  background: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
}
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-body img {
  width: 100%;
  border-radius: 10px;
  display: block;
  -webkit-user-drag: none;
}
.modal-tip { text-align: center; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: rgba(17,24,39,.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 200;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
}

/* ---------- 响应式（手机） ---------- */
/* 折叠标题行：桌面不显示 */
.acc-head { display: none; }

@media (max-width: 900px) {
  .work-zone { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 10px 10px 24px; }
  html, body { overflow-x: hidden; }
  .toast { top: 74px; bottom: auto; max-width: 88vw; }
  .stage-wrap, .toolbar, .panel { min-width: 0; }
  .toolbar { position: static; flex-direction: column; gap: 8px; }
  .topbar-inner { flex-wrap: wrap; row-gap: 10px; }
  .shop-links { flex-wrap: wrap; justify-content: center; }
  .shop-links-label { display: none; }
  .stage { min-height: 220px; }
  .topbar { padding: 12px 14px; }
  .shop-info h1 { font-size: 18px; }
  .stage-toolbar { flex-wrap: wrap; margin-bottom: 8px; }
  .stage-hint { display: none; }

  /* —— 照片下方：左中右三个入口 + 底部弹出面板 —— */
  .work-zone { padding-bottom: 108px; }
  .toolbar {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    height: auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-content: center;
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgba(30, 45, 72, .97);
    border-top: 1px solid rgba(255, 255, 255, .09);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .35);
    z-index: 60;
  }
  .panel {
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    min-width: 0;
  }
  .panel > .panel-title { display: none; }
  .acc-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    padding: 9px 4px;
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .acc-head:active { transform: scale(.97); }
  .acc-label { font-size: 13.5px; white-space: nowrap; }
  .acc-value {
    font-size: 11px;
    font-weight: 400;
    color: var(--muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .acc-arrow { display: none; }
  .panel.open .acc-head {
    background: #2f6fd0;
    border-color: #5b97ea;
    color: #fff;
  }
  .panel.open .acc-head .acc-value { color: rgba(255, 255, 255, .82); }

  /* 弹出面板：从菜单上方滑出，不挤动照片 */
  .acc-body { display: none; }
  .panel.open .acc-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 82px;
    max-height: 46vh;
    overflow-y: auto;
    padding: 14px;
    background: rgba(52, 78, 121, .98);
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 16px;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .5);
    z-index: 59;
    -webkit-overflow-scrolling: touch;
    animation: sheetIn .18s ease;
  }
  .panel.open .acc-body .panel-title { display: flex; }
  /* 添加文字/拍摄时间两个按钮在面板内吸顶，滚动时始终可点 */
  .panel.open .acc-body .text-actions {
    position: sticky;
    top: -14px;
    z-index: 2;
    margin: -14px -14px 0;
    padding: 14px 14px 8px;
    background: rgba(52, 78, 121, .99);
    border-radius: 16px 16px 0 0;
  }
  @keyframes sheetIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
  }

  /* 尺寸：竖排列表，一行一个，名称在左、比例在右 */
  .size-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    width: auto;
    min-width: 0;
    overflow: visible;
    padding-bottom: 0;
  }
  .size-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    padding: 9px 14px;
    border-radius: 10px;
    text-align: left;
    white-space: normal;
    background: rgba(255, 255, 255, .05);
  }
  .size-item:active { background: rgba(255, 255, 255, .1); }
  .size-item .size-name { font-size: 14px; }
  .size-item .size-ratio { font-size: 12.5px; margin-top: 0; }
  /* 尺寸选项多，面板给高一点，8 个尺寸一屏看完 */
  #panelSize .acc-body { max-height: 56vh; }
  /* 底部菜单已显示当前尺寸，照片上不再重复显示徽标 */
  .size-badge { display: none !important; }

  .panel-title { margin-bottom: 8px; font-size: 13px; }
  .text-actions .btn { padding: 12px 6px; font-size: 14px; }
  #btnExport { width: 100%; }
}

/* 文字区：添加文字 / 拍摄时间 两个按钮并排 */
.text-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.text-actions .btn { width: 100%; padding: 10px 4px; font-size: 13.5px; white-space: nowrap; }
