:root{
  --red: #d40000;
  --red-dark: #a80000;
  --red-light: #ff4d4d;
  --ink: #17181c;
  --ink-soft: #55585f;
  --line: #e6e5e8;
  --surface: #ffffff;
  --surface-sunken: #f6f5f7;
  --bg: #fbfafa;
  --radius-lg: 28px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20,10,10,.04), 0 12px 32px -12px rgba(20,10,10,.14);
  --focus: 0 0 0 3px rgba(212,0,0,.25);
}

@media (prefers-color-scheme: dark){
  :root{
    --ink: #f3f2f4;
    --ink-soft: #b5b3ba;
    --line: #2c2b30;
    --surface: #1c1b1f;
    --surface-sunken: #232226;
    --bg: #141316;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px -12px rgba(0,0,0,.5);
  }
}

*, *::before, *::after{ box-sizing: border-box; }

html{ color-scheme: light dark; }

body{
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3, .brand-title, .brand-sub{ font-family: 'Manrope', 'Inter', system-ui, sans-serif; }

.wrap{
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.visually-hidden{
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Header */
.site-header{
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.header-inner{ display:flex; align-items:center; justify-content:space-between; }
.brand{ display:flex; align-items:center; gap: 12px; text-decoration:none; color:inherit; }
.brand-mark{ border-radius: 22%; display:block; box-shadow: var(--shadow); }
.brand-text{ display:flex; flex-direction:column; line-height:1.15; }
.brand-title{ font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand-sub{ font-weight: 600; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--red); }

/* Layout */
.app-grid{
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  gap: 24px;
  padding: 32px 20px 56px;
  align-items: start;
}
@media (max-width: 860px){
  .app-grid{ grid-template-columns: 1fr; }
}

.panel{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
}

/* Type tabs */
.type-tabs{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}
.tab{
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 600;
  font-size: .85rem;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.tab:hover{ color: var(--ink); }
.tab.is-active{
  background: var(--red);
  color: #fff;
}
.tab:focus-visible{ outline: none; box-shadow: var(--focus); }

/* Fields */
.field-group{ display:flex; flex-direction:column; gap: 10px; }
.field-group.is-hidden{ display:none; }
.field-group + .field-group{ margin-top: 0; }

.two-col{ display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }

label{ font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.checkbox-row{ display:flex; align-items:center; gap:8px; font-weight:500; }
.checkbox-row input{ width:auto; }

input[type="text"], input[type="tel"], input[type="email"], input[type="url"], select, textarea{
  width: 100%;
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea{ resize: vertical; font-family: inherit; }
input:focus, select:focus, textarea:focus{
  outline: none;
  border-color: var(--red);
  box-shadow: var(--focus);
}

/* Style panel */
.style-panel{
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.style-panel summary{
  cursor: pointer;
  font-weight: 700;
  font-size: .95rem;
  list-style: none;
  display:flex;
  align-items:center;
  gap: 6px;
}
.style-panel summary::-webkit-details-marker{ display:none; }
.style-panel summary::before{
  content: "";
  width: 8px; height: 8px;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: rotate(-45deg);
  transition: transform .15s ease;
}
.style-panel[open] summary::before{ transform: rotate(45deg); }

.style-grid{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 18px;
}
@media (max-width: 480px){ .style-grid{ grid-template-columns: 1fr; } }

.style-field{ display:flex; flex-direction:column; gap:8px; }
.style-field label{ display:flex; justify-content:space-between; }
#s-size-val{ color: var(--ink); font-weight: 700; }

.color-input{ display:flex; gap:8px; align-items:center; }
.color-input input[type="color"]{
  -webkit-appearance: none;
  appearance: none;
  width: 40px; height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  flex: none;
}
.color-input input[type="color"]::-webkit-color-swatch-wrapper{ padding: 3px; }
.color-input input[type="color"]::-webkit-color-swatch{ border: none; border-radius: 7px; }
.color-input input[type="text"]{ min-width: 0; text-transform: uppercase; }

input[type="range"]{
  width: 100%;
  accent-color: var(--red);
}

/* Logo row */
.logo-row{ margin-top: 20px; }
.logo-label{ font-size: .82rem; font-weight: 600; color: var(--ink-soft); display:block; margin-bottom: 10px; }
.logo-options{ display:flex; gap: 14px; flex-wrap: wrap; }
.logo-option{
  display:flex; flex-direction:column; align-items:center; gap:6px;
  font-size: .78rem; font-weight: 600; color: var(--ink-soft);
  cursor: pointer;
}
.logo-option input{ position:absolute; opacity:0; pointer-events:none; }
.logo-swatch{
  width: 52px; height: 52px;
  border-radius: 22%;
  border: 2px solid var(--line);
  display:flex; align-items:center; justify-content:center;
  overflow: hidden;
  background: var(--surface-sunken);
  transition: border-color .15s ease, box-shadow .15s ease;
  font-size: 1.3rem;
  color: var(--ink-soft);
}
.logo-swatch img{ width:100%; height:100%; object-fit:cover; }
.logo-swatch--n7 img{ display:block; }
.logo-option input:checked + .logo-swatch{
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(212,0,0,.15);
}
.logo-option input:focus-visible + .logo-swatch{ box-shadow: var(--focus); }

/* Preview */
.preview-panel{
  position: sticky;
  top: 24px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 18px;
  text-align:center;
}
.preview-card{
  width: 100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 20px;
  background:
    linear-gradient(45deg, var(--surface-sunken) 25%, transparent 25%) -10px 0/20px 20px,
    linear-gradient(-45deg, var(--surface-sunken) 25%, transparent 25%) -10px 0/20px 20px,
    linear-gradient(45deg, transparent 75%, var(--surface-sunken) 75%) -10px 0/20px 20px,
    linear-gradient(-45deg, transparent 75%, var(--surface-sunken) 75%) -10px 0/20px 20px,
    var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  min-height: 280px;
}
.qr-render{ line-height: 0; }
.qr-render canvas, .qr-render img, .qr-render svg{
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.download-row{ display:flex; gap: 10px; flex-wrap: wrap; justify-content:center; width:100%; }
.btn{
  font: inherit;
  font-weight: 700;
  font-size: .88rem;
  border-radius: 999px;
  padding: 11px 20px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease, background .15s ease;
}
.btn:active{ transform: translateY(1px); }
.btn-primary{
  background: var(--red);
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(212,0,0,.6);
}
.btn-primary:hover{ filter: brightness(1.07); }
.btn-ghost{
  background: var(--surface-sunken);
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover{ background: var(--line); }

.hint{ color: var(--ink-soft); font-size: .8rem; margin: 0; min-height: 1.2em; }
.hint.is-offline{ color: var(--red); }

/* Footer */
.site-footer{
  border-top: 1px solid var(--line);
  padding: 22px 0 40px;
}
.site-footer p{
  margin:0;
  color: var(--ink-soft);
  font-size: .8rem;
  text-align:center;
}
