* { box-sizing: border-box; }
    .no-scrollbar::-webkit-scrollbar { display: none; }
    .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
    #designStage { cursor: crosshair; touch-action: none; }
    
    /* Selection & Hover Styles */
    .element-hover { cursor: pointer; transition: stroke 0.2s; stroke-linecap: round; stroke-linejoin: round; }
    .element-hover:hover { stroke: #6366f1; stroke-width: 2px; }
    .element-selected { stroke: #6366f1 !important; stroke-width: 2.5px !important; filter: drop-shadow(0 0 4px rgba(99, 102, 241, 0.4)); }
    
    /* Invisible Hit Area */
    .hit-target { cursor: pointer; fill: transparent; stroke: transparent; stroke-width: 16px; pointer-events: all; stroke-linecap: round; }
    .hit-target-selected { cursor: default; }
    .is-grabbing, .is-grabbing * { cursor: grabbing !important; }
    
    .handle { cursor: move; fill: #6366f1; stroke: white; stroke-width: 1.5; transition: r 0.2s; pointer-events: all; }
    .handle:hover { r: 6; }
    .handle-edge { fill: white; stroke: #6366f1; stroke-width: 2; cursor: grab; }
    .handle-center { cursor: grab; fill: #6366f1; stroke: white; stroke-width: 2; }
    
    /* Text Box Styling */
    .text-box-container { 
      pointer-events: auto; 
      overflow: visible; 
      display: flex;
      flex-direction: column;
      height: 100%;
      background: transparent;
      border: none;
      position: relative;
      box-sizing: border-box;
    }
    .text-box-content {
      font-family: 'Helvetica', sans-serif;
      line-height: 1.2;
      color: #334155;
      word-break: break-word;
      width: 100%;
      outline: none;
      padding: 2px 4px;
      white-space: pre-wrap;
      overflow: hidden;
      font-size: 12px;
      cursor: text;
    }
    .text-box-content[contenteditable="true"] { cursor: text; }
    
    /* Ruler Styles */
    .ruler { background: #fff; color: #475569; font-family: monospace; font-size: 9px; font-weight: bold; pointer-events: none; border-color: #e2e8f0; z-index: 10; user-select: none; -webkit-user-select: none; }
    .ruler-tick { stroke: #cbd5e1; stroke-width: 1; stroke-linecap: round; }
    .ruler-label { fill: #475569; font-size: 8px; font-weight: 800; }
    .ruler-center-marker { stroke: #6366f1; stroke-width: 1.5; }

    #workspace { transform-origin: top left; transition: transform 0.2s ease-out; }
    
    input[type="range"] { accent-color: #6366f1; }
    input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
    input[type=number] { -moz-appearance: textfield; }

    #marqueeBox { fill: rgba(99, 102, 241, 0.1); stroke: #6366f1; stroke-width: 1; stroke-dasharray: 4; pointer-events: none; stroke-linecap: round; }

    /* Selection Framing */
    .page-assembly { 
      position: relative;
      padding: 32px 0 0 32px; 
      display: block;
      background: #f1f5f9;
      transition: all 0.2s ease;
      border-radius: 2px;
      line-height: 0;
    }
    .page-assembly-wrapper {
        transition: all 0.2s ease;
        padding: 2px;
        display: inline-block;
        border: 2px solid transparent;
        margin: 6px 18px;
        border-radius: 4px;
        box-sizing: border-box;
    }
    .active-page.page-assembly-wrapper {
      border-color: #6366f1;
      box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
    }
    .canvas-page-enter-next {
      animation: canvasPageEnterNext 180ms ease-out;
    }
    .canvas-page-enter-prev {
      animation: canvasPageEnterPrev 180ms ease-out;
    }
    @keyframes canvasPageEnterNext {
      from { opacity: 0.7; transform: translateX(18px); }
      to { opacity: 1; transform: translateX(0); }
    }
    @keyframes canvasPageEnterPrev {
      from { opacity: 0.7; transform: translateX(-18px); }
      to { opacity: 1; transform: translateX(0); }
    }
    
    .page-container { 
      background: #eef2ff; /* Bleed Area Tint */
      position: relative;
      overflow: visible;
      outline: 1px solid #e2e8f0;
    }

    .visible-sheet {
        fill: white;
        stroke: #cbd5e1;
        stroke-width: 0.5;
    }

    .bleed-overlay {
        fill: rgba(165, 180, 252, 0.1);
        pointer-events: none;
    }

    /* Optimized Notebook Mode Layout - High Density */
    .notebook-view #viewport { padding: 2rem; overflow: hidden; }
    .notebook-view #workspace {
        display: grid;
        gap: 1.5rem;
        width: 100%;
        max-width: none;
        transform: none !important;
        align-items: start;
        justify-content: center;
    }
    .notebook-view .ruler, .notebook-view #rulerCorner { display: none !important; }
    .notebook-view .page-assembly-wrapper { margin: 0; padding: 0; border-radius: 4px; border: 2px solid transparent; }
    .notebook-view .active-page.page-assembly-wrapper { border-color: #6366f1; }
    .notebook-view .page-assembly { 
        padding: 0; 
        width: 100% !important; 
        height: auto !important; 
        cursor: pointer;
        box-shadow: 0 4px 20px -5px rgba(0,0,0,0.1);
        border: 1px solid #e2e8f0;
        border-radius: 4px;
        overflow: hidden;
    }
    .notebook-view .page-container { 
        position: relative; 
        left: 0; 
        top: 0; 
        width: 100% !important; 
        height: 100% !important; 
        border: none; 
    }

    .header-select {
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236366f1'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 0.4rem center;
        background-size: 0.8rem;
        padding-right: 1.5rem;
    }
    .selection-toolbar {
        visibility: visible;
        opacity: 1;
        transition: opacity 0.15s ease;
    }
    .selection-toolbar.hidden {
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
    }
    .pattern-icon {
        display: block;
        width: 20px;
        height: 8px;
    }
    .align-icon {
        display: block;
        width: 16px;
        height: 16px;
        stroke: #334155;
        stroke-width: 1.6;
        fill: none;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
    .modal-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.28);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 50;
    }
    .modal-backdrop.hidden { display: none; }
    .quality-option.active {
        border-color: #6366f1;
        background: #eef2ff;
        box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.18);
    }
