:root {
  --ink: #171716;
  --muted: #6f706d;
  --line: #dddcd5;
  --paper: #f4f1e9;
  --card: #fffdfa;
  --accent: #d34040;
  --accent-dark: #a92d2d;
  --lime: #d7f238;
  --shadow: 0 24px 70px rgba(54, 48, 37, 0.12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 2%, rgba(215, 242, 56, 0.18), transparent 23rem),
    linear-gradient(180deg, #f8f6ef 0%, var(--paper) 100%);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

.topbar {
  height: 72px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(23, 23, 22, 0.1);
  background: rgba(248, 246, 239, 0.82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--paper);
  background: var(--ink);
}
.brand-mark svg { width: 22px; height: 22px; }

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(23, 23, 22, 0.1);
  border-radius: 999px;
  color: #555650;
  background: rgba(255, 255, 255, 0.55);
  font-size: 12px;
}
.privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: #46a75a; box-shadow: 0 0 0 3px rgba(70, 167, 90, 0.12); }

.app-shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 58px 0 56px; }

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 48px;
  align-items: end;
  margin-bottom: 38px;
}

.eyebrow { grid-column: 1 / -1; margin: 0 0 -28px; font-size: 11px; font-weight: 800; letter-spacing: 0.2em; color: var(--accent); }
.intro h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(40px, 5vw, 72px); font-weight: 500; line-height: 0.98; letter-spacing: -0.055em; }
.intro h1 em { color: var(--accent); font-style: italic; font-weight: 500; }
.intro-copy { margin: 0 0 5px; max-width: 540px; color: var(--muted); font-size: 16px; line-height: 1.8; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 350px; min-height: 660px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255, 253, 250, 0.76); box-shadow: var(--shadow); overflow: hidden; }
.editor-card { min-width: 0; padding: 22px; background: #ebe9e2; border-right: 1px solid var(--line); }
.upload-view { height: 100%; min-height: 614px; }
.drop-zone { height: 100%; min-height: 614px; padding: 32px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 13px; border: 1.5px dashed #b8b6ad; border-radius: 18px; background: rgba(255,255,255,0.56); cursor: pointer; transition: .25s ease; text-align: center; }
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: #fffdf8; transform: translateY(-2px); }
.drop-zone strong { font-size: 20px; letter-spacing: -0.02em; }
.drop-zone > span:not(.upload-icon):not(.select-button) { color: var(--muted); font-size: 13px; }
.upload-icon { width: 64px; height: 64px; margin-bottom: 6px; display: grid; place-items: center; border-radius: 20px; background: var(--lime); color: var(--ink); transform: rotate(-4deg); }
.upload-icon svg { width: 30px; height: 30px; }
.select-button { margin-top: 8px; padding: 11px 20px; border: 0; border-radius: 999px; color: #fff; background: var(--ink); font-size: 13px; font-weight: 700; cursor: pointer; }
.file-input-hidden { width: 1px; height: 1px; position: absolute; overflow: hidden; opacity: 0; pointer-events: none; }

.preview-view { height: 100%; min-height: 614px; display: flex; flex-direction: column; }
.file-toolbar { min-height: 58px; padding: 0 4px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.file-meta { min-width: 0; display: flex; align-items: center; gap: 11px; }
.file-meta > div { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.file-meta strong { max-width: 440px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.file-meta span:not(.file-badge) { color: var(--muted); font-size: 11px; }
.file-badge { flex: none; min-width: 45px; padding: 8px 7px; border-radius: 8px; color: white; background: var(--accent); font-size: 10px; font-weight: 800; text-align: center; }
.ghost-button, .text-button { border: 0; background: transparent; cursor: pointer; }
.ghost-button { padding: 8px 12px; border: 1px solid #cfcdc5; border-radius: 9px; color: #555650; font-size: 12px; }
.ghost-button:hover { border-color: var(--ink); color: var(--ink); }

.preview-scroll { flex: 1; min-height: 0; display: grid; place-items: center; padding: 24px; border-radius: 14px; overflow: auto; background-color: #d8d5cc; background-image: linear-gradient(45deg, rgba(255,255,255,.23) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.23) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.23) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.23) 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0px; }
.preview-stage { position: relative; flex: none; line-height: 0; box-shadow: 0 12px 35px rgba(32, 30, 25, .22); background: white; overflow: hidden; touch-action: none; }
.preview-stage canvas { display: block; max-width: 100%; height: auto; }
.watermark-overlay { position: absolute; left: 4%; top: 4%; z-index: 2; color: var(--accent); font-family: Helvetica, Arial, "PingFang SC", sans-serif; font-size: 32px; font-weight: 700; line-height: 1.12; opacity: .72; white-space: nowrap; cursor: grab; user-select: none; transform-origin: left top; will-change: left, top, transform; }
.watermark-overlay:active { cursor: grabbing; }
.watermark-overlay:focus-visible { outline: 2px solid var(--lime); outline-offset: 4px; }
.page-nav { padding: 14px 0 0; display: flex; justify-content: center; align-items: center; gap: 14px; color: #5d5e59; font-size: 12px; }
.page-nav button { width: 31px; height: 31px; border: 1px solid #cac8bf; border-radius: 50%; background: rgba(255,255,255,.55); cursor: pointer; }
.page-nav button:disabled { opacity: .35; cursor: not-allowed; }

.control-panel { padding: 25px 25px 22px; background: var(--card); }
.panel-heading { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; font-size: 17px; font-weight: 800; }
.text-button { padding: 0; color: var(--muted); font-size: 11px; }
.text-button:hover { color: var(--accent); }
.control-group { min-width: 0; margin-bottom: 21px; }
.control-group label { margin-bottom: 9px; display: flex; justify-content: space-between; color: #53544f; font-size: 12px; font-weight: 650; }
.control-group output { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
#watermarkText { width: 100%; height: 44px; padding: 0 13px; border: 1px solid #d7d5cd; border-radius: 9px; outline: none; color: var(--ink); background: #fff; }
#watermarkText:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23,23,22,.06); }
.control-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

input[type="range"] { width: 100%; height: 4px; margin: 7px 0; border-radius: 999px; accent-color: var(--accent); cursor: pointer; }
.color-input-wrap { height: 34px; padding: 4px 8px 4px 5px; display: flex; align-items: center; gap: 7px; border: 1px solid #d7d5cd; border-radius: 8px; background: white; }
input[type="color"] { width: 27px; height: 25px; padding: 0; border: 0; border-radius: 6px; background: none; cursor: pointer; overflow: hidden; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.color-input-wrap span { color: #656660; font-size: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.divider { height: 1px; margin: 3px 0 21px; background: #e6e4dd; }
.position-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.position-grid button { aspect-ratio: 1; padding: 0; position: relative; border: 1px solid #d8d6ce; border-radius: 7px; background: #fff; cursor: pointer; }
.position-grid button:hover, .position-grid button.active { border-color: var(--ink); background: var(--ink); }
.position-grid button span { width: 5px; height: 5px; position: absolute; border-radius: 50%; background: #797a74; }
.position-grid button:hover span, .position-grid button.active span { background: var(--lime); }
[data-position="top-left"] span { top: 6px; left: 6px; }
[data-position="top-center"] span { top: 6px; left: calc(50% - 2.5px); }
[data-position="top-right"] span { top: 6px; right: 6px; }
[data-position="center"] span { top: calc(50% - 2.5px); left: calc(50% - 2.5px); }
[data-position="bottom-left"] span { bottom: 6px; left: 6px; }
[data-position="bottom-center"] span { bottom: 6px; left: calc(50% - 2.5px); }
[data-position="bottom-right"] span { bottom: 6px; right: 6px; }
.drag-hint { margin: -4px 0 21px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.drag-hint svg { width: 17px; height: 17px; }
.export-button { width: 100%; height: 50px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border: 0; border-radius: 12px; color: white; background: var(--ink); font-weight: 750; cursor: pointer; transition: .2s ease; }
.export-button:not(:disabled):hover { background: var(--accent); transform: translateY(-1px); box-shadow: 0 9px 20px rgba(211,64,64,.22); }
.export-button:disabled { opacity: .34; cursor: not-allowed; }
.export-button svg { width: 20px; height: 20px; }
.export-hint { margin: 10px 0 0; color: #8a8b85; font-size: 10px; text-align: center; }

.feature-strip { margin-top: 22px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.42); }
.feature-strip div { padding: 20px 24px; display: flex; flex-direction: column; gap: 5px; }
.feature-strip div + div { border-left: 1px solid var(--line); }
.feature-strip strong { font-size: 13px; }
.feature-strip span { color: var(--muted); font-size: 11px; }

.toast { max-width: min(420px, calc(100% - 32px)); padding: 12px 16px; position: fixed; left: 50%; bottom: 24px; z-index: 100; border-radius: 10px; color: white; background: #222; box-shadow: 0 12px 30px rgba(0,0,0,.2); font-size: 13px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #a52d2d; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .editor-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .control-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
  .panel-heading, .divider, .drag-hint, .export-button, .export-hint { grid-column: 1 / -1; }
  .control-row { gap: 14px; }
}

@media (max-width: 680px) {
  .topbar { height: 62px; padding: 0 16px; }
  .privacy-pill { padding: 7px 9px; font-size: 10px; }
  .app-shell { width: min(100% - 24px, 1440px); padding-top: 36px; }
  .intro { grid-template-columns: 1fr; gap: 18px; }
  .eyebrow { margin: 0 0 -4px; }
  .intro-copy { font-size: 14px; }
  .workspace { border-radius: 18px; }
  .editor-card { padding: 12px; }
  .upload-view, .drop-zone, .preview-view { min-height: 480px; }
  .preview-scroll { padding: 12px; }
  .file-meta strong { max-width: 190px; }
  .control-panel { padding: 22px 18px; display: block; }
  .feature-strip { grid-template-columns: 1fr; }
  .feature-strip div + div { border-left: 0; border-top: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
