* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
}

#app {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

/* Login */
#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 20px;
}

#login-screen h1 {
  font-size: 2.5rem;
  color: #2c3e50;
}

#login-form {
  display: flex;
  gap: 10px;
}

#login-form input {
  padding: 12px 16px;
  font-size: 16px;
  border: 2px solid #ddd;
  border-radius: 8px;
  width: 280px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 2px solid #ddd;
  margin-bottom: 24px;
}

header h1 {
  font-size: 1.8rem;
  color: #2c3e50;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

#current-user {
  font-weight: 600;
  color: #7f8c8d;
}

/* Buttons */
.btn-primary {
  padding: 10px 20px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.btn-primary:hover {
  background: #2980b9;
}

.btn-secondary {
  padding: 8px 16px;
  background: #ecf0f1;
  color: #2c3e50;
  border: 1px solid #bdc3c7;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-secondary:hover {
  background: #d5dbdb;
}

.btn-small {
  padding: 6px 12px;
  background: transparent;
  color: #7f8c8d;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.btn-small:hover {
  background: #ecf0f1;
}

.btn-danger {
  padding: 6px 12px;
  background: transparent;
  color: #e74c3c;
  border: 1px solid #e74c3c;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.btn-danger:hover {
  background: #fdecea;
}

/* Sections */
.section {
  margin-bottom: 24px;
}

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

.section-header h2 {
  font-size: 1.4rem;
  color: #2c3e50;
}

/* Lists */
#lists-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-card {
  background: white;
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.list-card:hover {
  border-color: #3498db;
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
}

.list-card.active {
  border-color: #3498db;
  background: #ebf5fb;
}

.list-card-name {
  font-size: 1.1rem;
  font-weight: 500;
}

.list-card-meta {
  font-size: 0.85rem;
  color: #95a5a6;
}

.list-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Join section */
.join-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

#join-form {
  display: flex;
  gap: 8px;
}

#share-code {
  padding: 10px 14px;
  font-size: 14px;
  border: 2px solid #ddd;
  border-radius: 6px;
  flex: 1;
  text-transform: uppercase;
}

/* Items section */
#items-section {
  margin-top: 24px;
}

.list-actions {
  display: flex;
  gap: 8px;
}

/* Add item */
.add-item {
  margin-bottom: 20px;
}

#add-item-form {
  display: flex;
  gap: 8px;
}

.autocomplete-wrapper {
  position: relative;
  flex: 1;
}

#item-name {
  padding: 12px 16px;
  font-size: 15px;
  border: 2px solid #ddd;
  border-radius: 8px;
  width: 100%;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 8px 8px;
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.autocomplete-list.visible {
  display: block;
}

.autocomplete-list li {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
}

.autocomplete-list li:hover {
  background: #ebf5fb;
}

/* Items */
#items-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.item-card {
  background: white;
  border-radius: 8px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #eee;
}

.item-card.done {
  opacity: 0.6;
  background: #f9f9f9;
}

.item-checkbox {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-size: 22px;
}

.item-name {
  flex: 1;
  font-size: 15px;
}

.item-card.done .item-name {
  text-decoration: line-through;
  color: #95a5a6;
}

.item-meta {
  font-size: 0.8rem;
  color: #95a5a6;
  white-space: nowrap;
}

/* Share code display */
#share-code-display {
  margin-top: 16px;
  padding: 16px;
  background: #ebf5fb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Members modal */
#members-modal {
  margin-top: 16px;
  padding: 16px;
  background: white;
  border-radius: 8px;
  border: 1px solid #ddd;
}

#members-modal h3 {
  margin-bottom: 12px;
  color: #2c3e50;
}

#members-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#members-list li {
  padding: 8px 12px;
  background: #f9f9f9;
  border-radius: 6px;
  font-size: 14px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #2c3e50;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  animation: fadeInOut 2s ease-in-out;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(10px); }
}

/* Responsive */
@media (max-width: 600px) {
  #app {
    padding: 12px;
  }

  header h1 {
    font-size: 1.3rem;
  }

  .section-header {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }

  #add-item-form {
    flex-direction: column;
  }

  .list-actions {
    flex-wrap: wrap;
  }

  #login-form {
    flex-direction: column;
  }

  #login-form input {
    width: 100%;
  }
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
}

#history-page-info {
  font-size: 14px;
  color: #7f8c8d;
  min-width: 60px;
  text-align: center;
}

#history-list li {
  padding: 10px 12px;
  background: #f9f9f9;
  border-radius: 6px;
  font-size: 14px;
  border-left: 3px solid #3498db;
}

#register-btn {
  margin-top: 8px;
  width: 100%;
}
