  :root {
    --bg: #E9EBEE;
    --panel: #FFFFFF;
    --ink: #14161A;
    --muted: #6B7079;
    --faint: #9AA0A8;
    --line: #DCDFE4;
    --line-strong: #C7CBD1;
    --accent: #2E3CF0;
    --accent-soft: #E6E8FE;
    --field: #F5F6F8;
    --radius: 10px;
    --mono: 'IBM Plex Mono', ui-monospace, monospace;
    --sans: 'IBM Plex Sans', system-ui, sans-serif;
    --display: 'Space Grotesk', system-ui, sans-serif;
  }
  html.dark {
    --bg: #0F1115;
    --panel: #1A1D23;
    --ink: #E7E9ED;
    --muted: #8B909A;
    --faint: #555B66;
    --line: #25292F;
    --line-strong: #2E333B;
    --accent: #5B6EF5;
    --accent-soft: #1A1F3A;
    --field: #13161B;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; }
  body {
    font-family: var(--sans);
    color: var(--ink);
    background-color: var(--bg);
    background-image: radial-gradient(var(--line-strong) 1px, transparent 1px);
    background-size: 22px 22px;
    background-position: -11px -11px;
    -webkit-font-smoothing: antialiased;
    line-height: 1.45;
    transition: background-color .22s ease, color .22s ease;
  }

  .shell { max-width: 1180px; margin: 0 auto; padding: 28px 22px 64px; }

  /* Header */
  .masthead {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    padding-bottom: 18px; margin-bottom: 22px;
    border-bottom: 1px solid var(--line-strong);
  }
  .brand { display: flex; align-items: center; gap: 12px; }
  .brand-mark {
    width: 34px; height: 34px; flex: none; position: relative;
    border: 2.5px solid var(--ink); border-radius: 7px;
  }
  .brand-mark::before, .brand-mark::after {
    content: ""; position: absolute; background: var(--accent);
  }
  .brand-mark::before { width: 9px; height: 9px; top: 4px; left: 4px; border-radius: 2px; }
  .brand-mark::after { width: 6px; height: 6px; bottom: 5px; right: 5px; border-radius: 1px; }
  .brand-text h1 {
    font-family: var(--display); font-weight: 700; font-size: 30px;
    letter-spacing: -0.03em; line-height: 1;
  }
  .brand-text p {
    font-family: var(--sans); font-size: 17px; color: var(--muted);
    font-weight: 500; letter-spacing: 0; margin-top: 7px;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  }
  .brand-text p .privacy {
    font-family: var(--mono); font-size: 13px; color: var(--faint);
    letter-spacing: 0.02em; padding-left: 10px;
    border-left: 1px solid var(--line-strong);
  }
  /* Dark mode toggle */
  .masthead-right { display: flex; align-items: center; gap: 16px; }
  .theme-toggle {
    width: 36px; height: 36px; border-radius: 8px; flex: none;
    border: 1px solid var(--line-strong); background: var(--panel);
    color: var(--muted); cursor: pointer; display: grid; place-items: center;
    transition: border-color .14s ease, color .14s ease, background .14s ease;
  }
  .theme-toggle:hover { border-color: var(--ink); color: var(--ink); }
  .theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .icon-sun { display: none; }
  .icon-moon { display: block; }
  html.dark .icon-sun { display: block; }
  html.dark .icon-moon { display: none; }

    .status {
    font-family: var(--mono); font-size: 11px; color: var(--muted);
    letter-spacing: 0.04em; text-align: right;
  }
  .status b { color: var(--ink); font-weight: 500; }

  /* Workspace grid */
  .workspace { display: grid; grid-template-columns: 1fr 380px; gap: 22px; align-items: start; }
  @media (max-width: 880px) { .workspace { grid-template-columns: 1fr; } }

  .panel {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 20px;
  }
  .panel + .panel { margin-top: 18px; }

  .seclabel {
    font-family: var(--mono); font-size: 10.5px; text-transform: uppercase;
    letter-spacing: 0.12em; color: var(--faint);
    display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
  }
  .seclabel::after { content: ""; flex: 1; height: 1px; background: var(--line); }

  /* Type tabs */
  .types { display: flex; flex-wrap: wrap; gap: 6px; }
  .type-tab {
    font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.04em;
    padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 7px;
    background: var(--panel); color: var(--muted); cursor: pointer;
    transition: all .14s ease;
  }
  .type-tab:hover { border-color: var(--ink); color: var(--ink); }
  .type-tab[aria-selected="true"] {
    background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
  }

  /* Fields */
  .fields { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
  .field { display: flex; flex-direction: column; gap: 6px; }
  .field.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .field label, .sublabel {
    font-family: var(--mono); font-size: 10.5px; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--muted);
  }
  /* info tooltip */
  .label-row { display: flex; align-items: center; gap: 6px; }
  .info {
    position: relative; width: 14px; height: 14px; flex: none; padding: 0;
    border: 1px solid var(--line-strong); border-radius: 50%;
    background: var(--panel); color: var(--faint); cursor: help;
    font-family: var(--mono); font-size: 9px; font-weight: 500; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    text-transform: none; letter-spacing: 0; transition: border-color .14s ease, color .14s ease;
  }
  .info:hover, .info:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
  .tip {
    position: absolute; left: calc(100% + 9px); top: 50%;
    transform: translateY(-50%) translateX(-4px);
    width: 224px; background: #14161A; color: #E7E9ED;
    border-radius: 9px; padding: 11px 13px; z-index: 30;
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
    box-shadow: 0 10px 30px rgba(20,22,26,.26);
    font-family: var(--sans); text-transform: none; letter-spacing: 0;
  }
  .info:hover .tip, .info:focus .tip, .info:focus-within .tip {
    opacity: 1; visibility: visible; pointer-events: auto;
    transform: translateY(-50%) translateX(0);
  }
  .tip::before {
    content: ""; position: absolute; right: 100%; top: 50%; transform: translateY(-50%);
    border: 6px solid transparent; border-right-color: var(--ink);
  }
  .tip-h {
    display: block; font-family: var(--mono); font-size: 9.5px; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--faint); margin-bottom: 9px;
  }
  .tip dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; margin: 0; }
  .tip dt { font-family: var(--mono); font-size: 11px; font-weight: 500; color: #7FE0A6; }
  .tip dd { margin: 0; font-size: 11.5px; line-height: 1.38; }
  @media (max-width: 560px) {
    .tip { left: auto; right: 0; top: calc(100% + 9px); transform: translateY(-4px); width: 210px; }
    .info:hover .tip, .info:focus .tip, .info:focus-within .tip { transform: translateY(0); }
    .tip::before { right: 8px; top: auto; bottom: 100%; transform: none; border-right-color: transparent; border-bottom-color: var(--ink); }
  }
  input[type="text"], input[type="url"], input[type="tel"], input[type="email"],
  input[type="password"], input[type="number"], textarea, select {
    font-family: var(--sans); font-size: 14px; color: var(--ink);
    background: var(--field); border: 1px solid var(--line-strong);
    border-radius: 8px; padding: 10px 12px; width: 100%;
    transition: border-color .14s ease, box-shadow .14s ease;
  }
  textarea { resize: vertical; min-height: 78px; line-height: 1.5; }
  input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--accent);
    background: var(--accent-soft); box-shadow: none;
  }
  select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%236B7079' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
  }
  .inline { display: flex; align-items: center; gap: 9px; }
  .inline input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); }
  .inline label { text-transform: none; letter-spacing: 0; font-family: var(--sans); font-size: 13px; color: var(--ink); }

  /* Style controls */
  .ctrl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .swatches { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
  .swatch {
    width: 24px; height: 24px; border-radius: 6px; cursor: pointer;
    border: 1px solid rgba(0,0,0,.14);
  }
  .swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
  input[type="color"] {
    -webkit-appearance: none; appearance: none; width: 24px; height: 24px;
    border: 1px solid var(--line-strong); border-radius: 6px; padding: 0; cursor: pointer; background: none;
  }
  input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
  input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
  .color-picker-wrap { position: relative; width: 24px; height: 24px; }
  .color-picker-wrap input[type="color"] { width: 100%; height: 100%; }
  .color-picker-plus {
    position: absolute; right: -4px; bottom: -4px; width: 13px; height: 13px; border-radius: 50%;
    background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; line-height: 13px;
    text-align: center; pointer-events: none; border: 1px solid var(--panel);
  }

  .seg { display: flex; gap: 5px; flex-wrap: wrap; }
  .seg button {
    font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.03em;
    padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 6px;
    background: var(--panel); color: var(--muted); cursor: pointer; transition: all .14s ease;
  }
  .seg button:hover { border-color: var(--ink); color: var(--ink); }
  .seg button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

  .range-row { display: flex; align-items: center; gap: 12px; }
  input[type="range"] { -webkit-appearance: none; appearance: none; height: 4px; background: var(--line-strong); border-radius: 3px; flex: 1; }
  input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--accent); }
  input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid #fff; }
  .range-val { font-family: var(--mono); font-size: 11px; color: var(--muted); min-width: 56px; text-align: right; }

  .logo-drop {
    border: 1.5px dashed var(--line-strong); border-radius: 8px; padding: 14px;
    text-align: center; cursor: pointer; transition: all .14s ease;
    font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.03em;
  }
  .logo-drop:hover, .logo-drop.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
  .logo-active { display: none; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
  .logo-active.show { display: flex; }
  .logo-active img { width: 30px; height: 30px; object-fit: contain; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
  .logo-active button { font-family: var(--mono); font-size: 11px; color: var(--accent); background: none; border: none; cursor: pointer; }

  .full { grid-column: 1 / -1; }

  /* Preview / calibration surface */
  .stage-wrap { position: sticky; top: 22px; }
  .stage {
    position: relative; aspect-ratio: 1; display: grid; place-items: center;
    background:
      linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 24px 24px,
      linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 24px 24px,
      var(--field);
    border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  }
  .bracket { position: absolute; width: 26px; height: 26px; border: 2.5px solid var(--accent); pointer-events: none; z-index: 3; }
  .bracket.tl { top: 14px; left: 14px; border-right: none; border-bottom: none; border-radius: 4px 0 0 0; }
  .bracket.tr { top: 14px; right: 14px; border-left: none; border-bottom: none; border-radius: 0 4px 0 0; }
  .bracket.bl { bottom: 14px; left: 14px; border-right: none; border-top: none; border-radius: 0 0 0 4px; }
  .bracket.br { bottom: 14px; right: 14px; border-left: none; border-top: none; border-radius: 0 0 4px 0; }
  .qr-holder {
    position: relative; z-index: 2; width: 64%; max-width: 280px;
    background: #fff; padding: 0; border-radius: 6px; line-height: 0;
    box-shadow: 0 6px 24px rgba(20,22,26,.10);
  }
  .qr-holder canvas, .qr-holder svg { width: 100% !important; height: auto !important; display: block; border-radius: 6px; }
  .empty {
    position: absolute; inset: 0; display: grid; place-items: center; z-index: 2;
    font-family: var(--mono); font-size: 11.5px; color: var(--faint);
    letter-spacing: 0.04em; text-align: center; padding: 0 30px;
  }
  .scanline {
    position: absolute; left: 14%; right: 14%; height: 2px; z-index: 4;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: .65; animation: scan 3.4s ease-in-out infinite;
  }
  @keyframes scan { 0%,100% { top: 22%; opacity: 0; } 50% { top: 78%; opacity: .7; } }

  .readout {
    margin-top: 14px; font-family: var(--mono); font-size: 11px; color: var(--muted);
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px;
  }
  .readout span b { color: var(--ink); font-weight: 500; }

  .exports { display: flex; gap: 8px; margin-top: 16px; }
  .exports button {
    flex: 1; font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.04em;
    padding: 11px 8px; border-radius: 8px; cursor: pointer; transition: all .14s ease;
    border: 1px solid var(--accent); background: var(--accent); color: #fff;
  }
  .exports button:hover:not(:disabled) { filter: brightness(1.12); }
  .exports button.ghost { background: var(--panel); color: var(--ink); }
  .exports button.ghost:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
  .exports button:disabled { opacity: .4; cursor: not-allowed; }

  .footnote { margin-top: 22px; font-family: var(--mono); font-size: 10.5px; color: var(--faint); letter-spacing: 0.03em; text-align: center; }

  @media (prefers-reduced-motion: reduce) { .scanline { animation: none; display: none; } }
