:root {
  --grid-ink: #17171a;
  --grid-muted: #6f7077;
  --grid-paper: #f8f7f3;
  --grid-card: #fff;
  --grid-line: #e6e3dc;
  --grid-blue: #315cff;
  --grid-blue-dark: #244bd9;
  --grid-blue-soft: #edf2ff;
  --grid-green: #177a55;
  --grid-shadow: 0 18px 48px rgba(30, 50, 90, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--grid-ink);
  background:
    radial-gradient(circle at 8% 20%, rgba(203, 222, 255, .5), transparent 20rem),
    radial-gradient(circle at 90% 8%, rgba(218, 229, 255, .55), transparent 19rem),
    var(--grid-paper);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Helvetica Neue", "Noto Sans SC", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { touch-action: manipulation; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.wrap { width: min(1200px, calc(100% - 32px)); margin: 0 auto; }
.top { position: sticky; top: 0; z-index: 20; }
.nav { display: flex; min-height: 56px; align-items: center; justify-content: space-between; gap: 20px; }
.navlinks { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.navlinks a { padding: 8px 11px; border-radius: 9px; color: var(--grid-muted); text-decoration: none; }
.navlinks .lang { font-weight: 700; color: var(--grid-ink); }

.hero { padding: clamp(40px, 6vw, 66px) 0 34px; text-align: center; }
.hero h1 { margin: 0; font-size: clamp(38px, 6vw, 62px); line-height: 1.06; letter-spacing: -.055em; }
.hero p { max-width: 760px; margin: 16px auto 0; color: var(--grid-muted); font-size: clamp(16px, 2vw, 18px); line-height: 1.7; }
.trust-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 23px; }
.trust-tag { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid #e5e7ec; border-radius: 999px; background: rgba(255,255,255,.74); color: #556070; font-size: 13px; }
.trust-tag b { color: var(--grid-green); font-size: 14px; }

.workspace { margin: 0 auto 56px; border: 1px solid var(--grid-line); border-radius: 24px; background: rgba(255,255,255,.94); box-shadow: var(--grid-shadow); overflow: hidden; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr); }
.editor-side, .result-side { min-width: 0; padding: 28px; }
.editor-side { border-right: 1px solid var(--grid-line); }
.section-title { display: flex; align-items: center; gap: 9px; margin: 0 0 16px; font-size: 18px; letter-spacing: -.02em; }
.section-number { display: inline-grid; width: 25px; height: 25px; place-items: center; border-radius: 8px; background: var(--grid-blue-soft); color: var(--grid-blue); font-size: 13px; }

.upload-zone { display: grid; min-height: 150px; place-items: center; padding: 24px; border: 1.5px dashed #b9cdfb; border-radius: 17px; background: linear-gradient(135deg, #fbfdff, #f5f8ff); text-align: center; transition: .18s ease; }
.upload-zone.is-dragging { border-color: var(--grid-blue); background: #edf3ff; transform: scale(.995); }
.upload-zone.is-hidden { display: none; }
.upload-icon { display: grid; width: 42px; height: 42px; place-items: center; margin: 0 auto 8px; border-radius: 12px; background: var(--grid-blue-soft); color: var(--grid-blue); font-size: 23px; }
.upload-zone h2 { margin: 0; font-size: 18px; }
.upload-zone p, .upload-formats { margin: 5px 0 14px; color: var(--grid-muted); font-size: 14px; }
.upload-formats { margin: 11px 0 0; font-size: 12px; }
.primary-button, .secondary-button, .ghost-button, .tile-download {
  border: 0; border-radius: 11px; font-weight: 750; cursor: pointer; transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.primary-button { padding: 12px 18px; color: #fff; background: var(--grid-blue); box-shadow: 0 7px 17px rgba(49, 92, 255, .22); }
.primary-button:hover { background: var(--grid-blue-dark); transform: translateY(-1px); }
.secondary-button { padding: 12px 16px; color: var(--grid-blue); background: #fff; border: 1px solid #b8c9f7; }
.secondary-button:hover { background: #f4f7ff; }
.ghost-button { padding: 9px 11px; color: #596475; background: #fff; border: 1px solid var(--grid-line); }
.ghost-button:hover { color: var(--grid-blue); border-color: #b8c9f7; }
.primary-button:disabled, .secondary-button:disabled, .tile-download:disabled { cursor: not-allowed; opacity: .55; transform: none; }

.editor-shell { display: none; }
.editor-shell.is-visible { display: block; }
.editor-canvas-wrap { position: relative; display: flex; width: fit-content; max-width: 100%; margin-inline: auto; overflow: hidden; border-radius: 16px; background: #e9edf4; box-shadow: inset 0 0 0 1px rgba(50, 68, 94, .08); }
.editor-canvas-wrap.is-drop-target { box-shadow: inset 0 0 0 2px var(--grid-blue); }
#editorCanvas { display: block; max-width: 100%; height: auto; cursor: default; }
#editorCanvas.is-pannable { cursor: grab; touch-action: none; }
#editorCanvas.is-view-dragging { cursor: grabbing; }
.divider-hit-layer { position: absolute; inset: 0; pointer-events: none; }
.divider-hit-target { position: absolute; z-index: 2; pointer-events: auto; touch-action: none; }
.divider-hit-target--vertical { cursor: col-resize; }
.divider-hit-target--horizontal { cursor: row-resize; }
.divider-hit-target.is-dragging { background: rgba(49, 92, 255, .08); }
.editor-help { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; color: var(--grid-muted); font-size: 12px; }
.editor-controls { display: flex; align-items: center; gap: 9px; }
.editor-controls label { display: flex; align-items: center; gap: 7px; }
.editor-controls input { width: 112px; accent-color: var(--grid-blue); }
.zoom-output { min-width: 39px; color: var(--grid-ink); font-variant-numeric: tabular-nums; }
.image-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.image-meta { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--grid-muted); font-size: 12px; }
.image-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.image-actions .ghost-button { padding: 7px 9px; font-size: 12px; }
.image-remove-button { color: #68717d; }

.preset-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; }
.preset-card { min-height: 102px; padding: 10px 6px; border: 1px solid #e5e8ef; border-radius: 13px; color: #526074; background: #fff; cursor: pointer; text-align: center; transition: .16s ease; }
.preset-card:hover { border-color: #aabefb; background: #f8faff; }
.preset-card.is-active { border-color: var(--grid-blue); color: var(--grid-blue); box-shadow: 0 0 0 2px rgba(49, 92, 255, .1); background: #f8faff; }
.preset-symbol { display: grid; width: 30px; height: 30px; margin: 0 auto 7px; place-items: center; }
.preset-symbol svg { width: 30px; height: 30px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.preset-card strong { display: block; color: var(--grid-ink); font-size: 13px; }
.preset-card small { display: block; margin-top: 2px; color: var(--grid-muted); font-size: 11px; }
.custom-controls { display: none; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; padding: 12px; border-radius: 13px; background: #f6f8fc; }
.custom-controls.is-visible { display: grid; }
.custom-controls label { color: #566174; font-size: 12px; font-weight: 700; }
.custom-controls input { width: 100%; margin-top: 6px; padding: 9px; border: 1px solid #d7dfea; border-radius: 9px; background: #fff; color: var(--grid-ink); }

.preview-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-top: 28px; }
.preview-head .section-title { margin-bottom: 4px; }
.preview-summary { color: var(--grid-muted); font-size: 12px; text-align: right; }
.preview-empty { display: grid; min-height: 176px; place-items: center; margin-top: 14px; border: 1px dashed #d7dce5; border-radius: 15px; color: var(--grid-muted); font-size: 13px; text-align: center; }
.preview-grid { display: none; grid-template-columns: repeat(var(--preview-columns, 3), minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.preview-grid.is-visible { display: grid; }
.preview-tile { position: relative; overflow: hidden; border: 1px solid #e6e9ef; border-radius: 10px; background: #eef1f6; cursor: pointer; transition: border-color .16s ease, box-shadow .16s ease; }
.preview-tile:hover { border-color: #aabefb; }
.preview-tile.is-selected { border-color: var(--grid-blue); box-shadow: 0 0 0 2px rgba(49, 92, 255, .18); }
.preview-tile:focus-visible { outline: 3px solid rgba(49, 92, 255, .32); outline-offset: 2px; }
.preview-tile canvas { display: block; width: 100%; height: 100%; }
.tile-number { position: absolute; top: 7px; left: 7px; display: grid; width: 24px; height: 24px; place-items: center; border-radius: 8px; color: #fff; background: rgba(20, 33, 55, .82); font-size: 12px; font-weight: 800; }
.tile-download { position: absolute; right: 6px; bottom: 6px; padding: 5px 7px; color: #fff; background: rgba(24, 45, 82, .84); font-size: 11px; opacity: 0; }
.preview-tile:hover .tile-download, .preview-tile:focus-within .tile-download { opacity: 1; }
.download-panel { display: grid; grid-template-columns: 1fr 1.14fr; gap: 10px; margin-top: 16px; }
.download-panel button { min-height: 54px; }
.download-panel .primary-button { font-size: 14px; }
.download-panel small { display: block; margin-top: 2px; color: rgba(255,255,255,.8); font-size: 11px; font-weight: 500; }

.notice { display: none; margin: 16px 0 0; padding: 11px 13px; border: 1px solid #f0c8c8; border-radius: 11px; color: #9e3131; background: #fff6f6; font-size: 13px; }
.notice.is-visible { display: block; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 30; max-width: calc(100% - 32px); padding: 11px 15px; border-radius: 11px; color: #fff; background: #20232a; box-shadow: 0 10px 28px rgba(0,0,0,.18); font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 18px); transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.content { padding: 8px 0 70px; }
.content-card { max-width: 920px; margin: 0 auto; padding: 38px; border: 1px solid var(--grid-line); border-radius: 21px; background: rgba(255,255,255,.86); }
.content-card + .content-card { margin-top: 18px; }
.content h2 { margin: 0 0 12px; font-size: clamp(25px, 4vw, 32px); letter-spacing: -.035em; }
.content h3 { margin: 28px 0 8px; font-size: 17px; }
.content p, .content li { color: #555e6b; font-size: 15px; line-height: 1.75; }
.content p { margin: 0; }
.content ul, .content ol { margin: 10px 0 0; padding-left: 1.25rem; }
.feature-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 24px; }
.feature-list article { padding: 16px; border: 1px solid #e7eaf0; border-radius: 14px; background: #fbfcff; }
.feature-list strong { display: block; margin-bottom: 5px; font-size: 15px; }
.feature-list span { color: var(--grid-muted); font-size: 13px; line-height: 1.55; }
.faq { border-top: 1px solid var(--grid-line); }
.faq details { border-bottom: 1px solid var(--grid-line); padding: 16px 0; }
.faq summary { position: relative; padding-right: 28px; cursor: pointer; font-size: 16px; font-weight: 750; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 2px; color: var(--grid-blue); font-size: 20px; font-weight: 500; }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin-top: 10px; }
.privacy-box { margin-top: 23px; padding: 16px 18px; border: 1px solid #ccebdd; border-radius: 14px; background: #f5fcf8; color: #35715a; font-size: 14px; line-height: 1.65; }
.privacy-box strong { color: #1a6044; }

.footer { padding: 32px 0 52px; border-top: 1px solid var(--grid-line); color: var(--grid-muted); font-size: 13px; text-align: center; }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--grid-blue); }
.brand-foot { color: var(--grid-ink); font-weight: 800; }

@media (max-width: 860px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .editor-side { border-right: 0; border-bottom: 1px solid var(--grid-line); }
  .preset-grid { grid-template-columns: repeat(5, minmax(70px, 1fr)); }
}

@media (max-width: 640px) {
  .wrap { width: min(100% - 22px, 1200px); }
  .nav { gap: 8px; }
  .navlinks { gap: 2px; }
  .navlinks a { padding: 7px 8px; }
  .hero { padding-top: 32px; }
  .hero p { font-size: 15px; }
  .trust-tags { gap: 7px; }
  .trust-tag { padding: 6px 9px; font-size: 12px; }
  .workspace { border-radius: 18px; margin-bottom: 34px; }
  .editor-side, .result-side { padding: 18px 14px; }
  .section-title { font-size: 16px; }
  .upload-zone { min-height: 180px; }
  .editor-help { align-items: flex-start; }
  .editor-controls { width: 100%; }
  .editor-controls input { flex: 1; }
  .image-meta-row { align-items: flex-start; flex-direction: column; }
  .image-actions { width: 100%; }
  .image-actions .ghost-button { flex: 1; }
  .preset-grid { grid-template-columns: repeat(3, 1fr); }
  .preset-card { min-height: 92px; }
  .preview-head { margin-top: 23px; }
  .tile-download { opacity: 1; }
  .download-panel { grid-template-columns: 1fr; }
  .content { padding-bottom: 48px; }
  .content-card { padding: 25px 19px; border-radius: 17px; }
  .feature-list { grid-template-columns: 1fr; }
}
