:root {
    --bg: #111827;
    --surface: #1f2937;
    --surface-light: #273449;
    --primary: #60a5fa;
    --primary-muted: #3b82f6;
    --danger: #f87171;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --handle: #fbbf24;
    --canvas-bg: #0f172a;
    --crosshair: #f9fafb;
    --crosshairActive: #facc15;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
}

.app {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid #1f2937;
    gap: 1rem;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

button {
    border: none;
    border-radius: 4px;
    padding: 0.45rem 0.85rem;
    background: var(--surface-light);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

button:hover {
    background: var(--primary-muted);
}

button.active {
    background: var(--primary);
    color: #0f172a;
}
button.recording {
    background: #ef4444; /* Red color for Capture button to show it is live */
    color: #fff;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

#confirmCalibrationBtn {
    background: #2dd4bf;
    color: #0f172a;
}

#confirmCalibrationBtn:hover {
    background: #14b8a6;
}

#clearCalibrationBtn {
    background: #facc15;
    color: #0f172a;
}

#clearCalibrationBtn:hover {
    background: #eab308;
}

#deleteSelectionBtn {
    background: var(--danger);
    color: #0f172a;
}

#deleteSelectionBtn:hover {
    background: #ef4444;
}

label {
    font-size: 0.85rem;
    color: var(--muted);
}

#unitInput,
#calibrationLengthInput {
    margin-left: 0.35rem;
    width: 6rem;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--surface-light);
    background: var(--surface-light);
    color: var(--text);
}

#scaleDisplay {
    margin-left: 1rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.canvas-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--canvas-bg);
    border-right: 1px solid #1f2937;
    position: relative;
}

#measurementCanvas {
    background: #000;
    max-width: 100%;
    max-height: 100%;
    border: 1px solid #1f2937;
    cursor: none;
    touch-action: none;
}

.crosshair {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: none;
}

.crosshair.active {
    display: block;
}

.crosshair-vertical,
.crosshair-horizontal {
    position: absolute;
    background: var(--crosshair);
}

.crosshair.hover .crosshair-vertical,
.crosshair.hover .crosshair-horizontal {
    background: var(--crosshairActive);
}

.crosshair-vertical {
    width: 2px;
    height: 100%;
    top: 0;
    transform: translateX(-1px);
}

.crosshair-horizontal {
    height: 2px;
    width: 100%;
    left: 0;
    transform: translateY(-1px);
}

.sidebar {
    width: 320px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
    overflow-y: auto;
}

.panel h2 {
    font-size: 1rem;
    margin: 0 0 0.5rem 0;
    color: var(--text);
}

.panel ol {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--muted);
}

.panel li {
    margin-bottom: 0.35rem;
}

ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#measurementList li,
#calibrationList li {
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    background: var(--surface-light);
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    border: 1px solid transparent;
}

#measurementList li.active {
    border-color: var(--primary);
}

#measurementList li:hover,
#calibrationList li:hover {
    background: var(--primary-muted);
}

.empty-state {
    font-size: 0.85rem;
    color: var(--muted);
    padding: 0.35rem 0;
}

@media (max-width: 1100px) {
    .sidebar {
        width: 260px;
    }
}

@media (max-width: 900px) {
    .content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 35vh;
    }

    .canvas-area {
        min-height: 65vh;
    }
}
 
 . c a m e r a - c o n t r o l s   {  
         d i s p l a y :   f l e x ;  
         f l e x - d i r e c t i o n :   c o l u m n ;  
         g a p :   0 . 7 5 r e m ;  
 }  
  
 . c o n t r o l - g r o u p   {  
         d i s p l a y :   f l e x ;  
         f l e x - d i r e c t i o n :   c o l u m n ;  
         g a p :   0 . 2 5 r e m ;  
 }  
  
 . c o n t r o l - g r o u p   l a b e l   {  
         d i s p l a y :   f l e x ;  
         j u s t i f y - c o n t e n t :   s p a c e - b e t w e e n ;  
         c o l o r :   v a r ( - - t e x t ) ;  
 }  
  
 . c o n t r o l - g r o u p   i n p u t [ t y p e = " r a n g e " ]   {  
         w i d t h :   1 0 0 % ;  
         c u r s o r :   p o i n t e r ;  
 }  
  
 . c o n t r o l - g r o u p   s e l e c t   {  
         b a c k g r o u n d :   v a r ( - - s u r f a c e - l i g h t ) ;  
         c o l o r :   v a r ( - - t e x t ) ;  
         b o r d e r :   1 p x   s o l i d   v a r ( - - s u r f a c e - l i g h t ) ;  
         p a d d i n g :   0 . 2 5 r e m ;  
         b o r d e r - r a d i u s :   4 p x ;  
 }  
  
 / *   S i d e b a r   C o n t r o l s   * /  
 . s i d e b a r   . c o n t r o l - g r o u p   {  
         m a r g i n - b o t t o m :   0 . 7 5 r e m ;  
 }  
  
 . s i d e b a r   l a b e l   {  
         d i s p l a y :   b l o c k ;  
         m a r g i n - b o t t o m :   0 . 2 5 r e m ;  
         c o l o r :   v a r ( - - m u t e d ) ;  
 }  
  
 . s i d e b a r   i n p u t [ t y p e = " t e x t " ] ,  
 . s i d e b a r   i n p u t [ t y p e = " n u m b e r " ]   {  
         w i d t h :   1 0 0 % ;  
         p a d d i n g :   0 . 4 5 r e m ;  
         b a c k g r o u n d :   v a r ( - - s u r f a c e - l i g h t ) ;  
         b o r d e r :   1 p x   s o l i d   v a r ( - - s u r f a c e - l i g h t ) ;  
         c o l o r :   v a r ( - - t e x t ) ;  
         b o r d e r - r a d i u s :   4 p x ;  
         f o n t - s i z e :   0 . 9 r e m ;  
 }  
  
 . b u t t o n - r o w   {  
         d i s p l a y :   f l e x ;  
         g a p :   0 . 5 r e m ;  
 }  
  
 . b u t t o n - r o w   b u t t o n   {  
         f l e x :   1 ;  
 }  
  
 . s e p a r a t o r   {  
         w i d t h :   1 p x ;  
         h e i g h t :   1 . 5 r e m ;  
         b a c k g r o u n d :   # 3 7 4 1 5 1 ;  
         m a r g i n :   0   0 . 2 5 r e m ;  
 }  
 