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

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

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

/* ヘッダー */
header {
  background: #2196F3;
  color: white;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  text-align: center;
}

header h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
}

/* セクション共通 */
section {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: #2196F3;
}

/* フォーム */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #555;
}

.required {
  color: #e53935;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2196F3;
}

.form-group textarea {
  resize: vertical;
}

.btn-add {
  width: 100%;
  padding: 12px;
  background: #2196F3;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.2s;
}

.btn-add:hover {
  background: #1976D2;
}

/* フィルター */
.filter-section {
  padding: 14px 20px;
}

.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-row input[type="text"] {
  flex: 1;
  min-width: 160px;
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
}

.filter-row select {
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
}

/* 近日受診 */
.upcoming-section {
  background: #fff8e1;
  border: 1px solid #ffe082;
}

.upcoming-section h2 {
  color: #f57f17;
}

#upcoming-list {
  list-style: none;
}

.upcoming-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #ffe082;
  font-size: 0.9rem;
}

.upcoming-item:last-child {
  border-bottom: none;
}

.upcoming-hospital {
  font-weight: 600;
}

.upcoming-days {
  font-size: 0.8rem;
  color: #e65100;
  font-weight: 700;
}

/* 一覧ヘッダー */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.list-header h2 {
  margin-bottom: 0;
}

.count-badge {
  background: #e3f2fd;
  color: #1565c0;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}

/* 記録リスト */
.record-list {
  list-style: none;
}

.empty-message {
  text-align: center;
  color: #aaa;
  padding: 32px 0;
  font-size: 0.9rem;
}

.record-item {
  border: 1px solid #e8eaf6;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
  position: relative;
}

.record-item:hover {
  box-shadow: 0 2px 8px rgba(33,150,243,0.15);
  border-color: #90caf9;
}

.record-item.has-next {
  border-left: 4px solid #ff9800;
}

.record-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.record-hospital {
  font-size: 1rem;
  font-weight: 700;
  color: #1565c0;
}

.record-date {
  font-size: 0.8rem;
  color: #888;
  white-space: nowrap;
}

.record-summary {
  font-size: 0.85rem;
  color: #555;
  margin-top: 6px;
  line-height: 1.5;
}

.record-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.tag-medicine {
  background: #e8f5e9;
  color: #2e7d32;
}

.tag-next {
  background: #fff3e0;
  color: #e65100;
}

.btn-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: #ccc;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.2s, background 0.2s;
  display: none;
}

.record-item:hover .btn-delete {
  display: block;
}

.btn-delete:hover {
  color: #e53935;
  background: #ffebee;
}

/* モーダル */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content {
  background: white;
  border-radius: 14px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
}

.modal-hospital {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1565c0;
  margin-bottom: 4px;
}

.modal-date {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 16px;
}

.modal-field {
  margin-bottom: 14px;
}

.modal-field-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.modal-field-value {
  font-size: 0.95rem;
  color: #333;
  white-space: pre-wrap;
  line-height: 1.6;
}

.modal-next {
  background: #fff3e0;
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 16px;
  font-size: 0.9rem;
}

.modal-next-label {
  font-weight: 700;
  color: #e65100;
}

/* レスポンシブ */
@media (max-width: 500px) {
  header h1 {
    font-size: 1.2rem;
  }

  .filter-row {
    flex-direction: column;
  }

  .filter-row select {
    width: 100%;
  }
}
