    /* ========== CSS ПЕРЕМЕННЫЕ ========== */
    :root {
      --bg-deep: #050506;
      --bg-base: #0a0a0c;
      --bg-elevated: #111114;
      --bg-surface: #18181c;
      --fg-primary: #EDEDEF;
      --fg-muted: #9399A3;
      --fg-dim: #6B7080;
      --accent: #5E6AD2;
      --accent-glow: rgba(94, 106, 210, 0.25);
      --border: rgba(255, 255, 255, 0.08);
      --border-hover: rgba(255, 255, 255, 0.15);
      --radius: 12px;
      --radius-sm: 8px;
      --radius-xs: 6px;
      --font-ui: 'IBM Plex Sans', sans-serif;
      --font-mono: 'JetBrains Mono', monospace;
      --transition: 200ms cubic-bezier(0.16, 1, 0.3, 1);
      --sidebar-width: 300px;
      --space-xs: 4px;
      --space-sm: 8px;
      --space-md: 12px;
      --space-lg: 16px;
      --space-xl: 24px;
    }

    /* ========== СБРОС И БАЗОВЫЕ СТИЛИ ========== */
    *, *::before, *::after {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    html, body {
      height: 100%;
      overflow: hidden;
    }

    body {
      font-family: var(--font-ui);
      background: var(--bg-deep);
      color: var(--fg-primary);
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }

    /* ========== СКРОЛЛБАР ========== */
    ::-webkit-scrollbar {
      width: 6px;
    }
    ::-webkit-scrollbar-track {
      background: transparent;
    }
    ::-webkit-scrollbar-thumb {
      background: var(--border-hover);
      border-radius: 3px;
    }
    ::-webkit-scrollbar-thumb:hover {
      background: var(--fg-dim);
    }

    /* ========== LAYOUT ========== */
    .app {
      display: flex;
      flex-direction: column;
      height: 100vh;
    }

    header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 12px 20px;
      background: var(--bg-base);
      border-bottom: 1px solid var(--border);
      z-index: 10;
      flex-shrink: 0;
    }

    .header-left {
      display: flex;
      align-items: center;
      gap: 14px;
    }

    .logo svg {
      height: 28px;
      width: auto;
    }

    .header-title {
      font-family: var(--font-mono);
      font-size: 14px;
      font-weight: 600;
      letter-spacing: 0.5px;
      color: var(--fg-muted);
      text-transform: uppercase;
    }

    .header-title span {
      color: var(--accent);
    }

    .header-right {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .bbox-info {
      font-family: var(--font-mono);
      font-size: 13px;
      color: var(--fg-muted);
      background: var(--bg-elevated);
      padding: 6px 14px;
      border-radius: var(--radius-xs);
      border: 1px solid var(--border);
      transition: all var(--transition);
    }

    .bbox-info strong {
      color: var(--fg-primary);
      font-weight: 600;
    }

    .header-hotkeys-btn {
      background: none;
      border: none;
      color: var(--fg-dim);
      cursor: pointer;
      padding: 6px;
      border-radius: var(--radius-xs);
      display: flex;
      align-items: center;
      justify-content: center;
      transition: color var(--transition), background var(--transition);
    }
    .header-hotkeys-btn:hover {
      color: var(--fg-primary);
      background: var(--bg-elevated);
    }

    /* ========== МОДАЛКА ГОРЯЧИХ КЛАВИШ ========== */
    .hotkeys-modal {
      width: 380px;
    }

    .hotkeys-list {
      gap: 0 !important;
    }

    .hotkey-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 8px 0;
      border-bottom: 1px solid var(--border);
      font-family: var(--font-ui);
      font-size: 13px;
      color: var(--fg-muted);
    }
    .hotkey-row:last-child {
      border-bottom: none;
    }
    .hotkey-row span {
      text-align: right;
    }

    .hotkey-row kbd {
      display: inline-block;
      background: var(--bg-elevated);
      border: 1px solid var(--border);
      border-radius: 4px;
      padding: 2px 7px;
      font-family: var(--font-mono);
      font-size: 11px;
      color: var(--fg-primary);
      line-height: 1.4;
    }

    main {
      display: flex;
      flex: 1;
      overflow: hidden;
    }

    /* ========== SIDEBAR ========== */
    .sidebar {
      width: var(--sidebar-width);
      flex-shrink: 0;
      background: var(--bg-base);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .sidebar-header {
      padding: 16px;
      border-bottom: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .sidebar-header h2 {
      font-family: var(--font-mono);
      font-size: 12px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 1.5px;
      color: var(--fg-dim);
    }

    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 10px 16px;
      border: none;
      border-radius: var(--radius-sm);
      font-family: var(--font-ui);
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      transition: all var(--transition);
      outline: none;
    }

    .btn:focus-visible {
      box-shadow: 0 0 0 2px var(--accent);
    }

    .btn-primary {
      background: var(--accent);
      color: #fff;
      box-shadow: 0 0 20px var(--accent-glow);
    }

    .btn-primary:hover {
      background: #6B77E0;
      box-shadow: 0 0 30px var(--accent-glow);
    }

    .btn-secondary {
      background: var(--bg-elevated);
      color: var(--fg-primary);
      border: 1px solid var(--border);
    }

    .btn-secondary:hover {
      background: var(--bg-surface);
      border-color: var(--border-hover);
    }

    .btn-accent-outline {
      background: var(--bg-elevated);
      color: var(--fg-primary);
      border: 1px solid var(--border);
      box-shadow: inset 0 0 0 1px rgba(94, 106, 210, 0.15);
    }

    .btn-accent-outline:hover {
      background: var(--bg-surface);
      border-color: var(--border-hover);
      box-shadow: inset 0 0 0 1px rgba(94, 106, 210, 0.3);
    }

    .btn-danger {
      background: transparent;
      color: #EF4444;
      border: 1px solid rgba(239, 68, 68, 0.2);
    }

    .btn-danger:hover {
      background: rgba(239, 68, 68, 0.1);
      border-color: rgba(239, 68, 68, 0.4);
    }

    .btn-icon {
      width: 32px;
      height: 32px;
      padding: 0;
      font-size: 16px;
      border-radius: var(--radius-xs);
    }

    .controls-row {
      display: flex;
      gap: 8px;
    }

    .controls-row .btn {
      flex: 1;
    }

    /* Чекбокс "Слепить экраны" */
    .toggle-row {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 12px 16px;
      border-bottom: 1px solid var(--border);
    }

    .toggle-label {
      font-size: 13px;
      color: var(--fg-muted);
      user-select: none;
      cursor: pointer;
    }

    .toggle {
      position: relative;
      width: 40px;
      height: 22px;
      flex-shrink: 0;
    }

    .toggle input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    .toggle-track {
      position: absolute;
      inset: 0;
      background: var(--bg-elevated);
      border: 1px solid var(--border);
      border-radius: 11px;
      cursor: pointer;
      transition: all var(--transition);
    }

    .toggle-track::after {
      content: '';
      position: absolute;
      top: 2px;
      left: 2px;
      width: 16px;
      height: 16px;
      background: var(--fg-dim);
      border-radius: 50%;
      transition: all var(--transition);
    }

    .toggle input:focus-visible + .toggle-track {
      box-shadow: 0 0 0 2px var(--accent);
    }

    .toggle input:checked + .toggle-track {
      background: var(--accent);
      border-color: var(--accent);
    }

    .toggle input:checked + .toggle-track::after {
      left: 20px;
      background: #fff;
    }

    /* Список экранов */
    .screen-list {
      flex: 1;
      overflow-y: auto;
      padding: 8px;
    }

    @property --border-angle {
      syntax: '<angle>';
      initial-value: 0deg;
      inherits: false;
    }

    @keyframes borderRotate {
      to { --border-angle: 360deg; }
    }

    .screen-card {
      background: var(--bg-elevated);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 12px;
      margin-bottom: 8px;
      border-left: 3px solid var(--card-color, var(--border));
      transition: all var(--transition);
      cursor: pointer;
    }

    .screen-card:hover {
      background: var(--bg-surface);
      border-color: var(--border-hover);
      border-left-color: var(--card-color, var(--border-hover));
    }

    .screen-card.active {
      border-color: var(--card-color);
      border-left-color: var(--card-color);
      background: var(--card-bg, var(--bg-elevated));
    }

    .screen-card-header {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 8px;
    }

    .screen-color-dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      flex-shrink: 0;
    }

    .screen-card-name {
      font-family: var(--font-mono);
      font-size: 13px;
      font-weight: 600;
      flex: 1;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .screen-card-res {
      font-family: var(--font-mono);
      font-size: 11px;
      color: var(--fg-dim);
    }

    .screen-card-info {
      font-size: 11px;
      color: var(--fg-dim);
      margin-bottom: 8px;
    }

    .screen-card-actions {
      display: flex;
      gap: 4px;
      align-items: center;
    }

    .screen-card-actions .btn-icon {
      width: 28px;
      height: 28px;
      font-size: 13px;
      background: var(--bg-surface);
      color: var(--fg-muted);
      border: 1px solid var(--border);
    }

    .screen-card-actions .btn-icon:hover {
      color: var(--fg-primary);
      border-color: var(--border-hover);
    }

    /* Inline-редактирование в карточке */
    .screen-card-edit {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-bottom: 8px;
    }

    .edit-row {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .edit-row label {
      font-size: 11px;
      color: var(--fg-dim);
      min-width: 48px;
      flex-shrink: 0;
    }

    .edit-inputs {
      display: flex;
      align-items: center;
      gap: 4px;
      flex: 1;
    }

    .edit-input {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-xs);
      padding: 4px 6px;
      color: var(--fg-primary);
      font-family: var(--font-mono);
      font-size: 12px;
      width: 100%;
      min-width: 0;
      outline: none;
      transition: border-color var(--transition);
      -moz-appearance: textfield;
    }

    .edit-input::-webkit-inner-spin-button,
    .edit-input::-webkit-outer-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }

    .edit-input:focus {
      border-color: var(--accent);
    }

    .edit-x {
      color: var(--fg-dim);
      font-family: var(--font-mono);
      font-size: 12px;
      flex-shrink: 0;
    }

    .rotation-input {
      background-color: var(--bg-surface) !important;
      border: 1px solid var(--border);
      border-radius: var(--radius-xs);
      padding: 4px 6px;
      color: var(--fg-primary) !important;
      font-family: var(--font-mono);
      font-size: 12px;
      width: 52px;
      text-align: right;
      outline: none;
      transition: border-color var(--transition);
      color-scheme: dark;
      -webkit-appearance: none;
      -moz-appearance: textfield;
      appearance: none;
    }
    .rotation-input::-webkit-outer-spin-button,
    .rotation-input::-webkit-inner-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }
    .rotation-input:focus {
      border-color: var(--accent);
    }

    .screen-card-name-input {
      font-family: var(--font-mono);
      font-size: 13px;
      font-weight: 600;
      color: var(--fg-primary);
      background: var(--bg-surface);
      border: 1px solid var(--accent);
      border-radius: var(--radius-xs);
      padding: 2px 6px;
      outline: none;
      width: 100%;
      min-width: 0;
      box-shadow: 0 0 0 3px var(--accent-glow);
    }

    /* Нижняя панель sidebar */
    .sidebar-footer {
      padding: 16px;
      border-top: 1px solid var(--border);
    }

    .compose-options {
      display: flex;
      flex-direction: column;
      margin-bottom: 10px;
    }

    .compose-options .toggle-row {
      padding: 4px 0;
      border-bottom: none;
    }

    /* Блок разрешения маски */
    .sidebar-resolution {
      padding: 14px 16px;
      border-top: 1px solid var(--border);
      background: var(--bg-elevated);
    }

    .resolution-label {
      font-size: 11px;
      font-weight: 500;
      color: var(--fg-dim);
      text-transform: uppercase;
      letter-spacing: 1px;
      margin-bottom: 6px;
    }

    .resolution-value {
      font-family: var(--font-mono);
      font-size: 18px;
      font-weight: 700;
      color: var(--fg-primary);
      letter-spacing: -0.5px;
    }

    .resolution-value .dim {
      color: var(--fg-dim);
      font-weight: 400;
      font-size: 13px;
    }

    /* Кнопки скачивания */
    .download-buttons {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .btn-download {
      flex: 1;
      padding: 10px 8px;
      font-size: 12px;
      font-weight: 600;
      color: #fff;
      border: none;
      border-radius: var(--radius-sm);
      cursor: pointer;
      transition: all var(--transition);
      font-family: var(--font-ui);
    }

    .btn-download-svg {
      background: linear-gradient(135deg, var(--accent), #7C3AED);
      box-shadow: 0 4px 20px rgba(94, 106, 210, 0.25);
    }

    .btn-download-svg:hover {
      box-shadow: 0 4px 28px rgba(94, 106, 210, 0.45);
      transform: translateY(-1px);
    }

    .btn-download-png {
      background: linear-gradient(135deg, #06B6D4, #3B82F6);
      box-shadow: 0 4px 20px rgba(6, 182, 212, 0.2);
    }

    .btn-download-png:hover {
      box-shadow: 0 4px 28px rgba(6, 182, 212, 0.4);
      transform: translateY(-1px);
    }

    .btn-download-all {
      background: linear-gradient(135deg, #10B981, #059669);
      box-shadow: 0 4px 20px rgba(16, 185, 129, 0.2);
      flex-basis: 100%;
    }

    .btn-download-all:hover {
      box-shadow: 0 4px 28px rgba(16, 185, 129, 0.4);
      transform: translateY(-1px);
    }

    .btn-download:active {
      transform: translateY(0);
    }

    .btn-download:disabled {
      opacity: 0.35;
      pointer-events: none;
      transform: none;
      box-shadow: none;
    }

    @keyframes btn-loading-pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.5; }
    }

    .btn-download.is-loading {
      pointer-events: none;
      animation: btn-loading-pulse 1.2s ease-in-out infinite;
    }

    /* ========== OVERLAP DIALOG ========== */
    .overlap-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.6);
      z-index: 1000;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.25s ease;
    }

    .overlap-overlay.visible {
      opacity: 1;
      pointer-events: auto;
    }

    .overlap-dialog {
      background: var(--bg-surface);
      border: 1px solid rgba(234, 179, 8, 0.3);
      border-radius: var(--radius);
      padding: 32px 36px;
      box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
      text-align: center;
      max-width: 420px;
      transform: scale(0.95);
      transition: transform 0.25s ease;
    }

    .overlap-overlay.visible .overlap-dialog {
      transform: scale(1);
    }

    .overlap-icon {
      margin-bottom: 16px;
    }

    .overlap-title {
      font-family: var(--font-mono);
      font-size: 18px;
      font-weight: 600;
      color: #EAB308;
      margin-bottom: 8px;
    }

    .overlap-desc {
      font-size: 14px;
      color: var(--fg-muted);
      margin-bottom: 24px;
      line-height: 1.5;
    }

    .overlap-actions {
      display: flex;
      gap: 10px;
      justify-content: center;
    }

    .overlap-actions .btn {
      min-width: 140px;
    }

    /* ========== CANVAS AREA ========== */
    .canvas-container {
      flex: 1;
      position: relative;
      overflow: hidden;
      background: var(--bg-deep);
    }

    .canvas-container canvas {
      display: block;
    }

    /* Подсказка на пустом холсте */
    .canvas-empty-hint {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      text-align: center;
      pointer-events: none;
      opacity: 0.4;
    }

    .canvas-empty-hint svg {
      width: 64px;
      height: 64px;
      margin-bottom: 16px;
    }

    .canvas-empty-hint p {
      font-family: var(--font-mono);
      font-size: 13px;
      color: var(--fg-dim);
    }

    /* ========== МОДАЛЬНОЕ ОКНО ========== */
    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.6);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 100;
      opacity: 0;
      pointer-events: none;
      transition: opacity 250ms ease;
    }

    .modal-overlay.active {
      opacity: 1;
      pointer-events: auto;
    }

    .modal {
      background: var(--bg-base);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      width: 420px;
      max-width: 90vw;
      box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
      transform: translateY(20px) scale(0.97);
      transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1);
    }

    .modal-overlay.active .modal {
      transform: translateY(0) scale(1);
    }

    .modal-header {
      padding: 20px 24px 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .modal-header h3 {
      font-family: var(--font-mono);
      font-size: 16px;
      font-weight: 600;
    }

    .modal-close {
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: transparent;
      border: none;
      color: var(--fg-dim);
      font-size: 20px;
      cursor: pointer;
      border-radius: var(--radius-xs);
      transition: all var(--transition);
    }

    .modal-close:hover {
      background: var(--bg-elevated);
      color: var(--fg-primary);
    }

    .modal-body {
      padding: 0 24px 24px;
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .form-group {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .form-group label {
      font-size: 12px;
      font-weight: 500;
      color: var(--fg-muted);
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    .form-group input {
      background: var(--bg-elevated);
      border: 1px solid var(--border);
      border-radius: var(--radius-xs);
      padding: 10px 12px;
      color: var(--fg-primary);
      font-family: var(--font-mono);
      font-size: 14px;
      outline: none;
      transition: all var(--transition);
    }

    .form-group input:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px var(--accent-glow);
    }

    .form-group input::placeholder {
      color: var(--fg-dim);
    }

    .form-row {
      display: grid;
      grid-template-columns: 1fr auto 1fr;
      align-items: end;
      gap: 0;
    }

    .form-row .form-group {
      min-width: 0;
    }

    .form-separator {
      color: var(--fg-dim);
      font-family: var(--font-mono);
      font-size: 16px;
      text-align: center;
      padding: 0 8px 10px;
      user-select: none;
    }

    /* Скрыть нативные спиннеры у number input */
    input[type="number"]::-webkit-inner-spin-button,
    input[type="number"]::-webkit-outer-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }
    input[type="number"] {
      -moz-appearance: textfield;
    }

    .modal-footer {
      padding: 0 24px 20px;
      display: flex;
      gap: 8px;
      justify-content: flex-end;
    }

    /* ========== ZOOM CONTROLS ========== */
    .zoom-controls {
      position: absolute;
      bottom: 16px;
      right: 16px;
      display: flex;
      gap: 4px;
      z-index: 5;
    }

    .zoom-controls .btn-icon {
      background: var(--bg-base);
      border: 1px solid var(--border);
      color: var(--fg-muted);
      width: 36px;
      height: 36px;
      font-size: 16px;
      backdrop-filter: blur(8px);
    }

    .zoom-controls .btn-icon:hover {
      background: var(--bg-elevated);
      color: var(--fg-primary);
    }

    .zoom-level {
      display: flex;
      align-items: center;
      padding: 0 10px;
      font-family: var(--font-mono);
      font-size: 11px;
      color: var(--fg-dim);
      background: var(--bg-base);
      border: 1px solid var(--border);
      border-radius: var(--radius-xs);
    }

    /* ========== GRID CONSTRUCTOR MODAL ========== */
    .grid-modal {
      width: 680px;
      max-width: 95vw;
    }

    .grid-modal .modal-body {
      gap: 14px;
    }

    .grid-settings-row {
      display: flex;
      gap: 12px;
      align-items: end;
    }

    .grid-settings-row .form-group {
      flex: 1;
      min-width: 0;
    }

    .grid-settings-row .form-separator {
      padding-bottom: 10px;
    }

    .grid-editor-wrapper {
      background: var(--bg-deep);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 12px;
      max-height: 420px;
      overflow: auto;
      display: flex;
      justify-content: center;
    }

    .grid-editor {
      display: inline-grid;
      gap: 2px;
      user-select: none;
    }

    .grid-cell {
      width: 28px;
      height: 28px;
      background: var(--bg-elevated);
      border: 1px solid var(--border);
      border-radius: 3px;
      cursor: pointer;
      transition: background 80ms ease, border-color 80ms ease;
    }

    .grid-cell:hover {
      border-color: var(--border-hover);
    }

    .grid-cell.active {
      background: var(--accent);
      border-color: var(--accent);
    }

    .grid-toolbar {
      display: flex;
      gap: 8px;
      align-items: center;
    }

    .grid-toolbar .btn {
      font-size: 12px;
      padding: 6px 12px;
    }

    .grid-cell-count {
      font-family: var(--font-mono);
      font-size: 12px;
      color: var(--fg-dim);
      margin-left: auto;
    }

    /* ========== CANVAS GRID PATTERN ========== */
    .grid-bg {
      position: absolute;
      inset: 0;
      pointer-events: none;
      opacity: 0.05;
      background-image:
        linear-gradient(rgba(255,255,255,0.5) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.5) 1px, transparent 1px);
      background-size: 50px 50px;
    }

    /* ========== НЕДАВНИЕ ПРОЕКТЫ ========== */
    .recent-modal {
      max-width: 520px;
    }

    .recent-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
      max-height: 60vh;
      overflow-y: auto;
      padding: 0 24px 16px;
    }

    .recent-item {
      display: flex;
      align-items: center;
      gap: 14px;
      padding: 12px;
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      cursor: pointer;
      transition: all var(--transition);
      position: relative;
    }

    .recent-item:hover {
      background: var(--bg-elevated);
      border-color: var(--border-hover);
    }

    .recent-item-preview {
      flex-shrink: 0;
      border-radius: var(--radius-xs);
      background: var(--bg-deep);
      border: 1px solid var(--border);
    }

    .recent-item-info {
      display: flex;
      flex-direction: column;
      gap: 3px;
      overflow: hidden;
      flex: 1;
      min-width: 0;
    }

    .recent-item-name {
      font-family: var(--font-mono);
      font-weight: 600;
      font-size: 13px;
      color: var(--fg-primary);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .recent-item-meta {
      font-family: var(--font-ui);
      font-size: 12px;
      color: var(--fg-muted);
    }

    .recent-item-time {
      font-family: var(--font-ui);
      font-size: 11px;
      color: var(--fg-dim);
    }

    .recent-item-delete {
      position: absolute;
      top: 8px;
      right: 8px;
      opacity: 0;
      transition: opacity var(--transition);
      width: 24px;
      height: 24px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--bg-deep);
      border: 1px solid var(--border);
      border-radius: var(--radius-xs);
      color: #EF4444;
      font-size: 12px;
      cursor: pointer;
      padding: 0;
    }

    .recent-item:hover .recent-item-delete {
      opacity: 1;
    }

    .recent-item-delete:hover {
      background: rgba(239, 68, 68, 0.15);
      border-color: rgba(239, 68, 68, 0.3);
    }

    .recent-empty {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 40px 24px;
      color: var(--fg-dim);
      font-size: 14px;
    }

    .recent-empty p {
      margin: 0;
    }

    /* ========== SIDEBAR TOGGLE (скрыта на десктопе) ========== */
    .sidebar-toggle {
      display: none;
      align-items: center;
      justify-content: center;
      background: none;
      border: none;
      color: var(--fg-muted);
      cursor: pointer;
      padding: 8px;
      border-radius: var(--radius-xs);
      transition: color var(--transition), background var(--transition);
      flex-shrink: 0;
    }
    .sidebar-toggle:hover {
      color: var(--fg-primary);
      background: var(--bg-elevated);
    }

    /* ========== SIDEBAR OVERLAY ========== */
    .sidebar-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.5);
      z-index: 49;
      opacity: 0;
      transition: opacity 0.3s ease;
      pointer-events: none;
    }
    .sidebar-overlay.visible {
      opacity: 1;
      pointer-events: auto;
    }

    /* ========== SIDEBAR DRAG HANDLE (bottom-sheet) ========== */
    .sidebar-drag-handle {
      display: none;
      width: 36px;
      height: 4px;
      background: var(--fg-dim);
      border-radius: 2px;
      margin: 10px auto 6px;
      flex-shrink: 0;
    }

    /* ========== iOS / MOBILE FIXES ========== */
    canvas {
      touch-action: none;
    }

    /* ========== RESPONSIVE: TABLET (≤768px) ========== */
    @media (max-width: 768px) {
      html, body {
        overscroll-behavior: none;
      }

      .app {
        height: 100dvh;
        height: 100vh;
      }

      /* Sidebar toggle видна */
      .sidebar-toggle {
        display: flex;
      }

      .sidebar-overlay {
        display: block;
      }

      /* Sidebar как drawer слева */
      .sidebar {
        position: fixed;
        z-index: 50;
        top: 0;
        left: 0;
        height: 100%;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
        border-right: none;
      }
      .sidebar.open {
        transform: translateX(0);
      }

      /* Header компактный */
      header {
        padding: 10px 12px;
      }
      .header-left {
        gap: 10px;
      }
      .header-title span {
        display: none;
      }
      .bbox-info {
        display: none;
      }
      #btnHotkeys {
        display: none;
      }
      .logo svg {
        height: 22px;
      }

      /* Кнопки крупнее для тача */
      .btn {
        min-height: 44px;
        padding: 10px 14px;
      }
      .btn-icon {
        width: 40px;
        height: 40px;
      }
      .screen-card-actions .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 15px;
      }
      .zoom-controls .btn-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
      }
      .zoom-level {
        padding: 0 12px;
        font-size: 12px;
      }
      .header-hotkeys-btn {
        padding: 10px;
      }
      .modal-close {
        width: 44px;
        height: 44px;
        font-size: 24px;
      }

      /* Модалки */
      .modal {
        width: 95vw;
        max-width: 95vw;
      }
      .grid-modal {
        width: 95vw;
        max-width: 95vw;
      }
      .hotkeys-modal {
        width: 95vw;
      }
      .recent-modal {
        max-width: 95vw;
      }

      /* Grid constructor ячейки крупнее */
      .grid-cell {
        width: 38px;
        height: 38px;
      }

      /* Form inputs: font-size 16px чтобы iOS не зумил */
      .form-group input {
        font-size: 16px;
      }
      .edit-input {
        font-size: 14px;
      }
      .rotation-input {
        font-size: 14px;
      }

      /* Overlap dialog */
      .overlap-dialog {
        padding: 24px 20px;
        max-width: 90vw;
      }
      .overlap-actions {
        flex-direction: column;
      }
      .overlap-actions .btn {
        min-width: auto;
        width: 100%;
      }
    }

    /* ========== RESPONSIVE: PHONE (≤480px) ========== */
    @media (max-width: 480px) {
      :root {
        --sidebar-width: 100%;
      }

      /* Sidebar как bottom-sheet */
      .sidebar {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        max-height: 75vh;
        transform: translateY(100%);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
      }
      .sidebar.open {
        transform: translateY(0);
      }

      .sidebar-drag-handle {
        display: block;
      }

      /* Header ещё компактнее */
      header {
        padding: 8px 10px;
      }
      .header-title {
        font-size: 11px;
      }
      .logo svg {
        height: 18px;
      }

      /* Zoom controls перенести в bottom-left */
      .zoom-controls {
        right: auto;
        left: 12px;
        bottom: 12px;
      }

      /* Модалки полноэкранные */
      .modal-overlay {
        align-items: flex-end;
      }
      .modal {
        width: 100vw;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 16px 16px 0 0;
        display: flex;
        flex-direction: column;
      }
      .modal-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 16px;
      }
      .modal-footer {
        position: sticky;
        bottom: 0;
        background: var(--bg-base);
        padding: 12px 24px 20px;
        border-top: 1px solid var(--border);
      }

      /* Grid modal полноэкранный */
      .grid-modal {
        width: 100vw;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 16px 16px 0 0;
        display: flex;
        flex-direction: column;
      }
      .grid-modal .modal-body {
        flex: 1;
        overflow-y: auto;
      }
      .grid-editor-wrapper {
        max-height: 50vh;
      }

      /* Grid cells крупнее для пальцев */
      .grid-cell {
        width: 44px;
        height: 44px;
      }

      /* Form row в колонку на узких экранах */
      .form-row {
        grid-template-columns: 1fr;
        gap: 8px;
      }
      .form-separator {
        display: none;
      }
      .grid-settings-row {
        flex-direction: column;
        gap: 8px;
      }
      .grid-settings-row .form-separator {
        display: none;
      }

      /* Screen card компактнее */
      .screen-card {
        padding: 10px;
      }
      .screen-card-actions {
        flex-wrap: wrap;
        gap: 6px;
      }

      /* Download buttons stack */
      .download-buttons {
        flex-direction: column;
      }

      /* Recent modal */
      .recent-list {
        max-height: 50vh;
      }

      /* Overlap dialog */
      .overlap-dialog {
        padding: 20px 16px;
        margin: 0 8px;
      }
    }
