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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

header {
  background-color: #2c3e50;
  color: white;
  padding: 1.5rem 2rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

nav {
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.nav-link:hover {
  background-color: rgba(255,255,255,0.1);
}

.nav-link.active {
  background-color: #3498db;
}

main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
  min-height: calc(100vh - 200px);
}

footer {
  background-color: #2c3e50;
  color: white;
  text-align: center;
  padding: 2rem;
  margin-top: 3rem;
}

/* Placeholder styles */
.placeholder {
  text-align: center;
  padding: 3rem 1rem;
  color: #666;
}

.placeholder h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

/* Form styles */
.dream-form {
  max-width: 600px;
  margin: 2rem auto;
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #333;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group input[type="date"]:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group textarea {
  resize: vertical;
}

.form-group.checkbox label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: normal;
}

.form-group.checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.error {
  display: block;
  color: #e74c3c;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.form-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary {
  background-color: #3498db;
  color: white;
  flex: 1;
}

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

.btn-secondary {
  background-color: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background-color: #7f8c8d;
}

.btn-danger {
  background-color: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background-color: #c0392b;
}

/* List view */
.dream-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.dream-card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border-left: 4px solid #95a5a6;
  transition: transform 0.2s, box-shadow 0.2s;
}

.dream-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.dream-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.dream-card-header h3 {
  font-size: 1.25rem;
  margin: 0;
  flex: 1;
}

.mood-badge {
  font-size: 1.5rem;
  display: inline-block;
  min-width: 2rem;
  text-align: center;
}

.dream-card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: #666;
  margin-bottom: 0.75rem;
  align-items: center;
}

.lucid-badge {
  background-color: #f1c40f;
  color: #333;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.dream-card-body {
  color: #555;
  margin: 0.75rem 0;
  line-height: 1.5;
}

.dream-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.tag-chip {
  background-color: #ecf0f1;
  color: #333;
  padding: 0.25rem 0.75rem;
  border-radius: 16px;
  font-size: 0.813rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.tag-chip:hover {
  background-color: #bdc3c7;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #666;
}

.empty-state h2 {
  font-size: 1.75rem;
  margin-bottom: 1rem;
  color: #333;
}

/* Detail view */
.dream-detail {
  max-width: 800px;
  margin: 2rem auto;
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.detail-header {
  border-bottom: 2px solid #ecf0f1;
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}

.detail-title-section {
  margin-bottom: 1.5rem;
}

.detail-title-section h1 {
  margin: 0 0 0.75rem 0;
  color: #333;
}

.detail-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 1rem;
  color: #666;
  align-items: center;
}

.mood-display {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.detail-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.detail-actions .btn {
  flex: 1;
  padding: 0.75rem 1.5rem;
}

.detail-body {
  margin: 2rem 0;
  line-height: 1.8;
  color: #444;
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-body p {
  margin: 0;
}

.detail-footer-meta {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid #ecf0f1;
  margin-bottom: 1rem;
}

.detail-tags {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.detail-tags strong {
  margin-right: 0.5rem;
  color: #333;
}

.timestamps {
  display: flex;
  gap: 2rem;
  font-size: 0.813rem;
  color: #999;
  padding-top: 1rem;
  border-top: 1px solid #ecf0f1;
}

.timestamps small {
  display: block;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: #3498db;
  text-decoration: none;
  transition: color 0.2s;
}

.back-link:hover {
  color: #2980b9;
  text-decoration: underline;
}

/* List container and filters */
.list-container {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 2rem;
  margin: 2rem 0;
}

.filter-panel {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  height: fit-content;
  position: sticky;
  top: 100px;
}

.filter-group {
  margin-bottom: 1.5rem;
}

.filter-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #333;
  font-size: 0.95rem;
}

.search-box {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.95rem;
}

.search-box:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.date-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.date-inputs input {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.95rem;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: #555;
}

.filter-checkbox input {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.list-results {
  display: flex;
  flex-direction: column;
}

.result-count {
  font-size: 0.95rem;
  color: #666;
  margin-bottom: 1rem;
  font-weight: 500;
}

/* Stats view */
.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin: 2rem 0;
}

.stat-card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border-top: 4px solid #3498db;
}

.stat-card h3 {
  margin: 0 0 1rem 0;
  color: #333;
  font-size: 1.1rem;
}

.stat-number {
  grid-column: span 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 200px;
}

.stat-number h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
  color: #666;
}

.stat-value {
  font-size: 3rem;
  font-weight: bold;
}

.mood-breakdown {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mood-row {
  display: grid;
  grid-template-columns: 120px 1fr 50px;
  gap: 1rem;
  align-items: center;
}

.mood-label {
  font-size: 0.95rem;
  font-weight: 500;
}

.mood-bar {
  height: 24px;
  border-radius: 4px;
  transition: width 0.3s;
}

.mood-percent {
  text-align: right;
  font-size: 0.875rem;
  font-weight: 600;
  color: #666;
}

.month-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 200px;
  margin-top: 1rem;
}

.month-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.month-bar {
  width: 100%;
  background-color: #3498db;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: background-color 0.2s;
}

.month-bar:hover {
  background-color: #2980b9;
}

.month-label {
  font-size: 0.75rem;
  color: #666;
  text-align: center;
  width: 100%;
}

.tags-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tag-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #f5f5f5;
  border-radius: 4px;
}

