:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #17191f;
  --muted: #6d717d;
  --line: #e2e4e9;
  --accent: #6c5ce7;
  --accent-2: #8d80ef;
  --shadow: 0 22px 70px rgba(26, 25, 38, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }

.topbar {
  height: 72px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  gap: 42px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 20px; letter-spacing: -.04em; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; position: relative; overflow: hidden; }
.brand-mark::before { content:""; width: 18px; height: 14px; border-radius: 4px; background: #fff; transform: rotate(-6deg); }
.brand-mark span { position: absolute; width: 6px; height: 6px; right: 6px; top: 6px; border-radius: 50%; background: #ffd269; border: 2px solid var(--accent); }
.topnav { display: flex; height: 100%; gap: 8px; }
.nav-link { position: relative; border: 0; background: transparent; padding: 0 14px; font-size: 14px; font-weight: 650; color: var(--muted); cursor: pointer; }
.nav-link:hover, .nav-link.active { color: var(--text); }
.nav-link.active::after { content:""; position: absolute; bottom: 0; left: 14px; right: 14px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.privacy-chip { font-size: 13px; font-weight: 650; color: #3f7459; background: #eaf8f0; padding: 8px 12px; border-radius: 99px; }
.lock-dot { display: inline-grid; place-items: center; width: 17px; height: 17px; margin-right: 5px; border-radius: 50%; background: #4da976; color: #fff; font-size: 10px; }
.ghost-button { width: 36px; height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; cursor: pointer; }

.app-shell { width: min(1480px, calc(100% - 40px)); margin: 0 auto; }
.intro { padding: 54px 6px 34px; display: flex; align-items: end; justify-content: space-between; gap: 40px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(32px, 4vw, 54px); line-height: 1.08; letter-spacing: -.055em; }
h1 span { color: var(--accent); }
.intro > p { margin: 0 0 6px; max-width: 420px; color: var(--muted); line-height: 1.8; font-size: 15px; }

.workspace { height: clamp(650px, 72vh, 780px); min-height: 650px; display: grid; grid-template-columns: 84px 320px minmax(0, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); }
.sidebar { min-height: 0; overflow-y: auto; background: #181a20; color: #b7bac3; padding: 12px 10px; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin; }
.tool { border: 0; background: transparent; color: inherit; border-radius: 12px; min-height: 72px; display: grid; place-items: center; align-content: center; gap: 7px; font-size: 12px; cursor: pointer; }
.tool-icon { display: grid; place-items: center; width: 26px; height: 26px; font-weight: 750; font-size: 20px; }
.tool:hover { background: #24262d; color: #fff; }
.tool.active { background: var(--accent); color: #fff; }

.control-panel { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 26px 24px; border-right: 1px solid var(--line); }
.panel-head { display: flex; align-items: start; justify-content: space-between; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0 0 6px; font-size: 19px; letter-spacing: -.02em; }
.panel-head p { margin: 0; color: var(--muted); font-size: 12px; }
.reset-button { border: 0; background: transparent; color: var(--accent); font-size: 12px; font-weight: 700; cursor: pointer; padding: 4px; }
.panel-content { display: none; padding-top: 24px; }
.panel-content.active { display: block; }
.range-row { display: block; margin-bottom: 24px; }
.range-row.compact { margin-bottom: 20px; }
.range-row > span { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 13px; }
.range-row b { font-weight: 650; }
.range-row output { color: var(--muted); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 4px; accent-color: var(--accent); cursor: pointer; }
.field-label { display: block; margin-bottom: 11px; font-size: 12px; color: var(--muted); font-weight: 650; }
.preset-section { margin-top: 30px; }
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.preset { border: 1px solid transparent; padding: 5px 5px 8px; background: transparent; border-radius: 9px; font-size: 11px; cursor: pointer; }
.preset.active { border-color: var(--accent); color: var(--accent); }
.preset-preview { display: block; height: 42px; border-radius: 6px; margin-bottom: 6px; background: linear-gradient(140deg, #6a567a, #f5b37d 48%, #315b68); }
.preset-preview.vivid { filter: saturate(1.65) contrast(1.08); }
.preset-preview.soft { filter: brightness(1.1) saturate(.75); }
.preset-preview.mono { filter: grayscale(1); }
.instruction { color: var(--muted); line-height: 1.6; font-size: 13px; margin: 0 0 18px; }
.ratio-grid, .action-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-bottom: 24px; }
.shape-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 20px; }
.choice { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; min-height: 44px; cursor: pointer; font-size: 13px; }
.choice:hover, .choice.active { border-color: var(--accent); color: var(--accent); background: rgba(108,92,231,.05); }
.primary { border: 0; border-radius: 11px; background: var(--accent); color: #fff; padding: 13px 22px; font-weight: 750; cursor: pointer; box-shadow: 0 10px 24px rgba(108,92,231,.22); }
.primary:hover { background: var(--accent-2); }
.primary:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }
.wide { width: 100%; margin-top: 8px; }
.dimension-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; }
.dimension-row label { display: grid; grid-template-columns: 1fr auto; gap: 6px; color: var(--muted); font-size: 12px; }
.dimension-row label input { grid-column: 1; width: 100%; margin-top: 7px; }
.dimension-row label span { grid-column: 2; align-self: center; margin-top: 7px; }
.dimension-link { padding-bottom: 11px; color: var(--muted); }
.angle-entry { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; margin: -10px 0 12px; }
.angle-entry input { width: 100%; }
.angle-entry span { color: var(--muted); font-size: 13px; }
input[type="number"], input[type="text"], select { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 9px; min-height: 42px; padding: 0 11px; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,92,231,.11); }
.check-row { display: flex; align-items: center; gap: 8px; margin: 17px 0; font-size: 13px; }
.check-row input { accent-color: var(--accent); }
.text-field { display: grid; gap: 8px; margin-bottom: 20px; font-size: 12px; color: var(--muted); }
.live-hint { margin: -4px 0 20px; padding: 9px 11px; border-radius: 9px; background: rgba(72,163,111,.1); color: #397a55; font-size: 11px; line-height: 1.45; }
.live-hint span { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #48a36f; box-shadow: 0 0 0 4px rgba(72,163,111,.12); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.color-line { display: grid; grid-template-columns: 1fr 1.6fr; gap: 12px; margin-bottom: 20px; }
.color-line label { display: grid; gap: 8px; color: var(--muted); font-size: 12px; }
.color-line input[type="color"] { width: 100%; height: 42px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.check-row.inline { margin: 0; min-height: 42px; align-content: center; color: var(--text); }
.mosaic-note { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px; }
.mosaic-note b, .mosaic-note small { display: block; }
.mosaic-note b { margin-bottom: 4px; font-size: 13px; }
.mosaic-note small { color: var(--muted); line-height: 1.45; font-size: 11px; }
.mosaic-preview { flex: 0 0 42px; height: 42px; border-radius: 9px; background: conic-gradient(#545765 25%, #9599a8 0 50%, #686c79 0 75%, #b7bac5 0); background-size: 14px 14px; }

.canvas-stage { min-width: 0; min-height: 0; background: #e8e9ed; display: grid; grid-template-rows: 54px minmax(0, 1fr) 46px; position: relative; }
.canvas-topline, .canvas-footer { padding: 0 20px; display: flex; align-items: center; justify-content: space-between; color: #6b6e78; font-size: 12px; background: rgba(255,255,255,.5); }
.canvas-actions { display: flex; align-items: center; gap: 8px; }
.history-control { display: flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid rgba(0,0,0,.08); border-radius: 9px; background: rgba(255,255,255,.65); }
.history-control button { min-width: 56px; height: 26px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; color: #555966; font-size: 12px; }
.history-control button:hover:not(:disabled) { background: rgba(108,92,231,.09); color: var(--accent); }
.history-control button:disabled { opacity: .35; cursor: not-allowed; }
.zoom-control { display: flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid rgba(0,0,0,.08); border-radius: 9px; background: rgba(255,255,255,.65); }
.zoom-control button { width: 28px; height: 26px; border: 0; background: transparent; cursor: pointer; font-size: 16px; }
.zoom-control span { min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; }
.canvas-viewport { min-width: 0; min-height: 0; padding: 32px; overflow: auto; overscroll-behavior: contain; display: grid; place-items: center; background-color: #dedfe4; background-image: linear-gradient(45deg, #d6d7dc 25%, transparent 25%), linear-gradient(-45deg, #d6d7dc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d6d7dc 75%), linear-gradient(-45deg, transparent 75%, #d6d7dc 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; }
.empty-state { width: min(430px, 90%); min-height: 340px; border: 1px dashed #b9bbc4; border-radius: 18px; background: rgba(255,255,255,.76); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 34px; text-align: center; backdrop-filter: blur(4px); }
.upload-visual { width: 70px; height: 70px; border-radius: 20px; background: rgba(108,92,231,.1); display: grid; place-items: center; color: var(--accent); margin-bottom: 18px; }
.upload-visual span { width: 34px; height: 34px; border: 2px dashed currentColor; border-radius: 9px; display: grid; place-items: center; font-size: 20px; }
.empty-state h2 { margin: 0 0 8px; font-size: 22px; }
.empty-state p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.sample-button { margin-top: 13px; border: 0; background: transparent; color: var(--accent); font-size: 12px; cursor: pointer; }
.canvas-wrap { position: relative; transform-origin: center; box-shadow: 0 18px 50px rgba(0,0,0,.2); line-height: 0; user-select: none; }
#editorCanvas { display: block; max-width: none; cursor: default; }
.crop-box { position: absolute; border: 2px solid #fff; outline: 9999px solid rgba(11,12,16,.52); box-shadow: 0 0 0 1px rgba(0,0,0,.4); pointer-events: none; }
.crop-box.rounded { border-radius: 28px; }
.crop-box.circle { border-radius: 50%; }
.crop-box::before, .crop-box::after { content:""; position:absolute; inset: 33.333% 0 auto; border-top: 1px dashed rgba(255,255,255,.7); }
.crop-box::after { inset: 66.666% 0 auto; }
.canvas-footer button { border: 0; background: transparent; color: var(--accent); font-weight: 650; font-size: 12px; cursor: pointer; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #48a36f; }

.benefits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; padding: 52px 6px 66px; }
.benefits article { display: flex; gap: 18px; }
.benefits article > span { font-size: 12px; color: var(--accent); font-weight: 800; padding-top: 4px; }
.benefits h3 { margin: 0 0 8px; font-size: 16px; }
.benefits p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.native-ad { width: min(100%, 1160px); min-height: 110px; margin: 0 auto 34px; overflow: hidden; }
.ad-banner { width: 728px; min-height: 90px; margin: 34px auto; overflow: hidden; }
footer { border-top: 1px solid var(--line); padding: 24px max(20px, calc((100vw - 1480px) / 2)); display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 18px); opacity: 0; pointer-events: none; z-index: 50; background: #17191f; color: #fff; border-radius: 10px; padding: 11px 16px; font-size: 13px; transition: .22s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

body.dark { --bg:#111318; --surface:#1b1e25; --surface-2:#242730; --text:#f3f4f7; --muted:#9da1ad; --line:#30333d; --shadow:0 24px 80px rgba(0,0,0,.34); color-scheme:dark; }
body.dark .topbar { background: rgba(27,30,37,.9); }
body.dark .canvas-stage { background:#242730; }
body.dark .canvas-topline, body.dark .canvas-footer { background:rgba(27,30,37,.78); color:#a8abb5; }
body.dark .zoom-control, body.dark .history-control { background: rgba(27,30,37,.82); border-color: rgba(255,255,255,.09); }
body.dark .history-control button { color: #c8cad1; }
body.dark .empty-state { background:rgba(27,30,37,.86); }
body.dark .privacy-chip { background:#20382d; color:#83d4a6; }
body.dark .live-hint { background: rgba(72,163,111,.14); color: #83d4a6; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 72px 280px minmax(0,1fr); }
  .control-panel { padding: 22px 18px; }
  .topnav { display:none; }
  .canvas-viewport { min-height: 500px; padding: 20px; }
}
@media (max-width: 780px) {
  .ad-banner { display:none; }
  .native-ad { width: min(100% - 24px, 1160px); margin-bottom: 24px; }
  .topbar { height: 62px; padding: 0 16px; }
  .privacy-chip { display:none; }
  .app-shell { width: min(100% - 24px, 1480px); }
  .intro { padding: 34px 2px 24px; display:block; }
  .intro > p { margin-top:16px; }
  .workspace { height: auto; min-height: 0; grid-template-columns: 1fr; grid-template-rows: auto auto minmax(540px, auto); border-radius: 16px; }
  .sidebar { flex-direction: row; overflow-x:auto; padding:8px; }
  .tool { min-width:67px; min-height:58px; }
  .control-panel { overflow: visible; scrollbar-gutter: auto; border-right:0; border-bottom:1px solid var(--line); }
  .panel-content { padding-top:18px; }
  .canvas-stage { min-height:560px; }
  .canvas-viewport { min-height:460px; }
  .history-control button { min-width:34px; }
  .history-control button span { display:none; }
  .benefits { grid-template-columns:1fr; padding:38px 4px 50px; }
}
@media (max-width: 480px) {
  .brand { font-size:17px; }
  h1 { font-size:34px; }
  .intro > p br { display:none; }
  .canvas-viewport { padding:12px; }
  .empty-state { padding:22px 16px; }
  .preset-grid { grid-template-columns:repeat(2,1fr); }
  footer { gap:12px; flex-direction:column; }
}
