﻿/* =========================
       Fonts: TheSans (Local)
       ========================= */
    @font-face{
      font-family: "TheSansBold";
      src:
        url("../fonts/TheSans-Bold.otf") format("opentype"),
        url("../fonts/TheSans-Bold-alinma.ttf") format("truetype");
      font-weight: 900;
      font-style: normal;
      font-display: swap;
    }

    @font-face{
      font-family: "TheSansPlain";
      src:
        url("../fonts/TheSans-Plain.otf") format("opentype"),
        url("../fonts/The-Sans-Plain-alinma.ttf") format("truetype");
      font-weight: 400;
      font-style: normal;
      font-display: swap;
    }

    @font-face{
      font-family: "TheSansArabicBold";
      src: url("../fonts/THESANSARABIC-BOLD.ttf") format("truetype");
      font-weight: 700;
      font-style: normal;
      font-display: swap;
    }

    @font-face{
      font-family: "TheSansArabicLight";
      src:
        url("../fonts/THESANSARABIC-LIGHT.ttf") format("truetype"),
        url("../fonts/TheSansArabic-Light.otf") format("opentype");
      font-weight: 300;
      font-style: normal;
      font-display: swap;
    }

    @font-face{
      font-family: "TheSansArabicExtraLight";
      src: url("../fonts/TheSansArabic-ExtraLight.otf") format("opentype");
      font-weight: 200;
      font-style: normal;
      font-display: swap;
    }

    :root{
      --bg: #f6f8fb;
      --card: #ffffff;
      --text: #0f172a;
      --muted: #64748b;
      --border: #e5e7eb;
      --shadow: 0 12px 30px rgba(2,6,23,.08);
      --radius: 18px;
      --radius-sm: 14px;
      --header-h: 60px;
      --mobile-bar-height: 64px;
      --preview-max-h: 720px;
      --preview-gap: 16px;

      --primary: #1d4ed8;
      --primarySoft: rgba(29,78,216,.10);
      --primary-300: #93c5fd;

      --danger: #dc2626;
      --dangerSoft: rgba(220,38,38,.10);

      --success: #16a34a;
      --successSoft: rgba(22,163,74,.10);

      --warning: #f59e0b;
      --warningSoft: rgba(245,158,11,.10);

      --focus: rgba(29,78,216,.20);

      --selectArrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
      
      --safe-area-top: env(safe-area-inset-top, 0px);
      --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    }

    *{box-sizing:border-box}
    html,body{height:100%}

    body{
      margin:0;
      font-family: "TheSansBold", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
      color: var(--text);
      background: var(--bg);
      padding: var(--safe-area-top) 0 var(--safe-area-bottom);
      position: relative;
      overflow-x: hidden;
    }

    /* =========================
       Header
       ========================= */
    header{
      padding: 16px 12px;
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      grid-template-areas: "brand actions";
      align-items: center;
      column-gap: 12px;
      row-gap: 10px;
      position: sticky;
      top: 0;
      z-index: 100;
      background: rgba(255,255,255,0.95);
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      border-bottom: 1px solid var(--border);
    }

    .brand{
      grid-area: brand;
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
    }

    .brandLogo-wrap{
      width: 66px;
      height: 66px;
      border-radius: 12px;
      padding: 9px;
      border: 1px solid var(--border);
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
    }

    .brandLogo{
      width: 100%;
      height: 100%;
      object-fit: contain;
      display: block;
    }

    .platform-name{
      display: block;
      font-size: clamp(10px, 1.6vw, 11px);
      color: var(--muted);
      font-weight: 900;
      letter-spacing: .2px;
      margin-bottom: 2px;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }

    .title{
      min-width: 0;
    }

    .title h1{
      margin:0;
      font-size: clamp(14px, 2.2vw, 16px);
      font-weight:900;
      letter-spacing: .1px;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }
    .title p{
      margin: 2px 0 0;
      color: var(--muted);
      font-size: clamp(10px, 1.6vw, 11px);
      font-weight:800;
      line-height: 1.4;
      display: none;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }

    .header-actions{
      grid-area: actions;
      display: flex;
      gap: 8px;
      align-items: center;
      justify-content: flex-end;
      flex-wrap: wrap;
    }

    .icon-btn{
      width: 40px;
      height: 40px;
      border-radius: 12px;
      border: 1px solid var(--border);
      background: var(--card);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: all 0.2s;
    }

    .icon-btn:hover{
      transform: translateY(-1px);
      box-shadow: 0 6px 12px rgba(2,6,23,.08);
    }

    .icon-btn svg{
      width: 20px;
      height: 20px;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    /* =========================
       Main Layout - Mobile First
       ========================= */
    main{
      display: flex;
      flex-direction: column;
      height: calc(100vh - var(--header-h) - var(--safe-area-bottom));
      height: calc(100svh - var(--header-h) - var(--safe-area-bottom));
    }

    .preview-section{
      flex: 1;
      min-height: calc(var(--preview-max-h) + var(--preview-gap) + var(--preview-pad) + var(--preview-pad));
      position: relative;
      --preview-pad: clamp(12px, 2.4vw, 18px);
      padding: var(--preview-pad);
      padding-bottom: calc(var(--preview-pad) + var(--preview-gap));
      display: grid;
      place-items: center;
      align-content: center;
      gap: var(--preview-gap);
      background:
        radial-gradient(circle at 20% 20%, rgba(59,130,246,0.08), transparent 55%),
        radial-gradient(circle at 80% 0%, rgba(20,184,166,0.08), transparent 50%);
    }

    .preview-frame{
      width: min(100%, 1440px);
      display: grid;
      place-items: center;
      padding: clamp(6px, 1.4vw, 14px);
      border-radius: calc(var(--radius) + 6px);
      background: linear-gradient(135deg, rgba(255,255,255,0.85), rgba(248,250,252,0.75));
      border: 1px solid rgba(148,163,184,0.35);
      box-shadow: 0 18px 36px rgba(15,23,42,0.12);
    }

    .controls-section{
      flex-shrink: 0;
      background: var(--card);
      border-top: 1px solid var(--border);
      max-height: 60vh;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }

    @media (min-width: 1024px){
      main{
        flex-direction: row;
        height: calc(100vh - var(--header-h));
      }
      
      .preview-section{
        flex: 1;
        order: 2;
      }
      
      .controls-section{
        flex: 0 0 450px;
        order: 1;
        border-right: 1px solid var(--border);
        border-top: none;
        max-height: none;
      }
      
      .title p{
        display: block;
      }
    }

    @media (max-width: 720px){
      :root{
        --header-h: 0px;
      }

      header{
        display: none;
      }

      .preview-section{
        overflow-y: auto;
        padding: 10px 10px calc(18px + var(--preview-gap));
        align-content: flex-start;
        -webkit-overflow-scrolling: touch;
        scroll-padding-bottom: calc(var(--mobile-bar-height) + 16px);
      }

      .canvas-container{
        max-height: var(--preview-max-h);
      }
    }

    @media (max-width: 1023px){
      main{
        height: calc(100vh - var(--header-h) - var(--safe-area-bottom) - var(--mobile-bar-height));
        height: calc(100svh - var(--header-h) - var(--safe-area-bottom) - var(--mobile-bar-height));
      }

      .preview-section{
        align-content: flex-start;
      }

      .preview-frame{
        width: 100%;
      }
    }

    @media (max-width: 640px){
      header{
        padding: 12px 10px;
        gap: 10px;
      }

      .brandLogo-wrap{
        width: 48px;
        height: 48px;
        padding: 6px;
      }

      .icon-btn{
        width: 36px;
        height: 36px;
      }

      .header-actions{
        gap: 6px;
      }

      .preset-btn.task-btn{
        padding: 12px 10px;
        font-size: 12px;
      }
    }

    @media (max-width: 420px){
      .header-actions{
        width: 100%;
        justify-content: space-between;
      }
    }

    /* =========================
       Canvas Container
       ========================= */
    .canvas-container{
      width: 100%;
      height: auto;
      aspect-ratio: 16 / 9;
      max-width: min(100%, calc(var(--preview-max-h) * 16 / 9));
      max-height: var(--preview-max-h);
      background: #f1f5f9;
      border-radius: calc(var(--radius) - 2px);
      overflow: hidden;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      touch-action: none;
      border: 1px solid var(--border);
      box-shadow: 0 14px 32px rgba(15,23,42,0.12);
    }

    .canvas-container.fullscreen{
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      z-index: 9999;
      border-radius: 0;
      border: none;
      aspect-ratio: auto;
      max-width: none;
      max-height: none;
      background: #0b1120;
    }

    @media (max-width: 640px){
      .preview-frame{
        padding: 6px;
        border-radius: 16px;
      }

      .canvas-container{
        border-radius: 14px;
      }
    }

    .canvas-container.fullscreen .canvas-stage{
      width: min(100vw, calc(100vh * 16 / 9));
      height: min(100vh, calc(100vw * 9 / 16));
    }

    .canvas-stage{
      position: relative;
      width: 100%;
      height: 100%;
      max-width: 100%;
      max-height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    canvas{
      display: block;
      width: 100%;
      height: 100%;
      cursor: grab;
      touch-action: none;
    }

    canvas.dragging{
      cursor: grabbing;
    }

    .canvas-overlay{
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      pointer-events: none;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(241, 245, 249, 0.9);
    }

    .canvas-placeholder{
      text-align: center;
      padding: 20px;
    }

    .canvas-placeholder h3{
      margin: 0 0 8px;
      font-size: 18px;
      color: var(--text);
    }

    .canvas-placeholder p{
      margin: 0;
      font-size: 14px;
      color: var(--muted);
    }

    /* =========================
       Bottom Action Bar (Mobile)
       ========================= */
    .bottom-bar{
      position: fixed;
      bottom: calc(var(--safe-area-bottom) + 8px);
      left: 10px;
      right: 10px;
      margin: 0 auto;
      max-width: 420px;
      background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(245,247,250,0.86));
      backdrop-filter: blur(18px) saturate(1.15);
      -webkit-backdrop-filter: blur(18px) saturate(1.15);
      border: 1px solid rgba(148,163,184,0.32);
      padding: 6px;
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 6px;
      z-index: 90;
      border-radius: 18px;
      box-shadow: 0 12px 26px rgba(15,23,42,0.16);
      overflow: hidden;
      isolation: isolate;
    }

    .bottom-bar::before{
      content: "";
      position: absolute;
      inset: 0;
      border-radius: inherit;
      background: linear-gradient(135deg, rgba(30,58,138,0.07), rgba(15,118,110,0.06));
      opacity: 0.9;
      pointer-events: none;
      z-index: 0;
    }

    @media (min-width: 1024px){
      .bottom-bar{
        display: none;
      }
    }

    .bottom-btn{
      position: relative;
      z-index: 1;
      padding: 6px;
      border-radius: 14px;
      border: 1px solid rgba(148,163,184,0.4);
      background: rgba(255,255,255,0.92);
      color: var(--text);
      font-weight: 900;
      font-size: 10px;
      line-height: 1.1;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      gap: 0;
      cursor: pointer;
      transition: transform 0.2s, box-shadow 0.2s;
      min-height: 48px;
      box-shadow:
        0 6px 12px rgba(15,23,42,0.12),
        inset 0 1px 0 rgba(255,255,255,0.8);
    }

    .bottom-btn .bottom-icon{
      width: 34px;
      height: 34px;
      border-radius: 12px;
      display: grid;
      place-items: center;
      background: rgba(255,255,255,0.7);
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.7),
        0 6px 12px rgba(15,23,42,0.18);
      transition: transform 0.2s, box-shadow 0.2s;
    }

    .bottom-btn .bottom-icon svg{
      width: 18px;
      height: 18px;
      stroke: currentColor;
      stroke-width: 2.2;
    }

    .bottom-btn.primary{
      background: linear-gradient(135deg, #1f2a44, #223a6b);
      color: #f8fafc;
      border-color: #1f2a44;
    }

    .bottom-btn.success{
      background: linear-gradient(135deg, #0f3d3e, #0f766e);
      color: #f8fafc;
      border-color: #0f3d3e;
    }

    .bottom-btn.warning{
      background: linear-gradient(135deg, #5f3a12, #a16207);
      color: #fff7ed;
      border-color: #5f3a12;
    }

    .bottom-btn.share{
      background: linear-gradient(135deg, #e5e7eb, #f8fafc);
      color: #111827;
      border-color: #cbd5e1;
    }

    .bottom-btn.primary .bottom-icon,
    .bottom-btn.success .bottom-icon,
    .bottom-btn.warning .bottom-icon{
      background: rgba(255,255,255,0.2);
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.4),
        0 8px 16px rgba(15,23,42,0.2);
    }

    .bottom-btn.share .bottom-icon{
      background: rgba(255,255,255,0.85);
    }

    .bottom-btn:active{
      transform: scale(0.97);
      box-shadow: 0 4px 10px rgba(15,23,42,0.14);
    }

    .bottom-btn:active .bottom-icon{
      transform: scale(0.92);
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.7),
        0 4px 10px rgba(15,23,42,0.2);
    }

    @media (hover: hover){
      .bottom-btn:hover{
        transform: translateY(-1px);
        box-shadow: 0 10px 18px rgba(15,23,42,0.16);
      }

      .bottom-btn:hover .bottom-icon{
        transform: translateY(-1px);
        box-shadow:
          inset 0 1px 0 rgba(255,255,255,0.7),
          0 10px 18px rgba(15,23,42,0.22);
      }
    }

    @media (max-width: 420px){
      .bottom-bar{
        left: 8px;
        right: 8px;
        padding: 5px;
        gap: 5px;
      }

      .bottom-btn{
        min-height: 44px;
        font-size: 9.5px;
      }

      .bottom-btn .bottom-icon{
        width: 30px;
        height: 30px;
        border-radius: 10px;
      }
    }

    .bottom-tools-backdrop{
      position: fixed;
      inset: 0;
      background: rgba(15,23,42,0.08);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s;
      z-index: 88;
    }

    .bottom-tools-backdrop.show{
      opacity: 1;
      pointer-events: auto;
    }

    .bottom-tools{
      position: fixed;
      left: 50%;
      bottom: calc(var(--safe-area-bottom) + 70px);
      transform: translate(-50%, 10px) scale(0.98);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s, transform 0.2s;
      background: rgba(255,255,255,0.98);
      border: 1px solid rgba(148,163,184,0.35);
      box-shadow: 0 18px 36px rgba(15,23,42,0.2);
      border-radius: 16px;
      padding: 8px;
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
      width: min(360px, calc(100vw - 32px));
      z-index: 89;
    }

    .bottom-tools.show{
      opacity: 1;
      pointer-events: auto;
      transform: translate(-50%, 0) scale(1);
    }

    .tool-btn{
      border: 1px solid rgba(148,163,184,0.4);
      background: linear-gradient(135deg, #f1f5f9, #ffffff);
      color: #111827;
      border-radius: 12px;
      padding: 10px 8px;
      font-size: 12px;
      font-weight: 900;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      cursor: pointer;
      transition: transform 0.2s, box-shadow 0.2s;
      box-shadow: 0 10px 20px rgba(15,23,42,0.12);
    }

    .tool-btn svg{
      width: 18px;
      height: 18px;
      stroke: currentColor;
      stroke-width: 2;
    }

    .tool-btn:active{
      transform: scale(0.98);
      box-shadow: 0 6px 12px rgba(15,23,42,0.12);
    }

    /* =========================
       Controls Panel
       ========================= */
    .panel{
      padding: 16px;
    }

    .panel + .panel{
      border-top: 1px solid var(--border);
    }

    .panel-header{
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 16px;
    }

    .panel-header h2{
      margin: 0;
      font-size: 16px;
      font-weight: 900;
    }

    .accordion-btn{
      background: none;
      border: none;
      width: 32px;
      height: 32px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      color: var(--muted);
    }

    .accordion-btn svg{
      width: 20px;
      height: 20px;
      stroke: currentColor;
      transition: transform 0.3s;
    }

    .accordion-btn.rotated svg{
      transform: rotate(180deg);
    }

    .accordion-content{
      overflow: hidden;
      transition: max-height 0.3s ease;
    }

    .accordion-content.collapsed{
      max-height: 0 !important;
    }

    /* =========================
       Form Elements
       ========================= */
    .form-group{
      margin-bottom: 16px;
    }

    .form-group label{
      display: block;
      font-size: 12px;
      color: var(--muted);
      margin-bottom: 6px;
      font-weight: 900;
    }

    input[type="text"], textarea, select{
      width: 100%;
      padding: 12px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: var(--card);
      color: var(--text);
      font-size: 14px;
      font-weight: 800;
      transition: all 0.2s;
    }

    textarea{
      min-height: 80px;
      resize: vertical;
      line-height: 1.6;
    }

    select{
      appearance: none;
      background-image: var(--selectArrow);
      background-repeat: no-repeat;
      background-position: left 12px center;
      background-size: 18px 18px;
      padding-left: 40px;
    }

    .range-group{
      display: flex;
      align-items: center;
      gap: 12px;
    }

    input[type="range"]{
      flex: 1;
      height: 6px;
      border-radius: 3px;
      background: var(--border);
      outline: none;
      -webkit-appearance: none;
    }

    input[type="range"]::-webkit-slider-thumb{
      -webkit-appearance: none;
      width: 20px;
      height: 20px;
      border-radius: 50%;
      background: var(--primary);
      cursor: pointer;
      border: 2px solid white;
      box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    }

    .range-value{
      min-width: 40px;
      text-align: center;
      font-size: 12px;
      font-weight: 900;
      color: var(--text);
    }

    .toggle-row{
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 10px 12px;
      border-radius: var(--radius-sm);
      background: #f8fafc;
      border: 1px solid var(--border);
      font-size: 12px;
      font-weight: 900;
      color: var(--text);
      cursor: pointer;
    }

    .toggle-row input{
      width: 18px;
      height: 18px;
      accent-color: var(--primary);
      cursor: pointer;
    }

    button:disabled,
    .preset-btn:disabled,
    .bottom-btn:disabled,
    .icon-btn:disabled{
      opacity: 0.5;
      cursor: not-allowed;
      transform: none;
      box-shadow: none;
    }

    input[type="range"]:disabled,
    select:disabled,
    textarea:disabled{
      opacity: 0.6;
      cursor: not-allowed;
    }

    .inline-note{
      font-size: 11px;
      color: var(--muted);
    }

    /* =========================
       Preset Buttons
       ========================= */
    .presets-grid{
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 8px;
      margin-top: 8px;
    }

    .preset-btn{
      padding: 10px 8px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: var(--card);
      color: var(--text);
      font-size: 12px;
      font-weight: 900;
      cursor: pointer;
      transition: all 0.2s;
      text-align: center;
    }

    .preset-btn:hover{
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }

    .preset-btn.primary{
      background: linear-gradient(135deg, #1d4ed8, #2563eb);
      color: #fff;
      border-color: #1d4ed8;
    }

    .task-btn{
      position: relative;
      overflow: hidden;
      border: 1px solid rgba(15,23,42,0.12);
      box-shadow: 0 10px 22px rgba(15,23,42,0.12);
      letter-spacing: .2px;
    }

    .task-btn::after{
      content: "";
      position: absolute;
      inset: 0;
      background: linear-gradient(120deg, rgba(255,255,255,0.32), rgba(255,255,255,0));
      opacity: 0;
      transition: opacity 0.2s;
      pointer-events: none;
    }

    .task-btn:hover{
      transform: translateY(-1px);
      box-shadow: 0 14px 30px rgba(15,23,42,0.18);
    }

    .task-btn:hover::after{
      opacity: 1;
    }

    .task-btn:active{
      transform: translateY(0);
      box-shadow: 0 8px 18px rgba(15,23,42,0.12);
    }

    .preset-btn.task-btn{
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 12px 14px;
      font-size: 13px;
    }

    .bottom-btn.task-btn{
      gap: 3px;
    }

    .task-btn.share{
      background: linear-gradient(135deg, #e2e8f0, #f8fafc);
      color: #0f172a;
      border-color: #cbd5e1;
    }

    .preset-btn.urgent{
      background: #fee2e2;
      border-color: #fca5a5;
      color: #dc2626;
    }

    .preset-btn.clean{
      background: #dbeafe;
      border-color: #93c5fd;
      color: #1d4ed8;
    }

    .preset-btn.strong{
      background: #fef3c7;
      border-color: #fcd34d;
      color: #d97706;
    }

    .preset-btn.calm{
      background: #dcfce7;
      border-color: #86efac;
      color: #16a34a;
    }

    .preset-btn.warning{
      background: #fef3c7;
      border-color: #fcd34d;
      color: #b45309;
    }

    /* =========================
       Template Grid
       ========================= */
    .templates-grid{
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
      gap: 8px;
      margin-top: 12px;
    }

    .template-item{
      position: relative;
      border: 2px solid transparent;
      border-radius: var(--radius-sm);
      overflow: hidden;
      cursor: pointer;
      transition: all 0.2s;
      background: var(--card);
    }

    .template-item.active{
      border-color: var(--primary);
      box-shadow: 0 0 0 3px var(--primarySoft);
    }

    .template-item img{
      width: 100%;
      height: 60px;
      object-fit: cover;
      display: block;
    }

    .template-item span{
      display: block;
      padding: 6px 4px;
      font-size: 10px;
      text-align: center;
      font-weight: 900;
      color: var(--muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .template-remove-btn{
      position: absolute;
      top: 6px;
      left: 6px;
      width: 22px;
      height: 22px;
      border-radius: 999px;
      border: 1px solid rgba(220,38,38,0.35);
      background: rgba(255,255,255,0.92);
      color: #dc2626;
      font-size: 16px;
      line-height: 1;
      font-weight: 900;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 2;
      transition: transform 0.2s, background 0.2s;
    }

    .template-remove-btn:hover{
      transform: scale(1.06);
      background: #fee2e2;
    }

    .templates-empty{
      grid-column: 1 / -1;
      border: 1px dashed #cbd5e1;
      border-radius: var(--radius-sm);
      padding: 14px 10px;
      text-align: center;
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
      background: #f8fafc;
    }

    /* =========================
       Drop Area
       ========================= */
    .drop-area{
      border: 2px dashed #cbd5e1;
      border-radius: var(--radius);
      padding: 24px 16px;
      text-align: center;
      background: #f8fafc;
      transition: all 0.3s;
      margin-bottom: 16px;
    }

    .drop-area.drag-over{
      border-color: var(--primary);
      background: rgba(29, 78, 216, 0.05);
    }

    .drop-area h4{
      margin: 0 0 8px;
      font-size: 14px;
      color: var(--text);
    }

    .drop-area p{
      margin: 0 0 16px;
      font-size: 12px;
      color: var(--muted);
    }

    .file-input-btn{
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 10px 16px;
      border-radius: var(--radius-sm);
      background: var(--primary);
      color: white;
      font-size: 13px;
      font-weight: 900;
      cursor: pointer;
      border: none;
      transition: all 0.2s;
    }

    .file-input-btn:hover{
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(29, 78, 216, 0.3);
    }

    /* =========================
       Toast Notifications
       ========================= */
    .toast-container{
      position: fixed;
      top: 20px;
      right: 20px;
      z-index: 1000;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .toast{
      padding: 12px 16px;
      border-radius: var(--radius-sm);
      background: var(--card);
      border: 1px solid var(--border);
      box-shadow: var(--shadow);
      display: flex;
      align-items: center;
      gap: 8px;
      animation: slideIn 0.3s ease;
      max-width: 300px;
    }

    .toast.success{
      border-color: var(--success);
      background: var(--successSoft);
    }

    .toast.error{
      border-color: var(--danger);
      background: var(--dangerSoft);
    }

    .toast.info{
      border-color: var(--primary);
      background: var(--primarySoft);
    }

    @keyframes slideIn{
      from{
        transform: translateX(100%);
        opacity: 0;
      }
      to{
        transform: translateX(0);
        opacity: 1;
      }
    }

    /* =========================
       Touch Gesture Hints
       ========================= */
    .gesture-hints{
      position: absolute;
      bottom: 20px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(0,0,0,0.7);
      color: white;
      padding: 8px 12px;
      border-radius: var(--radius-sm);
      font-size: 11px;
      display: flex;
      gap: 12px;
      opacity: 0;
      transition: opacity 0.3s;
      pointer-events: none;
    }

    .gesture-hints.show{
      opacity: 1;
    }

    .gesture-hint{
      display: flex;
      align-items: center;
      gap: 4px;
    }

    /* =========================
       Fullscreen Controls
       ========================= */
    .fullscreen-controls{
      position: fixed;
      top: 20px;
      right: 20px;
      z-index: 10000;
      display: flex;
      gap: 8px;
      opacity: 0;
      transition: opacity 0.3s;
    }

    .fullscreen-controls.show{
      opacity: 1;
    }

    /* =========================
       Utility Classes
       ========================= */
    .hidden{
      display: none !important;
    }

    .grid-2{
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
    }

    .flex-center{
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .gap-1{ gap: 4px; }
    .gap-2{ gap: 8px; }
    .gap-3{ gap: 12px; }
    .gap-4{ gap: 16px; }

    .mb-1{ margin-bottom: 4px; }
    .mb-2{ margin-bottom: 8px; }
    .mb-3{ margin-bottom: 12px; }
    .mb-4{ margin-bottom: 16px; }

    /* =========================
       Loading Indicator
       ========================= */
    .loading{
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(255,255,255,0.9);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 100;
    }

    .loading::after{
      content: '';
      width: 40px;
      height: 40px;
      border: 3px solid var(--border);
      border-top-color: var(--primary);
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }

    @keyframes spin{
      to{ transform: rotate(360deg); }
    }

