:root {
      --bg: #f4f7fb;
      --panel: rgba(255, 255, 255, .94);
      --panel-2: rgba(248, 250, 255, .96);
      --line: rgba(23, 36, 61, .12);
      --text: #162033;
      --muted: #5b6a84;
      --accent: #7c5cff;
      --accent-2: #27d9ff;
      --danger: #ff4d79;
      --success: #35e59f;
      --shadow: 0 18px 50px rgba(24, 44, 79, .10);
      --radius: 22px;
      --safe-bottom: var(--rand-unten,0px);
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      color-scheme: light;
    }

    * { box-sizing: border-box; }
    html, body { min-height: 100%; }
    body {
      margin: 0;
      min-height: 100dvh;
      overflow-x: hidden;
      overflow-y: auto;
      background:
        radial-gradient(circle at 12% 10%, rgba(124,92,255,.14), transparent 30%),
        radial-gradient(circle at 88% 18%, rgba(39,217,255,.12), transparent 28%),
        linear-gradient(145deg, #f9fbff 0%, #f3f7fd 52%, #eef4fb 100%);
      color: var(--text);
    }

    button, input, select { font: inherit; }
    a.btn { text-decoration: none; }
    button { -webkit-tap-highlight-color: transparent; }

    .app {
      height: 100dvh;
      display: grid;
      grid-template-rows: auto minmax(0, 1fr) auto;
    }

    .topbar {
      position: relative;
      z-index: 20;
      min-height: 64px;
      display: flex;
      align-items: center;
      gap: 10px;
      padding: max(10px, env(safe-area-inset-top)) 14px 10px;
      border-bottom: 1px solid var(--line);
      background: rgba(7,11,23,.78);
      backdrop-filter: blur(18px);
    }

    .brand {
      min-width: 0;
      display: flex;
      align-items: center;
      gap: 10px;
      margin-right: auto;
    }

    .brand-mark {
      width: 42px;
      height: 42px;
      border-radius: 15px;
      display: grid;
      place-items: center;
      font-size: 22px;
      background: linear-gradient(135deg, var(--accent), var(--accent-2));
      box-shadow: 0 8px 24px rgba(74,130,255,.35);
    }

    .brand h1 {
      margin: 0;
      font-size: clamp(17px, 2.3vw, 23px);
      line-height: 1;
      letter-spacing: -.03em;
    }

    .brand p {
      margin: 5px 0 0;
      color: var(--muted);
      font-size: 12px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .top-actions { display: flex; align-items: center; gap: 8px; }

    .btn, .icon-btn, .tool-btn, .finish-card {
      border: 1px solid var(--line);
      color: var(--text);
      background: rgba(255,255,255,.065);
      cursor: pointer;
      transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
    }
    .btn:active, .icon-btn:active, .tool-btn:active, .finish-card:active { transform: scale(.97); }
    .btn:hover, .icon-btn:hover, .tool-btn:hover { background: rgba(255,255,255,.105); }
    .btn:disabled, .icon-btn:disabled { opacity: .38; cursor: default; }

    .btn {
      min-height: 44px;
      padding: 0 16px;
      border-radius: 14px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      font-weight: 800;
    }
    .btn.primary {
      border-color: transparent;
      background: linear-gradient(135deg, var(--accent), #4b7dff);
      box-shadow: 0 10px 24px rgba(83,92,255,.28);
    }
    .btn.secondary { background: rgba(39,217,255,.09); border-color: rgba(39,217,255,.24); }
    .btn.danger { background: rgba(255,77,121,.1); border-color: rgba(255,77,121,.25); }
    .btn.full { width: 100%; }

    .icon-btn {
      width: 44px;
      height: 44px;
      border-radius: 14px;
      display: grid;
      place-items: center;
      font-size: 19px;
    }

    .workspace {
      position: relative;
      min-height: 0;
      display: grid;
      grid-template-columns: 88px minmax(0, 1fr) 290px;
      gap: 12px;
      padding: 12px;
    }

    .tool-rail, .inspector {
      min-height: 0;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: var(--panel);
      box-shadow: var(--shadow);
      backdrop-filter: blur(18px);
    }

    .tool-rail {
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding: 10px;
      overflow-y: auto;
      scrollbar-width: none;
    }
    .tool-rail::-webkit-scrollbar { display: none; }
    .tablet-color-button {
      display: none;
      width: 100%;
      min-height: 64px;
      flex: 0 0 auto;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      gap: 5px;
      padding: 8px 4px;
      border: 1px solid var(--line);
      border-radius: 17px;
      background: rgba(255,255,255,.92);
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
      cursor: pointer;
    }
    .tablet-color-button .color-orb {
      width: 34px;
      height: 34px;
    }

    .tool-btn {
      min-height: 82px;
      padding: 8px 6px;
      border-radius: 17px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: flex-start;
      gap: 5px;
      font-size: 12px;
      font-weight: 800;
      color: var(--muted);
      overflow: hidden;
    }
    .tool-btn > span:last-child {
      display: block;
      width: 100%;
      min-width: 0;
      max-width: 100%;
      text-align: center;
      line-height: 1.15;
      white-space: normal;
      overflow-wrap: anywhere;
      word-break: normal;
    }
    .svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
    .ui-icon {
      width: 1.35em;
      height: 1.35em;
      display: block;
      fill: none;
      stroke: currentColor;
      stroke-width: 1.85;
      stroke-linecap: round;
      stroke-linejoin: round;
      vector-effect: non-scaling-stroke;
    }
    .tool-btn .ico {
      width: 38px;
      height: 38px;
      display: grid;
      place-items: center;
      border-radius: 13px;
      color: #dce5ff;
      background: linear-gradient(145deg, rgba(255,255,255,.10), rgba(255,255,255,.025));
      box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 7px 18px rgba(0,0,0,.18);
      transition: transform .16s ease, color .16s ease, background .16s ease, box-shadow .16s ease;
    }
    .tool-btn .ico .ui-icon { width: 25px; height: 25px; }
    .tool-btn:hover .ico { transform: translateY(-1px); color: white; }
    .tool-btn.active {
      color: white;
      border-color: rgba(124,92,255,.66);
      background: linear-gradient(135deg, rgba(124,92,255,.26), rgba(39,217,255,.13));
      box-shadow: inset 0 0 0 1px rgba(255,255,255,.05), 0 8px 24px rgba(65,78,255,.16);
    }
    .tool-btn.active .ico {
      color: white;
      background: linear-gradient(135deg, rgba(124,92,255,.95), rgba(39,217,255,.78));
      box-shadow: 0 8px 22px rgba(75,97,255,.34), inset 0 1px 0 rgba(255,255,255,.3);
    }
    .toggle-setting {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      min-height: 54px;
      cursor: pointer;
      user-select: none;
    }
    .toggle-copy { min-width: 0; display: grid; gap: 3px; }
    .toggle-copy strong { color: var(--text); font-size: 14px; line-height: 1.2; }
    .toggle-copy small { color: var(--muted); font-size: 11px; line-height: 1.35; }
    .paint-mode-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 7px;
      align-items: stretch;
    }
    .paint-mode-btn {
      min-width: 0;
      min-height: 78px;
      padding: 10px 8px;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: rgba(255,255,255,.74);
      color: var(--muted-strong);
      display: grid;
      grid-template-rows: auto auto;
      place-items: center;
      align-content: center;
      gap: 3px;
      text-align: center;
      font: inherit;
      cursor: pointer;
      overflow: hidden;
    }
    .paint-mode-btn strong,
    .paint-mode-btn small {
      display: block;
      width: 100%;
      min-width: 0;
      max-width: 100%;
      white-space: normal;
      overflow-wrap: anywhere;
      word-break: normal;
    }
    .paint-mode-btn strong { color: inherit; font-size: 12px; line-height: 1.15; }
    .paint-mode-btn small { color: var(--muted); font-size: 9px; line-height: 1.2; }
    .paint-mode-btn.active {
      color: #fff;
      border-color: rgba(88,93,255,.72);
      background: linear-gradient(135deg, #7c5cff, #3b82f6);
      box-shadow: 0 8px 20px rgba(72,91,255,.22);
    }
    .paint-mode-btn.active small { color: rgba(255,255,255,.82); }
    .toggle-setting input { position: absolute; opacity: 0; pointer-events: none; }
    .toggle-ui {
      position: relative;
      flex: 0 0 auto;
      width: 48px;
      height: 28px;
      border-radius: 999px;
      border: 1px solid var(--line);
      background: #e7ebf3;
      box-shadow: inset 0 2px 5px rgba(35,48,75,.12);
      transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
    }
    .toggle-ui::after {
      content: '';
      position: absolute;
      top: 3px;
      left: 3px;
      width: 20px;
      height: 20px;
      border-radius: 50%;
      background: white;
      box-shadow: 0 2px 7px rgba(22,35,58,.28);
      transition: transform .18s ease;
    }
    .toggle-setting input:checked + .toggle-ui {
      border-color: rgba(76,91,255,.65);
      background: linear-gradient(135deg, #765cff, #2f8cff);
      box-shadow: 0 6px 16px rgba(75,91,255,.24), inset 0 1px 0 rgba(255,255,255,.25);
    }
    .toggle-setting input:checked + .toggle-ui::after { transform: translateX(20px); }
    .toggle-setting input:focus-visible + .toggle-ui { outline: 3px solid rgba(47,140,255,.24); outline-offset: 3px; }
    .btn .ui-icon, .icon-btn .ui-icon { width: 21px; height: 21px; }
    .icon-btn .ui-icon { width: 22px; height: 22px; }
    #mobileSettingsBtn {
      padding: 0 !important;
      display: inline-flex !important;
      align-items: center !important;
      justify-content: center !important;
      line-height: 1 !important;
    }
    #mobileSettingsBtn .ui-icon {
      display: block;
      width: 24px;
      height: 24px;
      margin: 0;
      flex: 0 0 24px;
      stroke-width: 2.05;
    }

    .stage-shell {
      position: relative;
      min-width: 0;
      min-height: 0;
      display: grid;
      place-items: center;
      border-radius: var(--radius);
      border: 1px solid rgba(255,255,255,.08);
      overflow: hidden;
      background:
        linear-gradient(45deg, rgba(255,255,255,.025) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.025) 75%),
        linear-gradient(45deg, rgba(255,255,255,.025) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.025) 75%),
        rgba(5,8,16,.72);
      background-position: 0 0, 16px 16px;
      background-size: 32px 32px;
      box-shadow: inset 0 0 80px rgba(0,0,0,.28);
    }

    .canvas-wrap {
      position: relative;
      width: min(100%, 1100px);
      height: 100%;
      min-height: 0;
      display: grid;
      place-items: center;
      padding: 18px;
    }

    .canvas-frame {
      position: relative;
      display: none;
      background: #fff;
      box-shadow: 0 24px 70px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.1);
      overflow: hidden;
      touch-action: none;
      user-select: none;
      max-width: 100%;
      max-height: 100%;
    }
    .canvas-frame.ready { display: block; }
    .canvas-frame canvas {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      display: block;
    }
    #paintCanvas { background: white; }
    #sourceCanvas { display: none; }
    #sourceCanvas, #lineCanvas, #galaxyFxCanvas, #holoFxCanvas, #neonCanvas, #barrierCanvas, #cursorCanvas { pointer-events: none; }
    #interactionCanvas { pointer-events: auto; touch-action: none; }
    #paintCanvas { z-index: 1; }
    #lineCanvas { z-index: 2; }
    #galaxyFxCanvas { z-index: 3; }
    #holoFxCanvas { z-index: 4; }
    #neonCanvas { z-index: 5; }
    #barrierCanvas { z-index: 6; }
    #interactionCanvas { z-index: 7; }
    #cursorCanvas { z-index: 8; }

    .empty-state {
      position: relative;
      isolation: isolate;
      overflow: hidden;
      width: min(500px, calc(100% - 34px));
      text-align: center;
      padding: 32px 28px 28px;
      border: 1px solid rgba(37,99,235,.13);
      border-radius: 30px;
      background:
        radial-gradient(circle at 18% 4%, rgba(124,92,255,.12), transparent 34%),
        radial-gradient(circle at 90% 92%, rgba(39,217,255,.12), transparent 38%),
        rgba(255,255,255,.95);
      box-shadow: 0 22px 64px rgba(37,51,78,.14), inset 0 1px 0 rgba(255,255,255,.9);
    }
    .empty-state::after {
      content: '';
      position: absolute;
      z-index: -1;
      inset: 0;
      background: linear-gradient(135deg, rgba(255,255,255,.72), transparent 48%);
      pointer-events: none;
    }
    .empty-state .hero {
      width: 72px;
      height: 72px;
      margin: 0 auto 16px;
      display: grid;
      place-items: center;
      border-radius: 24px;
      color: white;
      background: linear-gradient(135deg, #7c5cff, #2878f2 58%, #27d9ff);
      box-shadow: 0 14px 30px rgba(76,91,238,.28), inset 0 1px 0 rgba(255,255,255,.35);
    }
    .empty-state .hero .ui-icon { width: 38px; height: 38px; stroke-width: 1.75; }
    .empty-state h2 {
      max-width: 360px;
      margin: 0 auto 9px;
      font-size: clamp(25px, 4.5vw, 34px);
      line-height: 1.12;
      letter-spacing: -.025em;
    }
    .empty-state p {
      max-width: 390px;
      margin: 0 auto 22px;
      color: var(--muted);
      line-height: 1.5;
      font-size: 15px;
    }
    .empty-actions {
      width: min(100%, 360px);
      margin: 0 auto;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .empty-actions .btn {
      min-width: 0;
      min-height: 52px;
      padding-inline: 14px;
      justify-content: center;
      white-space: nowrap;
    }

    .zoom-badge, .orientation-badge {
      position: absolute;
      z-index: 8;
      top: 12px;
      padding: 8px 11px;
      border-radius: 999px;
      border: 1px solid var(--line);
      background: rgba(7,11,23,.82);
      backdrop-filter: blur(12px);
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
      pointer-events: none;
    }
    .zoom-badge { left: 12px; }
    .orientation-badge { right: 12px; }

    .zoom-controls {
      position: absolute;
      z-index: 8;
      right: 12px;
      bottom: 12px;
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px;
      border-radius: 18px;
      border: 1px solid var(--line);
      background: rgba(7,11,23,.82);
      backdrop-filter: blur(12px);
      box-shadow: var(--shadow);
    }
    .zoom-controls .icon-btn {
      width: 42px;
      height: 42px;
      border-radius: 13px;
      font-size: 20px;
    }
    .zoom-readout {
      min-width: 74px;
      height: 42px;
      padding: 0 12px;
      border-radius: 13px;
      border: 1px solid var(--line);
      background: rgba(255,255,255,.06);
      color: white;
      font-weight: 900;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      letter-spacing: -.02em;
    }

    .inspector {
      padding: 14px;
      overflow-y: auto;
    }
    .panel-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin: 2px 0 14px;
    }
    .panel-title h2 { margin: 0; font-size: 16px; }
    .section {
      padding: 14px;
      border: 1px solid var(--line);
      border-radius: 18px;
      background: rgba(255,255,255,.035);
      margin-bottom: 10px;
    }
    .section h3 { margin: 0 0 11px; font-size: 13px; color: #dbe2ff; }
    .label-row {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      align-items: center;
      color: var(--muted);
      font-size: 12px;
      margin-bottom: 8px;
    }
    .value-pill {
      min-width: 44px;
      padding: 4px 8px;
      text-align: center;
      border-radius: 999px;
      background: rgba(255,255,255,.07);
      color: white;
      font-weight: 800;
    }
    input[type="range"] {
      width: 100%;
      accent-color: var(--accent);
    }

    .range-scale {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      margin-top: 3px;
      color: var(--muted);
      font-size: 10px;
      font-weight: 700;
      line-height: 1;
      user-select: none;
    }

    .color-button {
      width: 100%;
      min-height: 62px;
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: 17px;
      background: rgba(255,255,255,.05);
      color: white;
      cursor: pointer;
      text-align: left;
    }
    .color-orb {
      width: 42px;
      height: 42px;
      border-radius: 50%;
      background: #ff3e7f;
      box-shadow: inset 0 0 0 2px rgba(255,255,255,.42), 0 7px 18px rgba(0,0,0,.25);
      flex: 0 0 auto;
    }
    .color-meta strong { display: block; }
    .color-meta span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

    .finish-mini-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
    .finish-mini {
      min-height: 44px;
      border: 1px solid var(--line);
      border-radius: 13px;
      background: rgba(255,255,255,.05);
      color: var(--muted);
      cursor: pointer;
      font-weight: 800;
    }
    .finish-mini.active { border-color: rgba(124,92,255,.65); color: white; background: rgba(124,92,255,.18); }

    .bottom-bar {
      display: none;
      position: relative;
      z-index: 20;
      gap: 8px;
      padding: 9px 10px calc(9px + var(--safe-bottom));
      border-top: 1px solid var(--line);
      background: rgba(7,11,23,.9);
      backdrop-filter: blur(18px);
      overflow-x: auto;
      overflow-y: hidden;
      scrollbar-width: none;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior-x: contain;
      touch-action: pan-x;
      scroll-snap-type: x proximity;
    }
    .bottom-bar::-webkit-scrollbar { display: none; }
    .bottom-bar .tool-btn { min-width: 72px; min-height: 58px; flex: 0 0 auto; scroll-snap-align: center; }
    .bottom-color {
      min-width: 72px;
      min-height: 58px;
      border-radius: 17px;
      border: 1px solid var(--line);
      background: rgba(255,255,255,.06);
      color: white;
      display: grid;
      place-items: center;
      cursor: pointer;
      flex: 0 0 auto;
    }
    .bottom-color .color-orb { width: 35px; height: 35px; }
    .contour-glow-action { margin-top: 10px; }
    .contour-glow-quick { min-width: 86px !important; }
    .tool-btn:disabled { opacity: .42; cursor: default; }

    .modal-backdrop {
      position: fixed;
      inset: 0;
      z-index: 100;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 18px;
      background: rgba(2,4,10,.72);
      backdrop-filter: blur(16px);
    }
    .modal-backdrop.open { display: flex; }
    .render-overlay {
      position: fixed;
      inset: 0;
      z-index: 140;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 20px;
      background: rgba(7,11,23,.48);
      backdrop-filter: blur(12px);
    }
    .render-overlay.open { display: flex; }
    .render-overlay-card {
      position: relative;
      overflow: hidden;
      width: min(420px, 100%);
      padding: 22px 22px 18px;
      border-radius: 24px;
      border: 1px solid rgba(255,255,255,.14);
      background:
        radial-gradient(circle at 18% 22%, rgba(129,230,217,.20), transparent 28%),
        radial-gradient(circle at 82% 18%, rgba(96,165,250,.18), transparent 24%),
        radial-gradient(circle at 50% 72%, rgba(173,132,255,.14), transparent 34%),
        linear-gradient(160deg, rgba(18,26,48,.96), rgba(10,16,31,.97));
      box-shadow: 0 28px 80px rgba(0,0,0,.42);
      color: #fff;
      text-align: center;
    }
    .render-cloud {
      position: absolute;
      inset: 0;
      pointer-events: none;
    }
    .render-cloud::after {
      content: "";
      position: absolute;
      inset: 0;
      background:
        linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent),
        linear-gradient(180deg, rgba(255,255,255,.05), transparent 40%, rgba(255,255,255,.03) 72%, transparent);
      mix-blend-mode: screen;
      animation: render-cloud-sheen 4.8s linear infinite;
    }
    .render-cloud-blob {
      position: absolute;
      border-radius: 999px;
      filter: blur(10px);
      opacity: .95;
      mix-blend-mode: screen;
      animation: render-cloud-drift 8s ease-in-out infinite;
    }
    .render-cloud-blob.blob-a {
      width: 210px;
      height: 100px;
      left: -20px;
      top: 26px;
      background: radial-gradient(circle at 40% 50%, rgba(255,255,255,.30), rgba(121,207,255,.15) 45%, rgba(121,207,255,0) 78%);
      animation-delay: 0s;
    }
    .render-cloud-blob.blob-b {
      width: 250px;
      height: 110px;
      right: -28px;
      top: 10px;
      background: radial-gradient(circle at 55% 44%, rgba(255,255,255,.24), rgba(173,132,255,.14) 48%, rgba(173,132,255,0) 80%);
      animation-duration: 10s;
      animation-delay: -2s;
    }
    .render-cloud-blob.blob-c {
      width: 270px;
      height: 120px;
      left: 50%;
      top: 86px;
      transform: translateX(-50%);
      background: radial-gradient(circle at 50% 42%, rgba(255,255,255,.24), rgba(86,235,196,.13) 46%, rgba(86,235,196,0) 82%);
      animation-duration: 9.2s;
      animation-delay: -4s;
    }
    .render-cloud-grid {
      position: absolute;
      inset: 0;
      background:
        linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
      background-size: 26px 26px;
      opacity: .22;
      mask-image: linear-gradient(180deg, transparent, rgba(0,0,0,.88) 20%, rgba(0,0,0,.88) 86%, transparent);
      animation: render-cloud-grid 7s linear infinite;
    }
    .render-overlay-card strong {
      position: relative;
      z-index: 1;
      display: block;
      font-size: 20px;
      letter-spacing: -.02em;
    }
    .render-overlay-card p {
      position: relative;
      z-index: 1;
      margin: 8px 0 14px;
      color: rgba(233,240,252,.78);
      font-size: 14px;
      line-height: 1.45;
    }
    .render-progress {
      position: relative;
      z-index: 1;
      height: 12px;
      overflow: hidden;
      border-radius: 999px;
      background: rgba(255,255,255,.08);
      border: 1px solid rgba(255,255,255,.08);
    }
    .render-progress-bar {
      width: 0%;
      height: 100%;
      border-radius: inherit;
      background: linear-gradient(90deg, #67e8f9, #60a5fa, #f472b6);
      transition: width .16s linear;
    }
    .render-progress-label {
      position: relative;
      z-index: 1;
      margin-top: 10px;
      color: rgba(255,255,255,.86);
      font-weight: 800;
      font-size: 13px;
      letter-spacing: .02em;
    }
    @keyframes render-cloud-drift {
      0%, 100% { transform: translate3d(0,0,0) scale(1); }
      33% { transform: translate3d(10px,-6px,0) scale(1.04); }
      66% { transform: translate3d(-8px,5px,0) scale(.98); }
    }
    @keyframes render-cloud-grid {
      from { transform: translate3d(0,0,0); }
      to { transform: translate3d(-26px,-26px,0); }
    }
    @keyframes render-cloud-sheen {
      from { transform: translateX(-58%); }
      to { transform: translateX(58%); }
    }
    @keyframes render-spin {
      to { transform: rotate(360deg); }
    }
    .modal {
      width: min(920px, 100%);
      max-height: min(92dvh, 900px);
      display: flex;
      flex-direction: column;
      border: 1px solid rgba(255,255,255,.12);
      border-radius: 28px;
      overflow: hidden;
      background: linear-gradient(155deg, rgba(20,28,50,.98), rgba(9,14,28,.98));
      box-shadow: 0 28px 90px rgba(0,0,0,.55);
    }
    .modal.compact { width: min(620px, 100%); }
    #exportModal .modal.compact { width: min(980px, 100%); }
    .modal-head {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 17px 18px;
      border-bottom: 1px solid var(--line);
    }
    .modal-head h2 { margin: 0; font-size: clamp(19px, 4vw, 26px); }
    .modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
    .modal-head .icon-btn { margin-left: auto; }
    .modal-body { min-height: 0; overflow: auto; padding: 18px; }
    .modal-foot {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      padding: 14px 18px calc(14px + var(--safe-bottom));
      border-top: 1px solid var(--line);
    }

    .template-toolbar {
      display: grid;
      gap: 10px;
      margin-bottom: 14px;
    }
    .template-toolbar-title {
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: .08em;
      color: var(--muted);
      font-weight: 800;
    }
    .template-filters {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }
    .template-filter {
      min-height: 38px;
      padding: 0 14px;
      border-radius: 999px;
      border: 1px solid var(--line);
      background: rgba(255,255,255,.05);
      color: var(--muted);
      cursor: pointer;
      font-weight: 800;
      transition: transform .16s ease, border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease;
    }
    .template-filter:hover { background: rgba(255,255,255,.09); color: white; }
    .template-filter.active {
      color: white;
      border-color: rgba(124,92,255,.55);
      background: linear-gradient(135deg, rgba(124,92,255,.28), rgba(39,217,255,.16));
      box-shadow: 0 8px 20px rgba(71,93,255,.16);
    }
    .template-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
      gap: 14px;
    }
    .template-card {
      min-width: 0;
      overflow: hidden;
      padding: 9px;
      border-radius: 20px;
      border: 1px solid var(--line);
      background: #fff;
      color: var(--text);
      cursor: pointer;
      text-align: left;
      box-shadow: 0 12px 30px rgba(24,44,79,.08);
      transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
    }
    .template-card:hover {
      transform: translateY(-2px);
      border-color: rgba(124,92,255,.42);
      box-shadow: 0 16px 34px rgba(24,44,79,.12);
    }
    .template-thumb {
      position: relative;
      aspect-ratio: 4 / 3;
      border-radius: 15px;
      overflow: hidden;
      display: grid;
      place-items: center;
      padding: 11px;
      background:
        linear-gradient(45deg, rgba(31,50,79,.035) 25%, transparent 25%, transparent 75%, rgba(31,50,79,.035) 75%),
        linear-gradient(45deg, rgba(31,50,79,.035) 25%, transparent 25%, transparent 75%, rgba(31,50,79,.035) 75%),
        #edf2f8;
      background-size: 22px 22px;
      background-position: 0 0, 11px 11px;
      box-shadow: inset 0 0 0 1px rgba(23,36,61,.06);
    }
    .template-paper {
      position: relative;
      z-index: 1;
      display: grid;
      place-items: center;
      overflow: hidden;
      background: #fff;
      border-radius: 4px;
      box-shadow: 0 10px 24px rgba(24,44,79,.13), 0 0 0 1px rgba(23,36,61,.06);
    }
    .template-paper.portrait { height: 100%; aspect-ratio: 210 / 297; }
    .template-paper.landscape { width: 100%; aspect-ratio: 297 / 210; }
    .template-paper.square { height: 92%; aspect-ratio: 1 / 1; }
    .template-paper img { width: 100%; height: 100%; object-fit: contain; display: block; }
    .template-orientation-chip {
      position: absolute;
      z-index: 2;
      left: 8px;
      bottom: 8px;
      min-height: 26px;
      display: inline-flex !important;
      align-items: center;
      gap: 5px;
      max-width: calc(100% - 16px);
      margin: 0 !important;
      padding: 0 9px;
      border-radius: 999px;
      border: 1px solid rgba(255,255,255,.18);
      background: rgba(28,40,61,.90) !important;
      color: #fff !important;
      font-size: 10px !important;
      font-weight: 900;
      backdrop-filter: blur(10px);
      box-shadow: 0 7px 18px rgba(24,44,79,.22);
    }
    .template-orientation-symbol {
      display: inline-block;
      flex: 0 0 auto;
      margin: 0 !important;
      border: 1.5px solid currentColor;
      border-radius: 2px;
      opacity: .96;
    }
    .template-orientation-symbol.portrait { width: 7px; height: 11px; }
    .template-orientation-symbol.landscape { width: 12px; height: 8px; }
    .template-orientation-symbol.square { width: 9px; height: 9px; }
    .template-card-info {
      display: block;
      min-width: 0;
      padding: 10px 4px 6px;
    }
    .template-category-badge {
      display: inline-flex !important;
      align-items: center;
      max-width: 100%;
      width: fit-content;
      margin: 0 0 8px !important;
      padding: 4px 9px;
      border-radius: 999px;
      border: 1px solid rgba(39,217,255,.24) !important;
      background: rgba(39,217,255,.10) !important;
      color: #176276 !important;
      font-size: 10px !important;
      font-weight: 850;
      letter-spacing: .02em;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .template-card strong {
      display: block;
      margin: 0 0 5px;
      color: #17263d;
      font-size: 16px;
      line-height: 1.2;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .template-meta {
      display: block !important;
      margin: 0 !important;
      color: var(--muted) !important;
      font-size: 11px !important;
      line-height: 1.35;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .template-warning {
      grid-column: 1 / -1;
      padding: 13px 15px;
      margin-bottom: 2px;
      border-radius: 15px;
      border: 1px solid rgba(255,193,7,.3);
      background: rgba(255,193,7,.09);
      color: #fff3c4;
      line-height: 1.45;
      font-size: 13px;
    }
    .template-warning strong { display: block; margin-bottom: 4px; color: #fff; }

    .template-empty {
      grid-column: 1 / -1;
      padding: 34px;
      text-align: center;
      color: var(--muted);
      border: 1px dashed var(--line);
      border-radius: 20px;
    }

    .color-layout {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 42px 220px;
      gap: 16px;
      align-items: stretch;
    }
    .picker-box {
      position: relative;
      min-height: 310px;
      border-radius: 20px;
      overflow: hidden;
      box-shadow: inset 0 0 0 1px rgba(255,255,255,.1);
      touch-action: none;
    }
    #slCanvas, #hueCanvas { width: 100%; height: 100%; display: block; touch-action: none; }
    .hue-box { min-height: 310px; border-radius: 20px; overflow: hidden; touch-action: none; }
    .picker-dot {
      position: absolute;
      width: 22px;
      height: 22px;
      border-radius: 50%;
      border: 3px solid white;
      box-shadow: 0 0 0 2px rgba(0,0,0,.45), 0 5px 16px rgba(0,0,0,.3);
      transform: translate(-50%, -50%);
      pointer-events: none;
    }
    .color-side { display: flex; flex-direction: column; gap: 12px; }
    .color-preview {
      min-height: 92px;
      border-radius: 20px;
      border: 1px solid var(--line);
      background: #ff3e7f;
      box-shadow: inset 0 0 25px rgba(255,255,255,.18);
    }
    .hex-field {
      display: flex;
      align-items: center;
      gap: 8px;
      border-radius: 14px;
      border: 1px solid var(--line);
      background: rgba(255,255,255,.05);
      padding: 8px 10px;
    }
    .hex-field span { color: var(--muted); font-weight: 900; }
    .hex-field input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: white; text-transform: uppercase; font-weight: 900; }
    .swatch-section { display: flex; flex-direction: column; gap: 7px; }
    .swatch-label {
      font-size: 11px;
      line-height: 1;
      font-weight: 900;
      letter-spacing: .035em;
      text-transform: uppercase;
      color: var(--muted);
    }
    .swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
    .swatch {
      position: relative;
      aspect-ratio: 1;
      min-width: 0;
      border: 2px solid rgba(255,255,255,.25);
      border-radius: 12px;
      cursor: pointer;
      box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 3px 9px rgba(25,38,69,.10);
    }
    .swatch:hover { transform: translateY(-1px); }
    .swatch.recent::after {
      content: '';
      position: absolute;
      inset: 3px;
      border-radius: 8px;
      border: 1px solid rgba(255,255,255,.34);
      pointer-events: none;
    }
    .swatch.empty {
      cursor: default;
      background: repeating-linear-gradient(135deg, #eef2f8 0 7px, #f8faff 7px 14px);
      border-style: dashed;
      border-color: #cad3e1;
      box-shadow: none;
    }
    .swatch.empty:hover { transform: none; }

    .finish-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(96px,1fr));
      gap: 10px;
      margin-top: 18px;
    }
    .finish-card {
      min-height: 74px;
      border-radius: 17px;
      padding: 9px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 7px;
      font-weight: 900;
      color: var(--muted);
    }
    .finish-card.active { color: white; border-color: rgba(124,92,255,.66); box-shadow: 0 0 0 2px rgba(124,92,255,.13); }
    .finish-sample { width: 100%; height: 24px; border-radius: 999px; box-shadow: inset 0 1px 0 rgba(255,255,255,.5); }
    .finish-standard { background: linear-gradient(90deg, #ff3e7f, #ff3e7f); }
    .finish-neon { background: radial-gradient(circle, #fff 0%, #ffb5d2 18%, #ff3e7f 44%, rgba(255,62,127,.3) 72%, transparent 100%), #151027; box-shadow: 0 0 12px rgba(255,62,127,.9), inset 0 0 8px rgba(255,255,255,.55); }
    .finish-metallic { background: linear-gradient(105deg, #6a204d 0%, #ff5ea1 28%, #fff 48%, #b22d66 65%, #ff8fbf 100%); }
    .finish-gold { background: linear-gradient(105deg, #5c3900 0%, #d69f1e 30%, #fff0a4 49%, #a56500 64%, #f6c94a 100%); }
    .finish-silver { background: linear-gradient(105deg, #4d5561 0%, #c9d2dc 31%, #fff 49%, #6f7b89 64%, #dbe3ea 100%); }
    .finish-chrome { background: linear-gradient(105deg, #203447 0%, #bde8ff 28%, #fff 46%, #395f79 63%, #d8f4ff 100%); }
    .finish-pearl { background: linear-gradient(105deg, #ffe1f2 0%, #dff9ff 32%, #fff 48%, #d9ccff 66%, #fff2d9 100%); }

    .export-preview {
      display: grid;
      grid-template-columns: minmax(320px, 1.08fr) minmax(320px, .92fr);
      gap: 22px;
      align-items: start;
    }
    .page-preview {
      width: min(100%, 380px);
      aspect-ratio: 210 / 297;
      margin: auto;
      padding: 2.38%;
      display: grid;
      place-items: center;
      background: white;
      box-shadow: 0 18px 55px rgba(0,0,0,.4);
    }
    .page-preview.landscape { aspect-ratio: 297 / 210; }
    .page-preview img { width: 100%; height: 100%; object-fit: contain; }
    .export-info {
      min-width: 0;
      display: grid;
      align-content: start;
    }
    .export-info h3 {
      margin: 0 0 9px;
      font-size: clamp(24px, 2vw, 38px);
      line-height: 1.05;
      overflow-wrap: anywhere;
    }
    .export-info p { color: var(--muted); line-height: 1.55; }
    .export-stats { display: grid; gap: 9px; margin: 18px 0; }
    .stat { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.04); }
    .stat span { color: var(--muted); }
    .export-format-choice {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      margin-top: 14px;
    }
    .export-format-btn {
      min-width: 0;
      min-height: 122px;
      padding: 14px;
      border: 1px solid #d8e0ec;
      border-radius: 18px;
      background: #fff;
      color: #182840;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      justify-content: space-between;
      gap: 8px;
      text-align: left;
      cursor: pointer;
      box-shadow: 0 8px 22px rgba(24,44,79,.07);
      overflow: hidden;
    }
    .export-format-btn:hover { background: #f1f5fc; border-color: #aebbd0; }
    .export-format-btn strong {
      font-size: clamp(17px, 1.3vw, 24px);
      line-height: 1;
      letter-spacing: -.03em;
    }
    .export-format-btn span {
      display: block;
      color: #5b6a84;
      font-size: 12px;
      line-height: 1.35;
      overflow-wrap: normal;
      word-break: normal;
      hyphens: auto;
    }
    .export-format-btn.holo-choice {
      grid-column: 1 / -1;
    }
    @media (min-width: 701px) and (max-width: 1100px) {
      #exportModal .modal.compact { width: min(860px, 100%); }
      .export-preview {
        grid-template-columns: minmax(260px, 1fr) minmax(280px, .95fr);
        gap: 18px;
      }
      .export-format-choice {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      .export-format-btn.holo-choice {
        grid-column: 1 / -1;
      }
    }
    @media (min-width: 701px) and (max-width: 820px) {
      #exportModal .modal.compact { width: min(680px, 100%); }
      .export-preview {
        grid-template-columns: 1fr;
      }
      .export-info h3 {
        font-size: 28px;
      }
      .export-format-choice {
        grid-template-columns: 1fr;
      }
      .export-format-btn.holo-choice {
        grid-column: auto;
      }
    }
    .export-format-btn.primary-choice {
      background: linear-gradient(135deg,#7657f3,#356fe8);
      border-color: transparent;
      color: #fff;
    }
    .export-format-btn.primary-choice:hover { background: linear-gradient(135deg,#6849e7,#2863da); }
    .export-format-btn.primary-choice span { color: rgba(255,255,255,.86); }
    .export-format-btn.holo-choice {
      grid-column: 1 / -1;
      background: linear-gradient(135deg, rgba(0,224,255,.13), rgba(176,76,255,.13), rgba(255,66,196,.12));
      border-color: rgba(116,116,255,.28);
    }
    .export-format-btn.holo-choice strong {
      background: linear-gradient(90deg, #08a9c7, #7657f3, #e532a7);
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
    }
    .export-format-btn.holo-choice:disabled { opacity: .42; cursor: default; }

    .toast-stack {
      position: fixed;
      z-index: 300;
      left: 50%;
      bottom: calc(20px + var(--safe-bottom));
      width: min(92vw, 480px);
      transform: translateX(-50%);
      display: grid;
      gap: 8px;
      pointer-events: none;
    }
    .legal-footer {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 14px;
      padding: 10px 16px calc(18px + var(--safe-bottom));
      color: rgba(64,81,107,.78);
      font-size: 12px;
      line-height: 1.2;
    }
    .legal-footer a {
      color: inherit;
      text-decoration: none;
      font-weight: 700;
      opacity: .9;
      transition: color .18s ease, opacity .18s ease;
    }
    .legal-footer a:hover,
    .legal-footer a:focus-visible {
      color: var(--text);
      opacity: 1;
    }
    .legal-footer-mobile { display: none; }
    @media (max-width: 700px) {
      body { overflow: hidden; }
      .app { grid-template-rows: auto minmax(0,1fr) auto auto !important; }
      .legal-footer:not(.legal-footer-mobile) { display: none; }
      .legal-footer-mobile {
        display: flex;
        border-top: 1px solid var(--line);
        background: rgba(7,11,23,.9);
        backdrop-filter: blur(18px);
        color: rgba(226,232,240,.82);
      }
      .legal-footer {
        gap: 12px;
        padding: 4px 12px calc(8px + var(--safe-bottom));
        font-size: 11px;
      }
    }
    .toast {
      padding: 13px 15px;
      border-radius: 15px;
      border: 1px solid rgba(255,255,255,.13);
      background: rgba(15,22,42,.95);
      color: white;
      box-shadow: 0 14px 42px rgba(0,0,0,.35);
      animation: toastIn .22s ease both;
    }
    @keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }

    .mobile-only { display: none; }
    .hidden-input {
      position: fixed;
      left: -10000px;
      top: 0;
      width: 1px;
      height: 1px;
      opacity: 0;
      overflow: hidden;
      pointer-events: none;
    }

    @media (max-width: 980px) {
      .workspace { grid-template-columns: 78px minmax(0,1fr); min-height: 0; }
      .inspector { display: none; }
      .mobile-only { display: inline-flex; }
      .topbar .btn .label { display: none; }
      .topbar .btn { width: 44px; padding: 0; }
      .tool-rail {
        height: 100%;
        max-height: 100%;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(10px + var(--safe-bottom));
      }
      .tablet-color-button {
        display: flex;
        position: static;
        margin-top: 2px;
        box-shadow: none;
        backdrop-filter: none;
      }
      /* Schmale Tablet-Werkzeugleiste: lange Namen dürfen den Button nie verlassen. */
      .tool-rail .tool-btn > span:last-child {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        text-align: center;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: normal;
      }
      .tool-rail .tool-btn {
        min-height: 88px;
        padding: 8px 6px;
      }
      .tool-rail .tool-btn .ico {
        flex: 0 0 auto;
      }
      .tool-rail .tool-btn[data-tool="rainbow"] > span:last-child {
        font-size: 10px;
        letter-spacing: 0;
      }
    }

    @media (max-width: 700px) {
      body { overflow: hidden; }
      .app { grid-template-rows: auto minmax(0,1fr) auto auto; }
      .topbar { min-height: 58px; padding: max(7px, env(safe-area-inset-top)) 9px 7px; gap: 6px; }
      .brand-mark { width: 38px; height: 38px; border-radius: 13px; }
      .brand p { display: none; }
      .brand h1 { font-size: 17px; }
      .top-actions { gap: 5px; }
      .topbar .icon-btn, .topbar .btn { width: 40px; height: 40px; min-height: 40px; border-radius: 12px; }
      .workspace { display: block; padding: 7px; }
      .tool-rail { display: none; }
      .tablet-color-button { display: none; }
      .stage-shell { width: 100%; height: 100%; border-radius: 17px; }
      .canvas-wrap { padding: 10px; }
      .empty-state {
        width: min(100%, 420px);
        padding: 24px 18px 20px;
        border-radius: 24px;
        box-shadow: 0 16px 44px rgba(37,51,78,.12), inset 0 1px 0 rgba(255,255,255,.92) !important;
      }
      .empty-state .hero {
        width: 58px;
        height: 58px;
        margin-bottom: 13px;
        border-radius: 19px;
      }
      .empty-state .hero .ui-icon { width: 31px; height: 31px; }
      .empty-state h2 {
        max-width: 285px;
        margin-bottom: 8px;
        font-size: clamp(24px, 7vw, 29px);
        line-height: 1.08;
      }
      .empty-state p {
        max-width: 300px;
        margin-bottom: 18px;
        font-size: 14px;
        line-height: 1.42;
      }
      .empty-actions {
        width: min(100%, 320px);
        grid-template-columns: 1fr;
        gap: 8px;
      }
      .empty-actions .btn { min-height: 48px; border-radius: 15px; }
      .stage-shell:not(.has-artwork) .canvas-footer {
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
      }
      .bottom-bar { display: flex; }
      .mobile-only { display: inline-flex; }
      .zoom-badge, .orientation-badge { top: 8px; padding: 6px 8px; font-size: 10px; }
      .zoom-badge { left: 8px; }
      .orientation-badge { right: 8px; }
      .zoom-controls { right: 8px; bottom: 8px; gap: 6px; padding: 6px; }
      .zoom-controls .icon-btn, .zoom-readout { height: 38px; }
      .zoom-controls .icon-btn { width: 38px; }
      .zoom-readout { min-width: 66px; font-size: 12px; }
      .modal-backdrop { padding: 0; align-items: flex-end; }
      .modal, .modal.compact { width: 100%; max-height: 94dvh; border-radius: 22px 22px 0 0; }
      .modal-head { padding: 11px 12px; gap: 8px; }
      .modal-head h2 { font-size: 18px; line-height: 1.1; }
      .modal-head p { margin-top: 2px; font-size: 10px; }
      .modal-head .icon-btn { width: 38px; height: 38px; border-radius: 12px; }
      .modal-body { padding: 10px; }
      .modal-foot { padding: 9px 10px calc(9px + var(--safe-bottom)); gap: 7px; flex-wrap: wrap; }
      .modal-foot .btn { min-height: 40px; flex: 1 1 140px; }

      .template-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
      .template-card { padding: 7px; border-radius: 18px; }
      .template-thumb { padding: 9px; border-radius: 13px; }
      .template-orientation-chip { left: 6px; bottom: 6px; min-height: 24px; padding: 0 7px; font-size: 9px !important; }
      .template-card-info { padding: 8px 2px 5px; }
      .template-category-badge { margin-bottom: 7px !important; }
      .template-card strong { font-size: 14px; }
      .template-filters { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
      .template-filter { flex: 0 0 auto; }

      /* Kompakte mobile Werkzeug-Einstellungen */
      #settingsModal .modal { max-height: min(88dvh, 620px); }
      #settingsModal .modal-head p { display: none; }
      #settingsModal .modal-body {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
        overflow: auto;
      }
      #settingsModal .section {
        min-width: 0;
        margin: 0;
        padding: 8px 9px 7px;
        border-radius: 13px;
      }
      #settingsModal .label-row {
        min-width: 0;
        gap: 5px;
        margin-bottom: 2px;
        font-size: 10px;
        line-height: 1.15;
      }
      #settingsModal .label-row > span:first-child {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      #settingsModal .value-pill {
        min-width: 34px;
        padding: 2px 6px;
        font-size: 10px;
        flex: 0 0 auto;
      }
      #settingsModal input[type="range"] {
        height: 22px;
        margin: 0;
      }
      #settingsModal #mobileClearBtn {
        grid-column: 1 / -1;
        min-height: 44px;
        margin-top: 1px;
        border-radius: 14px;
        font-size: 13px;
      }

      /* Saubere mobile Anordnung der drei Malmodi */
      #settingsModal {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
      }
      #settingsModal .modal,
      #settingsModal .modal.compact {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
      }
      #settingsModal .modal-head {
        width: 100%;
        min-width: 0;
        padding: 13px 14px;
      }
      #settingsModal .modal-head > div {
        min-width: 0;
        flex: 1 1 auto;
      }
      #settingsModal .modal-head h2 {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 19px;
      }
      #settingsModal .modal-head .icon-btn {
        flex: 0 0 42px;
        width: 42px;
        height: 42px;
      }
      #settingsModal .modal-body {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        padding: 12px 14px calc(14px + var(--safe-bottom));
        overflow-x: hidden;
      }
      #settingsModal .size-section {
        grid-column: 1 / -1;
      }
      #settingsModal .size-section input[type="range"] {
        display: block;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
      }
      #settingsModal .paint-mode-section {
        grid-column: 1 / -1;
        padding: 12px;
        border-radius: 17px;
      }
      #settingsModal .paint-mode-section .label-row {
        margin-bottom: 9px;
        font-size: 13px;
      }
      #settingsModal .paint-mode-section .value-pill {
        display: none;
      }
      #settingsModal .paint-mode-grid {
        grid-template-columns: 1fr;
        gap: 8px;
      }
      #settingsModal .paint-mode-btn {
        position: relative;
        width: 100%;
        min-height: 58px;
        padding: 10px 46px 10px 13px;
        border-radius: 14px;
        display: grid;
        grid-template-columns: 1fr;
        justify-items: start;
        align-content: center;
        gap: 2px;
        text-align: left;
        overflow: hidden;
      }
      #settingsModal .paint-mode-btn strong {
        width: 100%;
        font-size: 14px;
        line-height: 1.2;
        white-space: normal;
      }
      #settingsModal .paint-mode-btn small {
        width: 100%;
        font-size: 11px;
        line-height: 1.3;
        white-space: normal;
      }
      #settingsModal .paint-mode-btn::after {
        content: '';
        position: absolute;
        right: 13px;
        top: 50%;
        width: 22px;
        height: 22px;
        border: 2px solid rgba(98,110,137,.35);
        border-radius: 50%;
        transform: translateY(-50%);
        background: rgba(255,255,255,.72);
      }
      #settingsModal .paint-mode-btn.active::after {
        content: '✓';
        display: grid;
        place-items: center;
        color: #5364ff;
        border-color: rgba(255,255,255,.85);
        background: #fff;
        font-size: 14px;
        font-weight: 900;
      }
      #settingsModal #mobileContourGlowBtn {
        grid-column: 1 / -1;
        min-height: 44px;
        border-radius: 14px;
      }

      /* Flachere mobile Farbauswahl */
      #colorModal .modal { max-height: 93dvh; }
      #colorModal .modal-head p { display: none; }
      #colorModal .modal-body { padding: 9px 10px; }
      #colorModal .color-layout {
        grid-template-columns: minmax(0,1fr) 28px;
        gap: 8px;
      }
      #colorModal .picker-box,
      #colorModal .hue-box {
        min-height: 150px;
        height: 150px;
        border-radius: 14px;
      }
      #colorModal .picker-dot {
        width: 18px;
        height: 18px;
        border-width: 2px;
      }
      #colorModal .color-side {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: 46px minmax(0,1fr);
        gap: 7px;
        align-items: stretch;
      }
      #colorModal .color-preview {
        min-height: 42px;
        height: 42px;
        border-radius: 12px;
      }
      #colorModal .hex-field {
        min-height: 42px;
        padding: 5px 9px;
        border-radius: 12px;
      }
      #colorModal .swatch-section { grid-column: 1 / -1; gap: 5px; }
      #colorModal .swatch-label { font-size: 9px; }
      #colorModal .swatches {
        grid-template-columns: repeat(10, minmax(0,1fr));
        gap: 5px;
      }
      #colorModal .recent-swatches { grid-template-columns: repeat(5, minmax(0,1fr)); }
      #colorModal .swatch { border-radius: 8px; border-width: 1px; }
      #colorModal .finish-grid {
        grid-template-columns: repeat(6, minmax(72px,1fr));
        gap: 6px;
        margin-top: 9px;
        overflow-x: auto;
        padding-bottom: 2px;
      }
      #colorModal .finish-card {
        min-height: 54px;
        padding: 6px;
        border-radius: 13px;
        gap: 4px;
        font-size: 10px;
        flex: 0 0 auto;
      }
      #colorModal .finish-sample { height: 16px; }
      #colorModal .modal-foot { padding-top: 7px; }

      #exportModal .modal.compact { width: min(900px, calc(100% - 20px)); }
      #exportModal .export-preview {
        grid-template-columns: minmax(250px, 1fr) minmax(280px, .95fr);
        gap: 16px;
      }
      #exportModal .export-info { text-align: left; }
      #exportModal .modal { max-height: 94dvh; }
      #exportModal .modal-body { padding: 10px; }
      #exportModal .page-preview { width: min(58vw, 240px); }
      #exportModal .export-stats { margin: 10px 0; gap: 6px; }
      #exportModal .stat { padding: 8px 10px; }
      #exportModal .export-format-choice { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
      #exportModal .export-format-btn.holo-choice { grid-column: 1 / -1; }
      #exportModal .export-format-btn { min-height: 88px; padding: 11px; align-items: flex-start; text-align: left; }
      #exportModal .export-format-btn strong { font-size: 18px; }
      #exportModal .modal-foot { flex-wrap: nowrap; }
      #exportModal .modal-foot .btn { flex: 1 1 auto; }
    }

    @media (max-width: 420px) {
      .brand h1 { display: none; }
      .empty-state { padding: 21px 15px 18px; border-radius: 22px; }
      .empty-state .hero { width: 54px; height: 54px; margin-bottom: 11px; }
      .empty-state h2 { font-size: 24px; }
      .empty-state p { font-size: 13px; margin-bottom: 15px; }
      .empty-actions .btn { min-height: 46px; font-size: 14px; }
      .brand { margin-right: auto; }
      .template-grid { grid-template-columns: 1fr 1fr; }
      .template-card strong { font-size: 13px; }
      #settingsModal .modal-body { gap: 8px; padding: 10px 12px calc(12px + var(--safe-bottom)); }
      #settingsModal .section { padding: 8px 9px 7px; }
      #settingsModal .paint-mode-section { padding: 11px; }
      #settingsModal .paint-mode-btn { min-height: 56px; padding: 9px 44px 9px 12px; }
      #colorModal .picker-box,
      #colorModal .hue-box { min-height: 132px; height: 132px; }
      #colorModal .finish-card { min-width: 70px; }
    }

    @media (max-height: 650px) and (max-width: 700px) {
      #settingsModal .modal { max-height: 96dvh; }
      #settingsModal .modal-head { padding: 9px 12px; }
      #settingsModal .modal-body { padding: 8px 10px calc(9px + var(--safe-bottom)); gap: 7px; }
      #settingsModal .section { padding: 7px 8px 6px; }
      #settingsModal .paint-mode-section { padding: 9px; }
      #settingsModal .paint-mode-grid { gap: 6px; }
      #settingsModal .paint-mode-btn { min-height: 49px; padding: 7px 42px 7px 11px; }
      #settingsModal .paint-mode-btn strong { font-size: 13px; }
      #settingsModal .paint-mode-btn small { font-size: 10px; }
      #settingsModal input[type="range"] { height: 18px; }
      #colorModal .picker-box,
      #colorModal .hue-box { min-height: 118px; height: 118px; }
      #colorModal .finish-grid { margin-top: 6px; }
      #colorModal .finish-card { min-height: 48px; }
    }

    /* Light UI override */
    body { color: var(--text); }
    .topbar, .bottom-bar, .tool-rail, .inspector, .modal, .empty-state, .zoom-badge, .orientation-badge, .zoom-controls {
      background: rgba(255,255,255,.92) !important;
      color: var(--text) !important;
      border-color: var(--line) !important;
      box-shadow: var(--shadow) !important;
    }
    .stage-shell {
      border-color: rgba(23,36,61,.10) !important;
      background:
        linear-gradient(45deg, rgba(17,24,39,.03) 25%, transparent 25%, transparent 75%, rgba(17,24,39,.03) 75%),
        linear-gradient(45deg, rgba(17,24,39,.03) 25%, transparent 25%, transparent 75%, rgba(17,24,39,.03) 75%),
        #eef3f9 !important;
      background-position: 0 0, 16px 16px;
      background-size: 32px 32px;
      box-shadow: inset 0 0 40px rgba(21, 32, 51, .05) !important;
    }
    .btn, .icon-btn, .tool-btn, .finish-card, .color-button, .finish-mini, .bottom-color, .template-card, .template-filter, .stat, .section, .zoom-readout, .value-pill {
      color: var(--text) !important;
      border-color: var(--line) !important;
      background: rgba(255,255,255,.88) !important;
      box-shadow: 0 6px 18px rgba(24,44,79,.05);
    }
    .btn:hover, .icon-btn:hover, .tool-btn:hover, .template-filter:hover { background: #f4f7fd !important; }
    .btn.secondary, .btn.ghost { background: rgba(39,217,255,.10) !important; border-color: rgba(39,217,255,.24) !important; }
    .btn.primary { color: #fff !important; }
    .tool-btn { color: var(--muted) !important; }
    .tool-btn .ico {
      color: #40506a !important;
      background: linear-gradient(145deg, #ffffff, #eef3fb) !important;
      box-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 8px 18px rgba(24,44,79,.08) !important;
    }
    .tool-btn.active, .finish-mini.active, .template-filter.active { color: var(--text) !important; }
    .tool-btn.active .ico { color: #fff !important; }
    .brand p, .label-row, .color-meta span, .template-card .template-meta, .zoom-badge, .orientation-badge { color: var(--muted) !important; }
    .section h3, .panel-title h2, .brand h1, .empty-state h2 { color: var(--text) !important; }
    .color-button, .bottom-color { background: #fff !important; }
    .modal { background: linear-gradient(180deg, #ffffff, #f8fbff) !important; }
    .modal-backdrop { background: rgba(240,245,252,.72) !important; }
    .zoom-readout { background: #fff !important; color: var(--text) !important; }
    .value-pill { background: #eef3fb !important; }
    .template-category-badge { background: rgba(39,217,255,.08) !important; color: #1e5c6d !important; border-color: rgba(39,217,255,.22) !important; }
    .finish-card span:last-child, .finish-mini, .template-card strong { color: var(--text) !important; }
    .empty-state p { color: var(--muted) !important; }
    .canvas-frame { box-shadow: 0 22px 60px rgba(24,44,79,.16), 0 0 0 1px rgba(23,36,61,.08) !important; }



    /* Verbindliche Kontraste für das helle UI */
    .btn,
    .icon-btn,
    .tool-btn,
    .finish-card,
    .finish-mini,
    .color-button,
    .bottom-color,
    .template-filter,
    .template-card {
      text-shadow: none !important;
    }

    .btn.primary {
      background: linear-gradient(135deg, #7657f3 0%, #356fe8 100%) !important;
      border-color: transparent !important;
      color: #ffffff !important;
      box-shadow: 0 10px 24px rgba(70, 82, 210, .24) !important;
    }
    .btn.primary:hover {
      background: linear-gradient(135deg, #6849e7 0%, #2863da 100%) !important;
      color: #ffffff !important;
    }
    .btn.primary .ui-icon,
    .btn.primary .label,
    .btn.primary span { color: inherit !important; }

    .btn.secondary,
    .btn.ghost {
      background: #eef9fc !important;
      border-color: #b9e6ef !important;
      color: #164b5b !important;
    }
    .btn.secondary:hover,
    .btn.ghost:hover {
      background: #e2f4f8 !important;
      color: #113f4d !important;
    }

    .btn.danger {
      background: #fff1f4 !important;
      border-color: #f3beca !important;
      color: #a52249 !important;
    }
    .btn.danger:hover {
      background: #ffe5eb !important;
      color: #881b3c !important;
    }

    .icon-btn {
      background: #ffffff !important;
      border-color: #d9e1ec !important;
      color: #263750 !important;
    }
    .icon-btn:hover {
      background: #eef3fa !important;
      color: #172840 !important;
    }

    .tool-btn {
      background: #ffffff !important;
      color: #58677e !important;
    }
    .tool-btn:hover {
      background: #f3f6fb !important;
      color: #273750 !important;
    }
    .tool-btn.active {
      background: #eeebff !important;
      border-color: #9b8af1 !important;
      color: #392d7b !important;
      box-shadow: 0 8px 22px rgba(91, 76, 186, .13) !important;
    }
    .tool-btn.active .ico {
      background: linear-gradient(135deg, #7657f3, #2f9cc4) !important;
      color: #ffffff !important;
    }

    .finish-mini,
    .finish-card {
      background: #ffffff !important;
      color: #45546c !important;
    }
    .finish-mini:hover,
    .finish-card:hover {
      background: #f3f6fb !important;
      color: #25354d !important;
    }
    .finish-mini.active,
    .finish-card.active {
      background: #eeeaff !important;
      border-color: #8e7bea !important;
      color: #352875 !important;
      box-shadow: 0 0 0 2px rgba(118,87,243,.10) !important;
    }
    .finish-card.active span,
    .finish-mini.active { color: #352875 !important; }

    .color-button,
    .bottom-color {
      background: #ffffff !important;
      border-color: #d7e0eb !important;
      color: #1d2d45 !important;
    }
    .color-button:hover,
    .bottom-color:hover { background: #f3f6fb !important; }

    .template-filter {
      background: #ffffff !important;
      color: #53627a !important;
    }
    .template-filter:hover {
      background: #f0f4fa !important;
      color: #25364e !important;
    }
    .template-filter.active {
      background: linear-gradient(135deg, #7657f3, #3678d9) !important;
      border-color: transparent !important;
      color: #ffffff !important;
      box-shadow: 0 8px 20px rgba(76, 84, 196, .18) !important;
    }

    .template-card {
      background: #ffffff !important;
      color: #17263d !important;
    }
    .template-card:hover {
      background: #ffffff !important;
      color: #17263d !important;
    }
    .template-card strong { color: #17263d !important; }
    .template-thumb {
      background:
        linear-gradient(45deg, rgba(31,50,79,.035) 25%, transparent 25%, transparent 75%, rgba(31,50,79,.035) 75%),
        linear-gradient(45deg, rgba(31,50,79,.035) 25%, transparent 25%, transparent 75%, rgba(31,50,79,.035) 75%),
        #edf2f8 !important;
      background-size: 22px 22px !important;
      background-position: 0 0, 11px 11px !important;
    }
    .template-card .template-orientation-chip,
    .template-card .template-orientation-chip span {
      background: rgba(24, 35, 54, .94) !important;
      border-color: rgba(255,255,255,.30) !important;
      color: #f8fbff !important;
      opacity: 1 !important;
      text-shadow: 0 1px 2px rgba(0,0,0,.45) !important;
    }
    .template-card .template-orientation-symbol {
      background: transparent !important;
      border-color: currentColor !important;
      color: #f8fbff !important;
      opacity: 1 !important;
      text-shadow: none !important;
    }
    .template-card .template-category-badge {
      color: #14586b !important;
      text-shadow: none !important;
    }

    .hex-field { background: #ffffff !important; border-color: #d7e0eb !important; }
    .hex-field input { color: #17263d !important; }
    .template-warning {
      background: #fff8df !important;
      border-color: #ead27a !important;
      color: #654d00 !important;
    }
    .template-warning strong { color: #483700 !important; }



    .contour-glow-action.active,
    #mobileContourGlowBtn.active {
      color: #fff !important;
      border-color: transparent !important;
      background: linear-gradient(135deg, var(--accent), #4b7dff) !important;
      box-shadow: 0 10px 24px rgba(83,92,255,.22) !important;
    }

    /* Canvas controls always beneath the artwork */
    .stage-shell {
      grid-template-rows: minmax(0, 1fr) auto !important;
      place-items: stretch !important;
    }
    .canvas-wrap {
      width: 100% !important;
      height: auto !important;
      min-height: 0 !important;
    }
    .canvas-footer {
      min-width: 0;
      display: grid;
      grid-template-columns: minmax(70px, 1fr) auto minmax(70px, 1fr);
      align-items: center;
      gap: 10px;
      padding: 8px 10px 10px;
      border-top: 1px solid var(--line);
      background: rgba(255,255,255,.92);
    }
    .canvas-footer .zoom-badge,
    .canvas-footer .orientation-badge,
    .canvas-footer .zoom-controls {
      position: relative !important;
      inset: auto !important;
      top: auto !important;
      right: auto !important;
      bottom: auto !important;
      left: auto !important;
      margin: 0 !important;
    }
    .canvas-footer .zoom-badge { justify-self: start; }
    .canvas-footer .orientation-badge { justify-self: end; }
    .canvas-footer .zoom-controls { justify-self: center; }
    .canvas-footer .zoom-controls .pan-toggle {
      margin-right: 3px;
      border-color: #c8d2e1 !important;
    }
    .canvas-footer .zoom-controls .pan-toggle.active {
      color: #ffffff !important;
      background: linear-gradient(135deg, #7657f3, #2f9cc4) !important;
      border-color: #7657f3 !important;
      box-shadow: 0 7px 18px rgba(84, 78, 199, .28) !important;
    }
    .canvas-footer .zoom-controls .pan-toggle.active:hover {
      color: #ffffff !important;
      background: linear-gradient(135deg, #6849e7, #288eb5) !important;
    }
    @media (max-width: 620px) {
      .canvas-footer {
        grid-template-columns: 1fr auto;
        gap: 7px;
        padding: 7px 8px 8px;
      }
      .canvas-footer .zoom-controls {
        grid-column: 1 / -1;
        grid-row: 1;
        width: max-content;
        max-width: 100%;
      }
      .canvas-footer .zoom-badge { grid-column: 1; grid-row: 2; }
      .canvas-footer .orientation-badge { grid-column: 2; grid-row: 2; }
    }

    /* Smartphones im Querformat erhalten immer die vollständige mobile Werkzeugleiste. */
    @media (orientation: landscape) and (min-width: 701px) and (max-height: 700px) and (max-width: 980px) {
      .empty-state {
        width: min(560px, calc(100% - 24px));
        padding: 14px 18px;
        display: grid;
        grid-template-columns: 54px minmax(0,1fr);
        column-gap: 14px;
        text-align: left;
        align-items: center;
      }
      .empty-state .hero { grid-row: 1 / span 3; margin: 0; width: 54px; height: 54px; border-radius: 17px; }
      .empty-state .hero .ui-icon { width: 29px; height: 29px; }
      .empty-state h2 { max-width: none; margin: 0 0 3px; font-size: 22px; }
      .empty-state p { max-width: none; margin: 0 0 9px; font-size: 12px; }
      .empty-actions { width: 100%; grid-template-columns: 1fr 1fr; gap: 7px; }
      .empty-actions .btn { min-height: 38px; border-radius: 12px; font-size: 12px; }
      .start-blank-accordion,
      .start-main-actions { grid-column: 1 / -1; }
      .start-blank-accordion { max-width: 100%; margin-bottom: 7px; }
      .start-blank-head { min-height: 50px; grid-template-columns: 34px minmax(0,1fr) 22px; padding: 6px 8px; }
      .start-blank-head-icon { width: 34px; height: 34px; border-radius: 11px; }
      .start-blank-grid { grid-template-columns: repeat(3, minmax(0,1fr)); max-height: 118px; }
      .start-blank-thumb { height: 54px; }
      .start-blank-paper.portrait { height: 47px; }
      .start-blank-paper.square { height: 45px; }
      .start-blank-info { padding-top: 4px; }
      .start-blank-info small { display: none; }
      html, body { width: 100%; height: 100%; overflow: hidden !important; }
      .app {
        width: 100%;
        height: 100dvh;
        min-height: 0;
        grid-template-rows: auto minmax(0, 1fr) auto auto !important;
      }
      .topbar {
        min-height: 48px;
        padding: max(4px, env(safe-area-inset-top)) 8px 4px;
        gap: 5px;
      }
      .brand-mark { width: 34px; height: 34px; border-radius: 11px; }
      .brand p { display: none; }
      .brand h1 { font-size: 15px; }
      .topbar .icon-btn,
      .topbar .btn { width: 36px; height: 36px; min-height: 36px; border-radius: 11px; }
      .workspace {
        display: block !important;
        min-width: 0;
        min-height: 0;
        padding: 5px;
      }
      .tool-rail,
      .inspector { display: none !important; }
      .stage-shell {
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        border-radius: 14px;
      }
      .canvas-wrap { padding: 6px !important; }
      .canvas-footer { gap: 5px; padding: 4px 6px 5px; }
      .canvas-footer .zoom-controls { gap: 4px; padding: 4px; }
      .canvas-footer .zoom-controls .icon-btn,
      .canvas-footer .zoom-readout { height: 32px; }
      .canvas-footer .zoom-controls .icon-btn { width: 32px; }
      .canvas-footer .zoom-readout { min-width: 54px; font-size: 11px; }
      .canvas-footer .zoom-badge,
      .canvas-footer .orientation-badge { min-height: 28px; padding: 5px 7px; font-size: 9px; }
      .bottom-bar {
        display: flex !important;
        min-width: 0;
        gap: 5px;
        padding: 5px max(7px, env(safe-area-inset-right)) max(5px, var(--rand-unten,0px)) max(7px, env(safe-area-inset-left));
        overflow-x: auto !important;
        overflow-y: hidden !important;
      }
      .bottom-bar .tool-btn {
        min-width: 57px;
        min-height: 49px;
        padding: 3px 2px;
        gap: 2px;
        border-radius: 12px;
        font-size: 9px;
      }
      .bottom-bar .tool-btn .ico {
        width: 30px;
        height: 30px;
        border-radius: 9px;
      }
      .bottom-bar .tool-btn .ico .ui-icon { width: 20px; height: 20px; }
      .bottom-color {
        min-width: 57px;
        min-height: 49px;
        border-radius: 12px;
      }
      .bottom-color .color-orb { width: 30px; height: 30px; }
      .contour-glow-quick { min-width: 67px !important; }
    }



    /* Startfokus: freie Zeichenflächen aus /templates/leer/ */
    .empty-state {
      max-height: calc(100% - 24px);
      overflow-y: auto;
      scrollbar-width: thin;
      overscroll-behavior: contain;
    }
    .start-blank-accordion {
      width: 100%;
      max-width: 430px;
      margin: 0 auto 12px;
      border: 1px solid rgba(71, 91, 230, .16);
      border-radius: 19px;
      overflow: hidden;
      background: rgba(247, 250, 255, .94);
      box-shadow: 0 10px 28px rgba(37, 51, 78, .07), inset 0 1px 0 rgba(255,255,255,.96);
      text-align: left;
    }
    .start-blank-head {
      width: 100%;
      min-height: 66px;
      display: grid;
      grid-template-columns: 42px minmax(0, 1fr) 28px;
      align-items: center;
      gap: 10px;
      padding: 10px 12px;
      border: 0;
      background: linear-gradient(135deg, rgba(124,92,255,.08), rgba(39,217,255,.07));
      color: var(--text);
      cursor: pointer;
      text-align: left;
    }
    .start-blank-head-icon {
      width: 42px;
      height: 42px;
      display: grid;
      place-items: center;
      border-radius: 14px;
      color: #fff;
      background: linear-gradient(135deg, #7657f3, #2f8cff);
      box-shadow: 0 8px 18px rgba(75,91,255,.22);
    }
    .start-blank-head-icon .ui-icon { width: 23px; height: 23px; }
    .start-blank-head-copy { min-width: 0; display: grid; gap: 3px; }
    .start-blank-head-copy strong { font-size: 15px; line-height: 1.15; }
    .start-blank-head-copy small { color: var(--muted); font-size: 11px; line-height: 1.25; }
    .start-blank-chevron {
      font-size: 24px;
      line-height: 1;
      text-align: center;
      color: #52617a;
      transform: rotate(0deg);
      transition: transform .18s ease;
    }
    .start-blank-accordion:not(.open) .start-blank-chevron { transform: rotate(-90deg); }
    .start-blank-panel {
      display: block;
      padding: 10px;
      border-top: 1px solid rgba(23,36,61,.08);
    }
    .start-blank-accordion:not(.open) .start-blank-panel { display: none; }
    .start-blank-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
      max-height: min(250px, 31dvh);
      overflow-y: auto;
      overscroll-behavior: contain;
      scrollbar-width: thin;
      padding: 1px;
    }
    .start-blank-card {
      min-width: 0;
      padding: 7px;
      border: 1px solid rgba(23,36,61,.10);
      border-radius: 14px;
      background: #fff;
      color: var(--text);
      cursor: pointer;
      text-align: left;
      box-shadow: 0 6px 16px rgba(24,44,79,.05);
      transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
    }
    .start-blank-card:hover {
      transform: translateY(-1px);
      border-color: rgba(124,92,255,.36);
      box-shadow: 0 9px 20px rgba(24,44,79,.09);
    }
    .start-blank-thumb {
      position: relative;
      height: 82px;
      display: grid;
      place-items: center;
      overflow: hidden;
      border-radius: 10px;
      background:
        linear-gradient(45deg, rgba(31,50,79,.035) 25%, transparent 25%, transparent 75%, rgba(31,50,79,.035) 75%),
        linear-gradient(45deg, rgba(31,50,79,.035) 25%, transparent 25%, transparent 75%, rgba(31,50,79,.035) 75%),
        #edf2f8;
      background-size: 18px 18px;
      background-position: 0 0, 9px 9px;
      box-shadow: inset 0 0 0 1px rgba(23,36,61,.05);
    }
    .start-blank-paper {
      display: grid;
      place-items: center;
      overflow: hidden;
      background: #fff;
      box-shadow: 0 5px 13px rgba(24,44,79,.13), 0 0 0 1px rgba(23,36,61,.06);
    }
    .start-blank-paper.portrait { height: 72px; aspect-ratio: 210 / 297; }
    .start-blank-paper.landscape { width: 90%; aspect-ratio: 297 / 210; }
    .start-blank-paper.square { height: 68px; aspect-ratio: 1; }
    .start-blank-paper img { width: 100%; height: 100%; object-fit: contain; display: block; }
    .start-blank-info { display: grid; gap: 2px; padding: 7px 2px 1px; min-width: 0; }
    .start-blank-info strong {
      font-size: 12px;
      line-height: 1.2;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .start-blank-info small {
      color: var(--muted);
      font-size: 10px;
      line-height: 1.2;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .start-blank-loading,
    .start-blank-empty {
      grid-column: 1 / -1;
      padding: 14px 10px;
      border-radius: 12px;
      background: rgba(255,255,255,.72);
      color: var(--muted);
      font-size: 12px;
      text-align: center;
    }
    .start-main-actions { margin-top: 0; }

    @media (max-width: 700px) {
      .empty-state {
        max-height: calc(100% - 12px);
        overflow-y: auto;
      }
      .start-blank-accordion { margin-bottom: 10px; border-radius: 17px; }
      .start-blank-head { min-height: 58px; grid-template-columns: 38px minmax(0,1fr) 24px; padding: 8px 10px; gap: 8px; }
      .start-blank-head-icon { width: 38px; height: 38px; border-radius: 12px; }
      .start-blank-head-copy strong { font-size: 14px; }
      .start-blank-head-copy small { font-size: 10px; }
      .start-blank-panel { padding: 8px; }
      .start-blank-grid { max-height: min(220px, 30dvh); gap: 7px; }
      .start-blank-card { padding: 6px; border-radius: 12px; }
      .start-blank-thumb { height: 70px; border-radius: 9px; }
      .start-blank-paper.portrait { height: 61px; }
      .start-blank-paper.square { height: 58px; }
      .start-blank-info { padding-top: 6px; }
      .start-blank-info strong { font-size: 11px; }
      .start-blank-info small { font-size: 9px; }
    }



    /* Startansicht: drei klare Einstiege, Vorlagen erst nach Auswahl anzeigen */
    .empty-state {
      max-height: none;
      overflow: visible;
    }
    .start-choice-actions {
      width: min(100%, 430px);
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 9px;
    }
    .start-choice-btn {
      min-width: 0;
      min-height: 58px;
      padding: 8px 10px;
      flex-direction: column;
      line-height: 1.1;
    }
    .start-choice-btn .ui-icon { width: 23px; height: 23px; }
    #emptyFreeBtn {
      box-shadow: 0 11px 26px rgba(83,92,255,.22) !important;
    }
    #templatesModal[data-template-mode="blank"] #templateFilters {
      display: none;
    }
    #templatesModal[data-template-mode="blank"] .template-toolbar {
      margin-bottom: 10px;
    }
    #templatesModal[data-template-mode="blank"] #templateToolbarTitle {
      font-size: 13px;
      text-transform: none;
      letter-spacing: 0;
    }
    @media (max-width: 700px) {
      .start-choice-actions {
        grid-template-columns: 1fr;
        gap: 8px;
      }
      .start-choice-btn {
        min-height: 50px;
        flex-direction: row;
      }
    }
    @media (orientation: landscape) and (min-width: 701px) and (max-height: 700px) and (max-width: 980px) {
      .start-choice-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }
      .start-choice-btn {
        min-height: 40px;
        flex-direction: row;
      }
    }

  

    /* Einheitliche Vorlagenwahl: suchen, online ausmalen oder direkt als PDF laden */
    .template-mode-switch {
      display: grid;
      grid-template-columns: repeat(3, minmax(0,1fr));
      gap: 8px;
      margin-bottom: 12px;
    }
    .template-mode-btn {
      min-width: 0;
      min-height: 50px;
      padding: 8px 10px;
      border: 1px solid var(--line);
      border-radius: 15px;
      background: #fff;
      color: var(--muted-strong, #40516b);
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      font: inherit;
      font-weight: 850;
      cursor: pointer;
      box-shadow: 0 7px 18px rgba(24,44,79,.06);
    }
    .template-mode-btn.active {
      color: #fff;
      border-color: transparent;
      background: linear-gradient(135deg,#7657f3,#3578ed);
      box-shadow: 0 10px 24px rgba(76,91,238,.22);
    }
    .template-mode-btn .ui-icon { width: 20px; height: 20px; }
    .template-search-wrap { margin-bottom: 12px; }
    .template-search {
      width: 100%;
      min-height: 48px;
      padding: 0 15px;
      border: 1px solid #d6deea;
      border-radius: 15px;
      outline: 0;
      background: #fff;
      color: #182840;
      font: inherit;
      box-shadow: inset 0 1px 2px rgba(24,44,79,.04);
    }
    .template-search:focus { border-color: #6f65ef; box-shadow: 0 0 0 3px rgba(111,101,239,.13); }
    #templatesModal[data-template-mode="blank"] #templateSearchWrap { display:none; }

    .template-card {
      display: flex;
      flex-direction: column;
      padding: 9px;
      cursor: default;
    }
    .template-card-main {
      appearance: none;
      width: 100%;
      min-width: 0;
      padding: 0;
      border: 0;
      background: transparent;
      color: inherit;
      text-align: left;
      cursor: pointer;
      font: inherit;
    }
    .template-card-main:active { transform: none; }
    .template-card-actions {
      display: grid;
      grid-template-columns: minmax(0,1fr) 46px;
      gap: 7px;
      margin-top: auto;
      padding: 2px 3px 3px;
    }
    .template-use-btn, .template-download-btn {
      min-width: 0;
      min-height: 44px;
      border-radius: 13px;
      border: 1px solid #d7dfeb;
      font: inherit;
      font-weight: 850;
      cursor: pointer;
    }
    .template-use-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      padding: 0 10px;
      color: #fff;
      background: linear-gradient(135deg,#7657f3,#356fe8);
      border-color: transparent;
    }
    .template-download-btn {
      display: grid;
      place-items: center;
      padding: 0;
      color: #283b59;
      background: #f4f7fb;
    }
    .template-download-btn .ui-icon, .template-use-btn .ui-icon { width: 19px; height: 19px; }



    @media (max-width:700px) {
      .template-mode-switch { position:sticky; top:-10px; z-index:5; padding:4px 0 7px; background:rgba(255,255,255,.96); }
      .template-mode-btn { min-height:44px; padding:6px; font-size:12px; }
      .template-mode-btn .ui-icon { width:18px; height:18px; }
      .template-search { min-height:44px; }
      .template-card-actions { grid-template-columns:minmax(0,1fr) 42px; }
      .template-use-btn, .template-download-btn { min-height:42px; }
    }

    /* Einheitliche Vorlagenwahl: eine Ansicht, Kategorien als Sprungnavigation */
    #templatesModal .template-mode-switch { display: none !important; }
    #templatesModal .template-toolbar {
      position: sticky;
      top: -18px;
      z-index: 12;
      margin: 0 -18px 16px;
      padding: 12px 18px 10px;
      background: rgba(255,255,255,.985);
      border-bottom: 1px solid var(--line);
      box-shadow: 0 10px 24px rgba(24,44,79,.08);
      backdrop-filter: blur(16px);
    }
    #templatesModal .template-filters {
      flex-wrap: nowrap;
      overflow-x: auto;
      padding: 2px 2px 6px;
      scrollbar-width: thin;
      scroll-behavior: smooth;
    }
    #templatesModal .template-filter { flex: 0 0 auto; }
    #templatesModal .template-grid { display: block !important; }
    .template-category-section {
      scroll-margin-top: 118px;
      margin: 0 0 24px;
      padding-top: 2px;
    }
    .template-category-section:last-child { margin-bottom: 4px; }
    .template-section-head {
      position: sticky;
      top: 78px;
      z-index: 3;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin: 0 0 10px;
      padding: 10px 2px 9px;
      background: rgba(255,255,255,.96);
      backdrop-filter: blur(10px);
      border-bottom: 1px solid var(--line);
    }
    .template-section-head h3 { margin: 0; color: var(--text); font-size: 17px; }
    .template-section-head span { color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap; }
    .template-section-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
      gap: 14px;
    }
    .template-card-actions { grid-template-columns: minmax(0,1fr) minmax(82px,.52fr) !important; }
    .template-download-btn {
      display: inline-flex !important;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 0 10px !important;
      color: #283b59;
      background: #f4f7fb;
    }
    .template-download-btn span { font-weight: 900; }
    @media (max-width: 700px) {
      #templatesModal .template-toolbar {
        top: -10px;
        margin: 0 -10px 12px;
        padding: 9px 10px 8px;
      }
      .template-category-section { scroll-margin-top: 102px; margin-bottom: 19px; }
      .template-section-head { top: 66px; padding: 8px 1px 7px; }
      .template-section-head h3 { font-size: 15px; }
      .template-section-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
      .template-card-actions { grid-template-columns: minmax(0,1fr) 72px !important; }
      .template-download-btn { padding: 0 8px !important; }
    }
    @media (max-width: 410px) {
      .template-section-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
      .template-use-btn span { font-size: 11px; }
      .template-card-actions { grid-template-columns: minmax(0,1fr) 64px !important; gap: 5px; }
    }

    @media (max-width: 700px) {
      #exportModal .modal.compact {
        width: 100% !important;
        max-height: 94dvh !important;
        border-radius: 22px 22px 0 0 !important;
        overflow: hidden !important;
      }
      #exportModal .modal-body {
        padding: 8px 10px 10px !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
      }
      #exportModal .export-preview {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        min-width: 0 !important;
      }
      #exportModal .page-preview {
        width: min(100%, 180px) !important;
        margin: 0 auto !important;
      }
      #exportModal .export-info {
        display: block !important;
        min-width: 0 !important;
        text-align: left !important;
      }
      #exportModal .export-stats {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 6px !important;
        margin: 10px 0 !important;
        min-width: 0 !important;
      }
      #exportModal .stat {
        display: flex !important;
        justify-content: space-between !important;
        gap: 8px !important;
        min-width: 0 !important;
        padding: 8px 10px !important;
      }
      #exportModal .stat span,
      #exportModal .stat strong {
        min-width: 0 !important;
        overflow-wrap: anywhere !important;
      }
      #exportModal .stat strong {
        text-align: right !important;
      }
      #exportModal .export-format-choice {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 8px !important;
        margin-top: 10px !important;
      }
      #exportModal .export-format-btn,
      #exportModal .export-format-btn.holo-choice {
        grid-column: auto !important;
        min-width: 0 !important;
        min-height: 70px !important;
        padding: 10px 12px !important;
      }
      #exportModal .modal-foot {
        flex-wrap: wrap !important;
      }
      #exportModal .modal-foot .btn {
        flex: 1 1 140px !important;
      }
    }
