/* QRgo — "clean scan": emerald/teal accent, warm paper neutrals, high-contrast QR modules.
   Light default; dark via prefers-color-scheme. RTL aware. */

:root {
  /* light (paper) */
  --bg: #f6f4ef;
  --bg-2: #ece8df;
  --panel: #ffffff;
  --panel-2: #f1ede4;
  --line: #d9d2c2;
  --line-strong: #b9b0a0;
  --ink: #16241f;
  --ink-soft: #52635c;
  --ink-faint: #8a978f;
  --accent: #047857;        /* emerald-700 */
  --accent-deep: #065f46;
  --accent-soft: rgba(4, 120, 87, 0.12);
  --accent-glow: rgba(4, 120, 87, 0.24);
  --accent-2: #0d9488;      /* teal-600 (secondary) */
  --err: #c0392b;
  --radius: 16px;
  --radius-sm: 10px;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  --display: "Inter", "Apple SD Gothic Neo", sans-serif;
  --shadow-card: 0 1px 0 rgba(0,0,0,.02), 0 18px 40px -28px rgba(16, 60, 45, .35);
}
/* ===== 3-way theme (Light/Dark/System) — base :root above = native LIGHT. Opposite (dark) WCAG-aware auto-generated (contrast-solving ink/accent vs worst-case surface). ===== */
:root[data-theme="dark"]{
  --bg: #1e1b15;
  --bg-2: #090806;
  --panel: #323232;
  --panel-2: #0d0c09;
  --line: rgba(255,255,255,0.12);
  --line-strong: rgba(255,255,255,0.12);
  --ink: #a7c9bd;
  --ink-soft: #8da199;
  --ink-faint: #748279;
  --accent: #059a70;
  --accent-deep: #0a9a71;
  --accent-soft: #059a70;
  --accent-glow: rgba(0,0,0,0.40);
  --accent-2: #0d988c;
  --err: #d96357;
}












@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1714;
    --bg-2: #0f1f1a;
    --panel: #14241f;
    --panel-2: #18302a;
    --line: #29443c;
    --line-strong: #3a5b50;
    --ink: #e6f0ec;
    --ink-soft: #9fb6ad;
    --ink-faint: #6b857c;
    --accent: #34d399;        /* emerald-400 for dark */
    --accent-deep: #6ee7b7;
    --accent-soft: rgba(52, 211, 153, 0.14);
    --accent-glow: rgba(52, 211, 153, 0.32);
    --accent-2: #2dd4bf;
    --err: #f47067;
    --shadow-card: 0 1px 0 rgba(0,0,0,.2), 0 18px 40px -22px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background:
    radial-gradient(900px 520px at 88% -8%, var(--accent-soft), transparent 60%),
    radial-gradient(720px 460px at -4% 108%, var(--accent-soft), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
b, h1, h2, h3 { font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }

/* i18n switcher theming */
.i18n-switch {
  --i18n-switch-bg: var(--panel-2);
  --i18n-switch-border: var(--line);
  --i18n-switch-fg: var(--ink);
  --i18n-switch-active-bg: var(--accent-soft);
  --i18n-switch-active-fg: var(--accent);
  --i18n-switch-menu-bg: var(--panel);
  --i18n-switch-menu-border: var(--line);
}

/* ── topbar ─────────────────────────────────────────────── */
.topbar {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px clamp(16px, 5vw, 32px) 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  color: #ffffff;
  box-shadow: 0 8px 22px -10px var(--accent-glow);
}
.brand h1 {
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: -.015em;
  line-height: 1.1;
}
.brand p { font-size: 12.5px; color: var(--ink-soft); }
.brand .accent { color: var(--accent); font-weight: 600; }

.offline-badge {
  display: none;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: .02em;
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.offline-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ── tabs ───────────────────────────────────────────────── */
.head { max-width: 1080px; margin: 0 auto; padding: 6px clamp(16px, 5vw, 32px) 0; }
.tabs {
  display: flex; gap: 7px; overflow-x: auto;
  padding: 8px 0 14px;
  scrollbar-width: thin;
}
.tabs::-webkit-scrollbar { height: 6px; }
.tabs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.tab {
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}
.tab:hover { color: var(--ink); border-color: var(--line-strong); }
.tab.is-active {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #ffffff;
  border-color: var(--accent-deep);
  box-shadow: 0 6px 16px -8px var(--accent-glow);
}
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── workspace ──────────────────────────────────────────── */
.wrap { max-width: 1080px; margin: 0 auto; padding: 4px clamp(16px, 5vw, 32px) 40px; }
.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.panel-title {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.size-info {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  text-align: right;
}
.hint {
  font-size: 12.5px;
  color: var(--ink-soft);
  max-width: 70%;
  line-height: 1.5;
}

/* ── forms ──────────────────────────────────────────────── */
.forms { padding: 14px 20px 6px; }
.form { display: none; flex-direction: column; gap: 12px; }
.form.is-active { display: flex; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: .01em;
}
.field-label .unit {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-faint);
  margin-left: 4px;
}
.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: inherit;
  font-size: 14.5px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 92px; font-family: inherit; }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-faint); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field select { cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-faint) 50%), linear-gradient(135deg, var(--ink-faint) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px;
}
.check {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; color: var(--ink-soft); cursor: pointer;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ── options ────────────────────────────────────────────── */
.options {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
}
.opt-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}
.opt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.opt-field .range-val {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-left: 8px;
}
.color-input { display: inline-flex; align-items: center; gap: 8px; }
.color-input input[type="color"] {
  width: 42px; height: 38px; padding: 0; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); cursor: pointer;
}
.color-input input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.color-input input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
.color-input code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
}
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  background: var(--line); border-radius: 999px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  box-shadow: 0 2px 6px -1px var(--accent-glow);
  transition: transform .12s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border: none; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}
