/* ============================================================
   图灵 · 一句话改图 —— 极简前台样式
   方向：Brutally minimal 工具向
   · 暖纸白 #F7F5F0 / 墨色 #1B1813 / 单强调紫 #133E31（图灵品牌）
   · 全站 Google 非衬线体 Noto Sans SC（自托管，大陆直连无障碍）
   · 入场 stagger 编排；prefers-reduced-motion 全量降级
   ============================================================ */

/* ── 自托管 Noto Sans SC（OFL 许可）── */
@font-face {
  font-family: 'Noto Sans SC'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/noto-latin-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Sans SC'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/noto-latin-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Sans SC'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/noto-latin-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Sans SC'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/noto-chinese-simplified-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Noto Sans SC'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/noto-chinese-simplified-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Noto Sans SC'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/noto-chinese-simplified-700.woff2') format('woff2');
}

:root {
  --paper: #F7F5F0;
  --paper-deep: #EFECE4;
  --ink: #1B1813;
  --ink-60: rgba(27, 24, 19, .62);
  --ink-40: rgba(27, 24, 19, .40);
  --line: rgba(27, 24, 19, .16);
  --line-strong: rgba(27, 24, 19, .36);
  --accent: #133E31;
  --accent-deep: #0E2A21;
  --accent-ink: #FFFFFF;
  --ok: #1D7A46;
  --err: #C0392B;

  --font-display: 'Noto Sans SC', 'PingFang SC', 'HarmonyOS Sans SC', 'MiSans', sans-serif;
  --font-body: 'Noto Sans SC', 'PingFang SC', 'HarmonyOS Sans SC', 'MiSans', 'Microsoft YaHei', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Cascadia Mono', Menlo, monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-1: 0 1px 2px rgba(27, 24, 19, .05);
  --shadow-2: 0 8px 24px rgba(27, 24, 19, .08);
  --shadow-3: 0 24px 64px rgba(27, 24, 19, .12);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 160ms;
  --t-med: 320ms;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* 纸面颗粒 */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.05'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--accent); color: #fff; }

/* ── 顶栏 ─────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px clamp(20px, 5vw, 56px);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  text-decoration: none; color: var(--ink);
  font-family: var(--font-display);
  font-size: 24px; letter-spacing: .02em;
  display: flex; align-items: baseline; gap: 10px;
}
.wordmark-tuling { font-weight: 700; }
.wordmark-sep { color: var(--accent); font-weight: 400; }
.wordmark-sub {
  font-family: var(--font-body);
  font-size: 13px; letter-spacing: .32em; color: var(--ink-60);
}

.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-right[hidden] { display: none; }

.power-chip {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: transparent; color: var(--ink);
  padding: 7px 14px; cursor: pointer;
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.power-chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.power-chip-label { font-size: 12px; letter-spacing: .18em; color: var(--ink-60); }
.power-chip-num {
  font-family: var(--font-mono); font-size: 17px; font-weight: 700;
  color: var(--accent); min-width: 2ch; text-align: right;
}

/* ── 按钮 ─────────────────────────────── */
.btn {
  font-family: var(--font-body); font-size: 14px;
  border-radius: 999px; border: 1px solid transparent;
  padding: 10px 22px; cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out),
              background var(--t-fast), border-color var(--t-fast),
              box-shadow var(--t-fast), color var(--t-fast);
  min-height: 44px;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: var(--shadow-2);
}
.btn-primary:hover:not([disabled]) { background: var(--accent-deep); transform: translateY(-1px); }

.btn-outline { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover:not([disabled]) { border-color: var(--accent); color: var(--accent); }

.btn-ghost { background: transparent; color: var(--ink-60); border-color: transparent; }
.btn-ghost:hover { color: var(--ink); }

.btn-block { width: 100%; }

.linklike {
  background: none; border: 0; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--ink-60);
  text-decoration: underline; text-underline-offset: 4px;
  text-decoration-color: var(--line-strong);
  min-height: 44px; padding: 0 4px;
}
.linklike:hover { color: var(--accent); }

/* ── 页面骨架 ─────────────────────────── */
.page {
  flex: 1; width: 100%; max-width: 860px;
  margin: 0 auto; padding: clamp(28px, 6vh, 64px) clamp(20px, 5vw, 40px) 80px;
  position: relative; z-index: 1;
}

