* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #f5f5f7;
  color: #1c1c1e;
}

#app {
  max-width: 390px;
  margin: 0 auto;
  padding: 12px;
}

h1 {
  font-size: 20px;
  margin: 8px 0 16px;
}

.add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.add-form input {
  flex: 1;
  min-width: 0;
  padding: 8px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.add-form button {
  padding: 8px 12px;
  font-size: 14px;
  border: none;
  border-radius: 6px;
  background: #007aff;
  color: #fff;
}

.add-form button:disabled {
  background: #a9a9a9;
}

.limit-message {
  color: #c00;
  font-size: 13px;
  margin: 0 0 8px;
}

.habit-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.habit-item {
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.habit-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.habit-name input {
  width: 100%;
  font-size: 14px;
  padding: 4px;
}

.habit-streak {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}

.habit-toggle {
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  background: #e5e5ea;
}

.habit-toggle.done {
  background: #34c759;
  color: #fff;
}

.habit-actions {
  display: flex;
  gap: 4px;
}

.habit-actions button {
  border: none;
  background: none;
  font-size: 14px;
  padding: 4px;
}

.history-table {
  width: 100%;
  max-width: 390px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 10px;
}

.history-table th,
.history-table td {
  text-align: center;
  padding: 4px 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-table th:first-child,
.history-table td:first-child {
  text-align: left;
  width: 32%;
}

.day-cell.done {
  color: #34c759;
}

.day-cell.missed {
  color: #d0d0d5;
}

.day-cell.none {
  color: #f0f0f2;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] {
  display: none;
}

.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  max-width: 320px;
  width: 100%;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.modal-actions .danger {
  background: #ff3b30;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
}

.modal-actions button:not(.danger) {
  background: #e5e5ea;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
}
