/* Image Cutout — full-screen editor. A slim top bar, then three panels (model · work area · result)
   that together fill exactly one viewport; the SEO guide and footer sit below the fold. */
:root {
  --bg: #efeafb; --bg-2: #f6f2ff; --card: #ffffff; --line: #e6dff7; --line-strong: #cfc2f2;
  --text: #2b2440; --muted: #7d739a; --faint: #a89fc4;
  --accent: #7c5cff; --accent-2: #a78bfa; --accent-soft: #efe9ff; --accent-deep: #5b3fe0;
  --pos: #22c55e; --pos-soft: #e8f9ee; --neg: #ef4444; --neg-soft: #fdecec;
  --shadow: 0 8px 28px rgba(92, 64, 190, .10), 0 1px 2px rgba(92, 64, 190, .06);
  --radius: 14px; --radius-sm: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text); background: radial-gradient(1200px 700px at 20% -10%, #f9f6ff 0%, var(--bg) 60%, #ebe4fa 100%) fixed;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ===== app shell: exactly one viewport tall; panels fill it, nothing inside scrolls the page ===== */
.app { height: 100vh; height: 100dvh; min-height: 520px; display: flex; flex-direction: column; }
.topbar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 6px 14px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { width: 24px; height: 24px; }
.brand-name { font-weight: 700; letter-spacing: .2px; }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.ghost-btn { border: 1px solid var(--line-strong); background: transparent; border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--accent-deep); }
.ghost-btn:hover { background: var(--accent-soft); }
.top-link { color: var(--muted); }
.lang-select { border: 1px solid var(--line-strong); background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235b3fe0'/%3E%3C/svg%3E") no-repeat right 9px center; border-radius: 999px; padding: 3px 24px 3px 10px; font: inherit; font-size: 12px; color: var(--accent-deep); appearance: none; -webkit-appearance: none; max-width: 150px; cursor: pointer; }
.lang-select:hover { background-color: var(--accent-soft); }
.seo-langs { font-size: 13px; line-height: 2; color: var(--muted); margin: 0 0 8px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 6px 16px 14px; }
.footer a { margin: 0 2px; }

/* ===== workspace grid: tool panel · work area · result, all the remaining height ===== */
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 200px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 0 8px 8px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.8); padding: 10px 12px; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.card-side { overflow: auto; scrollbar-width: thin; }   /* the tool panel may scroll on a short viewport; the stages never do */
.card-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head-sub { margin-top: 14px; }
.card-title { margin: 0; font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 7px; }
.card-title::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); flex: none; }
.status-inline { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot-idle { background: var(--faint); } .dot-busy { background: #f59e0b; animation: pulse 1s infinite; } .dot-ok { background: var(--pos); } .dot-err { background: var(--neg); }
@keyframes pulse { 50% { opacity: .35; } }

/* ===== model options (left panel) ===== */
.model-list { display: flex; flex-direction: column; gap: 6px; }
.model-opt { display: flex; flex-direction: column; gap: 2px; text-align: left; border: 1px solid var(--line); background: #faf8ff; border-radius: 12px; padding: 7px 10px; color: var(--text); }
.model-opt:hover { border-color: var(--accent-2); }
.model-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.model-opt.is-active { border-color: var(--accent); background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); color: #fff; box-shadow: 0 6px 16px rgba(124, 92, 255, .32); }
.model-opt-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.model-opt-name { font-weight: 700; font-size: 12px; letter-spacing: .1px; }
.model-tag { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-deep); flex: none; }
.model-tag-quality { background: #fff1dc; color: #b45309; }
.model-opt.is-active .model-tag { background: rgba(255,255,255,.24); color: #fff; }
.model-opt-desc { font-size: 10.5px; color: var(--muted); line-height: 1.35; }
.model-opt-meta { font-size: 10.5px; color: var(--accent-deep); font-weight: 600; line-height: 1.35; }
.model-opt.is-active .model-opt-desc, .model-opt.is-active .model-opt-meta { color: rgba(255,255,255,.9); }
.model-opt.is-ready:not(.is-active) .model-opt-meta::before { content: "✓ "; color: var(--pos); }
.model-opt.is-unavailable { opacity: .55; cursor: not-allowed; }
.model-more { display: inline-block; font-size: 10.5px; margin-top: 6px; color: var(--muted); }
.progress { position: relative; height: 18px; margin-top: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; flex: none; }
.progress-bar { position: absolute; inset: 0 auto 0 0; width: 0%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .2s; }
.progress-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10.5px; color: var(--accent-deep); font-weight: 600; }
.device-row { margin-top: 8px; }
.device-badge { font-size: 10.5px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 999px; padding: 2px 8px; }
.device-badge.is-gpu { color: var(--accent-deep); border-style: solid; background: var(--accent-soft); }

.mode-group { display: flex; flex-direction: column; gap: 6px; }
.mode-btn { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #faf8ff; border-radius: 999px; padding: 6px 11px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; }
.mode-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.mode-pos .mode-dot { background: var(--pos); } .mode-neg .mode-dot { background: var(--neg); }
.mode-pos.is-active { background: var(--pos); border-color: var(--pos); color: #fff; box-shadow: 0 6px 14px rgba(34,197,94,.3); }
.mode-pos.is-active .mode-dot { background: #fff; }
.mode-neg.is-active { background: var(--neg); border-color: var(--neg); color: #fff; box-shadow: 0 6px 14px rgba(239,68,68,.3); }
.mode-neg.is-active .mode-dot { background: #fff; }

.action-row { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.pill-btn { border: 1px solid var(--line-strong); background: #fff; color: var(--accent-deep); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600; }
.pill-btn:hover:not(:disabled) { background: var(--accent-soft); }
.pill-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill-primary:hover:not(:disabled) { background: var(--accent-deep); }
.pill-small { padding: 4px 10px; font-size: 11.5px; }

.stats { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 12px 0 0; padding: 0; font-size: 11px; color: var(--muted); }
.stats div { display: flex; gap: 4px; }
.stats dt { margin: 0; } .stats dd { margin: 0; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.embed-card { margin-top: 12px; border: 1.5px dashed var(--accent-2); border-radius: var(--radius-sm); padding: 9px 11px; background: #fbf9ff; font-size: 11px; color: var(--accent-deep); min-height: 58px; flex: none; }
.embed-line { font-weight: 600; line-height: 1.4; word-break: break-word; }
.embed-line.is-ok::before { content: "✓ "; color: var(--pos); }
.embed-hint { color: var(--muted); margin-top: 5px; }
.guide-link { display: block; margin-top: auto; padding-top: 12px; font-size: 11px; color: var(--muted); text-align: center; }

/* ===== center panel: the work area fills its panel; the photo is fitted into it by JS (fitBox) ===== */
.work-tools { display: flex; gap: 6px; align-items: center; }
.work-hint { flex: none; margin: -4px 0 8px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.t-pos { color: #16a34a; font-weight: 600; } .t-neg { color: #dc2626; font-weight: 600; }
.stage { position: relative; flex: 1; min-height: 0; border-radius: var(--radius-sm); background: var(--bg-2); overflow: hidden; }
.stage.is-dragover { outline: 2px dashed var(--accent); outline-offset: -6px; }
.stage-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--muted); }
.stage-empty-title { margin: 0 0 6px; font-weight: 600; color: var(--text); }
.stage-empty-sub { margin: 0 0 10px; font-size: 12px; }
.demo-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.demo-thumb { width: 96px; height: 64px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; padding: 0; background: #ddd; }
.demo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.demo-thumb:hover, .demo-thumb:focus-visible { border-color: var(--accent); outline: none; }
.canvas-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; touch-action: none; }
.canvas-box { position: relative; line-height: 0; touch-action: none; border-radius: 4px; overflow: hidden; box-shadow: 0 10px 30px rgba(92, 64, 190, .18);
  transform-origin: center center; will-change: transform; flex: none; }
.canvas-box.is-pannable { cursor: grab; }
.canvas-box.is-pannable.is-panning { cursor: grabbing; }
.canvas-box.is-pannable #canvas-overlay { cursor: grab; }
.canvas-box.is-pannable.is-panning #canvas-overlay { cursor: grabbing; }
.canvas-box canvas { display: block; width: 100%; height: 100%; }
#canvas-overlay { position: absolute; inset: 0; cursor: crosshair; }
#canvas-overlay.is-neg { cursor: not-allowed; }
.stage-busy { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 12px; color: var(--accent-deep); box-shadow: var(--shadow); white-space: nowrap; z-index: 2; }
.spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== right panel: the result fills its panel on a checkerboard (object-fit keeps the aspect) ===== */
.bg-bar { flex: none; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin: -2px 0 8px; }
.bg-label { font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-right: 2px; }
.bg-presets { display: contents; }
.bg-swatch { width: 26px; height: 26px; border-radius: 8px; border: 2px solid transparent; padding: 0; background: none; display: inline-flex; align-items: center; justify-content: center; position: relative; cursor: pointer; }
.bg-swatch:hover { border-color: var(--accent-2); }
.bg-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.bg-swatch.is-active { border-color: var(--accent); box-shadow: 0 0 0 1.5px #fff inset; }
.sw { display: block; width: 100%; height: 100%; border-radius: 5px; border: 1px solid rgba(43,36,64,.12); }
.sw-checker { background-color: #fff; background-image: linear-gradient(45deg, #d9d3ea 25%, transparent 25%), linear-gradient(-45deg, #d9d3ea 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d9d3ea 75%), linear-gradient(-45deg, transparent 75%, #d9d3ea 75%); background-size: 8px 8px; background-position: 0 0, 0 4px, 4px -4px, -4px 0; }
.sw-white { background: #fff; }
.sw-blur { background: radial-gradient(circle at 35% 35%, #fff 0, #c9bffb 35%, #7c5cff 70%, #4c3ab5 100%); filter: blur(1.2px); }
.sw-picker { background: conic-gradient(#f87171, #fbbf24, #4ade80, #38bdf8, #a78bfa, #f87171); }
.bg-swatch-color input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.sw-upload { display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: var(--accent-deep); background: var(--accent-soft); border-style: dashed; border-color: var(--accent-2); background-size: cover; background-position: center; }
.sw-upload.has-image { color: transparent; border-style: solid; }
.checker { position: relative; flex: 1; min-height: 0; border-radius: var(--radius-sm); overflow: hidden;
  background-color: #fff; background-image: linear-gradient(45deg, #e9e5f3 25%, transparent 25%), linear-gradient(-45deg, #e9e5f3 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e9e5f3 75%), linear-gradient(-45deg, transparent 75%, #e9e5f3 75%);
  background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0; }
.result-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; color: var(--faint); font-size: 12px; line-height: 1.7; }
.result-empty p { margin: 0; }
#canvas-result { display: block; width: 100%; height: 100%; }
.result-box { box-shadow: 0 8px 24px rgba(92, 64, 190, .16); }

/* ===== zoom bar (work area + result) ===== */
.zoombar { position: absolute; right: 10px; bottom: 10px; z-index: 3; display: flex; align-items: center; gap: 2px;
  background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 999px; padding: 3px 4px; box-shadow: var(--shadow); }
.zoom-btn { border: 0; background: transparent; color: var(--accent-deep); border-radius: 999px; min-width: 24px; height: 24px; padding: 0 6px;
  font-size: 14px; font-weight: 700; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.zoom-btn:hover:not(:disabled) { background: var(--accent-soft); }
.zoom-btn:disabled { opacity: .35; }
.zoom-btn.zoom-reset { font-size: 11px; font-weight: 700; letter-spacing: .2px; padding: 0 9px; }
.zoom-pct { font-size: 11px; font-weight: 700; color: var(--muted); min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .zoombar { right: 8px; bottom: 8px; } .zoom-pct { min-width: 36px; } }

/* toast + drop overlay */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #2b2440; color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 12.5px; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 30; }
.page-drop { position: fixed; inset: 0; pointer-events: none; display: none; background: rgba(124, 92, 255, .08); border: 3px dashed var(--accent); z-index: 20; }
body.is-dragging .page-drop { display: block; }

/* responsive: two rows on medium screens, a stacked page on phones */
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 190px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .card-result { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .app { height: auto; min-height: 0; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: none; padding: 0 8px 8px; }
  .card-side { order: 1; overflow: visible; } .card-work { order: 0; } .card-result { order: 2; }
  .stage { flex: none; height: 58vh; } .checker { flex: none; height: 46vh; }
  .mode-group { flex-direction: row; } .mode-btn { flex: 1; justify-content: center; }
  .guide-link { margin-top: 12px; }
  .topbar { padding: 6px 10px; } .top-link { display: none; }
}
@media (max-width: 480px) { .badge-privacy { display: none; } .topbar-actions { gap: 8px; } .bg-label { display: none; } }
@media (max-height: 640px) and (min-width: 721px) { .work-hint { display: none; } .card-head-sub { margin-top: 8px; } }
@media (prefers-reduced-motion: reduce) { .spinner, .dot-busy { animation: none; } }

/* ===== top-bar accent + count badge ===== */
.ghost-btn-accent { background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent-deep); font-weight: 600; }
.ghost-btn-accent:hover { background: #e7dfff; }
.count-badge { display: inline-block; min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px; margin-left: 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; text-align: center; vertical-align: 1px; }

/* ===== Design canvas overlay ===== */
.compose { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: rgba(43, 36, 64, .55); backdrop-filter: blur(3px); }
.compose-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 10px 16px; background: var(--card); box-shadow: var(--shadow); }
.compose-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.compose-actions { margin-left: auto; }
.compose-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-right: 2px; }
.chip { border: 1px solid var(--line-strong); background: #fff; color: var(--text); border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.chip:hover { background: var(--accent-soft); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-color { padding: 3px 10px 3px 6px; cursor: pointer; }
.chip-color input[type="color"] { width: 20px; height: 20px; border: none; background: none; padding: 0; border-radius: 5px; cursor: pointer; }
.chip-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.chip-color input[type="color"]::-webkit-color-swatch { border: 1px solid var(--line-strong); border-radius: 5px; }
.compose-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 18px; }
.compose-empty { text-align: center; color: #efeafb; max-width: 360px; }
.compose-empty p:first-child { font-weight: 700; font-size: 16px; margin: 0 0 6px; }
.compose-empty p:last-child { font-size: 13px; color: #cfc6ea; margin: 0; }
#compose-canvas { max-width: 100%; max-height: calc(100vh - 130px); width: auto; height: auto; border-radius: 8px; box-shadow: 0 12px 40px rgba(0,0,0,.4); touch-action: none; cursor: default; background: #fff; }
#compose-canvas.bg-transparent { background-color: #fff; background-image: linear-gradient(45deg, #e9e5f3 25%, transparent 25%), linear-gradient(-45deg, #e9e5f3 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e9e5f3 75%), linear-gradient(-45deg, transparent 75%, #e9e5f3 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; }
.compose-hint { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); margin: 0; font-size: 11.5px; color: #efeafb; background: rgba(43,36,64,.6); padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
@media (max-width: 720px) { .compose-actions { margin-left: 0; } .compose-hint { display: none; } .compose-label { display: none; } }

/* ===== SEO content section (below the tool) ===== */
.seo { max-width: 860px; margin: 8px auto 0; padding: 22px 20px 8px; color: var(--text); }
.seo h1 { font-size: 26px; line-height: 1.25; margin: 0 0 12px; letter-spacing: -.2px; }
.seo h2 { font-size: 18px; margin: 26px 0 8px; color: var(--accent-deep); }
.seo-lead { font-size: 15px; line-height: 1.7; color: #4a4363; margin: 0; }
.seo-steps, .seo-uses { padding-left: 20px; line-height: 1.65; }
.seo-steps li, .seo-uses li { margin: 6px 0; }
.seo-faq { display: flex; flex-direction: column; gap: 8px; }
.seo-faq details { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); padding: 2px 14px; }
.seo-faq summary { cursor: pointer; font-weight: 600; padding: 10px 0; list-style: none; }
.seo-faq summary::-webkit-details-marker { display: none; }
.seo-faq summary::before { content: "＋"; color: var(--accent); font-weight: 700; margin-right: 8px; }
.seo-faq details[open] summary::before { content: "－"; }
.seo-faq p { margin: 0 0 12px; color: #4a4363; line-height: 1.6; }
.seo-more { font-size: 13px; color: var(--muted); margin: 22px 0 4px; }
