:root{
  --primary: #2E5BFF;
  --accent: #09274A;
  --muted: #6b7280;
  --bg: #f4f5f9;
  --panel: #ffffff;
  --danger: #d9534f;
  --success: #0b8457;
  --glass: rgba(255,255,255,0.85);
  --shadow: 0 8px 32px rgba(14,30,60,0.08);
  --radius: 10px;
}

/* make toolbar scrollable when content too tall */
#toolbar {
  overflow:auto;
  max-height: 100vh;
  -webkit-overflow-scrolling: touch;
  padding-right: 10px; /* breathing room for scrollbar */
}

/* dim steps that are not available */
.step.inactive { opacity: 0.45; filter: saturate(0.95); pointer-events: none; }

/* make upload button more obvious */
.tool-btn.large { min-height:44px; }

/* ensure modal inputs don't close on accidental backspace */
.modal input:focus { outline: 2px solid rgba(46,91,255,0.12); }


/* Reset & base */
* { box-sizing: border-box; }
html,body { height:100%; margin:0; font-family:'Poppins',sans-serif; background:var(--bg); color:#24292f; }
a { color:var(--primary); text-decoration:none; }

/* Main layout */
.tool-wrapper { display:flex; height:100vh; width:100%; overflow:hidden; }

/* LEFT WORKFLOW PANEL */
#toolbar {
  width: 300px;                    /* wider workflow panel */
  background: var(--panel);
  padding: 20px;
  border-right: 1px solid rgba(0,0,0,0.04);
  box-shadow: var(--shadow);
  display:flex;
  flex-direction:column;
  gap:16px;
  z-index:60;
}

.brand { display:flex; align-items:center; gap:10px; padding-bottom:4px; border-bottom:1px solid rgba(0,0,0,0.04);}
.brand-logo { height:34px; width:auto; display:block; }
.brand-name { font-weight:600; font-size:1rem; color:var(--accent); }

/* Workflow */
.workflow-title { font-size:14px; color:var(--muted); margin-top:8px; }
.step { display:flex; gap:12px; padding:12px 0; border-bottom:1px dashed rgba(0,0,0,0.03); }
.step-num { min-width:30px; height:30px; border-radius:8px; background:linear-gradient(180deg,#fff,#f6f8ff); display:flex; align-items:center; justify-content:center; font-weight:600; color:var(--primary); border:1px solid rgba(46,91,255,0.06); }
.step-content { flex:1; }
.step-title { font-weight:600; font-size:0.96rem; color:#24323a; margin-bottom:4px; }
.step-note { font-size:13px; color:var(--muted); margin-bottom:8px; }

.logo img {
  height: 40px;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}


/* Buttons in panel */
.tool-btn {
  background:#fff;
  border:1px solid rgba(0,0,0,0.06);
  padding:10px 12px;
  border-radius:8px;
  cursor:pointer;
  font-size:14px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  transition:all .12s ease;
}
.tool-btn.small { padding:8px 10px; font-size:13px; }
.tool-btn.large { width:100%; text-align:center; }
.tool-btn.red { border-color:var(--danger); color:var(--danger); }
.tool-btn:hover:not(.disabled) { transform:translateY(-1px); box-shadow:0 8px 18px rgba(2,6,23,0.04); }

.row-gap { display:flex; gap:8px; margin-top:6px; }

/* Info block */
.info-block { margin-top:6px; padding:10px; background:linear-gradient(180deg, rgba(46,91,255,0.03), rgba(255,255,255,0.4)); border-radius:8px; border:1px solid rgba(46,91,255,0.05); }
.info-title { font-weight:700; color:#21313c; margin-bottom:6px; }
.info-text { color:var(--muted); font-size:14px; margin-bottom:8px; }
.metric { padding:8px; background:rgba(0,0,0,0.03); border-radius:6px; font-weight:600; color:#111; }

/* Canvas area */
#canvas-area { flex:1; position:relative; display:flex; flex-direction:column; overflow:hidden; }
#canvas-toolbar { display:flex; gap:16px; align-items:center; padding:14px 18px; background:transparent; z-index:40; }
.canvas-status { background:var(--glass); padding:8px 12px; border-radius:8px; font-weight:600; color:#111; box-shadow:var(--shadow); }
.canvas-hints { color:var(--muted); font-size:14px; }

/* canvas container */
#canvas-container { flex:1; position:relative; display:flex; justify-content:center; align-items:center; background:linear-gradient(180deg,#f7f9fc,#eef6ff); overflow:hidden; }
#measureCanvas { max-width:100%; max-height:100%; background:#fff; cursor:crosshair; border-radius:8px; box-shadow:0 10px 30px rgba(12,30,70,0.06); touch-action:none; }

/* overlays */
.overlay { position:absolute; pointer-events:none; z-index:80; }
.hud { top:18px; right:18px; background:var(--glass); padding:10px 12px; border-radius:8px; box-shadow:var(--shadow); font-size:13px; text-align:left; color:#111; pointer-events:none; }
#areaLabel { pointer-events:none; display:flex; align-items:center; justify-content:center; min-width:100px; min-height:40px; padding:6px 10px; background:rgba(255,255,255,0.92); border-radius:8px; border:1px solid rgba(0,0,0,0.06); box-shadow:0 8px 24px rgba(12,30,70,0.08); font-weight:700; color:#0b3a2a; }

.hidden { display:none !important; }

/* MODALS */
.modal { position:fixed; left:50%; top:50%; transform:translate(-50%,-50%); width:360px; background:var(--panel); padding:18px; border-radius:12px; box-shadow:0 18px 60px rgba(12,30,70,0.18); z-index:120; }
.modal .hint { font-size:13px; color:var(--muted); margin-bottom:8px; }
.modal input, .modal select { width:100%; padding:10px;border-radius:8px;border:1px solid rgba(0,0,0,0.08); margin-bottom:10px; font-size:14px; }
.modal-actions { display:flex; gap:8px; justify-content:flex-end; margin-top:8px; }
.primary { background:var(--primary); color:#fff; border:none; padding:10px 12px; border-radius:8px; cursor:pointer; font-weight:600; }
.secondary { background:#f2f4f8; color:#111; border:1px solid rgba(0,0,0,0.06); padding:10px 12px; border-radius:8px; cursor:pointer; }

/* small responsive */
@media (max-width: 1100px) {
  #toolbar { width: 260px; padding:16px; }
  .modal { width:320px; }
}
@media (max-width: 820px) {
  /* stack vertically on small screens */
  .tool-wrapper { flex-direction:column; }
  #toolbar { width:100%; height:auto; display:flex; flex-wrap:wrap; gap:10px; order:2; }
  #canvas-area { order:1; height:60vh; }
  #measureCanvas { width:100%; height:100%; border-radius:8px; }
}

/* accessibility focus */
.tool-btn:focus, .primary:focus, .secondary:focus { outline: 3px solid rgba(46,91,255,0.15); outline-offset:2px; }

/* Export button states */
.tool-btn[aria-disabled="true"] { opacity:0.5; pointer-events:none; }
