    * { margin: 0; padding: 0; box-sizing: border-box; }
    html, body { width: 100%; height: 100%; }
    body {
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      background: #f7f7f7;
      color: #1a1a1a;
      line-height: 1.6;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
      background-attachment: fixed;
    }
    .wrap { max-width: 1400px; margin: 0 auto;}
    .header { margin-top: 32px; margin-bottom: 40px; text-align: center; }
    .header-title {
      font-size: 48px; font-weight: 800; letter-spacing: -1.5px; margin-bottom: 12px;
      background: linear-gradient(135deg, #110623 0%, #4a4a4a 100%);
      -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    }
    .header-subtitle { font-size: 16px; color: #666; font-weight: 400; letter-spacing: .2px; }

    .controls-section, .preview-card {
      background: white; border-radius: 20px; padding: 32px;
    }
    .palette-card {
      background: white; border-radius: 20px; padding: 24px 32px;;
    }
    .controls-section { margin-bottom: 40px; }
    .palette-strip-fullwidth {
      width: 100vw; position: relative; left: 50%; right: 50%;
      margin-left: -50vw; margin-right: -50vw;
      margin-bottom: 0;
    }
    .palette-strip-fullwidth + .hero-stack { margin-top: 0; }
    .palette-strip-fullwidth .swatch-wrap { padding-bottom: 24px; }
    .palette-strip-fullwidth .color-strip {
      display: flex; padding: 0; background: none; border-radius: 0;
      border: none; width: 100%; gap: 0;
    }
    .hero-stack { display: grid; gap: 20px; justify-items: center; margin-bottom: 24px; }
    .hero-stack .palette-card { width: min(100%, 1120px); }
    .palette-topbar { display: flex; align-items: stretch; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; width: min(100%, 1120px); margin-left: auto; margin-right: auto; padding: 24px 32px; box-sizing: border-box; background: white; border-radius: 20px; }
    .palette-topbar .pill { margin-left: auto; min-height: 56px; height: 56px; padding-inline: 18px; border-radius: 14px; }
    
    /* Центрирование palette-topbar на узких экранах */
    @media (max-width: 900px) {
      .palette-topbar { flex-direction: column; align-items: center; justify-content: center; }
      .palette-topbar .pill { margin-left: 0; width: 100%; justify-content: center; }
      .palette-topbar .generator-cta--topbar { width: 100%; justify-content: center; }
    }
    
    /* Дополнительное центрирование для очень узких экранов */
    @media (max-width: 768px) {
      .palette-topbar { flex-direction: column; align-items: center; justify-content: center; }
      .palette-topbar .pill { margin-left: 0; width: 100%; justify-content: center; }
      .palette-topbar .generator-cta--topbar { width: 100%; justify-content: center; }
    }
    
    @media (max-width: 640px) {
      .palette-topbar { flex-direction: column; align-items: center; justify-content: center; }
      .palette-topbar .pill { margin-left: 0; width: 100%; justify-content: center; }
      .palette-topbar .generator-cta--topbar { width: 100%; justify-content: center; }
    }
    
    @media (max-width: 380px) {
      .palette-topbar { flex-direction: column; align-items: center; justify-content: center; }
      .palette-topbar .pill { margin-left: 0; width: 100%; justify-content: center; }
      .palette-topbar .generator-cta--topbar { width: 100%; justify-content: center; }
    }
    .generator-cta { display: grid; justify-items: center; gap: 10px; margin: 24px 0; }
    .generator-cta--topbar { display: flex; align-items: center; gap: 14px; margin: 0; }
    .generator-cta--topbar .btn-primary { width: 340px; min-width: 340px; max-width: 340px; height: 56px; padding: 0 28px; font-size: 15px; border-radius: 14px; }
    .generator-cta .btn-primary { height: 56px; padding: 0 28px; font-size: 15px; }
    .space-hint { display: inline-flex; align-items: center; gap: 10px; color: #777; font-size: 13px; font-weight: 600; }
    .space-key { display: inline-flex; align-items: center; justify-content: center; min-width: 64px; height: 30px; padding: 0 14px; border-radius: 999px; background: #f5f5f5; border: 1px solid #e8e8e8; color: #1a1a1a; font-size: 12px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; }
    .settings-wrap { display: grid; gap: 24px; justify-items: stretch; margin-bottom: 24px; }
    .settings-wrap .controls-section { width: min(100%, 1120px); margin: 0 auto; }
    .controls-label, .card-label, .extras-title, .editor-field-label, .mini-label {
      display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: #999;
    }
    .controls-label { margin-bottom: 16px; }
    .card-label { margin-bottom: 14px; }
    .controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
    .controls.centered { justify-content: center; }
    .settings-wrap .controls { justify-content: flex-start; }
    .seg {
      display: flex; background: #f5f5f5; border-radius: 10px; padding: 4px; border: 1px solid #e8e8e8; gap: 0;
    }
    .seg button {
      flex: 1; height: 40px; padding: 0 16px; background: transparent; border: none; color: #666; font-size: 13px;
      font-weight: 600; cursor: pointer; border-radius: 8px; transition: all .25s ease; white-space: nowrap;
    }
    .seg button.active { background: white; color: #1a1a1a; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
    .seg button:hover:not(.active) { color: #1a1a1a; background: rgba(0,0,0,.02); }
    .seedmode-btn { height: 36px; padding: 0 12px; background: transparent; border: none; color: #888; font-size: 12px; font-weight: 600; cursor: pointer; border-radius: 6px; transition: all .2s ease; white-space: nowrap; }
    .seedmode-btn.active { background: white; color: #1a1a1a; box-shadow: 0 1px 6px rgba(0,0,0,.08); }
    .seedmode-btn:hover:not(.active) { color: #1a1a1a; background: rgba(0,0,0,.04); }

    .toggle {
      display: inline-flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; background: #f5f5f5;
      border: 1px solid #e8e8e8; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600; color: #1a1a1a;
      transition: all .25s ease; user-select: none;
    }
    .toggle input { position: absolute; opacity: 0; pointer-events: none; }
    .toggle .track { width: 48px; height: 28px; background: #10b981; border-radius: 999px; position: relative; }
    .toggle .thumb {
      position: absolute; width: 24px; height: 24px; background: white; border-radius: 999px; top: 2px; left: 2px;
      transition: left .3s cubic-bezier(.4,0,.2,1); box-shadow: 0 2px 6px rgba(0,0,0,.12);
    }
    .toggle .track { width: 48px; height: 28px; background: #10b981; border-radius: 999px; position: relative; transition: background .3s ease; }
    .toggle input:checked + .track { background: #7C83D4; }
    .toggle input:checked + .track .thumb { left: 22px; }

    .pill, .seed-box {
      display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; background: #f5f5f5;
      border: 1px solid #e8e8e8; border-radius: 10px; font-size: 13px; font-weight: 600; color: #1a1a1a; white-space: nowrap;
    }
    .pill:hover, .seed-box:hover { background: #fafafa; border-color: #d8d8d8; }
    .pill input[type="range"] { width: 120px; height: 4px; border-radius: 2px; background: #ddd; outline: none; -webkit-appearance: none; appearance: none; cursor: pointer; }
    .pill input[type="range"]::-webkit-slider-thumb, .picker-range::-webkit-slider-thumb, #pickerHue::-webkit-slider-thumb {
      -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: white; cursor: pointer;
      box-shadow: 0 2px 6px rgba(0,0,0,.15); border: 2px solid #1a1a1a;
    }
    .pill input[type="range"]::-moz-range-thumb, .picker-range::-moz-range-thumb, #pickerHue::-moz-range-thumb {
      width: 18px; height: 18px; border-radius: 50%; background: white; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.15); border: 2px solid #1a1a1a;
    }
    .pill .value { font-variant-numeric: tabular-nums; min-width: 28px; text-align: right; font-weight: 700; }
    .stepper-btn { width: 32px; height: 32px; border-radius: 999px; border: 1px solid #dcdcdc; background: #fff; color: #1a1a1a; font-size: 20px; line-height: 1; font-weight: 500; padding: 0; }
    .stepper-btn:hover { background: #f7f7f7; }
    .stepper-btn:active { transform: translateY(1px); }

    .btn-primary, .btn-secondary, .btn-export, .swatch-lock, .seed-preview {
      display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: all .25s ease; cursor: pointer;
    }
    .btn-primary {
      position: relative; height: 48px; padding: 0 24px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white;
      border: none; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: 0 4px 16px rgba(16,185,129,.3); overflow: hidden;
    }
    .btn-primary:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(16,185,129,.4); }
    .btn-secondary, .btn-export {
      height: 44px; padding: 0 18px; background: white; border: 1px solid #e8e8e8; border-radius: 10px; font-size: 13px; font-weight: 600; color: #1a1a1a;
    }
    .btn-secondary:hover, .btn-export:hover:not(:disabled) { background: #f5f5f5; border-color: #d8d8d8; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
    .btn-export:disabled { opacity: .4; cursor: not-allowed; }
    .btn-icon, .btn-export svg { width: 16px; height: 16px; }

    .seed-box { padding-right: 8px; }
    .seed-preview {
      width: 34px; height: 34px; border-radius: 10px; border: 1px solid rgba(0,0,0,.08); background: #8B5CF6; box-shadow: 0 4px 12px rgba(0,0,0,.08);
    }
    .seed-input { width: 92px; border: none; background: transparent; font: inherit; font-weight: 700; color: #1a1a1a; outline: none; text-transform: uppercase; }
    .seed-input::placeholder { color: #999; }
    .seed-box input[type="color"] { position: absolute; opacity: 0; pointer-events: none; }

    .main-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; max-width: 1120px; margin: 0 auto; }
    .main-grid .preview-stack { width: 100%; margin: 0; }
    .codes-card { width: 100%; }
    .preview-stack { display: grid; gap: 24px; }
    .preview-surface {
      position: relative; width: 100%; aspect-ratio: 1 / 1; border-radius: 22px; background: #f4f4f4; overflow: hidden; box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
      isolation: isolate;
    }
    .preview-art,
    .preview-glow,
    .preview-vignette {
      position: absolute; inset: 0; pointer-events: none;
    }
    .preview-art { z-index: 1; }
    .preview-glow {
      z-index: 2; mix-blend-mode: screen; opacity: .82;
      background:
        radial-gradient(circle at 18% 16%, rgba(255,255,255,.30), rgba(255,255,255,0) 26%),
        radial-gradient(circle at 78% 28%, rgba(255,255,255,.18), rgba(255,255,255,0) 30%),
        radial-gradient(circle at 52% 82%, rgba(255,255,255,.10), rgba(255,255,255,0) 28%);
    }
    .preview-vignette {
      z-index: 4;
      background:
        radial-gradient(120% 110% at 50% 50%, rgba(255,255,255,0) 42%, rgba(0,0,0,.08) 100%),
        linear-gradient(180deg, rgba(255,255,255,.14) 0%, rgba(255,255,255,0) 20%, rgba(0,0,0,.02) 100%);
    }
    .preview-legend {
      display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px;
    }
    .preview-pill {
      display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 999px;
      background: #fafafa; border: 1px solid #ececec; box-shadow: 0 1px 0 rgba(255,255,255,.75) inset;
      color: #1a1a1a; font-size: 12px; font-weight: 760; line-height: 1;
    }
    .preview-pill-dot {
      width: 12px; height: 12px; border-radius: 999px; border: 1px solid rgba(0,0,0,.08); flex: 0 0 auto;
    }
    .preview-pill span {
      color: #747474; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Courier New', monospace; font-weight: 700;
    }
    .preview-toolbar { display: grid; gap: 14px; margin-bottom: 18px; }
    .preview-toolbar-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .preview-seg-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
    .preview-meta { font-size: 14px; font-weight: 700; color: #2a2a2a; margin-bottom: 0; }
    .preview-seg { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 0; }
    .preview-shuffle { min-width: 44px; width: 44px; height: 40px; padding: 0; border-radius: 10px; }
    .preview-chip {
      display: inline-flex; align-items: center; justify-content: center; height: 40px; padding: 0 14px;
      background: #fff; border: 1px solid #e8e8e8; border-radius: 10px; cursor: pointer;
      font-size: 13px; font-weight: 700; color: #1a1a1a; transition: all .22s ease;
    }
    .preview-chip:hover { background: #f6f6f6; border-color: #cfcfcf; }
    .preview-chip.active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; box-shadow: 0 6px 16px rgba(0,0,0,.12); }
    .preview-caption { display: grid; gap: 14px; }
    .palette-grid + .preview-caption { margin-top: 30px; }
    .note-list { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
    .note-item {
      display: grid; gap: 3px; padding: 12px 14px; background: #fafafa; border: 1px solid #ececec; border-radius: 12px;
    }
    .note-item strong { font-size: 13px; }
    .note-item span { color: #777; font-size: 13px; line-height: 1.45; }

    .palette-grid, .export-buttons { display: grid; gap: 24px; }
    .export-section { margin-top: 0; padding-top: 0; }
    .export-buttons { display: flex; flex-wrap: wrap; gap: 12px; }
    .color-strip {
      display: flex; align-items: stretch; padding: 0; background: none;
      border-radius: 0; border: none; width: 100%; gap: 0;
    }
    .swatch-wrap { flex: 1 1 0; min-width: 28px; display: grid; gap: 12px; margin-bottom: 0; }
    .color-swatch {
      position: relative; width: 100%; height: auto; aspect-ratio: 4 / 8; border: none; box-shadow: none; overflow: hidden;
      cursor: pointer; transition: all .25s ease; background: #ddd; border-radius: 0;
    }
    .color-swatch:hover { filter: brightness(1.08); }
    .color-swatch::after {
      content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,.18) 0%, transparent 100%); opacity: 0; transition: opacity .3s ease;
    }
    .color-swatch:hover::after { opacity: 1; }
    .swatch-lock {
      height: 28px; padding: 0 10px 0 8px; border: 0.1px solid #e0e0e0; background: white; border-radius: 999px;
      display: inline-flex; align-items: center; gap: 5px; color: #999;
      font-size: 13px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap;
      transition: all .2s ease; cursor: pointer; max-width: calc(100% - 4px); overflow: hidden; margin: 0 4px;
    }
    .swatch-lock:hover { border-color: #bbb; color: #555; }
    .swatch-lock.active { background: #1a1a1a; color: white; border-color: #1a1a1a; }
    .swatch-lock svg { flex-shrink: 0; }
    .dominance-bar { display: flex; height: 48px; border-radius: 12px; overflow: hidden; border: 1px solid #e8e8e8; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
    .dominance-segment { flex: 1 1 0; height: 100%; position: relative; border-right: 1px solid rgba(255,255,255,.4); }
    .dominance-segment:last-child { border-right: none; }

    .codes-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
    .codes-sort-links { display: flex; align-items: center; margin-left: auto; }
    .codes-sort-link {
      font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: #bbb; text-decoration: none; transition: color .2s ease;
    }
    .codes-sort-link.active { color: #1a1a1a; text-decoration: underline; text-underline-offset: 3px; }
    .codes-sort-sep { font-size: 12px; font-weight: 700; color: #bbb; margin: 0 10px; }
    .details { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .rowCard {
      background: #fff; border: 1px solid #e8e8e8; border-radius: 14px; overflow: hidden; cursor: pointer; display: grid; grid-template-columns: 56px 1fr; min-height: 110px; transition: all .25s ease;
    }
    .rowCard:hover { border-color: #d8d8d8; box-shadow: 0 10px 24px rgba(0,0,0,.08); transform: translateY(-2px); }
    .miniChip { border-right: 1px solid #e8e8e8; background: #eee; }
    .rowBody { padding: 12px 14px; display: grid; gap: 10px; align-content: start; }
    .rowTop { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
    .idx { font-weight: 700; color: #7a7a7a; font-size: 12px; }
    .hint { font-size: 12px; color: #7a7a7a; text-transform: lowercase; }
    .codeLine { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
    .codeTag {
      display: inline-flex; gap: 8px; align-items: baseline; border: 1px solid #dcdcdc; border-radius: 999px; padding: 7px 10px; background: rgba(0,0,0,.02); cursor: pointer; transition: all .2s ease;
    }
    .codeTag:hover { background: rgba(0,0,0,.04); border-color: #cfcfcf; }
    .label { font-size: 12px; font-weight: 800; color: #7a7a7a; }
    .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; font-weight: 700; color: #7a7a7a; }

    .modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.4); z-index: 9999; backdrop-filter: blur(4px); }
    .modal.show { display: flex; }
    .modal-content {
      background: white; border-radius: 24px; padding: 40px; width: 100%; max-width: 800px; box-shadow: 0 20px 60px rgba(0,0,0,.2); max-height: 90vh; overflow-y: auto;
    }
    .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; padding-bottom: 20px; border-bottom: 1px solid #e8e8e8; }
    .modal-title { font-size: 24px; font-weight: 800; color: #1a1a1a; }
    .modal-close { width: 40px; height: 40px; border: none; background: #f5f5f5; border-radius: 10px; font-size: 20px; cursor: pointer; }
    .modal-body { display: grid; grid-template-columns: 280px 1fr; gap: 40px; }
    .wheel-container, .editor-controls { display: grid; gap: 20px; }
    .inline-picker { width: 260px; display: flex; flex-direction: column; gap: 10px; }
    .picker-sv { width: 260px; height: 260px; border-radius: 10px; overflow: hidden; cursor: crosshair; position: relative; box-shadow: 0 2px 8px rgba(0,0,0,.10); }
    #pickerSV { display: block; width: 100%; height: 100%; }
    .picker-sv-cursor {
      position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.3);
      transform: translate(-50%, -50%); pointer-events: none; top: 50%; left: 50%;
    }
    #pickerHue, .picker-range { -webkit-appearance: none; appearance: none; width: 100%; height: 16px; border-radius: 8px; border: none; outline: none; cursor: pointer; }
    #pickerHue { background: linear-gradient(to right,#ff0000,#ffff00,#00ff00,#00ffff,#0000ff,#ff00ff,#ff0000); }
    .color-tiles-row { display: flex; gap: 12px; }
    .color-tile { flex: 1; display: flex; flex-direction: column; gap: 8px; }
    .color-tile-swatch { width: 100%; height: 64px; border-radius: 14px; border: 1px solid rgba(0,0,0,.06); background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.08); }
    .codes-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
    .codes-col { display: flex; flex-direction: column; gap: 12px; }
    .editor-field { display: grid; gap: 12px; }
    .editor-field-value {
      font-size: 13px; font-family: 'Courier New', monospace; font-weight: 600; color: #1a1a1a; padding: 10px 12px; background: #f5f5f5; border-radius: 8px; border: 1px solid #e8e8e8;
      cursor: pointer;
    }
    .editor-field-value--static { color: #999; cursor: default; }
    .editor-actions { display: flex; gap: 12px; margin-top: 20px; }
    .btn-modal { flex: 1; height: 44px; background: white; border: 1.5px solid #e8e8e8; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer; color: #1a1a1a; }
    .btn-modal.primary { background: #1a1a1a; color: white; border-color: #1a1a1a; }
    .toast {
      position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1a1a1a; color: white; padding: 14px 20px; border-radius: 10px; font-size: 13px; font-weight: 600;
      opacity: 0; pointer-events: none; transition: opacity .3s ease; z-index: 10000; box-shadow: 0 8px 24px rgba(0,0,0,.2);
    }
    .toast.show { opacity: 1; }
    .privacy-note { margin: 22px 0 0; text-align: center; font-size: 12px; color: #8a8a8a; letter-spacing: .2px; padding-bottom: 30px; }

    @media (max-width: 1080px) {
      .main-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
      .details { grid-template-columns: 1fr; }
    }
    @media (max-width: 860px) {
      .main-grid { grid-template-columns: 1fr; gap: 32px; }
      .main-grid .preview-stack { width: 100%; margin: 0 auto; }
    }
    @media (max-width: 900px) {
      .generator-cta--topbar { width: 100%; justify-content: flex-start; }
      .generator-cta--topbar .btn-primary { width: 340px; min-width: 340px; max-width: 340px; flex: none; }
      .palette-topbar .pill { margin-left: 0; }
    }

    @media (max-width: 768px) {
      .wrap { padding: 32px 20px; }
      .header-title { font-size: 36px; }
      .controls-section, .preview-card, .palette-card, .modal-content { padding: 24px; }
      .modal-body, .codes-two-col { grid-template-columns: 1fr; }
      .color-swatch { aspect-ratio: 4 / 6; }
      .generator-cta--topbar { flex-wrap: wrap; gap: 10px; }
      .generator-cta--topbar .btn-primary { width: 340px; min-width: 340px; max-width: 340px; }
      .note-list { grid-template-columns: 1fr; }
    }

/* Одинаковые боковые отступы для Settings и Preview на планшетах */
@media (max-width: 1024px) and (min-width: 641px) {
  .settings-wrap,
  .main-grid {
    padding-left: 24px;
    padding-right: 24px;
    box-sizing: border-box;
  }
}

/* Одинаковые боковые отступы для Settings и Preview на мобильных */
@media (max-width: 640px) {
  .settings-wrap,
  .main-grid {
    padding-left: 16px;
    padding-right: 16px;
    box-sizing: border-box;
  }
}

    /* ========== ПЛАНШЕТЫ (iPad и большие планшеты) ========== */
    @media (max-width: 1024px) and (min-width: 641px) {
      /* Скрыть только названия цветов, оставить кнопки замочков */
      .swatch-lock { font-size: 0; }
      .swatch-lock svg { margin: 0; }
      
        #userSvgPreviewSurface {
    aspect-ratio: 1 / 1;
    border-radius: 22px;
    overflow: hidden;
  }

  #userSvgPreviewSurface > svg {
    width: 100%;
    height: 100%;
    display: block;
  }
      
      .wrap { max-width: 100%; padding: 0 24px; }
      .header { margin-top: 24px; margin-bottom: 32px; }
      .header-title { font-size: 40px; letter-spacing: -1px; }
      .header-subtitle { font-size: 15px; }
      
      .controls-section, .preview-card, .palette-card { padding: 28px; border-radius: 18px; }
      .controls-section { margin-bottom: 32px; }
      
      .main-grid { grid-template-columns: 1fr; gap: 28px; }
      .preview-surface { aspect-ratio: 1 / 0.9; }
      
      .palette-topbar { padding: 20px 28px; gap: 12px; }
      .palette-topbar .pill { height: 52px; padding-inline: 16px; }
      
      .generator-cta--topbar .btn-primary { width: 100%; max-width: 280px; height: 52px; font-size: 14px; }
      
      .controls { gap: 14px; }
      .seg button { height: 38px; padding: 0 14px; font-size: 12px; }
      .pill, .seed-box { min-height: 44px; height: 44px; padding: 0 14px; font-size: 12px; }
      .pill input[type="range"] { width: 100px; }
      
      .stepper-btn { width: 30px; height: 30px; font-size: 18px; }
      .btn-primary { height: 44px; padding: 0 20px; font-size: 13px; }
      .btn-secondary, .btn-export { height: 40px; padding: 0 16px; font-size: 12px; }
      
      .preview-legend { gap: 8px; margin-top: 12px; }
      .preview-pill { padding: 6px 10px; font-size: 11px; }
      .preview-pill-dot { width: 10px; height: 10px; }
      
      .note-list { grid-template-columns: repeat(2, 1fr); gap: 12px; }
      .note-item { padding: 10px 12px; }
      
      .export-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
      .btn-export { width: 100%; }
      
      .space-hint { font-size: 12px; }
      .space-key { min-width: 56px; height: 28px; font-size: 11px; }
    }

    /* ========== МАЛЕНЬКИЕ ПЛАНШЕТЫ И БОЛЬШИЕ СМАРТФОНЫ (640px - 768px) ========== */
    @media (max-width: 768px) and (min-width: 641px) {
      /* Скрыть только названия цветов, оставить кнопки замочков */
      .swatch-lock { font-size: 0; }
      .swatch-lock svg { margin: 0; }
      
      .wrap { max-width: 100%; padding: 0 18px; }
      .header { margin-top: 20px; margin-bottom: 28px; }
      .header-title { font-size: 32px; letter-spacing: -0.8px; }
      .header-subtitle { font-size: 14px; }
      
      .controls-section, .preview-card, .palette-card { padding: 20px; border-radius: 16px; }
      .controls-section { margin-bottom: 24px; }
      
      .main-grid { grid-template-columns: 1fr; gap: 20px; }
      .preview-surface { aspect-ratio: 1 / 0.85; }
      
       .palette-topbar { 
        padding: 12px 16px; 
        gap: 8px; 
        flex-wrap: wrap;
        flex-direction: column;
        align-items: center;
      }
      .palette-topbar .pill { height: 48px; padding-inline: 14px; margin-left: 0; }
      
      .generator-cta--topbar { flex-direction: column; width: 100%; }
      .generator-cta--topbar .btn-primary { width: 100%; max-width: none; height: 48px; }
      
      .controls { gap: 12px; flex-wrap: wrap; }
      .seg { padding: 3px; }
      .seg button { height: 36px; padding: 0 12px; font-size: 11px; }
      .pill, .seed-box { min-height: 42px; height: 42px; padding: 0 12px; font-size: 11px; }
      .pill input[type="range"] { width: 90px; }
      
      .stepper-btn { width: 28px; height: 28px; font-size: 16px; }
      .btn-primary { height: 42px; padding: 0 18px; font-size: 12px; }
      .btn-secondary, .btn-export { height: 38px; padding: 0 14px; font-size: 11px; }
      
      .preview-legend { gap: 6px; margin-top: 10px; }
      .preview-pill { padding: 5px 9px; font-size: 10px; }
      .preview-pill-dot { width: 9px; height: 9px; }
      
      .note-list { grid-template-columns: repeat(2, 1fr); gap: 10px; }
      .note-item { padding: 8px 10px; }
      
      .export-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
      .btn-export { width: 100%; }
      
      .controls-label { margin-bottom: 12px; font-size: 11px; }
      .card-label { margin-bottom: 10px; font-size: 11px; }
      .space-hint { font-size: 11px; }
      .space-key { min-width: 52px; height: 26px; font-size: 10px; }
    }

    /* ========== СМАРТФОНЫ (до 640px) ========== */
    @media (max-width: 640px) {
      /* Убрать скругление с главной палитры */
      .palette-strip-fullwidth .color-strip { border-radius: 0 !important; }
      .color-swatch { border-radius: 0 !important; }
      
      /* Скрыть только названия цветов, оставить кнопки замочков */
      .swatch-lock { font-size: 0; }
      .swatch-lock svg { margin: 0; }
      .swatch-wrap { gap: 0; }
      
      /* Отступ для оверфлоу */
      body { overflow-x: hidden; }
      * { -webkit-tap-highlight-color: rgba(0,0,0,.05); }
      
      html, body { width: 100%; height: 100%; }
      body { background-attachment: scroll; overflow-x: hidden; }
      
      .wrap { max-width: 100%; padding: 0 16px; margin: 0 auto; }
      
      /* Заголовок */
      .header { margin-top: 16px; margin-bottom: 20px; text-align: center; }
      .header-title { 
        font-size: 28px; 
        font-weight: 800; 
        letter-spacing: -0.6px; 
        margin-bottom: 8px; 
        line-height: 1.2;
      }
      .header-subtitle { 
        font-size: 13px; 
        color: #666; 
        font-weight: 400; 
        letter-spacing: 0px;
      }
      
      /* Карточки и секции */
      .controls-section, .preview-card, .palette-card, .modal-content { 
        background: white; 
        border-radius: 14px; 
        padding: 16px; 
      }
      .controls-section { margin-bottom: 20px; }
      .palette-card { padding: 16px; }
      
      /* Полноширинная палитра */
      .palette-strip-fullwidth {
        width: 100vw;
        position: relative;
        left: 50%;
        right: 50%;
        margin-left: -50vw;
        margin-right: -50vw;
        margin-bottom: 0;
      }
      .palette-strip-fullwidth .swatch-wrap { padding-bottom: 16px; }
      .palette-strip-fullwidth .color-strip { width: 100%; }
      
      /* Основная сетка */
      .main-grid { 
        display: grid; 
        grid-template-columns: 1fr; 
        gap: 16px; 
        align-items: start; 
        max-width: 100%; 
        margin: 0 auto; 
      }
      .main-grid .preview-stack { width: 100%; margin: 0; }
      .codes-card { width: 100%; }
      
      /* Превью */
      .preview-surface { 
        position: relative; 
        width: 100%; 
        aspect-ratio: 1 / 0.8; 
        border-radius: 16px; 
        background: #f4f4f4; 
        overflow: hidden;
      }
      .preview-legend { 
        display: flex; 
        flex-wrap: wrap; 
        gap: 6px; 
        margin-top: 8px; 
      }
      .preview-pill { 
        display: inline-flex; 
        align-items: center; 
        gap: 6px; 
        padding: 4px 8px; 
        border-radius: 999px; 
        background: #fafafa; 
        border: 1px solid #ececec; 
        color: #1a1a1a; 
        font-size: 9px; 
        font-weight: 700; 
        line-height: 1;
      }
      .preview-pill-dot { 
        width: 8px; 
        height: 8px; 
        border-radius: 999px; 
        flex: 0 0 auto;
      }
      .preview-pill span { font-size: 9px; }
      
      /* Топбар палитры */
      .palette-topbar { 
        display: flex; 
        align-items: center; 
        justify-content: space-between; 
        gap: 8px; 
        margin-bottom: 16px; 
        flex-wrap: wrap; 
        width: 100%; 
        padding: 12px 16px; 
        box-sizing: border-box; 
        background: white; 
        border-radius: 14px; 
      }
      .palette-topbar .pill { 
        margin-left: 0; 
        min-height: 40px; 
        height: 40px; 
        padding-inline: 12px; 
        border-radius: 10px; 
      }
      
      /* Кнопки и элементы управления */
      .generator-cta { 
        display: grid; 
        justify-items: center; 
        gap: 8px; 
        margin: 16px 0; 
        text-align: center;
      }
      .generator-cta--topbar { 
        display: flex; 
        flex-direction: column; 
        align-items: stretch; 
        gap: 10px; 
        margin: 0; 
        width: 100%; 
      }
      .generator-cta--topbar .btn-primary { 
        width: 100%; 
        max-width: none; 
        min-width: auto; 
        height: 44px; 
        padding: 0 16px; 
        font-size: 13px; 
        border-radius: 12px; 
      }
      
      /* Контролы */
      .controls { 
        display: flex; 
        flex-wrap: wrap; 
        gap: 10px; 
        align-items: center; 
        width: 100%;
        justify-content: center;
      }
      .controls.centered { 
        justify-content: center; 
      }
      .settings-wrap .controls { 
        justify-content: center; 
      }
      
      /* Центрирование топбара палитры */
      .palette-topbar { 
        flex-direction: column; 
        align-items: center; 
        gap: 12px;
      }
      
      /* Центрирование блока с количеством цветов */
      .pill { 
        margin: 0 auto; 
        width: auto;
      }
      
      /* Отступ между палитрой и кнопками замочков */
      .swatch-wrap { 
        gap: 8px; 
        margin-bottom: 8px;
      }
      
      /* Сегментированный контроль */
      .seg { 
        display: flex; 
        background: #f5f5f5; 
        border-radius: 8px; 
        padding: 3px; 
        border: 1px solid #e8e8e8; 
        gap: 0;
        flex-wrap: wrap;
      }
      .seg button { 
        flex: 1 1 auto;
        min-width: 60px;
        height: 34px; 
        padding: 0 10px; 
        background: transparent; 
        border: none; 
        color: #666; 
        font-size: 11px; 
        font-weight: 600; 
        cursor: pointer; 
        border-radius: 6px; 
        transition: all .25s ease; 
        white-space: nowrap;
      }
      .seg button.active { 
        background: white; 
        color: #1a1a1a; 
        box-shadow: 0 1px 4px rgba(0,0,0,.04); 
      }
      
      /* Кнопки режима */
      .seedmode-btn { 
        height: 32px; 
        padding: 0 10px; 
        background: transparent; 
        border: none; 
        color: #888; 
        font-size: 10px; 
        font-weight: 600; 
        cursor: pointer; 
        border-radius: 5px; 
        transition: all .2s ease; 
        white-space: nowrap; 
      }
      .seedmode-btn.active { 
        background: white; 
        color: #1a1a1a; 
        box-shadow: 0 1px 4px rgba(0,0,0,.06); 
      }
      
      /* Тоггл */
      .toggle { 
        display: inline-flex; 
        align-items: center; 
        gap: 8px; 
        height: 40px; 
        padding: 0 12px; 
        background: #f5f5f5; 
        border: 1px solid #e8e8e8; 
        border-radius: 8px; 
        cursor: pointer; 
        font-size: 11px; 
        font-weight: 600; 
        color: #1a1a1a; 
        transition: all .25s ease; 
        user-select: none;
      }
      .toggle .track { 
        width: 44px; 
        height: 26px; 
        background: #10b981; 
        border-radius: 999px; 
        position: relative; 
        transition: background .3s ease; 
      }
      .toggle .thumb { 
        position: absolute; 
        width: 22px; 
        height: 22px; 
        background: white; 
        border-radius: 999px; 
        top: 2px; 
        left: 2px; 
        transition: left .3s cubic-bezier(.4,0,.2,1); 
        box-shadow: 0 1px 3px rgba(0,0,0,.1);
      }
      .toggle input:checked + .track { background: #7C83D4; }
      .toggle input:checked + .track .thumb { left: 20px; }
      
      /* Пилюли и инпуты */
      .pill, .seed-box { 
        display: flex; 
        align-items: center; 
        gap: 10px; 
        min-height: 40px; 
        height: 40px; 
        padding: 0 12px; 
        background: #f5f5f5; 
        border: 1px solid #e8e8e8; 
        border-radius: 8px; 
        font-size: 11px; 
        font-weight: 600; 
        color: #1a1a1a; 
        white-space: nowrap;
      }
      .pill input[type="range"] { 
        width: 80px; 
        height: 3px; 
        border-radius: 2px; 
        background: #ddd; 
      }
      .pill input[type="range"]::-webkit-slider-thumb,
      .picker-range::-webkit-slider-thumb,
      #pickerHue::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background: white;
        cursor: pointer;
        box-shadow: 0 1px 4px rgba(0,0,0,.12);
        border: 2px solid #1a1a1a;
      }
      .pill .value { 
        font-variant-numeric: tabular-nums; 
        min-width: 24px; 
        text-align: right; 
        font-weight: 700; 
      }
      
      /* Кнопки степпера */
      .stepper-btn { 
        width: 26px; 
        height: 26px; 
        border-radius: 999px; 
        border: 1px solid #dcdcdc; 
        background: #fff; 
        color: #1a1a1a; 
        font-size: 16px; 
        line-height: 1; 
        font-weight: 500; 
        padding: 0; 
        cursor: pointer;
      }
      .stepper-btn:active { transform: translateY(1px); }
      
      /* Основные кнопки */
      .btn-primary { 
        position: relative; 
        height: 40px; 
        padding: 0 18px; 
        background: linear-gradient(135deg, #10b981 0%, #059669 100%); 
        color: white; 
        border: none; 
        border-radius: 10px; 
        font-size: 12px; 
        font-weight: 600; 
        box-shadow: 0 2px 8px rgba(16,185,129,.2); 
        overflow: hidden;
      }
      .btn-primary:active { transform: translateY(1px); }
      
      /* Вторичные кнопки */
      .btn-secondary, .btn-export { 
        height: 38px; 
        padding: 0 14px; 
        background: white; 
        border: 1px solid #e8e8e8; 
        border-radius: 8px; 
        font-size: 11px; 
        font-weight: 600; 
        color: #1a1a1a; 
        cursor: pointer;
      }
      .btn-secondary:active, 
      .btn-export:active:not(:disabled) { 
        background: #f5f5f5; 
        border-color: #d8d8d8; 
      }
      
      .btn-icon, .btn-export svg { 
        width: 14px; 
        height: 14px; 
      }
      
      /* Превью семени */
      .seed-box { padding-right: 6px; }
      .seed-preview { 
        width: 30px; 
        height: 30px; 
        border-radius: 8px; 
        border: 1px solid rgba(0,0,0,.08); 
        background: #8B5CF6; 
        box-shadow: 0 2px 6px rgba(0,0,0,.06);
      }
      .seed-input { 
        width: 80px; 
        border: none; 
        background: transparent; 
        font: inherit; 
        font-weight: 700; 
        color: #1a1a1a; 
        outline: none; 
        text-transform: uppercase; 
        font-size: 11px;
      }
      
      /* Метки и лейблы */
      .controls-label, .card-label, .extras-title, .editor-field-label, .mini-label { 
        display: block; 
        font-size: 10px; 
        font-weight: 700; 
        text-transform: uppercase; 
        letter-spacing: 0.8px; 
        color: #999;
      }
      .controls-label { margin-bottom: 12px; }
      .card-label { margin-bottom: 10px; }
      
      /* Подсказка с клавишей */
      .space-hint { 
        display: inline-flex; 
        align-items: center; 
        justify-content: center;
        gap: 8px; 
        color: #777; 
        font-size: 10px; 
        font-weight: 600; 
        width: 100%;
      }
      .space-key { 
        display: inline-flex; 
        align-items: center; 
        justify-content: center; 
        min-width: 48px; 
        height: 24px; 
        padding: 0 10px; 
        border-radius: 999px; 
        background: #f5f5f5; 
        border: 1px solid #e8e8e8; 
        color: #1a1a1a; 
        font-size: 9px; 
        font-weight: 800; 
        letter-spacing: 0.4px; 
        text-transform: uppercase; 
      }
      
      /* Сетка заметок */
      .note-list { 
        display: grid; 
        grid-template-columns: 1fr; 
        gap: 8px; 
      }
      .note-item { 
        display: grid; 
        gap: 2px; 
        padding: 8px 10px; 
        background: #fafafa; 
        border: 1px solid #ececec; 
        border-radius: 10px;
      }
      .note-item strong { 
        font-size: 11px; 
        font-weight: 700; 
        color: #1a1a1a; 
      }
      .note-item span { 
        font-size: 10px; 
        color: #666; 
      }
      
      /* Кнопки экспорта */
      .export-buttons { 
        display: grid; 
        grid-template-columns: 1fr; 
        gap: 10px; 
        margin-top: 12px; 
      }
      .btn-export { 
        width: 100%; 
        height: 40px; 
        display: flex; 
        align-items: center; 
        justify-content: center; 
        gap: 8px; 
      }
      
      /* Модальное окно */
      .modal-content { padding: 16px; }
      .modal-body { 
        display: grid; 
        grid-template-columns: 1fr; 
        gap: 16px; 
      }
      .codes-two-col { 
        display: grid; 
        grid-template-columns: 1fr; 
        gap: 12px; 
      }
      .codes-col { 
        display: flex; 
        flex-direction: column; 
        gap: 10px; 
      }
      .editor-field { 
        display: grid; 
        gap: 10px; 
      }
      .editor-field-value { 
        font-size: 11px; 
        font-family: 'Courier New', monospace; 
        font-weight: 600; 
        color: #1a1a1a; 
        padding: 8px 10px; 
        background: #f5f5f5; 
        border-radius: 6px; 
        border: 1px solid #e8e8e8;
      }
      
      /* Действия в модальном окне */
      .editor-actions { 
        display: flex; 
        gap: 10px; 
        margin-top: 16px; 
      }
      .btn-modal { 
        flex: 1; 
        height: 40px; 
        background: white; 
        border: 1.5px solid #e8e8e8; 
        border-radius: 8px; 
        font-size: 12px; 
        font-weight: 700; 
        cursor: pointer; 
        color: #1a1a1a; 
      }
      .btn-modal.primary { 
        background: #1a1a1a; 
        color: white; 
        border-color: #1a1a1a; 
      }
      
      /* Палитра цветов */
      .color-swatch { 
        aspect-ratio: 4 / 6; 
        border-radius: 12px; 
        overflow: hidden;
      }
      .swatch-wrap { padding-bottom: 12px; }
      .palette-grid { 
        display: grid; 
        grid-template-columns: repeat(2, 1fr); 
        gap: 8px; 
      }
      
      /* Превью палитры */
      .preview-toolbar { 
        display: grid; 
        gap: 10px; 
        margin-bottom: 12px; 
      }
      .preview-toolbar-top { 
        display: flex; 
        align-items: center; 
        justify-content: space-between; 
        gap: 8px; 
        flex-wrap: wrap;
      }
      .preview-meta { 
        font-size: 12px; 
        font-weight: 700; 
        color: #2a2a2a; 
        margin-bottom: 0; 
      }
      .preview-seg { 
        display: flex; 
        flex-wrap: wrap; 
        gap: 8px; 
        margin-bottom: 0; 
      }
      .preview-chip { 
        display: inline-flex; 
        align-items: center; 
        justify-content: center; 
        height: 36px; 
        padding: 0 12px; 
        background: #fff; 
        border: 1px solid #e8e8e8; 
        border-radius: 8px; 
        cursor: pointer; 
        font-size: 11px; 
        font-weight: 700; 
        color: #1a1a1a; 
        transition: all .22s ease;
      }
      .preview-chip:active { 
        background: #1a1a1a; 
        color: #fff; 
        border-color: #1a1a1a; 
      }
      
      /* Тост-уведомление */
      .toast { 
        position: fixed; 
        left: 16px; 
        right: 16px; 
        bottom: 16px; 
        transform: none; 
        background: #1a1a1a; 
        color: white; 
        padding: 12px 16px; 
        border-radius: 8px; 
        font-size: 12px; 
        font-weight: 600; 
        opacity: 0; 
        pointer-events: none; 
        transition: opacity .3s ease; 
        z-index: 10000; 
        box-shadow: 0 4px 12px rgba(0,0,0,.15);
      }
      .toast.show { opacity: 1; }
      
      /* Примечание о конфиденциальности */
      .privacy-note { 
        margin: 16px 0 0; 
        text-align: center; 
        font-size: 11px; 
        color: #8a8a8a; 
        letter-spacing: 0px; 
        padding-bottom: 20px; 
      }
      
      /* Оптимизация для сенсорных экранов */
      @supports (padding: max(0px)) {
        .wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
        .toast { left: max(16px, env(safe-area-inset-left)); right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); }
      }
    }

    /* ========== ОЧЕНЬ МАЛЕНЬКИЕ СМАРТФОНЫ (до 380px) ========== */
    @media (max-width: 380px) {
      .wrap { padding: 0 12px; }
      
      .header { margin-top: 12px; margin-bottom: 16px; }
      .header-title { font-size: 24px; letter-spacing: -0.4px; }
      .header-subtitle { font-size: 12px; }
      
      .controls-section, .preview-card, .palette-card { padding: 12px; border-radius: 12px; }
      .controls-section { margin-bottom: 16px; }
      
      .main-grid { gap: 12px; }
      .preview-surface { aspect-ratio: 1 / 0.75; }
      
      .palette-topbar { 
        padding: 10px 12px; 
        gap: 6px;
        flex-direction: column;
        align-items: center;
      }
      .palette-topbar .pill { 
        height: 36px; 
        padding-inline: 10px;
        margin: 0 auto;
        width: auto;
      }
      
      .generator-cta--topbar .btn-primary { height: 40px; font-size: 12px; }
      
      .seg button { height: 32px; padding: 0 8px; font-size: 10px; }
      .pill, .seed-box { height: 36px; padding: 0 10px; font-size: 10px; }
      .pill input[type="range"] { width: 70px; }
      
      .stepper-btn { width: 24px; height: 24px; font-size: 14px; }
      .btn-primary { height: 36px; padding: 0 14px; font-size: 11px; }
      .btn-secondary, .btn-export { height: 34px; padding: 0 12px; font-size: 10px; }
      
      .preview-legend { gap: 4px; margin-top: 6px; }
      .preview-pill { padding: 3px 6px; font-size: 8px; }
      .preview-pill-dot { width: 6px; height: 6px; }
      
      .note-list { gap: 6px; }
      .note-item { padding: 6px 8px; }
      
      .export-buttons { gap: 8px; }
      .btn-export { height: 36px; }
      
      .controls-label, .card-label { font-size: 9px; margin-bottom: 8px; }
      .space-key { min-width: 44px; height: 22px; font-size: 8px; }
      
      .palette-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
      
      .preview-chip { height: 32px; padding: 0 10px; font-size: 10px; }
      .preview-meta { font-size: 11px; }
      
      .modal-content { padding: 12px; }
      .editor-actions { gap: 8px; }
      .btn-modal { height: 36px; font-size: 11px; }
      
      .toast { left: 12px; right: 12px; bottom: 12px; padding: 10px 12px; font-size: 11px; }
      .privacy-note { font-size: 10px; margin: 12px 0 0; padding-bottom: 16px; }
    }

/* ===== inline styles extracted from palette-generator.html ===== */
.history-bar--empty .history-nav-btn,
  .history-bar--empty .history-thumbs { opacity: 0.35; pointer-events: none; }
  .history-nav-btn {
    display: flex; align-items: center; gap: 5px;
    padding: 6px 12px; border: 1.5px solid #e0e0e0; border-radius: 8px;
    background: #fff; color: #555; font-size: 12px; font-weight: 600;
    cursor: pointer; white-space: nowrap; flex-shrink: 0;
    transition: background .15s, border-color .15s, color .15s;
  }
  .history-nav-btn:hover:not(:disabled) { background: #f0f0f0; border-color: #ccc; color: #111; }
  .history-nav-btn:disabled { opacity: 0.35; cursor: default; }
  .history-bar {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
  
  .history-bar {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.history-thumbs {
  min-width: 0;
  width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.history-thumbs {
  min-width: 0;
}
  .history-thumbs::-webkit-scrollbar { display: none; }
  .history-thumb {
    display: flex; border-radius: 7px; overflow: hidden;
    flex-shrink: 0; height: 28px; cursor: pointer;
    border: 2px solid transparent; transition: border-color .15s, transform .15s;
  }
  .history-thumb:hover { transform: translateY(-2px); }
  .history-thumb-swatch { width: 18px; height: 28px; }

  .preview-color-locks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 4px;
  }
  .preview-color-lock-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 8px;
    border-radius: 8px;
    background: #f7f7f7;
    transition: background .15s;
  }
  .preview-color-lock-row:hover { background: #f0f0f0; }
  .preview-color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex: 0 0 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
  }
  .preview-color-lock-name {
    font-size: 11px;
    font-weight: 500;
    color: #666;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
  }
  .preview-lock-btn {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    padding: 0;
    transition: color .15s, background .15s;
  }
  .preview-lock-btn:hover { color: #999; background: #e8e8e8; }
  .preview-lock-btn.active { color: #111; }
  .preview-lock-btn.active:hover { color: #333; background: #e8e8e8; }

  .export-format-wrap{
    display:flex;
    align-items:center;
    gap:8px;
    position:relative;
  }

  .export-help{
    position:relative;
    display:flex;
    align-items:center;
    justify-content:center;
  }

  .export-help-btn{
    width:22px;
    height:22px;
    flex:0 0 22px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    border:none;
    border-radius:999px;
    background:#f1f1f1;
    color:#b8b8b8;
    cursor:help;
    font-size:12px;
    font-weight:700;
    line-height:1;
    padding:0;
    transition:background .18s ease, color .18s ease, transform .18s ease;
  }

  .export-help:hover .export-help-btn,
  .export-help:focus-within .export-help-btn{
    background:#ebebeb;
    color:#9f9f9f;
    transform:translateY(-1px);
  }

  .export-tooltip{
    position:absolute;
    left:50%;
    bottom:calc(100% + 10px);
    transform:translateX(-50%) translateY(4px);
    min-width:220px;
    max-width:260px;
    padding:10px 12px;
    border-radius:10px;
    background:#2f2f2f;
    color:#fff;
    font-size:12px;
    line-height:1.5;
    font-weight:500;
    box-shadow:0 10px 26px rgba(0,0,0,.16);
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transition:opacity .18s ease, transform .18s ease, visibility .18s ease;
    z-index:20;
    text-align:left;
  }

  .export-tooltip::after{
    content:"";
    position:absolute;
    left:50%;
    top:100%;
    transform:translateX(-50%);
    border:6px solid transparent;
    border-top-color:#2f2f2f;
  }

  .export-help:hover .export-tooltip,
  .export-help:focus-within .export-tooltip{
    opacity:1;
    visibility:visible;
    transform:translateX(-50%) translateY(0);
  }
  
  .export-tooltip {
  max-width: min(260px, calc(100vw - 24px));
}

.export-buttons .export-format-wrap:nth-child(2) .export-tooltip,
.export-buttons .export-format-wrap:nth-child(3) .export-tooltip {
  left: auto;
  right: 0;
  transform: translateY(4px);
}

.export-buttons .export-format-wrap:nth-child(2) .export-tooltip::after,
.export-buttons .export-format-wrap:nth-child(3) .export-tooltip::after {
  left: auto;
  right: 8px;
  transform: none;
}

.export-buttons .export-format-wrap:nth-child(2):hover .export-tooltip,
.export-buttons .export-format-wrap:nth-child(2):focus-within .export-tooltip,
.export-buttons .export-format-wrap:nth-child(3):hover .export-tooltip,
.export-buttons .export-format-wrap:nth-child(3):focus-within .export-tooltip {
  transform: translateY(0);
}

  @media (max-width: 768px) {
.user-svg-bg-lock,
.template-bg-lock {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin: 12px auto 0 !important;
  justify-content: center !important;
}
    
      #userSvgPreviewSurface {
    aspect-ratio: 1 / 1;
    border-radius: 22px;
    overflow: hidden;
  }

  #userSvgPreviewSurface > svg {
    width: 100%;
    height: 100%;
    display: block;
  }

    .export-tooltip{
      left:auto;
      right:0;
      transform:translateY(4px);
    }

    .export-tooltip::after{
      left:auto;
      right:8px;
      transform:none;
    }

    .export-help:hover .export-tooltip,
    .export-help:focus-within .export-tooltip{
      transform:translateY(0);
    }
  }

/* ===== FIX: history ===== */
.history-bar--empty .history-nav-btn,
  .history-bar--empty .history-thumbs { opacity: 0.35; pointer-events: none; }
  .history-nav-btn {
    display: flex; align-items: center; gap: 5px;
    padding: 6px 12px; border: 1.5px solid #e0e0e0; border-radius: 8px;
    background: #fff; color: #555; font-size: 12px; font-weight: 600;
    cursor: pointer; white-space: nowrap; flex-shrink: 0;
    transition: background .15s, border-color .15s, color .15s;
  }
  .history-nav-btn:hover:not(:disabled) { background: #f0f0f0; border-color: #ccc; color: #111; }
  .history-nav-btn:disabled { opacity: 0.35; cursor: default; }
  .history-bar {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
  
  .history-bar {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.history-thumbs {
  min-width: 0;
  width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.history-thumbs {
  min-width: 0;
}
  .history-thumbs::-webkit-scrollbar { display: none; }
  .history-thumb {
    display: flex; border-radius: 7px; overflow: hidden;
    flex-shrink: 0; height: 28px; cursor: pointer;
    border: 2px solid transparent; transition: border-color .15s, transform .15s;
  }
  .history-thumb:hover { transform: translateY(-2px); }
  .history-thumb-swatch { width: 18px; height: 28px; }

  .preview-color-locks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 4px;
  }
  .preview-color-lock-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 8px;
    border-radius: 8px;
    background: #f7f7f7;
    transition: background .15s;
  }
  .preview-color-lock-row:hover { background: #f0f0f0; }
  .preview-color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex: 0 0 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
  }
  .preview-color-lock-name {
    font-size: 11px;
    font-weight: 500;
    color: #666;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
  }
  .preview-lock-btn {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    padding: 0;
    transition: color .15s, background .15s;
  }
  .preview-lock-btn:hover { color: #999; background: #e8e8e8; }
  .preview-lock-btn.active { color: #111; }
  .preview-lock-btn.active:hover { color: #333; background: #e8e8e8; }

  .export-format-wrap{
    display:flex;
    align-items:center;
    gap:8px;
    position:relative;
  }

  .export-help{
    position:relative;
    display:flex;
    align-items:center;
    justify-content:center;
  }

  .export-help-btn{
    width:22px;
    height:22px;
    flex:0 0 22px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    border:none;
    border-radius:999px;
    background:#f1f1f1;
    color:#b8b8b8;
    cursor:help;
    font-size:12px;
    font-weight:700;
    line-height:1;
    padding:0;
    transition:background .18s ease, color .18s ease, transform .18s ease;
  }

  .export-help:hover .export-help-btn,
  .export-help:focus-within .export-help-btn{
    background:#ebebeb;
    color:#9f9f9f;
    transform:translateY(-1px);
  }

  .export-tooltip{
    position:absolute;
    left:50%;
    bottom:calc(100% + 10px);
    transform:translateX(-50%) translateY(4px);
    min-width:220px;
    max-width:260px;
    padding:10px 12px;
    border-radius:10px;
    background:#2f2f2f;
    color:#fff;
    font-size:12px;
    line-height:1.5;
    font-weight:500;
    box-shadow:0 10px 26px rgba(0,0,0,.16);
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transition:opacity .18s ease, transform .18s ease, visibility .18s ease;
    z-index:20;
    text-align:left;
  }

  .export-tooltip::after{
    content:"";
    position:absolute;
    left:50%;
    top:100%;
    transform:translateX(-50%);
    border:6px solid transparent;
    border-top-color:#2f2f2f;
  }

  .export-help:hover .export-tooltip,
  .export-help:focus-within .export-tooltip{
    opacity:1;
    visibility:visible;
    transform:translateX(-50%) translateY(0);
  }
  
  .export-tooltip {
  max-width: min(260px, calc(100vw - 24px));
}

.export-buttons .export-format-wrap:nth-child(2) .export-tooltip,
.export-buttons .export-format-wrap:nth-child(3) .export-tooltip {
  left: auto;
  right: 0;
  transform: translateY(4px);
}

.export-buttons .export-format-wrap:nth-child(2) .export-tooltip::after,
.export-buttons .export-format-wrap:nth-child(3) .export-tooltip::after {
  left: auto;
  right: 8px;
  transform: none;
}

.export-buttons .export-format-wrap:nth-child(2):hover .export-tooltip,
.export-buttons .export-format-wrap:nth-child(2):focus-within .export-tooltip,
.export-buttons .export-format-wrap:nth-child(3):hover .export-tooltip,
.export-buttons .export-format-wrap:nth-child(3):focus-within .export-tooltip {
  transform: translateY(0);
}

  @media (max-width: 768px) {
.user-svg-bg-lock,
.template-bg-lock {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin: 12px auto 0 !important;
  justify-content: center !important;
}
    
      #userSvgPreviewSurface {
    aspect-ratio: 1 / 1;
    border-radius: 22px;
    overflow: hidden;
  }

  #userSvgPreviewSurface > svg {
    width: 100%;
    height: 100%;
    display: block;
  }

    .export-tooltip{
      left:auto;
      right:0;
      transform:translateY(4px);
    }

    .export-tooltip::after{
      left:auto;
      right:8px;
      transform:none;
    }

    .export-help:hover .export-tooltip,
    .export-help:focus-within .export-tooltip{
      transform:translateY(0);
    }
  }