body {
  margin: 0;
  overflow: hidden;
  font-family: 'Segoe UI', sans-serif;
  background-color: #121212;
  color: white;
}

[data-theme="light"] body {
  background-color: white;
  color: black;
}

.toolbar {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: rgba(18, 18, 18, 0.17);
  padding: 8px 16px;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;  /* 👈 important: align to left */
  align-items: center;
  gap: 8px;
  padding: 10px;
  width: 100%;
  box-sizing: border-box;
}

[data-theme="light"] .toolbar {
  background: rgba(255, 255, 255, 0.95);
  color: black;
}

.tool {
  font-size: 1.2rem;
  padding: 8px 12px;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  min-width: 40px;
  min-height: 40px;
}

.tool:hover {
  background: rgba(100, 100, 100, 0.1);
}

.tool.active {
  box-shadow: 0 0 0 3px #5a5aff;
}

.tool-options {
  display: none;
  flex-direction: column;
  background: rgba(18, 18, 18, 0.95);
  padding: 6px;
  border-radius: 6px;
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
}

[data-theme="light"] .tool-options {
  background: rgba(255, 255, 255, 0.9);
  color: black;
}

.tool-options label {
  margin: 5px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
}

.color-swatch:hover {
  border: 2px solid #5a5aff;
}

#canvas-container {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  cursor: crosshair;
}

#drawingCanvas {
  width: 100%;
  height: 100%;
  background-image: radial-gradient(#ffffff22 1px, transparent 0);
  background-size: 25px 25px;
  touch-action: none;
}

[data-theme="light"] #drawingCanvas {
  background-image: radial-gradient(#00000022 1px, transparent 0);
}

footer {
  position: fixed;
  bottom: 10px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  color: inherit;
  font-size: 0.9rem;
}

footer a {
  color: inherit;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  .toolbar {
    gap: 6px;
  }
}

body.keyboard-open #canvas-container {
  transform: translateY(-100px); /* Push canvas up temporarily */
  transition: transform 0.3s ease;
}

/* Size Preview Circle */
.size-preview {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  border: 2px dashed rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  transition: width 0.1s ease, height 0.1s ease;
}

[data-theme="light"] .size-preview {
  border-color: rgba(0, 0, 0, 0.7);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}

/* Tool-specific preview styles */
.size-preview.pen {
  background: rgba(255, 255, 255, 0.1);
}

.size-preview.eraser {
  background: rgba(255, 0, 0, 0.1);
  border-color: rgba(255, 0, 0, 0.5);
}

.size-preview.highlight {
  background: rgba(255, 255, 0, 0.2);
  border-color: rgba(255, 255, 0, 0.5);
}

.size-preview.line {
  background: rgba(0, 0, 255, 0.1);
  border-color: rgba(0, 0, 255, 0.5);
}

/* Add to existing .tool-options CSS */
.tool-options {
  /* ... existing styles ... */
  transition: all 0.2s ease;
}

/* Size input feedback */
.size-input:focus {
  outline: 2px solid #5a5aff;
}

/* Size Preview Label */
.size-preview .size-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px black;
    pointer-events: none;
    z-index: 1001;
}

[data-theme="light"] .size-preview .size-label {
    color: black;
    text-shadow: 1px 1px 2px white;
}
/* Shape tool styling */
.shapes {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  justify-content: center;
}

.shape-btn {
  width: 32px;
  height: 32px;
  border: 2px solid transparent;
  background: rgba(100, 100, 100, 0.2);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  transition: all 0.2s;
}

.shape-btn:hover {
  background: rgba(100, 100, 100, 0.4);
}

.shape-btn.active {
  border-color: #5a5aff;
  background: rgba(90, 90, 255, 0.2);
}

/* Make sure tool-options are properly styled for shapes */
.tool-options {
  max-width: 250px;
}

/* Update size preview for shapes */
.size-preview.shape {
  border: 2px solid rgba(0, 255, 255, 0.7);
  background: rgba(0, 255, 255, 0.1);
}

/* Pomodoro Timer Styles */
.pomodoro-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 320px;
}

