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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  background: #f0f4f8;
  color: #1e293b;
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  padding: 20px 16px;
  text-align: center;
}

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

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

main {
  max-width: 700px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
}

/* フォーム */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}

.form-group input[type="text"],
.form-group input[type="date"] {
  padding: 9px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  width: 100%;
}

.form-group input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.pain-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}

.pain-scale {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.pain-label {
  font-size: 0.75rem;
  color: #94a3b8;
  white-space: nowrap;
}

input[type="range"] {
  flex: 1;
  accent-color: #3b82f6;
  height: 6px;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  padding: 11px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-primary:active {
  transform: scale(0.98);
}

/* グラフ */
.chart-container {
  position: relative;
  min-height: 150px;
}

#painChart {
  width: 100%;
  height: 160px;
  display: none;
}

/* 記録一覧 */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
}

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

.count-badge {
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-text {
  text-align: center;
  color: #94a3b8;
  font-size: 0.9rem;
  padding: 20px 0;
}

.record-item {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  position: relative;
}

.record-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.record-date {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 500;
}

.record-exercise {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  flex: 1;
}

.record-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.record-count {
  font-size: 0.85rem;
  color: #475569;
}

.pain-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
}

.pain-low {
  background: #dcfce7;
  color: #166534;
}

.pain-mid {
  background: #fef9c3;
  color: #854d0e;
}

.pain-high {
  background: #fee2e2;
  color: #991b1b;
}

.record-memo {
  font-size: 0.8rem;
  color: #64748b;
  font-style: italic;
}

.delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 1.1rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.2s;
  flex-shrink: 0;
}

.delete-btn:hover {
  color: #ef4444;
}

/* レスポンシブ */
@media (min-width: 600px) {
  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .pain-group,
  .form-group:last-child {
    grid-column: 1 / -1;
  }
}
