/* ベースリセット */
* {
  box-sizing: border-box;
}

body {
  font-family: "Yu Gothic", "Segoe UI", Tahoma, sans-serif;
  background-color: #fdf6e3;
  color: #333;
  margin: 0;
  padding: 1rem;
  transition: background-color 0.3s, color 0.3s;
}

@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #eee;
  }
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

header h1 {
  flex-grow: 1;
  font-size: 1.5rem;
}

button {
  cursor: pointer;
  background-color: #4c6cb3;
  border: none;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 1rem;
  transition: background-color 0.3s;
}

button:hover,
button:focus {
  background-color: #3a53a1;
  outline: none;
}

button:disabled {
  background-color: #999;
  cursor: default;
}

main {
  max-width: 600px;
  margin: 0 auto;
}

#todo-list-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.todo-date-block {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 0.75rem;
  background-color: #fff8dc;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.3s, border-color 0.3s;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.todo-date-block:focus,
.todo-date-block:hover {
  background-color: #dce4f7;
  border-color: #4c6cb3;
  outline: none;
}

.todo-date-block h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  color: #4c6cb3;
}

.todo-item {
  font-size: 0.95rem;
  color: #555;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  white-space: pre-wrap;
}

.todo-item.empty {
  font-style: italic;
  color: #999;
}

/* ダークモード */
@media (prefers-color-scheme: dark) {
  .todo-date-block {
    background-color: #2a2a2a;
    border-color: #555;
  }
  .todo-date-block:focus,
  .todo-date-block:hover {
    background-color: #3f4a8a;
    border-color: #7a8fd0;
  }
  .todo-date-block h4 {
    color: #a3b1ff;
  }
  .todo-item {
    color: #ccc;
  }
  .todo-item.empty {
    color: #666;
  }
}

/* モーダル */
.modal-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal-bg[hidden] {
  display: none;
}

.modal {
  background-color: #fff;
  color: #333;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  max-width: 400px;
  width: 90vw;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: background-color 0.3s, color 0.3s;
}

@media (prefers-color-scheme: dark) {
  .modal {
    background-color: #222;
    color: #eee;
  }
}

.modal label {
  display: block;
  margin: 0.5rem 0 1rem 0;
}

.modal input[type="date"],
.modal input[type="time"],
.modal textarea {
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 1px solid #999;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  color: inherit;
  background-color: #fff;
  transition: border-color 0.3s;
}

@media (prefers-color-scheme: dark) {
  .modal input[type="date"],
  .modal input[type="time"],
  .modal textarea {
    background-color: #333;
    border-color: #666;
    color: #eee;
  }
}

.modal textarea {
  resize: vertical;
  min-height: 70px;
}

.modal-buttons {
  text-align: right;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-buttons button {
  background-color: #4c6cb3;
  color: white;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 1rem;
  transition: background-color 0.3s;
}

.modal-buttons button:hover,
.modal-buttons button:focus {
  background-color: #3a53a1;
  outline: none;
}

.modal-buttons button:active {
  background-color: #2e427a;
}