[data-theme="light"] .pomodoro-modal {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.pomodoro-modal.active {
    display: block;
}

.pomodoro-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.pomodoro-header h3 {
    margin: 0;
    font-size: 1.2rem;
    opacity: 0.8;
}

.close-modal {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.close-modal:hover {
    background: rgba(100, 100, 100, 0.2);
}

.timer-modes {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.mode-btn {
    flex: 1;
    padding: 8px;
    border: none;
    background: rgba(100, 100, 100, 0.2);
    color: inherit;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.mode-btn.active {
    background: #5a5aff;
    color: white;
}

.timer-display-large {
    font-size: 4rem;
    font-weight: bold;
    text-align: center;
    margin: 20px 0;
    font-family: monospace;
}

.timer-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.timer-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    background: rgba(100, 100, 100, 0.2);
    color: inherit;
}

.timer-btn:hover {
    background: rgba(100, 100, 100, 0.4);
}

.start-btn {
    background: #5a5aff;
    color: white;
}

.start-btn:hover {
    background: #4a4aff;
}

.timer-settings {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 15px;
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    opacity: 0.8;
    padding: 5px;
}

.settings-header i:last-child {
    margin-left: auto;
    transition: transform 0.2s;
}

.settings-panel {
    display: none;
    padding: 15px 0;
}

.settings-panel.active {
    display: block;
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    opacity: 0.8;
}

.setting-item input {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.2);
    color: inherit;
}

.save-settings {
    width: 100%;
    padding: 8px;
    background: #5a5aff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Floating Timer */
.floating-timer {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(90, 90, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 10px 20px;
    border: 1px solid rgba(90, 90, 255, 0.5);
    z-index: 100;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.floating-timer:hover {
    background: rgba(90, 90, 255, 0.3);
    transform: scale(1.05);
}

.floating-timer.break-mode {
    background: rgba(255, 165, 0, 0.2);
    border-color: rgba(255, 165, 0, 0.5);
}

.floating-timer-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timer-mode-icon {
    font-size: 1.2rem;
}

.timer-time {
    font-size: 1.2rem;
    font-weight: bold;
    font-family: monospace;
    min-width: 70px;
}

.floating-timer button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.floating-timer button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .floating-timer {
        top: auto;
        bottom: 80px;
        right: 20px;
    }
    
    .pomodoro-modal {
        width: 90%;
        min-width: auto;
    }
    
    .timer-display-large {
        font-size: 3rem;
    }
}

/* Animation for timer completion */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.timer-complete {
    animation: pulse 1s ease infinite;
}

/* Pomodoro Timer Button */
#pomodoroBtn {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

#pomodoroBtn:hover {
    background: rgba(100, 100, 100, 0.1);
}

/* Pomodoro Modal */
.pomodoro-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 320px;
}

[data-theme="light"] .pomodoro-modal {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.pomodoro-modal.active {
    display: block;
}

.pomodoro-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.pomodoro-header h3 {
    margin: 0;
    font-size: 1.2rem;
    opacity: 0.8;
}

.close-modal {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.close-modal:hover {
    background: rgba(100, 100, 100, 0.2);
}

.timer-modes {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.mode-btn {
    flex: 1;
    padding: 8px;
    border: none;
    background: rgba(100, 100, 100, 0.2);
    color: inherit;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.mode-btn.active {
    background: #5a5aff;
    color: white;
}

.timer-display-large {
    font-size: 4rem;
    font-weight: bold;
    text-align: center;
    margin: 20px 0;
    font-family: monospace;
}

.timer-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.timer-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    background: rgba(100, 100, 100, 0.2);
    color: inherit;
}

.timer-btn:hover {
    background: rgba(100, 100, 100, 0.4);
}

.start-btn {
    background: #5a5aff;
    color: white;
}

.start-btn:hover {
    background: #4a4aff;
}

.timer-settings {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 15px;
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    opacity: 0.8;
    padding: 5px;
}

.settings-header i:last-child {
    margin-left: auto;
    transition: transform 0.2s;
}

.settings-panel {
    display: none;
    padding: 15px 0;
}

.settings-panel.active {
    display: block;
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    opacity: 0.8;
}

.setting-item input {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.2);
    color: inherit;
}

.save-settings {
    width: 100%;
    padding: 8px;
    background: #5a5aff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Floating Timer */
.floating-timer {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(90, 90, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 10px 20px;
    border: 1px solid rgba(90, 90, 255, 0.5);
    z-index: 100;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.floating-timer:hover {
    background: rgba(90, 90, 255, 0.3);
    transform: scale(1.05);
}

.floating-timer.break-mode {
    background: rgba(255, 165, 0, 0.2);
    border-color: rgba(255, 165, 0, 0.5);
}

.floating-timer-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timer-mode-icon {
    font-size: 1.2rem;
}

.timer-time {
    font-size: 1.2rem;
    font-weight: bold;
    font-family: monospace;
    min-width: 70px;
}

.floating-timer button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.floating-timer button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .floating-timer {
        top: auto;
        bottom: 80px;
        right: 20px;
    }
    
    .pomodoro-modal {
        width: 90%;
        min-width: auto;
    }
    
    .timer-display-large {
        font-size: 3rem;
    }
}

/* Animation for timer completion */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.timer-complete {
    animation: pulse 1s ease infinite;
}

/* Ensure floating timer is above everything */
.floating-timer {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(90, 90, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 10px 20px;
    border: 1px solid rgba(90, 90, 255, 0.5);
    z-index: 9999;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.floating-timer.break-mode {
    background: rgba(255, 165, 0, 0.9);
    border-color: rgba(255, 165, 0, 0.5);
}

/* Ensure modal is above everything */
.pomodoro-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    z-index: 10000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 320px;
}

.pomodoro-modal.active {
    display: block;
}
/* Floating Timer - Desktop */
.floating-timer {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(90, 90, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 10px 20px;
    border: 1px solid rgba(90, 90, 255, 0.5);
    z-index: 9999;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.floating-timer.break-mode {
    background: rgba(255, 165, 0, 0.9);
    border-color: rgba(255, 165, 0, 0.5);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .floating-timer {
        top: auto;
        bottom: 90px; /* Position above the toolbar */
        right: 10px;
        padding: 8px 15px;
        font-size: 0.9rem;
        max-width: 150px; /* Limit width on mobile */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .floating-timer-content {
        gap: 5px; /* Reduce gap between elements */
    }
    
    .timer-mode-icon {
        font-size: 1rem; /* Smaller icon */
    }
    
    .timer-time {
        font-size: 1rem; /* Smaller text */
        min-width: 60px; /* Smaller minimum width */
    }
    
    .floating-timer button {
        padding: 2px 5px; /* Smaller buttons */
        font-size: 0.8rem;
    }
    
    /* Even smaller for very small screens */
    @media (max-width: 380px) {
        .floating-timer {
            bottom: 85px;
            right: 5px;
            left: 5px; /* Take full width minus margins */
            max-width: none;
            border-radius: 30px;
        }
        
        .floating-timer-content {
            justify-content: space-between; /* Spread out content */
        }
    }
}

/* Landscape mode on mobile */
@media (max-width: 896px) and (orientation: landscape) {
    .floating-timer {
        bottom: 70px; /* Higher in landscape */
        right: 10px;
        padding: 5px 12px;
    }
    
    .timer-time {
        font-size: 0.9rem;
        min-width: 55px;
    }
}

/* Ensure modal is above everything */
.pomodoro-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    z-index: 10000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 320px;
    max-width: 90%; /* Prevent overflow on small screens */
    max-height: 90vh; /* Prevent overflow on small screens */
    overflow-y: auto; /* Allow scrolling if content too tall */
}

.pomodoro-modal.active {
    display: block;
}

/* Modal mobile optimizations */
@media (max-width: 768px) {
    .pomodoro-modal {
        width: 95%;
        min-width: auto;
        padding: 20px;
        max-height: 80vh;
    }
    
    .timer-display-large {
        font-size: 3rem;
        margin: 15px 0;
    }
    
    .timer-controls {
        flex-wrap: wrap;
    }
    
    .timer-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}