body { 
  font-family: system-ui, sans-serif; 
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

/* Welcome Screen Styles */
#welcomeScreen {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding-top: 100px;
}

.welcome-content {
  text-align: center;
  width: 100%;
  padding: 0 20px;
}

.welcome-content h2 {
  color: #345;
  margin-bottom: 20px;
  font-size: 32px;
}

.welcome-content p {
  color: #567;
  font-size: 18px;
  margin-bottom: 30px;
}

.welcome-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-top: 30px;
}

.welcome-btn {
  padding: 12px 24px;
  font-size: 16px;
  background: #4a90e2;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  min-width: 150px;
}

.welcome-btn:hover {
  background: #3a7bc8;
}

/* Main App Container */
#mainApp {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* Header Styles */
header { 
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: white;
  border-bottom: 1px solid #ddd;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0; /* Prevent header from shrinking */
  min-height: 48px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap; /* Allow wrapping on very small screens */
}

.header-right {
  position: relative;
}

/* Catalog Name Display */
.catalog-name-container {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-left: 1px solid #ddd;
  border-right: 1px solid #ddd;
}

.catalog-name {
  font-weight: 600;
  color: #345;
  font-size: 14px;
}

.edit-catalog-name {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
  font-size: 14px;
}

.edit-catalog-name:hover {
  opacity: 1;
}

.catalog-name-input {
  padding: 4px 8px;
  border: 1px solid #4a90e2;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #345;
  background: white;
}

.sidebar-toggle {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  color: #333;
  display: none; /* Hidden by default, shown on mobile */
}

#saveBtn {
  padding: 8px 16px;
  background: #4a90e2;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

#saveBtn:hover {
  background: #3a7bc8;
}

/* Hamburger Menu Styles */
.hamburger {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 20px;
  cursor: pointer;
  color: #333;
}

.hamburger:hover {
  background: #f0f0f0;
}

/* Dropdown Menu */
.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  min-width: 150px;
  z-index: 1000;
}

.dropdown-menu.show {
  display: block;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: #333;
}

.menu-item:hover {
  background: #f0f0f0;
}

.menu-item:first-child {
  border-radius: 6px 6px 0 0;
}

.menu-item:last-child {
  border-radius: 0 0 6px 6px;
}

/* Main Container Layout */
.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar Styles */
.sidebar {
  width: 250px;
  background: #f8f9fa;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  margin-left: -250px;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #ddd;
  background: white;
}

.sidebar-header h3 {
  margin: 0 0 12px 0;
  color: #345;
  font-size: 18px;
}

.add-set-btn {
  width: 100%;
  padding: 8px;
  background: #4a90e2;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.add-set-btn:hover {
  background: #3a7bc8;
}

.sets-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.set-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 4px;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.set-item:hover {
  background: #e9ecef;
}

.set-item.active {
  background: #4a90e2;
  color: white;
}

.set-name {
  flex: 1;
  font-size: 14px;
}

.set-delete {
  background: none;
  border: none;
  color: #999;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.6;
}

.set-delete:hover {
  opacity: 1;
  color: #dc3545;
}

.set-item.active .set-delete {
  color: white;
}

/* Content Area */
.content-area {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Stamp List */
.stamp-list {
  width: 300px;
  border-right: 1px solid #ddd;
  overflow-y: auto;
  background: white;
}

.stamp-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  transition: background 0.2s;
  position: relative;
}

.stamp-item:hover {
  background: #f8f9fa;
}

.stamp-item.active {
  background: #e7f3ff;
}

.stamp-item-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.stamp-list-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  flex-shrink: 0;
}

