/* ===================================
   水印相框 — 移动端优先样式
   =================================== */

:root {
  --bg: #f0efec;
  --surface: #ffffff;
  --text: #17171a;
  --text-2: #6e6e76;
  --text-3: #a5a5ad;
  --line: #e5e4e0;
  --accent: #17171a;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Helvetica Neue", "Hiragino Sans GB", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
  touch-action: manipulation;
}

/* ---------- 布局 ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  flex: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + var(--safe-t)) 20px 12px;
}

.brand h1 {
  margin: 0;
  font-family: ui-serif, Georgia, "Songti SC", "Times New Roman", serif;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.brand p {
  margin: 3px 0 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--text-3);
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.btn-text {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: rgba(0, 0, 0, 0.045);
  transition: background .15s;
}

.btn-text:active {
  background: rgba(0, 0, 0, 0.09);
}

.scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 24px;
}

/* ---------- 空态 ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 100%;
  padding: 24px 0 48px;
}

.empty-art {
  margin-bottom: 28px;
}

.ea-frame {
  width: 116px;
  height: 98px;
  padding: 9px 9px 24px;
  background: var(--surface);
  border-radius: 5px;
  box-shadow: 0 12px 34px rgba(30, 26, 18, 0.13),
              0 2px 6px rgba(30, 26, 18, 0.06);
  transform: rotate(-3deg);
}

.ea-frame i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(140deg, #d6d2c9 0%, #c0bbb0 55%, #b3ada1 100%);
}

.empty h2 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.empty-desc {
  margin: 0 0 30px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-2);
}

.btn-primary {
  padding: 14px 38px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform .12s, opacity .12s;
}

.btn-primary:active {
  transform: scale(0.97);
  opacity: 0.88;
}

.empty-note {
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--text-3);
}

/* ---------- 预览 ---------- */

.preview {
  margin-bottom: 16px;
}

.canvas-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  border-radius: 20px;
  background: #e3e1db;
  min-height: 180px;
}

#canvas {
  display: block;
  max-width: 100%;
  max-height: 44vh;
  width: auto;
  height: auto;
  border-radius: 3px;
  box-shadow: 0 10px 28px rgba(30, 26, 18, 0.16);
}

.preview-tip {
  margin: 10px 2px 0;
  font-size: 12.5px;
  color: var(--text-3);
  text-align: center;
}

/* ---------- 控制面板 ---------- */

.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 15px 16px 17px;
}

.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.group-val {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* 色卡 */
.swatches {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.swatch {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--c);
  border: 1px solid rgba(0, 0, 0, 0.09);
  transition: box-shadow .15s, transform .12s;
}

.swatch:active {
  transform: scale(0.94);
}

.swatch.on {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

/* 滑块 */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  margin: 0;
}

.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: #e8e7e3;
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -10px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

.range::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: #e8e7e3;
}

.range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--text-2);
  transition: all .15s;
}

.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 分段控件 */
.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 11px;
  background: #f2f1ee;
}

.segmented button {
  flex: 1;
  padding: 9px 0;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  transition: all .15s;
}

.segmented button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.09);
}

/* EXIF 列表 */
.meta-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px 18px;
  margin: 0;
  font-size: 13.5px;
}

.meta-list dt {
  color: var(--text-2);
}

.meta-list dd {
  margin: 0;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 底栏 ---------- */

.bottombar {
  flex: none;
  padding: 10px 16px calc(10px + var(--safe-b));
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}

.btn-save {
  display: block;
  width: 100%;
  height: 52px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform .12s, opacity .12s;
}

.btn-save:active {
  transform: scale(0.985);
  opacity: 0.9;
}

.btn-save:disabled {
  opacity: 0.45;
}

[hidden] {
  display: none !important;
}

/* 文件选择框：视觉隐藏但仍在文档流中，保证 iOS 上 .click() 能唤起相册 */
.sr-input {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- 长按保存弹层 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-t)) 20px calc(20px + var(--safe-b));
  background: rgba(18, 18, 20, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  overscroll-behavior: contain;
  animation: fade-in .2s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-height: 100%;
}

.overlay-inner img {
  max-width: 100%;
  max-height: 68vh;
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  -webkit-touch-callout: default;
}

.overlay-tip {
  margin: 20px 0 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.02em;
}

.overlay-close {
  margin-top: 18px;
  padding: 12px 44px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
}

.overlay-close:active {
  background: rgba(255, 255, 255, 0.24);
}
