:root {
  --primary: #4a90e2;
  --primary-dark: #3a7bc8;
  --bg: #f0f4f8;
  --card: #ffffff;
  --text: #333;
  --text-muted: #666;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

header {
  background: var(--primary);
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  font-weight: 700;
}

#installBtn {
  background: white;
  color: var(--primary);
  border: none;
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}

#installBtn:hover { background: #f5f5f5; }

main {
  padding: 1.25rem 1rem 2rem;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.add-task {
  background: var(--card);
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
  color: #444;
}

.field input {
  width: 100%;
  padding: 0.85rem 0.9rem;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 1rem;
  background: #fafafa;
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

.datetime-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

#addBtn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.95rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  margin-top: 0.25rem;
  transition: background 0.2s;
}

#addBtn:hover { background: var(--primary-dark); }

.tasks h2 {
  margin-bottom: 1rem;
  font-size: 1.35rem;
}

#calendar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.week-row {
  display: grid;
  gap: 0.6rem;
}

.week-row.mon-thu { grid-template-columns: repeat(4, 1fr); }
.week-row.fri-sun { grid-template-columns: repeat(3, 1fr); }

.day-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  min-height: 120px;
  display: flex;
  flex-direction: column;
}

.day-header {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
  color: var(--primary);
  border-bottom: 1px solid #eee;
  padding-bottom: 0.3rem;
}

.day-number {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.day-tasks {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.day-task {
  background: #f0f7ff;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.3rem;
}

.day-task-time { color: var(--primary); font-weight: 600; font-size: 0.8rem; }
.day-task-text { flex: 1; word-break: break-word; }

.delete-btn {
  background: #ff4d4d;
  color: white;
  border: none;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* Mobile: stack days vertically */
@media (max-width: 700px) {
  .week-row {
    grid-template-columns: 1fr !important;
  }
  .day-card { min-height: auto; }
}

@media (min-width: 701px) {
  #calendar { gap: 1rem; }
}

/* Mobile first adjustments */
@media (max-width: 600px) {
  .datetime-row {
    grid-template-columns: 1fr;
  }
  header {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  #installBtn {
    width: 100%;
  }
  main { padding: 1rem 0.75rem 2rem; }
  .add-task { padding: 1rem; }
}

@media (min-width: 900px) {
  main { padding-top: 2rem; }
  .add-task { padding: 1.5rem; }
}