.presets { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--s1) 0 50%, var(--s2) 50% 100%);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.swatch:hover { transform: translateY(-2px); box-shadow: 0 6px 14px -8px rgba(0,0,0,.3); }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.reset-btn {
  margin-top: 14px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
}
.reset-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── preview panel ──────────────────────────────────────── */
.preview-panel { position: sticky; top: 12px; }
.canvas-wrap {
  position: relative;
  padding: 24px;
  display: grid;
  place-items: center;
  background:
    repeating-conic-gradient(var(--panel) 0 25%, var(--panel-2) 0 50%) 0 0 / 18px 18px;
  min-height: 340px;
}
#qrCanvas {
  display: block;
  width: min(320px, 70vw);
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  box-shadow: 0 12px 30px -14px rgba(0,0,0,.3);
  background: #ffffff;
}
.canvas-empty, .canvas-err {
  position: absolute;
  inset: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 20px;
  color: var(--ink-soft);
  font-size: 13.5px;
  background: var(--panel);
  border-radius: 8px;
}
.canvas-err strong { color: var(--err); font-size: 14px; }
.canvas-err span { font-size: 12.5px; color: var(--ink-soft); }
.canvas-err[hidden], .canvas-empty[hidden] { display: none !important; }

.actions {
  display: flex;
  gap: 9px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  flex-wrap: wrap;
}
.btn {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #ffffff;
  border-color: var(--accent-deep);
  box-shadow: 0 6px 16px -8px var(--accent-glow);
}
.btn-primary:hover { color: #ffffff; filter: brightness(1.05); }
.btn-ghost { flex: 0 0 46px; padding: 11px 0; font-size: 16px; }

/* ── ad slots (money-lab pattern) ───────────────────────── */
.ad-slot { display: none; margin: 24px 0; }
.ad-slot.is-live, .ad-slot.is-preview { display: block; }
.ad-label {
  display: block;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  opacity: .8;
  margin-bottom: 5px;
  text-align: center;
}
.ad-ph {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}
.ad-slot.is-preview .ad-ph { display: flex; }
.ad-slot.is-preview .adsbygoogle { display: none !important; }
.ad-slot.is-live .ad-ph { display: none; }

/* ── info / FAQ ─────────────────────────────────────────── */
.info { margin-top: 30px; color: var(--ink-soft); font-size: 14px; line-height: 1.7; }
.info h2 { font-size: 15px; color: var(--ink); margin: 22px 0 8px; }
.info > h2:first-child { margin-top: 0; }
.info p { margin-bottom: 8px; }
.info b, .info strong { color: var(--ink); }
.info code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 1px 5px;
  border-radius: 4px;
  word-break: break-all;
}
.faq { margin: 4px 0 8px; }
.faq dt { color: var(--ink); font-weight: 600; margin-top: 12px; }
.faq dd { margin: 4px 0 0; }

.disclaimer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.6;
  text-align: center;
  padding: 0 8px;
}
.disclaimer b { color: var(--ink-soft); }

/* ── footer ─────────────────────────────────────────────── */
.foot {
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px clamp(16px, 5vw, 32px) 80px;
  text-align: center;
}
.foot a { color: var(--ink-faint); font-size: 12px; }
.foot a:hover { color: var(--accent); }

/* ── toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-err { background: var(--err); color: #fff; }

/* ── RTL ────────────────────────────────────────────────── */
[dir="rtl"] .field select {
  background-position: 18px center, 13px center;
  padding-right: 13px; padding-left: 32px;
}
[dir="rtl"] .hint { text-align: left; }
[dir="rtl"] .field-label .unit { margin-left: 0; margin-right: 4px; }

/* ── responsive ─────────────────────────────────────────── */
@media (max-width: 820px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { position: static; order: -1; }
  .offline-badge { display: none !important; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; padding-top: 18px; }
  .brand h1 { font-size: 18px; }
  .panel-head { padding: 14px 16px; }
  .forms { padding: 12px 16px 4px; }
  .options { padding: 12px 16px 16px; }
  .field-row { grid-template-columns: 1fr; }
  .opt-grid { grid-template-columns: 1fr; }
  .hint { max-width: 100%; }
  .actions { padding: 14px 16px; }
  .btn { font-size: 13px; padding: 10px 12px; }
  #qrCanvas { width: min(280px, 80vw); }
}

@media (min-width: 760px) {
  .offline-badge { display: inline-flex; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
