/* Stili dello strumento Pianificazione */
:root {
      --bg: #040914;
      --surface: #0a1527;
      --surface2: #111820;
      --surface3: #161e28;
      --border: #1e2d3f;
      --border-bright: #2a3f58;
      --text: #dce8f8;
      --muted: #6b83a3;
      --accent: #67caff;
      --accent-glow: rgba(56,184,255,.18);
      --accent2: #7c5cfc;
      --red: #ff4444;
      --blue: #2d8fff;
      --danger: #c0392b;
      --sidebar-w: 270px;
      --radius: 10px;
      --radius-sm: 7px;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }

    body {
      font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
      background: var(--bg);
      color: var(--text);
      height: 100vh;
      overflow: hidden;
    }

    /* ── Layout ── */
    .app {
      display: flex;
      height: calc(100vh - 66px);
      width: 100vw;
    }

    /* ── Sidebar ── */
    .sidebar {
      width: var(--sidebar-w);
      background: var(--surface);
      border-right: 1px solid var(--border);
      height: 100%;
      overflow-y: auto;
      overflow-x: hidden;
      overscroll-behavior: contain;
      display: flex;
      flex-direction: column;
      gap: 0;
      position: relative;
    }

    .sidebar::before {
      content: '';
      position: absolute;
      top: 0; left: 0; right: 0;
      height: 1px;
      background: linear-gradient(90deg, transparent, var(--accent), transparent);
      opacity: .5;
    }

    .sidebar::-webkit-scrollbar { width: 4px; }
    .sidebar::-webkit-scrollbar-thumb {
      background: var(--border-bright);
      border-radius: 99px;
    }
    .sidebar::-webkit-scrollbar-track { background: transparent; }

    /* ── Sidebar Header ── */
    .sidebar-header {
      padding: 20px 16px 16px;
      border-bottom: 1px solid var(--border);
    }

    .logo {
      display: flex;
      align-items: center;
      gap: 9px;
      margin-bottom: 6px;
    }

    .logo-icon {
      width: 28px;
      height: 28px;
      background: linear-gradient(135deg, var(--accent), var(--accent2));
      border-radius: 7px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      flex-shrink: 0;
      box-shadow: 0 0 14px var(--accent-glow);
    }

    .logo-text {
      font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
      font-size: 13px;
      font-weight: 700;
      letter-spacing: .5px;
      color: var(--text);
    }

    .logo-badge {
      font-size: 10px;
      color: var(--muted);
      font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
      letter-spacing: .3px;
    }

    .hint {
      font-size: 11.5px;
      color: var(--muted);
      line-height: 1.5;
    }

    /* ── Sections ── */
    .section {
      padding: 14px 16px;
      border-bottom: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .section-label {
      font-size: 10px;
      font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
      text-transform: uppercase;
      letter-spacing: 1.2px;
      color: var(--muted);
    }

    /* ── File Upload ── */
    .upload-area {
      position: relative;
      border: 1px dashed var(--border-bright);
      border-radius: var(--radius);
      padding: 12px;
      background: rgba(255,255,255,.02);
      cursor: pointer;
      transition: border-color .2s, background .2s;
      text-align: center;
    }

    .upload-area:hover {
      border-color: var(--accent);
      background: var(--accent-glow);
    }

    .upload-area input[type="file"] {
      position: absolute;
      inset: 0;
      opacity: 0;
      cursor: pointer;
      width: 100%;
      height: 100%;
    }

    .upload-label {
      font-size: 12px;
      color: var(--muted);
      pointer-events: none;
    }

    .upload-label span {
      color: var(--accent);
      font-weight: 500;
    }

    /* ── Tools Grid ── */
    .tools-grid {
      display: flex;
      flex-direction: column;
      gap: 5px;
    }

    .toolbtn {
      display: flex;
      align-items: center;
      gap: 10px;
      width: 100%;
      padding: 9px 11px;
      border-radius: var(--radius-sm);
      border: 1px solid transparent;
      background: var(--surface2);
      color: var(--text);
      cursor: pointer;
      user-select: none;
      font-family: 'Comic Sans MS', sans-serif;
      font-size: 13px;
      font-weight: 400;
      transition: background .15s, border-color .15s, box-shadow .15s;
      position: relative;
      overflow: hidden;
    }

    .toolbtn::after {
      content: '';
      position: absolute;
      left: 0; top: 0; bottom: 0;
      width: 2px;
      background: var(--accent);
      opacity: 0;
      transition: opacity .15s;
    }

    .toolbtn:hover {
      background: var(--surface3);
      border-color: var(--border-bright);
    }

    .toolbtn.active {
      background: var(--surface3);
      border-color: rgba(56,184,255,.4);
      box-shadow: 0 0 0 1px rgba(56,184,255,.1) inset, 0 2px 8px rgba(56,184,255,.06);
      color: #fff;
    }

    .toolbtn.active::after { opacity: 1; }

    .tool-icon {
      width: 20px;
      height: 20px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }

    .swatch {
      width: 14px;
      height: 14px;
      border-radius: 50%;
      border: 1.5px solid rgba(255,255,255,.2);
    }

    .swatch-pen {
      width: 14px;
      height: 14px;
      border-radius: 4px;
      background: linear-gradient(135deg, #fff 40%, var(--accent));
      border: 1.5px solid rgba(255,255,255,.2);
    }

    .swatch-eraser {
      width: 14px;
      height: 14px;
      border-radius: 4px;
      background: repeating-conic-gradient(rgba(255,255,255,.15) 0% 25%, transparent 0% 50%) 0 / 7px 7px;
      border: 1.5px solid rgba(255,255,255,.2);
    }

    .tool-name { flex: 1; }

    .tool-key {
      font-size: 10px;
      font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
      color: var(--muted);
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 4px;
      padding: 1px 5px;
    }

    /* ── Sliders ── */
    .slider-group {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .slider-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .slider-label {
      font-size: 11.5px;
      color: var(--muted);
      font-weight: 400;
    }

    .slider-value {
      font-size: 11px;
      font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
      color: var(--accent);
      background: rgba(56,184,255,.1);
      padding: 1px 7px;
      border-radius: 99px;
      border: 1px solid rgba(56,184,255,.2);
    }

    input[type="range"] {
      -webkit-appearance: none;
      width: 100%;
      height: 3px;
      border-radius: 99px;
      background: var(--border-bright);
      outline: none;
    }

    input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: var(--accent);
      cursor: pointer;
      border: 2px solid var(--surface);
      box-shadow: 0 0 6px var(--accent-glow);
      transition: transform .1s;
    }

    input[type="range"]::-webkit-slider-thumb:hover {
      transform: scale(1.2);
    }

    input[type="range"]::-moz-range-thumb {
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: var(--accent);
      cursor: pointer;
      border: 2px solid var(--surface);
    }

    /* ── Buttons ── */
    .btn-row {
      display: flex;
      gap: 7px;
    }

    .btn {
      flex: 1;
      padding: 9px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border-bright);
      background: var(--surface2);
      color: var(--text);
      cursor: pointer;
      font-size: 12.5px;
      font-family: 'Comic Sans MS', sans-serif;
      font-weight: 500;
      user-select: none;
      transition: background .15s, border-color .15s, transform .1s;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
    }

    .btn:hover { background: var(--surface3); border-color: var(--accent); }
    .btn:active { transform: scale(.97); }

    .btn.danger {
      background: rgba(192,57,43,.12);
      border-color: rgba(192,57,43,.3);
      color: #e07070;
    }

    .btn.danger:hover {
      background: rgba(192,57,43,.2);
      border-color: rgba(192,57,43,.5);
    }

    /* ── Status ── */
    .status-bar {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 10px 16px;
      border-top: 1px solid var(--border);
      margin-top: auto;
    }

    .status-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--accent);
      box-shadow: 0 0 6px var(--accent);
      flex-shrink: 0;
    }

    .status-text {
      font-size: 11px;
      font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
      color: var(--muted);
    }

    /* ── Shortcuts ── */
    .shortcuts {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .shortcut {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 11.5px;
      color: var(--muted);
    }

    .shortcut-keys {
      display: flex;
      gap: 3px;
    }

    .kbd {
      padding: 2px 6px;
      border-radius: 5px;
      border: 1px solid var(--border-bright);
      background: var(--surface2);
      color: var(--text);
      font-size: 10px;
      font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    }

    /* ── Stage ── */
    .stage {
      flex: 1;
      position: relative;
      overflow: hidden;
      background: var(--bg);
    }

    .stage-bg-pattern {
      position: absolute;
      inset: 0;
      background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
      background-size: 40px 40px;
      opacity: .35;
      pointer-events: none;
    }

    canvas {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      display: block;
    }

    /* ── Canvas cursor ── */
    #fg { cursor: crosshair; }
    #fg.pan-cursor { cursor: grab; }
    #fg.panning { cursor: grabbing; }

    /* ── Upload placeholder overlay ── */
    .empty-state {
      position: absolute;
      inset: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 12px;
      pointer-events: none;
    }

    .empty-icon {
      font-size: 48px;
      opacity: .15;
    }

    .empty-text {
      font-size: 14px;
      color: var(--muted);
      opacity: .7;
    }

    .embedded .plan-header{display:none}.embedded .app{height:100vh}@media(max-width:750px){.embedded .app{height:auto;min-height:100svh}}.plan-header{height:66px;display:flex;align-items:center;gap:15px;padding:5px 22px;background:rgba(4,9,20,.96);border-bottom:1px solid #223a59;position:relative;z-index:3}.plan-header img{width:52px;height:52px;object-fit:contain}.plan-header strong{font-family:Georgia,serif;letter-spacing:.1em;font-size:1rem}.plan-header a{margin-left:auto;color:#9bdcff;text-decoration:none;font-size:.85rem}.plan-header a:hover{text-decoration:underline}.plan-note{font-size:12px;line-height:1.5;color:#9bb5d1}.plan-note a{color:#8ed5ff}.stage:before{content:"";position:absolute;inset:10% 15%;background:url('logo.png') center/contain no-repeat;opacity:.045;pointer-events:none}.sidebar{z-index:2}.btn.export{background:#173d62;border-color:#479acf;color:#eff8ff}#fg{touch-action:none}@media(max-width:750px){body{height:auto;overflow:auto}.plan-header{height:58px;padding:4px 13px}.plan-header img{width:42px;height:42px}.plan-header strong{font-size:.82rem}.app{height:auto;min-height:calc(100svh - 58px);display:flex;flex-direction:column}.sidebar{width:100%;height:auto;max-height:none;overflow:visible;display:block;border-right:0;border-bottom:1px solid #2a3f58}.sidebar-header{padding:11px 16px}.sidebar .section{padding:11px 16px}.stage{height:57svh;min-height:320px;width:100%}.tools-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.sidebar .status-bar{padding:8px 16px}}@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;animation:none!important;transition:none!important}}
