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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Meiryo", sans-serif;
  background: #f0f4f8;
  color: #1a2533;
  font-size: 16px;
  line-height: 1.6;
}

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

header {
  background: #1565c0;
  color: white;
  text-align: center;
  padding: 20px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

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

.add-section,
.cards-section {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1565c0;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e3eaf5;
}

.form-group {
  margin-bottom: 12px;
}

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

.required {
  color: #e53935;
}

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

input[type="text"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #1565c0;
  background: white;
}

textarea {
  resize: vertical;
  min-height: 60px;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 12px;
  background: #1565c0;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.btn-primary:hover {
  background: #0d47a1;
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 12px;
  background: #e0e0e0;
  color: #333;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

.btn-secondary:hover {
  background: #bdbdbd;
}

.btn-print {
  padding: 8px 16px;
  background: #2e7d32;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-print:hover {
  background: #1b5e20;
}

.cards-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e3eaf5;
}

.cards-header h2 {
  margin: 0;
  padding: 0;
  border: none;
}

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.empty-msg {
  text-align: center;
  color: #aaa;
  padding: 24px;
  font-size: 0.95rem;
}

/* 健康情報カード */
.health-card {
  border: 2px solid #1565c0;
  border-radius: 12px;
  overflow: hidden;
}

.card-header {
  background: #1565c0;
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-name {
  font-size: 1.2rem;
  font-weight: 700;
}

.card-meta {
  font-size: 0.85rem;
  opacity: 0.9;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.btn-edit,
.btn-delete {
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 600;
}

.btn-edit {
  background: rgba(255,255,255,0.25);
  color: white;
}

.btn-edit:hover {
  background: rgba(255,255,255,0.4);
}

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

.btn-delete:hover {
  background: #b71c1c;
}

.card-body {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card-field {
  display: flex;
  flex-direction: column;
}

.card-field.full-width {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #1565c0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}

.field-value {
  font-size: 1rem;
  color: #1a2533;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.field-value.empty {
  color: #bbb;
  font-size: 0.85rem;
}

.field-value.alert {
  font-weight: 700;
  color: #c62828;
}

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

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2 {
  margin-bottom: 16px;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

/* 印刷スタイル */
@media print {
  body {
    background: white;
    font-size: 14px;
  }

  .container {
    padding: 0;
    max-width: 100%;
  }

  header {
    background: #1565c0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border-radius: 0;
    margin-bottom: 12px;
  }

  .add-section,
  .btn-print,
  .card-actions,
  .subtitle {
    display: none !important;
  }

  .cards-section {
    box-shadow: none;
    padding: 0;
  }

  .health-card {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .card-header {
    background: #1565c0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

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

  .card-body {
    grid-template-columns: 1fr;
  }

  .card-field.full-width {
    grid-column: 1;
  }
}
