/* ===================== THEME TOKENS ===================== */
:root{
  --radius: 18px;
  --radius-sm: 12px;
  --font-head: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --accent: #5b8cff;
  --accent-2: #7b5bff;
  --grad: linear-gradient(135deg, #5b8cff, #7b5bff);
  --shadow: 0 18px 40px -18px rgba(0,0,0,.55);
  transition: background .3s;
}

[data-theme="dark"]{
  --bg: #0b0d14;
  --bg-2: #11131d;
  --surface: #161a26;
  --surface-2: #1d2231;
  --border: #262c3d;
  --text: #eef1f7;
  --muted: #9aa3b8;
  --chip: #1d2231;
  --chip-active: rgba(91,140,255,.16);
}

[data-theme="light"]{
  --bg: #eef1f8;
  --bg-2: #e6eaf4;
  --surface: #ffffff;
  --surface-2: #f4f6fc;
  --border: #e2e7f1;
  --text: #131722;
  --muted: #5c6479;
  --chip: #f0f3fa;
  --chip-active: rgba(91,140,255,.14);
}

*{ box-sizing: border-box; margin:0; padding:0; }
html,body{ height:100%; }
body{
  font-family: var(--font-body);
  background: radial-gradient(1200px 800px at 80% -10%, rgba(123,91,255,.10), transparent 60%),
              radial-gradient(900px 700px at -10% 110%, rgba(91,140,255,.10), transparent 55%),
              var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
  transition: background .35s, color .35s;
}

/* ===================== SIDEBAR ===================== */
.sidebar{
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand{ display:flex; align-items:center; gap:12px; padding: 4px 6px 14px; border-bottom:1px solid var(--border); }
.brand-logo{
  width:42px; height:42px; border-radius:13px;
  background: var(--grad);
  display:grid; place-items:center; color:#fff;
  box-shadow: 0 8px 20px -8px var(--accent);
}
.brand-logo svg{ width:22px; height:22px; }
.brand-text h1{ font-family:var(--font-head); font-size:18px; font-weight:800; letter-spacing:-.3px; }
.brand-text span{ font-size:11.5px; color:var(--muted); }

.nav-label{ font-size:11px; text-transform:uppercase; letter-spacing:1.2px; color:var(--muted); margin:0 8px 8px; }
.type-nav{ display:flex; flex-direction:column; gap:4px; overflow-y:auto; flex:1; }
.type-btn{
  display:flex; align-items:center; gap:11px;
  padding:10px 12px; border-radius:12px;
  background:transparent; border:none; cursor:pointer;
  color:var(--muted); font-family:var(--font-body); font-size:14px; font-weight:500;
  text-align:left; transition: .18s;
}
.type-btn .ti{ font-size:17px; width:22px; text-align:center; }
.type-btn:hover{ background:var(--surface); color:var(--text); }
.type-btn.active{ background:var(--chip-active); color:var(--text); box-shadow: inset 0 0 0 1px rgba(91,140,255,.25); }

.sidebar-footer{ border-top:1px solid var(--border); padding-top:14px; }
.theme-toggle{
  width:100%; display:flex; align-items:center; gap:10px; justify-content:center;
  padding:11px; border-radius:12px; cursor:pointer;
  background:var(--surface); border:1px solid var(--border); color:var(--text);
  font-family:var(--font-body); font-size:13.5px; font-weight:600;
}
.theme-toggle .ico-sun{ display:none; }
[data-theme="light"] .theme-toggle .ico-sun{ display:inline; }
[data-theme="light"] .theme-toggle .ico-moon{ display:none; }

/* ===================== MAIN ===================== */
.main{ display:flex; flex-direction:column; min-width:0; }
.topbar{
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding: 24px 30px; border-bottom:1px solid var(--border);
  position:sticky; top:0; z-index:5;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
}
.topbar h2{ font-family:var(--font-head); font-size:21px; font-weight:700; letter-spacing:-.4px; }
.topbar p{ color:var(--muted); font-size:13.5px; margin-top:3px; }

.workspace{
  display:grid; grid-template-columns: 1fr 380px;
  gap:24px; padding:24px 30px 60px; align-items:start;
}

/* ===================== CARDS ===================== */
.panel{ display:flex; flex-direction:column; gap:20px; min-width:0; }
.card{
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-head{ display:flex; align-items:baseline; justify-content:space-between; margin-bottom:16px; }
.card-head h3{ font-family:var(--font-head); font-size:15px; font-weight:700; }
.card-head .hint, .hint{ font-size:12px; color:var(--muted); }

/* ===================== FIELDS ===================== */
.fields{ display:grid; gap:14px; }
.field{ display:flex; flex-direction:column; gap:7px; }
.field.row2{ grid-template-columns:1fr 1fr; display:grid; gap:14px; }
.field label, .design-block > label{ font-size:12.5px; font-weight:600; color:var(--muted); }
.field input, .field textarea, .field select,
.color-field select, .size-line select, .export-size{
  width:100%; padding:12px 14px; border-radius:12px;
  background: var(--surface-2); border:1px solid var(--border);
  color:var(--text); font-family:var(--font-body); font-size:14px;
  transition:.15s; outline:none;
}
.field input:focus, .field textarea:focus, .field select:focus{
  border-color: var(--accent); box-shadow:0 0 0 3px rgba(91,140,255,.15);
}
.field textarea{ resize:vertical; min-height:90px; }
.field .sub{ font-size:11.5px; color:var(--muted); }
.grid2{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }

/* ===================== PRESETS ===================== */
.presets{ display:grid; grid-template-columns:repeat(auto-fill,minmax(86px,1fr)); gap:12px; }
.preset{
  cursor:pointer; border:1px solid var(--border); border-radius:14px;
  padding:10px 8px 8px; background:var(--surface-2);
  display:flex; flex-direction:column; align-items:center; gap:7px; transition:.18s;
}
.preset:hover{ transform:translateY(-2px); border-color:var(--accent); }
.preset.active{ border-color:var(--accent); box-shadow:0 0 0 2px rgba(91,140,255,.3); }
.preset .swatch{
  width:46px; height:46px; border-radius:11px; display:grid; place-items:center;
  position:relative; overflow:hidden;
}
.preset .swatch svg{ width:34px; height:34px; }
.preset span{ font-size:11px; font-weight:600; color:var(--muted); text-align:center; }

/* ===================== DESIGN GRID ===================== */
.design-grid{ display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.design-block{ display:flex; flex-direction:column; gap:10px; }
.chip-row{ display:flex; flex-wrap:wrap; gap:8px; }
.chip{
  cursor:pointer; padding:8px 10px; border-radius:11px;
  background:var(--chip); border:1px solid var(--border);
  display:flex; align-items:center; gap:7px; font-size:12.5px; font-weight:500; color:var(--text);
  transition:.15s;
}
.chip:hover{ border-color:var(--accent); }
.chip.active{ background:var(--chip-active); border-color:var(--accent); box-shadow: inset 0 0 0 1px rgba(91,140,255,.3); }
.chip .glyph{ width:18px; height:18px; }
.chip .glyph svg{ width:18px; height:18px; display:block; }

.color-row{ display:flex; gap:12px; flex-wrap:wrap; }
.color-field{ display:flex; flex-direction:column; gap:5px; align-items:center; flex:1; min-width:70px; }
.color-field.full{ align-items:stretch; }
.color-field input[type=color]{
  width:100%; height:42px; border:1px solid var(--border); border-radius:11px;
  background:var(--surface-2); cursor:pointer; padding:4px;
}
.color-field span{ font-size:11px; color:var(--muted); }
.gradient-row{ margin-top:2px; }

.switch-line{ display:flex; align-items:center; gap:9px; font-size:13px; color:var(--text); cursor:pointer; font-weight:500; }
.switch-line input{ width:18px; height:18px; accent-color:var(--accent); cursor:pointer; }

.upload-row{ display:flex; gap:10px; align-items:center; }
.upload-btn{
  flex:1; cursor:pointer; text-align:center; padding:11px;
  border-radius:12px; border:1px dashed var(--border); background:var(--surface-2);
  color:var(--text); font-size:13px; font-weight:600; transition:.15s;
}
.upload-btn:hover{ border-color:var(--accent); color:var(--accent); }
.slider-line{ display:flex; align-items:center; gap:12px; font-size:12.5px; color:var(--muted); }
.slider-line input[type=range]{ flex:1; accent-color:var(--accent); }

/* ===================== PREVIEW ===================== */
.preview-panel{ position:sticky; top:96px; }
.preview-sticky{ display:flex; flex-direction:column; gap:18px; }
.preview-stage{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:26px; display:flex; flex-direction:column; align-items:center; gap:14px;
  box-shadow:var(--shadow);
}
.preview-frame{
  width:300px; height:300px; border-radius:18px; overflow:hidden;
  display:grid; place-items:center; position:relative;
  background:
    linear-gradient(45deg, rgba(128,128,128,.08) 25%, transparent 25%, transparent 75%, rgba(128,128,128,.08) 75%),
    linear-gradient(45deg, rgba(128,128,128,.08) 25%, transparent 25%, transparent 75%, rgba(128,128,128,.08) 75%);
  background-size:22px 22px; background-position:0 0, 11px 11px;
}
#qrHolder{ display:grid; place-items:center; }
#qrHolder canvas, #qrHolder svg{ border-radius:10px; max-width:280px; height:auto; }
.preview-cap{ font-size:12px; color:var(--muted); }

.download-block{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:18px; display:flex; flex-direction:column; gap:13px; box-shadow:var(--shadow);
}
.seg{ display:flex; background:var(--surface-2); border:1px solid var(--border); border-radius:12px; padding:4px; gap:4px; }
.seg-btn{
  flex:1; padding:9px; border:none; border-radius:9px; cursor:pointer;
  background:transparent; color:var(--muted); font-family:var(--font-body); font-weight:600; font-size:13px; transition:.15s;
}
.seg-btn.active{ background:var(--grad); color:#fff; box-shadow:0 6px 14px -8px var(--accent); }
.size-line{ display:flex; align-items:center; justify-content:space-between; gap:12px; font-size:13px; color:var(--muted); }
.size-line select{ width:auto; padding:9px 12px; }

/* ===================== BUTTONS ===================== */
.btn{
  border:none; cursor:pointer; border-radius:12px; padding:11px 16px;
  font-family:var(--font-body); font-weight:600; font-size:14px; transition:.18s;
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
}
.btn.primary{ background:var(--grad); color:#fff; box-shadow:0 12px 26px -12px var(--accent); }
.btn.primary:hover{ transform:translateY(-1px); filter:brightness(1.05); }
.btn.big{ padding:15px; font-size:15px; }
.btn.ghost{ background:var(--surface-2); color:var(--text); border:1px solid var(--border); }
.btn.ghost:hover{ border-color:var(--accent); color:var(--accent); }
.btn.wide{ width:100%; }
.btn.tiny{ padding:8px 12px; font-size:12.5px; }

/* ===================== TOAST ===================== */
.toast{
  position:fixed; bottom:26px; left:50%; transform:translateX(-50%) translateY(40px);
  background:#11131d; color:#fff; padding:13px 20px; border-radius:13px;
  border:1px solid var(--border); box-shadow:0 18px 40px -16px rgba(0,0,0,.6);
  font-size:14px; font-weight:600; opacity:0; pointer-events:none; transition:.3s; z-index:100;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

/* ===================== SEO FOOTER ===================== */
.site-footer{
  border-top:1px solid var(--border);
  padding:40px 30px 50px;
  max-width:1100px; margin:0 auto; width:100%;
  display:grid; grid-template-columns:1.3fr 1fr; gap:40px;
}
.site-footer .seo-block h2, .site-footer .faq-block h2{
  font-family:var(--font-head); font-size:19px; font-weight:700; margin-bottom:12px; letter-spacing:-.3px;
}
.site-footer h3{ font-family:var(--font-head); font-size:15px; font-weight:600; margin:18px 0 7px; color:var(--text); }
.site-footer p{ color:var(--muted); font-size:14px; line-height:1.7; }
.site-footer strong{ color:var(--text); font-weight:600; }
.site-footer a{ color:var(--accent); text-decoration:none; font-weight:600; }
.site-footer a:hover{ text-decoration:underline; }
.attribution{
  margin-top:6px; padding:14px 16px; border:1px solid var(--border);
  border-radius:12px; background:var(--surface-2);
}
.attribution strong{ color:var(--accent); }
.faq-block details{
  border:1px solid var(--border); border-radius:12px; padding:13px 16px; margin-bottom:10px;
  background:var(--surface); transition:.2s;
}
.faq-block details[open]{ border-color:var(--accent); }
.faq-block summary{
  cursor:pointer; font-weight:600; font-size:14px; color:var(--text); list-style:none;
  display:flex; justify-content:space-between; align-items:center; gap:10px;
}
.faq-block summary::after{ content:'+'; color:var(--accent); font-size:18px; font-weight:700; }
.faq-block details[open] summary::after{ content:'–'; }
.faq-block summary::-webkit-details-marker{ display:none; }
.faq-block details p{ margin-top:9px; font-size:13.5px; }
.copyright{
  grid-column:1 / -1; text-align:center; padding-top:24px; margin-top:6px;
  border-top:1px solid var(--border); color:var(--muted); font-size:13px;
}
.copyright a{ color:var(--accent); text-decoration:none; }
.copyright a:hover{ text-decoration:underline; }

/* ===================== HAMBURGER / DRAWER ===================== */
.topbar-left{ display:flex; align-items:center; gap:14px; min-width:0; }
.hamburger{
  display:none; flex-direction:column; justify-content:center; gap:5px;
  width:42px; height:42px; flex-shrink:0; padding:0 11px;
  background:var(--surface-2); border:1px solid var(--border); border-radius:12px; cursor:pointer;
}
.hamburger span{ display:block; height:2.5px; width:100%; background:var(--text); border-radius:3px; transition:.28s; }
body.nav-open .hamburger span:nth-child(1){ transform:translateY(7.5px) rotate(45deg); }
body.nav-open .hamburger span:nth-child(2){ opacity:0; }
body.nav-open .hamburger span:nth-child(3){ transform:translateY(-7.5px) rotate(-45deg); }

.sidebar-close{
  display:none; margin-left:auto; width:34px; height:34px; flex-shrink:0;
  background:var(--surface); border:1px solid var(--border); border-radius:10px;
  color:var(--muted); font-size:15px; cursor:pointer;
}
.sidebar-close:hover{ color:var(--text); border-color:var(--accent); }

.sidebar-overlay{
  position:fixed; inset:0; background:rgba(5,7,12,.55); backdrop-filter:blur(2px);
  opacity:0; pointer-events:none; transition:.3s; z-index:40;
}
body.nav-open .sidebar-overlay{ opacity:1; pointer-events:auto; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1100px){
  .workspace{ grid-template-columns:1fr; }
  .preview-panel{ position:static; }
  .preview-sticky{ flex-direction:row; flex-wrap:wrap; }
  .preview-stage, .download-block{ flex:1; min-width:280px; }
}

/* tablet & below → sidebar becomes an off-canvas drawer */
@media (max-width: 860px){
  body{ grid-template-columns:1fr; }
  .hamburger{ display:flex; }
  .sidebar-close{ display:block; }
  .sidebar{
    position:fixed; top:0; left:0; z-index:50;
    width:276px; max-width:84vw; height:100%;
    transform:translateX(-104%); transition:transform .32s cubic-bezier(.4,0,.2,1);
    box-shadow:0 0 60px -10px rgba(0,0,0,.6);
  }
  body.nav-open .sidebar{ transform:translateX(0); }
  .type-nav{ overflow-y:auto; }
}

@media (max-width: 640px){
  .topbar{ padding:16px 18px; }
  .topbar h2{ font-size:17px; }
  .topbar p{ display:none; }
  .workspace{ padding:18px 16px 50px; gap:18px; }
  .card{ padding:16px; }
  .design-grid{ grid-template-columns:1fr; }
  .preview-sticky{ flex-direction:column; }
  .site-footer{ grid-template-columns:1fr; gap:28px; padding:32px 18px 44px; }
  .seg-btn{ padding:10px 6px; }
  #resetBtn{ font-size:0; padding:11px 13px; }   /* show only the ↺ glyph */
  #resetBtn::before{ content:'↺'; font-size:15px; }
}

@media (max-width: 420px){
  .brand-text h1{ font-size:16px; }
  .preview-frame{ width:240px; height:240px; }
  .presets{ grid-template-columns:repeat(auto-fill,minmax(72px,1fr)); }
}