.empty-thumb {
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-thumb::after {
  content: '';
  width: 24px;
  height: 24px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23999" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="M21 15l-5-5L5 21"/></svg>') center no-repeat;
  background-size: contain;
  opacity: 0.3;
}

.stamp-summary {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.stamp-summary strong {
  color: #234;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stamp-summary span {
  color: #678;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stamp-delete {
  background: none;
  border: none;
  color: #999;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.stamp-item:hover .stamp-delete {
  opacity: 0.6;
}

.stamp-delete:hover {
  opacity: 1;
  color: #dc3545;
}

.condition {
  color: #28a745;
  font-weight: 500;
}

.no-stamps {
  padding: 20px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

/* Form Styles */
#stampForm {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: white;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 12px;
}

.form-header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 2px solid #eee;
}

.form-header h3 {
  margin: 0;
  color: #345;
}

.new-stamp-btn {
  padding: 6px 12px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.new-stamp-btn:hover {
  background: #218838;
}

form label { 
  color: #234; 
  font-weight: 600; 
  align-self: center; 
}

form input, 
form textarea, 
form select { 
  padding: 8px; 
  border: 1px solid #ccd; 
  border-radius: 6px; 
}

form textarea {
  min-height: 60px;
  resize: vertical;
}

.row { 
  grid-column: 1 / -1; 
}

.thumb { 
  max-width: 220px; 
  border: 1px solid #ccc; 
  padding: 4px; 
  background: #fff;
  display: block;
  margin-bottom: 10px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.thumb:hover {
  opacity: 0.9;
}

.image-delete-btn {
  padding: 6px 12px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 8px;
}

.image-delete-btn:hover {
  background: #c82333;
}

/* Lightbox styles */
.lightbox {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  animation: fadeIn 0.3s;
  cursor: pointer;
}

.lightbox.show {
  display: flex;
  justify-content: center;
  align-items: center;
}

.lightbox-content {
  max-width: 90%;
  max-height: 90%;
  animation: zoomIn 0.3s;
  cursor: default;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 2001;
}

.lightbox-close:hover {
  color: #bbb;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes zoomIn {
  from { transform: scale(0.8); }
  to { transform: scale(1); }
}

/* Custom Fields Section */
.custom-fields-section {
  grid-column: 1 / -1;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid #eee;
}

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

.section-header h4 {
  margin: 0;
  color: #345;
  font-size: 16px;
}

.add-field-btn {
  padding: 4px 10px;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.add-field-btn:hover {
  background: #5a6268;
}

.custom-fields {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 12px;
}

.muted { 
  color: #678; 
  font-size: 12px; 
}

/* Responsive Design */
@media (max-width: 768px) {
  /* Reduce overall size on mobile */
  body {
    font-size: 14px;
  }
  
  header {
    padding: 8px 12px;
    min-height: 44px;
  }
  
  .sidebar-toggle {
    display: block;
    padding: 6px 8px;
    font-size: 16px;
  }
  
  #saveBtn {
    padding: 6px 10px;
    font-size: 13px;
  }
  
  .hamburger {
    padding: 6px 10px;
    font-size: 18px;
  }
  
  .catalog-name-container {
    padding: 0 8px;
  }
  
  .catalog-name {
    font-size: 13px;
  }
  
  /* Main container properly accounts for header */
  .main-container {
    height: calc(100vh - 44px);
    overflow: hidden;
  }
  
  .sidebar {
    position: fixed;
    height: 100vh;
    top: 0;
    left: 0;
    z-index: 50;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    overflow-y: auto;
    width: 260px;
  }
  
  .sidebar.collapsed {
    transform: translateX(-100%);
    margin-left: 0;
  }
  
  .sidebar-header {
    padding: 12px;
  }
  
  .sidebar-header h3 {
    font-size: 16px;
    margin: 0 0 10px 0;
  }
  
  .add-set-btn {
    padding: 6px;
    font-size: 13px;
  }
  
  .set-item {
    padding: 8px 10px;
    font-size: 13px;
  }
  
  /* Add close button for mobile */
  .sidebar-header::after {
    content: '×';
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    display: block;
  }
  
  /* Hide stamp list on mobile - we'll show it differently */
  .stamp-list {
    display: none;
  }
  
  /* Mobile stamp list modal */
  .stamp-list.mobile-view {
    display: block;
    position: fixed;
    top: 44px; /* Account for header height */
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background: white;
    z-index: 45;
    border: none;
    overflow-y: auto;
    padding: 12px;
  }
  
  .stamp-item {
    padding: 10px 12px;
  }
  
  .stamp-list-thumb {
    width: 40px;
    height: 40px;
  }
  
  .stamp-summary strong {
    font-size: 13px;
  }
  
  .stamp-summary span {
    font-size: 11px;
  }
  
  .content-area {
    flex-direction: column;
    width: 100%;
    height: calc(100vh - 44px); /* Account for header */
    overflow: hidden;
  }
  
  #stampForm {
    grid-template-columns: 1fr;
    height: 100%;
    overflow-y: auto;
    padding: 12px;
    width: 100%;
  }
  
  .form-header h3 {
    font-size: 16px;
  }
  
  .new-stamp-btn {
    padding: 5px 10px;
    font-size: 12px;
  }
  
  form label {
    font-size: 13px;
    margin-bottom: 4px;
    font-weight: 500;
  }
  
  form input, 
  form textarea, 
  form select {
    padding: 6px 8px;
    font-size: 14px;
  }
  
  .custom-fields-section h4 {
    font-size: 14px;
  }
  
  .add-field-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
  
  .custom-fields {
    grid-template-columns: 1fr;
  }
  
  /* Add overlay when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 49;
  }
  
  .sidebar-overlay.show {
    display: block;
  }
  
  /* Smaller status text */
  .muted {
    font-size: 11px;
  }
  
  /* Hide catalog name on very small screens */
  @media (max-width: 480px) {
    .catalog-name-container {
      display: none;
    }
  }
}

/* Desktop only - hide mobile elements */
@media (min-width: 769px) {
  .stamp-list.mobile-view {
    display: none !important;
  }
}