  :root {
      --bg: #0f172a;
      --panel: #111827;
      --text: #f8fafc;
      --muted: #cbd5e1;
      --accent: #2563eb;
      --accent2: #16a34a;
      --warn: #dc2626;
      --border: #334155;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      font-family: Arial, Helvetica, sans-serif;
      background: #e5e7eb;
      color: #111827;
      height: 100vh;
      display: grid;
      grid-template-columns: 260px 1fr;
    }
    .sidebar {
      background: var(--bg);
      color: var(--text);
      padding: 10px;
      overflow: auto;
      border-right: 1px solid var(--border);
    }
    .sidebar h1 { font-size: 22px; margin: 0 0 8px; }
    .sidebar p { color: var(--muted); font-size: 14px; line-height: 1.45; }
    .section {
      background: rgba(255,255,255,0.03);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 6px;
      margin-top: 4px;
    }
    .section h2 { margin: 0 0 3px; font-size: 14px; }
    .btn, input[type="file"]::file-selector-button, select {
      width: 100%;
      margin: 3px 0;
      padding: 8px 10px;
      border: none;
      border-radius: 10px;
      cursor: pointer;
      font-size: 13px;
      font-weight: 600;
    }
    select {
      background: #fff;
      color: #111827;
      cursor: pointer;
      border: 1px solid #cbd5e1;
    }
    .btn.primary { background: var(--accent); color: white; }
    .btn.green { background: var(--accent2); color: white; }
    .btn.gray { background: #334155; color: white; }
    .btn.red { background: var(--warn); color: white; }
    .btn:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
    input[type="file"] { width: 100%; color: var(--muted); }
    .small { font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
    .status {
      font-size: 12px;
      padding: 4px;
      background: #0b1220;
      border-radius: 10px;
      border: 1px solid var(--border);
      color: #dbeafe;
      line-height: 1.4;
    }
    .areas { display: flex; flex-direction: column; gap: 8px; }
    .area {
      background: #0b1220;
      border: 1px solid var(--border);
      padding: 10px;
      border-radius: 10px;
    }
    .area b { display: block; margin-bottom: 4px; }
    .main { display: flex; flex-direction: column; min-width: 0; }
    .toolbar {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      padding: 10px;
      background: white;
      border-bottom: 1px solid #cbd5e1;
    }
    .toolbar button {
      padding: 10px 12px;
      border-radius: 10px;
      border: 1px solid #cbd5e1;
      background: white;
      cursor: pointer;
      font-weight: 600;
    }
    .canvasWrap {
      position: relative;
      flex: 1;
      overflow: hidden;
      background: #cbd5e1;
    }
     canvas { 
      width: 100%;
      height: 100%;
      display: block;
      touch-action: none;
      cursor: crosshair;
    } 
     .legend {
  position: absolute;
  right: 12px;
  top: 12px;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 50%; /* Start as a circle */
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  z-index: 100;
}

/* This is how it looks when opened */
.legend.active {
  width: auto;
  height: auto;
  max-width: 290px;
  border-radius: 10px;
  padding: 15px;
  display: block; /* Switch back to normal text layout */
}

/* Hide the text until active */
.legend .content {
  display: none;
}
.legend.active .content {
  display: block;
}

/* The question mark symbol */
.legend::before {
  content: "?";
  font-weight: bold;
  font-size: 18px;
  color: var(--accent);
}
.legend.active::before {
  content: "Close ✖"; /* Change text when open */
  font-size: 12px;
  display: block;
  margin-bottom: 8px;
  color: var(--warn);
}
    
    @media (max-width: 900px) {
      body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
      .sidebar { max-height: 50vh; }
    }
 