.tag-name {
  font-weight: 500;
  color: #333;
}

.tag-count {
  background: #3498db;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
}

/* Settings view */
.settings-container {
  max-width: 800px;
  margin: 2rem auto;
}

.settings-container h1 {
  margin-bottom: 2rem;
}

.settings-section {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.settings-section h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  color: #333;
}

.settings-section p {
  color: #666;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.settings-section button {
  display: inline-block;
}

@media (max-width: 768px) {
  .list-container {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .filter-group {
    margin-bottom: 0;
  }

  .dream-list {
    grid-template-columns: 1fr;
  }

  .stats-container {
    grid-template-columns: 1fr;
  }

  .mood-row {
    grid-template-columns: 100px 1fr 40px;
  }
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #e0e0e0;
  }

  header {
    background-color: #1f1f1f;
  }

  .nav-link:hover {
    background-color: rgba(255,255,255,0.15);
  }

  main {
    color: #e0e0e0;
  }

  footer {
    background-color: #1f1f1f;
  }

  .dream-form,
  .dream-detail,
  .stat-card,
  .filter-panel,
  .settings-section {
    background: #2a2a2a;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  }

  .dream-card {
    background: #2a2a2a;
  }

  .form-group label,
  .filter-group label,
  .stat-card h3,
  .dream-detail h1,
  .dream-card-header h3,
  .empty-state h2,
  .settings-section h1,
  .settings-section h2 {
    color: #e0e0e0;
  }

  .form-group input[type="text"],
  .form-group input[type="date"],
  .form-group textarea,
  .form-group select,
  .search-box,
  .date-inputs input {
    background-color: #3a3a3a;
    color: #e0e0e0;
    border-color: #444;
  }

  .form-group input:focus,
  .form-group textarea:focus,
  .form-group select:focus,
  .search-box:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
  }

  .error {
    color: #ff6b6b;
  }

  .empty-state,
  .placeholder {
    color: #999;
  }

  .dream-card-meta,
  .detail-meta,
  .timestamps,
  .dream-card-body,
  .detail-body,
  .filter-checkbox,
  .settings-section p {
    color: #b0b0b0;
  }

  .tag-chip,
  .tag-item {
    background: #3a3a3a;
    color: #e0e0e0;
  }

  .tag-item {
    background: #3a3a3a;
  }

  .mood-bar {
    opacity: 0.9;
  }

  .result-count {
    color: #b0b0b0;
  }

  a,
  .back-link {
    color: #64b5f6;
  }

  a:hover,
  .back-link:hover {
    color: #90caf9;
  }

  .detail-header {
    border-bottom-color: #444;
  }

  .detail-footer-meta,
  .timestamps {
    border-top-color: #444;
  }
}
