.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  left: unset;
  height: 100%;
  width: 250px;
  background: var(--bg-color);
  border: none;
  border-left: 2px solid transparent;
  border-image: linear-gradient(to bottom, var(--white), var(--blue-start)) 1;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1000;
}
.sidebar.open {
  transform: translateX(0);
}

/* New header for sidebar content */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem; /* Adjust padding as needed */
  /* Optional: Add a subtle separator at the bottom */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1); 
}

.sidebar-close {
  /* Removed absolute positioning */
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-color);
  cursor: pointer;
  padding: 0.5rem; /* Add padding for easier clicking */
}

.sidebar-list {
  list-style: none;
  padding: 2rem 1rem;
  margin: 0;
}
.sidebar-link {
  display: block;
  color: var(--text-color);
  text-decoration: none;
  padding: 0.5rem 0;
}
.sidebar-link:focus,
.sidebar-link:hover {
  outline: none;
  text-decoration: underline;
}

.sidebar-link.ai-studio-link {
  background: linear-gradient(135deg, var(--blue-start), var(--white));
  color: var(--bg-color);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  font-weight: 600;
  text-align: center;
  transition: all 0.3s ease;
}

.sidebar-link.ai-studio-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(110, 193, 228, 0.3);
}

.sidebar-chat-item {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  overflow: hidden;
}

.sidebar-chat-button {
  flex-grow: 1;
  background: transparent;
  border: none;
  color: var(--text-color);
  text-align: right;
  padding: 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s ease;
}

.sidebar-chat-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-delete-button {
  background: transparent;
  border: none;
  color: #ff4444;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
  border-radius: 4px;
  margin: 0.25rem;
}

.sidebar-delete-button:hover {
  background: rgba(255, 68, 68, 0.1);
}

.sidebar-delete-button:focus {
  outline: 2px solid #ff4444;
  outline-offset: 2px;
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out;
  z-index: 900;
  pointer-events: none;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Bottom sheet styles */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  max-height: 50%;
  background: var(--bg-color);
  border-top: 2px solid var(--blue-start);
  transform: translateY(100%);
  transition: transform 0.3s ease-out;
  z-index: 1000;
  touch-action: none;
}
.bottom-sheet.open {
  transform: translateY(0);
}
.bottom-sheet.dragging {
  transition: none;
}
.bottom-sheet.expanded {
  max-height: 100vh;
  height: 100vh;
  width: 100vw;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /* Remove any styles that might hide the header */
}

.bottom-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  cursor: grab;
  position: relative;
  /* Ensure header stays visible in all states */
  flex-shrink: 0;
  z-index: 1001;
  min-height: 60px;
}

.bottom-sheet-header:active {
  cursor: grabbing;
}

.bottom-sheet-header::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

.bottom-sheet-title {
  color: var(--text-color);
  font-size: 1.25rem;
  font-weight: 600;
  flex-grow: 1;
  margin: 0;
}
.bottom-sheet-close {
  background: transparent;
  border: none;
  color: var(--text-color);
  font-size: 1.5rem;
  cursor: pointer;
  /* Make close button always visible with proper sizing */
  opacity: 1;
  visibility: visible;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
  /* Ensure consistent behavior across all input methods */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.bottom-sheet-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.bottom-sheet-close:focus {
  outline: 2px solid var(--blue-start);
  outline-offset: 2px;
}

/* Add active state for better touch feedback */
.bottom-sheet-close:active {
  background: rgba(255, 255, 255, 0.2);
}

.bottom-sheet-list {
  list-style: none;
  padding: 1rem;
  margin: 0;
}
.bottom-sheet-link {
  display: block;
  color: var(--text-color);
  text-decoration: none;
  padding: 0.5rem 0;
}
.bottom-sheet-content {
  padding: 1rem;
  flex-grow: 1;
  overflow-y: auto;
  /* Ensure content doesn't overlap header */
  flex-shrink: 1;
}

.toggle-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.toggle-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.toggle-button {
  background: var(--bg-color);
  border: 2px solid var(--blue-start);
  border-radius: 12px;
  width: 100%;
  min-height: 60px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  gap: 1rem;
  padding: 1rem;
}

.toggle-button:hover {
  background: rgba(110, 193, 228, 0.1);
  border-color: var(--white);
}

.toggle-button:focus {
  outline: 2px solid var(--blue-start);
  outline-offset: 2px;
}

.toggle-button.active {
  border-color: var(--white);
  background: rgba(110, 193, 228, 0.2);
}

.toggle-button.active::after {
  content: '✓';
  position: absolute;
  top: -5px;
  right: 10px;
  background: var(--white);
  color: var(--bg-color);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

.toggle-button svg {
  width: 24px;
  height: 24px;
  stroke: var(--white);
  fill: none;
  flex-shrink: 0;
}

.toggle-label {
  color: var(--text-color);
  font-size: 1rem;
  text-align: right;
  font-weight: 500;
  margin: 0;
  flex-grow: 1;
}

.bottom-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
  z-index: 900;
}
.bottom-sheet-overlay.active {
  opacity: 1;
  visibility: visible;
}