 :root{
      --orange:#f47c20;
      --orange-dark:#d9600b;
      --orange-soft:#fff1e7;
      --ink:#1f2937;
      --muted:#6b7280;
      --line:#d8dde4;
      --panel:#ffffff;
      --page:#f4f6f8;
      --blueprint:#fbfcfd;
      --danger:#b42318;
      --shadow:0 12px 30px rgba(20, 30, 45, .09);
    }

    *{box-sizing:border-box}
    html,body{margin:0;min-height:100%;font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:var(--ink);background:var(--page)}
    button,input,textarea{font:inherit}

    .app{min-height:100vh;display:grid;grid-template-rows:auto 1fr}

    header{
      background:#111827;
      color:white;
      padding:16px 22px;
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:18px;
      position:sticky;
      top:0;
      z-index:50;
      box-shadow:0 6px 20px rgba(0,0,0,.18);
    }

    .brand{display:flex;align-items:center;gap:13px;min-width:0}
    .logo{
      width:52px;
      height:52px;
      overflow:visible;
      background:transparent;
      display:flex;
      align-items:center;
      justify-content:center;
      flex:0 0 auto;
      box-shadow:none;
    }

    .logo img{
      width:100%;
      height:100%;
      object-fit:contain;
      display:block;
      background:transparent;
    }
    .brand h1{font-size:1.15rem;margin:0}
    .brand p{font-size:.86rem;margin:4px 0 0;color:#cbd5e1}

    .header-actions{display:flex;gap:9px;flex-wrap:wrap;justify-content:flex-end}
    .btn{
      border:0;border-radius:11px;padding:10px 14px;font-weight:850;cursor:pointer;
      transition:transform .15s ease,background .15s ease
    }
    .btn:hover{transform:translateY(-1px)}
    .btn:disabled{
      opacity:.65;
      cursor:not-allowed;
      transform:none;
    }
.btn-light{background:white;color:#111827}
    .btn-dark{background:#273244;color:white}
    .btn-danger{background:#fee4e2;color:var(--danger)}

    main{
      display:grid;
      grid-template-columns:240px minmax(620px,1fr) 285px;
      gap:16px;
      padding:16px;
      min-height:0;
    }

    .panel{
      background:var(--panel);
      border:1px solid #e6e9ed;
      border-radius:18px;
      box-shadow:var(--shadow);
    }

    .sidebar{
      padding:17px;
      align-self:start;
      position:sticky;
      top:93px;
      max-height:calc(100vh - 110px);
      overflow:auto;
    }

    h2{font-size:1rem;margin:0 0 6px}
    .help{font-size:.87rem;line-height:1.45;color:var(--muted);margin:0 0 15px}

    .how-to-btn{
      width:100%;
      border:0;
      background:var(--orange);
      color:white;
      border-radius:12px;
      padding:10px 12px;
      font-weight:800;
      font-size:.9rem;
      line-height:1.2;
      cursor:pointer;
      margin-bottom:14px;
      transition:.16s ease;
      box-shadow:0 5px 14px rgba(244,124,32,.24);
      text-align:center;
      white-space:nowrap;
    }

    .how-to-btn:hover{
      background:var(--orange-dark);
      transform:translateY(-1px);
      box-shadow:0 7px 18px rgba(244,124,32,.3);
    }

    .modal-backdrop{
      position:fixed;
      inset:0;
      background:rgba(17,24,39,.68);
      display:none;
      align-items:center;
      justify-content:center;
      padding:24px;
      z-index:200;
    }

    .modal-backdrop.open{display:flex}

    .how-to-modal{
      width:min(520px,100%);
      background:white;
      border-radius:18px;
      box-shadow:0 24px 70px rgba(0,0,0,.28);
      overflow:hidden;
      animation:modalIn .18s ease;
    }

    @keyframes modalIn{
      from{opacity:0;transform:translateY(8px) scale(.98)}
      to{opacity:1;transform:translateY(0) scale(1)}
    }

    .modal-header{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:12px;
      padding:17px 18px;
      background:#111827;
      color:white;
    }

    .modal-header h3{margin:0;font-size:1.05rem}

    .modal-close{
      width:34px;
      height:34px;
      border:0;
      border-radius:9px;
      background:#273244;
      color:white;
      cursor:pointer;
      font-size:1.2rem;
      font-weight:900;
    }

    .modal-content{
      padding:20px;
    }

    .how-step{
      display:grid;
      grid-template-columns:38px 1fr;
      gap:12px;
      align-items:start;
      margin-bottom:15px;
    }

    .how-step:last-child{margin-bottom:0}

    .step-number{
      width:38px;
      height:38px;
      border-radius:12px;
      background:var(--orange);
      color:white;
      display:grid;
      place-items:center;
      font-weight:900;
    }

    .how-step strong{display:block;margin-bottom:3px}
    .how-step p{margin:0;color:var(--muted);font-size:.88rem;line-height:1.45}

    .library{display:grid;gap:9px}

    .library-group-title{
      margin:15px 0 7px;
      padding-top:12px;
      border-top:1px solid #e5e8ec;
      font-size:.72rem;
      font-weight:900;
      text-transform:uppercase;
      letter-spacing:.07em;
      color:var(--muted);
    }

    .library-group-title:first-child{
      margin-top:0;
      padding-top:0;
      border-top:0;
    }

    .library-item.content-item{
      border-style:dashed;
      background:#fafbfc;
    }

    .frame-layout{
      width:100%;
      height:100%;
      min-height:42px;
      display:grid;
      gap:7px;
    }

.frame-layout.dynamic-layout{
      grid-template-columns:repeat(auto-fit,minmax(90px,1fr));
      grid-auto-rows:minmax(42px,1fr);
    }

.zone-count{
      margin-top:6px;
      font-size:.75rem;
      color:var(--muted);
      text-align:center;
    }

    .inline-zone-controls{
      position:absolute;
      top:36px;
      right:6px;
      display:none;
      gap:5px;
      z-index:12;
    }

    .blueprint-box.selected .inline-zone-controls{
      display:flex;
    }

    .inline-zone-btn{
      width:28px;
      height:28px;
      border:1px solid #d6dbe1;
      border-radius:8px;
      background:white;
      color:#374151;
      display:grid;
      place-items:center;
      cursor:pointer;
      font-size:1rem;
      font-weight:900;
      line-height:1;
      box-shadow:0 3px 8px rgba(17,24,39,.12);
    }

    .inline-zone-btn:hover{
      border-color:var(--orange);
      color:var(--orange-dark);
      background:var(--orange-soft);
    }

    .inline-zone-btn:disabled{
      opacity:.4;
      cursor:not-allowed;
      background:#f3f4f6;
      color:#9ca3af;
      border-color:#e5e7eb;
    }

    .snap-zone{
      min-width:0;
      min-height:34px;
      border:2px dashed #aeb6bf;
      border-radius:8px;
      background:rgba(255,255,255,.62);
      display:flex;
      align-items:center;
      justify-content:center;
      text-align:center;
      padding:6px;
      color:#7b8490;
      font-size:.7rem;
      font-weight:800;
      transition:.15s ease;
      overflow:hidden;
      position:relative;
    }

    .snap-zone.zone-over{
      border-color:var(--orange);
      border-style:solid;
      background:#fff0e3;
      box-shadow:
        inset 0 0 0 3px rgba(244,124,32,.18),
        0 0 0 3px rgba(244,124,32,.16);
      transform:scale(1.025);
    }

    .snap-zone.zone-over::after{
      content:"Drop Here";
      position:absolute;
      inset:0;
      display:grid;
      place-items:center;
      background:rgba(255,240,227,.9);
      color:var(--orange-dark);
      font-size:.74rem;
      font-weight:900;
      text-transform:uppercase;
      letter-spacing:.05em;
      pointer-events:none;
    }

    .snap-zone.filled{
      border-style:solid;
      border-color:#a9b2bc;
      background:white;
      color:#49525e;
    }

    .nested-content{
      width:100%;
      height:100%;
      min-height:28px;
      display:flex;
      flex-direction:column;
      align-items:center;
      justify-content:center;
      gap:5px;
      pointer-events:none;
    }

    .nested-icon{
      width:25px;
      height:25px;
      border-radius:7px;
      background:#e9edf1;
      display:grid;
      place-items:center;
      font-weight:900;
      color:#4b5563;
    }

    .nested-lines{
      width:82%;
      display:flex;
      flex-direction:column;
      gap:4px;
    }

    .nested-line{
      height:5px;
      border-radius:999px;
      background:#b9c1ca;
    }

    .nested-line.short{width:58%}

    .nested-image{
      width:82%;
      height:70%;
      min-height:22px;
      border:2px dashed #9fa9b3;
      border-radius:6px;
      display:grid;
      place-items:center;
      font-size:.68rem;
    }

    .nested-remove{
      position:absolute;
      top:3px;
      right:3px;
      width:19px;
      height:19px;
      border:0;
      border-radius:6px;
      background:#fee4e2;
      color:var(--danger);
      cursor:pointer;
      font-weight:900;
      line-height:1;
      z-index:2;
    }

    .nested-remove:hover{background:#fecaca}

    .drop-hint{
      font-size:.66rem;
      line-height:1.25;
      color:#8b949f;
    }
    .library-item{
      border:1px solid var(--line);
      border-radius:13px;
      background:white;
      padding:11px;
      display:flex;
      align-items:center;
      gap:10px;
      cursor:grab;
      user-select:none;
      transition:.16s ease;
    }
    .library-item:hover{
      border-color:var(--orange);
      background:var(--orange-soft);
      transform:translateY(-1px);
    }
    .library-item:active{cursor:grabbing}
    .lib-icon{
      width:35px;height:35px;border-radius:10px;background:#edf0f3;
      display:grid;place-items:center;font-weight:900;flex:0 0 auto
    }
    .library-item strong{display:block;font-size:.88rem}
    .library-item span{display:block;font-size:.74rem;color:var(--muted);margin-top:2px}

    .workspace{padding:16px;min-width:0;grid-column:2;grid-row:1}

    .left-sidebar{grid-column:1;grid-row:1}
    .right-sidebar{grid-column:3;grid-row:1}
    .toolbar{
      display:flex;
      align-items:end;
      justify-content:space-between;
      gap:14px;
      margin-bottom:13px;
      flex-wrap:wrap;
    }

.website-field{min-width:220px;flex:1}
    .website-field label,
    .field label{
      display:block;
      font-size:.74rem;
      font-weight:900;
      color:var(--muted);
      text-transform:uppercase;
      letter-spacing:.05em;
      margin-bottom:6px;
    }
    input,textarea{
      width:100%;
      border:1px solid var(--line);
      border-radius:11px;
      padding:10px 11px;
      outline:none;
      background:white;
    }

    input[type="color"]{
      width:100%;
      height:44px;
      padding:4px;
      cursor:pointer;
      border-radius:11px;
      background:white;
    }

    .color-row{
      display:grid;
      grid-template-columns:72px minmax(0,1fr) auto;
      gap:8px;
      align-items:center;
    }

    .hex-input{
      text-transform:uppercase;
      font-family:Consolas, "Courier New", monospace;
      font-weight:800;
      letter-spacing:.03em;
    }

    .color-error{
      display:none;
      margin-top:6px;
      color:var(--danger);
      font-size:.75rem;
      line-height:1.35;
    }

    .color-error.show{display:block}

    .reset-color-btn{
      border:1px solid var(--line);
      background:#f8fafc;
      color:#4b5563;
      border-radius:10px;
      padding:10px 12px;
      font-weight:800;
      cursor:pointer;
    }

    .reset-color-btn:hover{
      border-color:var(--orange);
      color:var(--orange-dark);
    }
    input:focus,textarea:focus{
      border-color:var(--orange);
      box-shadow:0 0 0 3px rgba(244,124,32,.13);
    }

    .mode-controls{
      display:flex;
      gap:7px;
      background:#eef1f4;
      border-radius:12px;
      padding:4px;
    }
    .mode-btn{
      border:0;
      border-radius:9px;
      padding:8px 11px;
      background:transparent;
      color:#4b5563;
      font-weight:850;
      cursor:pointer;
    }
    .mode-btn.active{background:white;color:var(--orange-dark);box-shadow:0 2px 8px rgba(0,0,0,.08)}

    .browser{
      border:1px solid #cfd5dc;
      border-radius:15px;
      overflow:hidden;
      background:white;
    }
    .browser-bar{
      height:45px;background:#e9edf1;border-bottom:1px solid #d1d7de;
      display:flex;align-items:center;gap:10px;padding:0 12px;
    }
    .dots{display:flex;gap:6px}
    .dot{width:10px;height:10px;border-radius:50%;background:#aab2bd}
    .url{
      flex:1;background:white;border:1px solid #cfd5dc;border-radius:8px;
      padding:6px 10px;text-align:center;color:#7b8490;font-size:.76rem
    }

    .canvas-wrap{
      background:#dfe4ea;
      padding:18px;
      overflow:auto;
    }

    #canvas{
      width:100%;
      min-width:650px;
      height:690px;
      position:relative;
      overflow:hidden;
      background:
        linear-gradient(#e8ebef 1px, transparent 1px),
        linear-gradient(90deg,#e8ebef 1px, transparent 1px),
        var(--blueprint);
      background-size:24px 24px;
      border:2px dashed #b8c0c9;
      border-radius:12px;
      touch-action:none;
      user-select:none;
    }

    #canvas.draw-mode{cursor:crosshair}
    #canvas.select-mode{cursor:default}
    #canvas.drag-over{border-color:var(--orange);box-shadow:inset 0 0 0 4px rgba(244,124,32,.12)}

    .canvas-message{
      position:absolute;
      inset:0;
      display:grid;
      place-items:center;
      pointer-events:none;
      text-align:center;
      color:#7a8490;
      padding:40px;
    }
    .canvas-message strong{display:block;color:#303846;font-size:1.08rem;margin-bottom:6px}

    .blueprint-box{
      position:absolute;
      min-width:80px;
      min-height:60px;
      border:2px solid #9aa4af;
      background:rgba(239,242,245,.93);
      border-radius:10px;
      overflow:hidden;
      resize:both;
      cursor:grab;
      box-shadow:0 4px 10px rgba(28,39,52,.08);
      touch-action:none;
    }

    .blueprint-box:active{cursor:grabbing}

    .blueprint-box.selected{
      border-color:var(--orange);
      box-shadow:0 0 0 4px rgba(244,124,32,.15);
      z-index:10;
    }

    .blueprint-box.drop-target{
      border-color:var(--orange);
      background:var(--orange-soft);
      box-shadow:0 0 0 4px rgba(244,124,32,.18);
    }

    .box-label{
      height:30px;
      background:#dce1e6;
      border-bottom:1px solid #bdc5cd;
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:8px;
      padding:0 8px;
      font-size:.72rem;
      font-weight:900;
      text-transform:uppercase;
      letter-spacing:.05em;
    }

    .box-label span{pointer-events:none}

.box-controls{
      display:flex;
      align-items:center;
      gap:5px;
    }

    .quick-delete{
      border:0;
      width:23px;
      height:23px;
      border-radius:7px;
      display:grid;
      place-items:center;
      background:rgba(255,255,255,.78);
      color:var(--danger);
      cursor:pointer;
      font-weight:900;
      font-size:.9rem;
      line-height:1;
    }

    .quick-delete:hover{
      background:#fee4e2;
      transform:scale(1.06);
    }

    .blueprint-box.assigned .box-label{
      background:var(--frame-color, var(--orange));
      color:white;
      border-bottom-color:rgba(0,0,0,.18);
    }

    .box-body{
      height:calc(100% - 30px);
      min-height:28px;
      display:grid;
      place-items:center;
      padding:8px;
      text-align:center;
      color:#68717d;
      font-weight:750;
      font-size:.78rem;
      pointer-events:auto;
    }

    .frame-layout,
    .snap-zone{
      pointer-events:auto;
    }

    .nested-content,
    .drop-hint{
      pointer-events:none;
    }

    .box-body .empty-box{
      border:2px dashed #b0b8c1;
      border-radius:7px;
      width:100%;
      height:100%;
      min-height:24px;
      display:grid;
      place-items:center;
      padding:6px;
    }

.draw-ghost{
      position:absolute;
      border:2px dashed var(--orange);
      background:rgba(244,124,32,.13);
      border-radius:9px;
      pointer-events:none;
      z-index:100;
    }

    .inspector-empty{
      border:2px dashed #d3d8de;
      border-radius:13px;
      padding:20px 13px;
      text-align:center;
      color:var(--muted);
      background:#fafafa;
      font-size:.87rem;
    }
    .field{margin-bottom:13px}
    textarea{min-height:105px;resize:vertical;line-height:1.4}
    .selection-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:8px}
    .small-note{font-size:.76rem;line-height:1.4;color:var(--muted);margin-top:12px}
    .save-status{text-align:center;color:var(--muted);font-size:.77rem;margin-top:11px}

    @media(max-width:1130px){
      main{grid-template-columns:220px minmax(580px,1fr)}
      .left-sidebar{grid-column:1;grid-row:1}
      .workspace{grid-column:2;grid-row:1}
      .right-sidebar{grid-column:1 / -1;grid-row:2;position:static;max-height:none}
    }

    @media(max-width:800px){
      header{align-items:flex-start;flex-direction:column}
      main{grid-template-columns:1fr}
      .left-sidebar,.workspace,.right-sidebar{grid-column:1;grid-row:auto}
      .sidebar{position:static;max-height:none}
      #canvas{min-width:620px}
    }

    @media print{
      body{background:white}
      header,.left-sidebar,.right-sidebar,.toolbar,.browser-bar{display:none!important}
      main{display:block;padding:0}
      .panel,.browser{border:0;box-shadow:none}
      .workspace{padding:0}
      .canvas-wrap{padding:0;background:white}
      #canvas{border:0;width:100%;min-width:0;height:720px;background:white}
      .blueprint-box{resize:none;box-shadow:none}
    }