/* 入场编排：3 组 stagger */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}
.auth-card, .studio { animation: rise-in var(--t-med) var(--ease-out) both; }
.step:nth-of-type(1) { animation-delay: 60ms; }
.step { animation: rise-in var(--t-med) var(--ease-out) both; }
.step:nth-of-type(2) { animation-delay: 120ms; }
.generate-row { animation: rise-in var(--t-med) var(--ease-out) 180ms both; }

/* ── 登录卡 ───────────────────────────── */
.auth-card { max-width: 460px; margin: 0 auto; }

.auth-kicker {
  font-size: 12px; letter-spacing: .42em; color: var(--accent);
  text-transform: uppercase; margin-bottom: 18px;
  display: flex; align-items: center; gap: 12px;
}
.auth-kicker::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.auth-title {
  font-family: var(--font-display);
  font-size: clamp(34px, 6vw, 46px);
  line-height: 1.14; letter-spacing: -0.02em;
  margin-bottom: 14px;
}
.auth-title br + * { }

.auth-sub { color: var(--ink-60); font-size: 14.5px; margin-bottom: 34px; max-width: 40ch; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form[hidden] { display: none; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 12.5px; letter-spacing: .14em; color: var(--ink-60); }

.field-input {
  font: inherit; font-size: 15.5px;
  background: #FFFFFF;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 15px; color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  min-height: 48px;
}
.field-input::placeholder { color: var(--ink-40); }
.field-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

.field-row { display: flex; gap: 10px; align-items: flex-end; }
.field-row .field { flex: 1; }

.auth-links { display: flex; gap: 22px; justify-content: center; margin-top: 4px; }

/* ── 工作台步骤 ───────────────────────── */
.step { margin-bottom: 44px; }

.step-head {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.step-no {
  font-family: var(--font-mono); font-size: 13px; color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 6px; padding: 1px 7px;
}
.step-title {
  font-family: var(--font-display);
  font-size: 26px; letter-spacing: -0.01em; font-weight: 700;
}
.step-hint { font-size: 13px; color: var(--ink-40); }

/* 上传区 */
.dropzone {
  border: 1.6px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #FFFFFF;
  min-height: 220px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; position: relative; overflow: hidden;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow-1);
  outline: none;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, #fff);
  box-shadow: var(--shadow-2);
}
.dropzone.has-files { padding: 18px; justify-content: flex-start; }

.dropzone-icon { width: 46px; height: 46px; color: var(--accent); margin-bottom: 12px; }
.dropzone-text { font-size: 15.5px; font-weight: 600; }
.dropzone-sub { font-size: 12.5px; color: var(--ink-40); margin-top: 4px; }

.thumb-row { display: flex; gap: 12px; flex-wrap: wrap; width: 100%; }
.thumb {
  position: relative; width: 108px; height: 108px;
  border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--line); background: var(--paper-deep);
  animation: rise-in var(--t-fast) var(--ease-out) both;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x {
  position: absolute; top: 5px; right: 5px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: rgba(27, 24, 19, .78); color: #fff;
  font-size: 13px; line-height: 1;
  display: grid; place-items: center;
}
.thumb-x:hover { background: var(--err); }
.thumb-size {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-family: var(--font-mono); font-size: 10px;
  background: rgba(27, 24, 19, .62); color: #fff;
  text-align: center; padding: 2px 0;
}

/* 一句话输入 */
.prompt-box {
  width: 100%; resize: vertical; min-height: 108px;
  font-family: var(--font-body); font-size: 17px; line-height: 1.7;
  color: var(--ink); background: #FFFFFF;
  border: 1.6px solid var(--line-strong); border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.prompt-box::placeholder { color: var(--ink-40); font-size: 15.5px; }
.prompt-box:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }

.prompt-presets { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.preset {
  font-size: 12.5px; color: var(--ink-60);
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; padding: 6px 14px; cursor: pointer;
  transition: all var(--t-fast);
}
.preset:hover { border-color: var(--accent); color: var(--accent); }

/* 生成行 */
.generate-row {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  margin: 8px 0 52px;
}
.btn-generate {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 12px 44px; border-radius: var(--radius-sm);
}
.generate-label { font-size: 17px; font-weight: 700; letter-spacing: .06em; }
.generate-cost { font-family: var(--font-mono); font-size: 11.5px; opacity: .82; }
.generate-note { font-size: 12.5px; color: var(--ink-40); }

/* 结果 */
.results[hidden] { display: none; }
.results-head { margin-bottom: 16px; }
.results-title { font-family: var(--font-display); font-size: 22px; }

.result-list { display: flex; flex-direction: column; gap: 26px; }

.result-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #FFFFFF; overflow: hidden;
  box-shadow: var(--shadow-2);
  animation: rise-in var(--t-med) var(--ease-out) both;
}

.compare {
  position: relative; width: 100%; aspect-ratio: attr(data-ratio, 1 / 1);
  user-select: none; touch-action: none;
  background:
    repeating-conic-gradient(var(--paper-deep) 0% 25%, #FFFFFF 0% 50%) 0 0 / 22px 22px;
}
.compare img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; pointer-events: none;
}
.compare .img-after { clip-path: inset(0 0 0 var(--split, 50%)); }
.compare .img-before { clip-path: inset(0 calc(100% - var(--split, 50%)) 0 0); }

.compare-bar {
  position: absolute; top: 0; bottom: 0; left: var(--split, 50%);
  width: 2px; background: var(--accent); transform: translateX(-1px);
  pointer-events: none;
}
.compare-bar::after {
  content: '⇔';
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 18px;
  box-shadow: var(--shadow-2);
}
.compare-tags { position: absolute; top: 12px; left: 0; right: 0; display: flex; justify-content: space-between; padding: 0 14px; pointer-events: none; }
.compare-tag {
  font-size: 11px; letter-spacing: .18em;
  background: rgba(27, 24, 19, .72); color: #fff;
  border-radius: 5px; padding: 3px 9px;
}

.result-actions {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.result-meta { font-size: 12.5px; color: var(--ink-40); margin-right: auto; font-family: var(--font-mono); }

/* 历史 */
.history[hidden] { display: none; }
.history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.history-title { font-size: 13px; letter-spacing: .22em; color: var(--ink-60); }
.history-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.history-item {
  flex: 0 0 auto; width: 84px; height: 84px;
  border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--line); cursor: pointer;
  transition: transform var(--t-fast), border-color var(--t-fast);
  background: var(--paper-deep);
}
.history-item:hover { transform: translateY(-2px); border-color: var(--accent); }
.history-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── 弹层 ─────────────────────────────── */
.redeem-dialog {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  box-shadow: var(--shadow-3);
  padding: 30px; width: min(92vw, 400px);
}
.redeem-dialog::backdrop { background: rgba(27, 24, 19, .35); backdrop-filter: blur(3px); }
.redeem-title { font-family: var(--font-display); font-size: 22px; margin-bottom: 6px; }
.redeem-sub { font-size: 13px; color: var(--ink-60); margin-bottom: 20px; }
.redeem-input { width: 100%; margin-bottom: 18px; font-family: var(--font-mono); letter-spacing: .1em; text-transform: uppercase; }
.redeem-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Toast ────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 34px; z-index: 60;
  transform: translate(-50%, 20px);
  background: var(--ink); color: var(--paper);
  font-size: 14px; border-radius: 999px;
  padding: 12px 24px; box-shadow: var(--shadow-3);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
  max-width: min(88vw, 560px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--err); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* ── 页脚 ─────────────────────────────── */
.footer {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 18px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-40);
}
.footer-sep { color: var(--line-strong); }
#footerState { font-family: var(--font-mono); }

