:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --muted: #94a3b8;
  --border: #e6eaf1;
  --brand: #0891b2;
  --brand-2: #6366f1;
  --grad: linear-gradient(135deg, #06b6d4 0%, #6366f1 100%);
  --grad-soft: linear-gradient(135deg, #ecfeff 0%, #eef2ff 100%);
  --danger: #ef4444;
  --ok: #10b981;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.12);
}

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

html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex; flex-direction: column; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -.02em; }

/* ---------------- header ---------------- */
.site-header {
  display: flex; align-items: center; gap: 22px;
  padding: 12px 26px; background: rgba(255,255,255,.85);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100;
}
.logo { display: flex; align-items: center; gap: 9px; }
.logo:hover { text-decoration: none; }
.logo-mark { border-radius: 9px; box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.logo-text { font-size: 21px; font-weight: 800; color: var(--ink); }
.logo-text span { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.logo-text.small { font-size: 17px; }

.top-nav { display: flex; gap: 4px; margin-left: 6px; }
.top-nav a { color: var(--ink-soft); font-size: 14.5px; font-weight: 600; padding: 8px 14px; border-radius: 9px; }
.top-nav a:hover { background: #f1f5f9; text-decoration: none; }
.top-nav a.active { color: var(--brand-2); }

.header-right { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.breadcrumb { font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.breadcrumb .sep { color: var(--border); }
.lang-select { position: relative; }
.lang-btn { background: #f1f5f9; border: none; border-radius: 9px; padding: 8px 12px; font-size: 13.5px; cursor: pointer; color: var(--ink-soft); font-weight: 600; font-family: inherit; }
.lang-menu { position: absolute; right: 0; top: 42px; background: #fff; border: 1px solid var(--border); border-radius: 12px; list-style: none; margin: 0; padding: 6px; min-width: 150px; z-index: 50; box-shadow: var(--shadow-lg); }
.lang-menu li { padding: 8px 14px; cursor: pointer; font-size: 14px; border-radius: 8px; }
.lang-menu li:hover { background: #f1f5f9; }
.lang-menu li.active { color: var(--brand-2); font-weight: 700; }
.hamburger { display: none; background: none; border: none; cursor: pointer; flex-direction: column; gap: 4px; padding: 6px; }
.hamburger span { width: 22px; height: 2px; background: var(--ink-soft); border-radius: 2px; }
.main-menu { position: absolute; right: 16px; top: 64px; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 8px; min-width: 230px; z-index: 60; box-shadow: var(--shadow-lg); }
.main-menu a { display: block; padding: 10px 14px; color: var(--ink); font-size: 14.5px; font-weight: 600; border-radius: 9px; }
.main-menu a.muted { color: var(--muted); font-weight: 500; }
.main-menu a:hover { background: #f1f5f9; text-decoration: none; }
.main-menu hr { border: none; border-top: 1px solid var(--border); margin: 6px 4px; }

/* ---------------- buttons ---------------- */
.btn { border: none; border-radius: 11px; padding: 11px 20px; font-size: 14.5px; font-weight: 600; cursor: pointer; font-family: inherit; transition: transform .08s, box-shadow .15s, background .15s; }
.btn:active { transform: translateY(1px); }
.btn.full { width: 100%; }
.btn-grad { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(99,102,241,.28); }
.btn-grad:hover { box-shadow: 0 10px 26px rgba(99,102,241,.36); }
.btn-lg { padding: 15px 32px; font-size: 16px; border-radius: 13px; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f8fafc; border-color: #d6dbe6; }
.btn-link-red { background: none; color: var(--danger); padding: 11px 14px; }
.btn-link-red:hover { background: #fef2f2; }
.linkbtn { background: none; border: none; color: var(--brand-2); font-weight: 700; cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row .btn { flex: 1; }

.view { flex: 1; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 30px; }
.section-head h2 { font-size: 30px; margin: 0 0 8px; }
.section-head p { color: var(--ink-soft); font-size: 16px; margin: 0; line-height: 1.55; }

/* ---------------- home / hero ---------------- */
.hero { position: relative; overflow: hidden; padding: 64px 24px 56px; text-align: center; background: var(--grad-soft); }
.hero-glow { position: absolute; width: 600px; height: 600px; top: -260px; left: 50%; transform: translateX(-50%); background: radial-gradient(circle, rgba(99,102,241,.18), transparent 60%); pointer-events: none; }
.hero-inner { position: relative; max-width: 740px; margin: 0 auto; }
.badge { display: inline-block; background: #fff; border: 1px solid var(--border); color: var(--ink-soft); font-size: 13px; font-weight: 600; padding: 7px 15px; border-radius: 999px; box-shadow: var(--shadow); }
.hero h1 { font-size: 50px; line-height: 1.08; margin: 22px 0 16px; }
.hero-sub { font-size: 18px; color: var(--ink-soft); line-height: 1.6; margin: 0 auto 30px; max-width: 580px; }

.dropzone { background: #fff; border: 2px dashed #cdd6e6; border-radius: 20px; padding: 38px 24px; max-width: 560px; margin: 0 auto; color: var(--muted); transition: border-color .15s, background .15s; }
.dropzone.dragover { border-color: var(--brand-2); background: #f5f7ff; }
.dropzone svg { color: var(--brand-2); }
.dz-title { font-size: 18px; font-weight: 700; color: var(--ink); margin: 12px 0 4px; }
.dz-or { color: var(--muted); font-size: 13px; margin: 6px 0 14px; }
.dz-hint { font-size: 13px; color: var(--muted); margin: 16px 0 0; }
.dropzone.small { padding: 26px; border-radius: 16px; }

/* ---------------- templates ---------------- */
.templates-section { max-width: 1140px; margin: 0 auto; padding: 64px 24px; }
.tpl-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 28px; }
.tpl-chip { background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 8px 16px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; transition: all .12s; }
.tpl-chip:hover { border-color: #c7cfde; }
.tpl-chip.active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(99,102,241,.28); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px; }
.tpl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; text-align: center; transition: transform .12s, box-shadow .15s, border-color .15s; }
.tpl-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #d7defb; }
.tpl-thumb { display: flex; align-items: center; justify-content: center; height: 120px; margin-bottom: 12px; }
.tpl-shape { background: var(--grad); border-radius: 8px; box-shadow: 0 6px 16px rgba(99,102,241,.25); max-width: 100%; max-height: 100%; }
.tpl-shape.round { border-radius: 50%; }
.tpl-name { font-size: 14.5px; font-weight: 700; margin: 0 0 2px; }
.tpl-dim { font-size: 12.5px; color: var(--muted); }

/* ---------------- features ---------------- */
.features { max-width: 1140px; margin: 0 auto; padding: 8px 24px 72px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.feat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; transition: transform .12s, box-shadow .15s; }
.feat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.feat-ic { width: 44px; height: 44px; border-radius: 11px; background: var(--grad-soft); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 14px; }
.feat-card h3 { font-size: 16.5px; margin: 0 0 6px; }
.feat-card p { font-size: 13.5px; color: var(--ink-soft); margin: 0; line-height: 1.5; }

/* ---------------- editor ---------------- */
.edit-titlebar { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px; background: #fff; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.edit-title { font-size: 16px; font-weight: 700; }
.edit-hint { font-size: 13px; color: var(--muted); }

.editor { display: flex; min-height: 62vh; }
.tool-tabs { display: flex; flex-direction: column; background: #fff; border-right: 1px solid var(--border); min-width: 132px; padding: 8px; gap: 2px; }
.tool-tabs button { display: flex; align-items: center; gap: 9px; background: none; border: none; padding: 11px 12px; text-align: left; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); border-radius: 10px; font-family: inherit; }
.tool-tabs button .ti { font-size: 15px; width: 18px; text-align: center; }
.tool-tabs button:hover { background: #f1f5f9; }
.tool-tabs button.active { background: var(--grad-soft); color: var(--brand-2); }

.tool-panel { width: 256px; padding: 20px; background: #fff; border-right: 1px solid var(--border); }
.panel h2 { font-size: 17px; margin: 0 0 16px; }
.panel label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 13px; }
.panel label.check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 500; }
.panel input[type=number], .panel select { width: 100%; padding: 10px 11px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; margin-top: 5px; font-family: inherit; color: var(--ink); background: #fff; }
.panel input[type=number]:focus, .panel select:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.panel input[type=range] { width: 100%; margin-top: 8px; accent-color: var(--brand-2); }
.panel .muted { color: var(--muted); }
.panel .small { font-size: 12px; font-weight: 500; }
.panel .full { margin-top: 6px; }

.unit-toggle { display: inline-flex; background: #f1f5f9; border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.unit-toggle .unit { background: none; border: none; padding: 7px 18px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); border-radius: 8px; font-family: inherit; }
.unit-toggle .unit.active { background: #fff; color: var(--brand-2); box-shadow: var(--shadow); }

.opt-row { display: flex; gap: 10px; margin-bottom: 14px; }
.opt { flex: 1; background: #fff; border: 1px solid var(--border); border-radius: 11px; padding: 14px 4px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-soft); line-height: 1.6; font-family: inherit; }
.opt.active { border-color: var(--brand-2); color: var(--brand-2); background: var(--grad-soft); }

.target-row { display: flex; gap: 8px; margin: 6px 0 4px; }
.target-row input { flex: 2; padding: 10px; border: 1px solid var(--border); border-radius: 10px; font-family: inherit; }
.target-row select { flex: 1; padding: 10px 4px; border: 1px solid var(--border); border-radius: 10px; font-family: inherit; }

.format-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 8px 0 6px; }
.fmt { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 0; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); font-family: inherit; }
.fmt.active { border-color: var(--brand-2); color: var(--brand-2); background: var(--grad-soft); }

.tpl-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 56vh; overflow-y: auto; }
.tpl-mini button { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 6px; cursor: pointer; font-size: 11.5px; font-weight: 600; color: var(--ink-soft); line-height: 1.4; font-family: inherit; }
.tpl-mini button:hover { border-color: var(--brand-2); color: var(--brand-2); }
.tpl-mini button small { display: block; color: var(--muted); font-weight: 500; }

/* ---------------- stage / canvas ---------------- */
.stage { flex: 1; background: #eef1f6; display: flex; align-items: center; justify-content: center; padding: 22px; overflow: auto;
  background-image: radial-gradient(#dde3ee 1px, transparent 1px); background-size: 18px 18px; }
.canvas-wrap { position: relative; line-height: 0; }
#canvas { max-width: 100%; max-height: 68vh; border-radius: 8px; box-shadow: var(--shadow-lg);
  background: repeating-conic-gradient(#fff 0% 25%, #eef0f3 0% 50%) 50% / 20px 20px; }

.crop-overlay { position: absolute; inset: 0; }
.crop-box { position: absolute; border: 1.5px solid #fff; box-shadow: 0 0 0 9999px rgba(15,23,42,.5); cursor: move; border-radius: 2px; }
.crop-box.grid::before { content:""; position:absolute; inset:0; pointer-events:none;
  background-image: linear-gradient(rgba(255,255,255,.55),rgba(255,255,255,.55)),linear-gradient(rgba(255,255,255,.55),rgba(255,255,255,.55));
  background-size: 1px 100%, 1px 100%; background-position: 33.33% 0, 66.66% 0; background-repeat: no-repeat; }
.crop-box.grid::after { content:""; position:absolute; inset:0; pointer-events:none;
  background-image: linear-gradient(rgba(255,255,255,.55),rgba(255,255,255,.55)),linear-gradient(rgba(255,255,255,.55),rgba(255,255,255,.55));
  background-size: 100% 1px, 100% 1px; background-position: 0 33.33%, 0 66.66%; background-repeat: no-repeat; }
.handle { position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid var(--brand-2); border-radius: 4px; }
.handle.nw { left: -7px; top: -7px; cursor: nwse-resize; }
.handle.ne { right: -7px; top: -7px; cursor: nesw-resize; }
.handle.sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.handle.se { right: -7px; bottom: -7px; cursor: nwse-resize; }

/* ---------------- info bar ---------------- */
.info-bar { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; background: #fff; border-top: 1px solid var(--border); flex-wrap: wrap; gap: 12px; }
.info-cols { display: flex; gap: 36px; font-size: 13px; color: var(--ink-soft); }
.info-cols strong { color: var(--ink); font-weight: 700; }
.action-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------- batch ---------------- */
.batch-wrap { display: flex; gap: 0; min-height: 64vh; }
.batch-panel { width: 280px; padding: 22px; background: #fff; border-right: 1px solid var(--border); }
.batch-panel h2 { font-size: 17px; margin: 0 0 16px; }
.batch-panel label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 13px; }
.batch-panel label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.batch-panel select, .batch-panel input[type=number] { width: 100%; padding: 10px 11px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; margin-top: 5px; font-family: inherit; }
.batch-panel input[type=range] { width: 100%; accent-color: var(--brand-2); margin-top: 8px; }
.batch-panel .btn { margin-top: 8px; }
.bop { border-top: 1px dashed var(--border); padding-top: 14px; margin-top: 4px; margin-bottom: 6px; }

.batch-main { flex: 1; padding: 22px; overflow-y: auto; }
.batch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 18px; }
.bcard { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.bcard .thumb { height: 110px; background: #eef1f6 repeating-conic-gradient(#fff 0% 25%, #eef0f3 0% 50%) 50% / 16px 16px; display: flex; align-items: center; justify-content: center; }
.bcard .thumb img { max-width: 100%; max-height: 100%; }
.bcard .meta { padding: 10px 11px; }
.bcard .bname { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bcard .bstat { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.bcard .bstat.done { color: var(--ok); }
.bcard .bdl { color: var(--brand-2); font-weight: 700; cursor: pointer; }
.bcard .bx { color: var(--muted); cursor: pointer; font-weight: 700; }

/* ---------------- download ---------------- */
.download-stage { background: #eef1f6; background-image: radial-gradient(#dde3ee 1px, transparent 1px); background-size: 18px 18px; display: flex; align-items: center; justify-content: center; padding: 28px; min-height: 52vh; }
#downloadPreview { max-width: 100%; max-height: 60vh; border-radius: 10px; box-shadow: var(--shadow-lg); }

/* ---------------- footer ---------------- */
.site-footer { background: #fff; border-top: 1px solid var(--border); margin-top: auto; }
.foot-inner { max-width: 1140px; margin: 0 auto; padding: 22px 24px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.foot-links { display: flex; gap: 18px; }
.foot-links a { color: var(--ink-soft); font-size: 13.5px; font-weight: 600; }
.foot-copy { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ---------------- toast ---------------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--ink); color: #fff; padding: 13px 22px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 999; opacity: 0; transition: opacity .25s, transform .25s; box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .top-nav { display: none; }
  .hamburger { display: flex; }
  .hero h1 { font-size: 34px; }
  .editor, .batch-wrap { flex-direction: column; }
  .tool-tabs { flex-direction: row; overflow-x: auto; min-width: 0; }
  .tool-tabs button { white-space: nowrap; }
  .tool-panel, .batch-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .feature-grid { grid-template-columns: 1fr 1fr; }
}