/* 加载中 */
@keyframes spin { to { transform: rotate(360deg); } }
.busy-ring {
  display: inline-block; width: 14px; height: 14px; vertical-align: -2px;
  border: 2px solid color-mix(in srgb, var(--paper) 40%, transparent);
  border-top-color: var(--paper); border-radius: 50%;
  animation: spin .8s linear infinite; margin-right: 6px;
}

/* ── 响应式 ───────────────────────────── */
@media (max-width: 560px) {
  .wordmark-sub { display: none; }
  .field-row { flex-direction: column; align-items: stretch; }
  .field-row .btn { width: 100%; }
  .btn-generate { width: 100%; }
  .topbar { padding: 14px 18px; }
}

/* ── 降级 ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
}

/* 顶栏 logo 图 */
.wordmark { align-items: center; }
.wordmark .brand-logo { width: 38px; height: 38px; border-radius: 9px; margin-right: 12px; flex: 0 0 auto; }

/* 品牌中英混排 */
.wordmark-cn {
  font-size: 15px; font-weight: 500; color: var(--ink-60);
  letter-spacing: .24em; margin-left: 2px;
}

/* 顶栏 logo 改用宽幅图形：保比例 */
.wordmark .brand-logo { width: auto; height: 34px; border-radius: 0; margin-right: 12px; }
