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

:root {
  --primary: #e57b8a;
  --primary-dark: #c95f6f;
  --primary-light: #fce8eb;
  --accent: #f5a7b0;
  --text: #333;
  --text-light: #666;
  --bg: #fdf6f7;
  --card-bg: #fff;
  --border: #f0d0d5;
  --success: #4caf6e;
  --danger: #e55a5a;
  --shadow: 0 2px 8px rgba(229,123,138,0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 2rem;
}

header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  text-align: center;
  padding: 1.5rem 1rem 1.2rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

header .subtitle {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-top: 0.3rem;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 0.85rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 0.3rem;
}

.required {
  color: var(--primary);
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--primary-light);
}

.hint {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.3rem;
}

/* プレビュー */
.preview {
  background: var(--primary-light);
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin: 0.85rem 0;
}

.preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  padding: 0.25rem 0;
  color: var(--text-light);
}

.preview-row.subtotal {
  border-top: 1px solid var(--accent);
  margin-top: 0.3rem;
  padding-top: 0.45rem;
  color: var(--text);
  font-weight: 600;
}

.preview-row.total {
  border-top: 2px solid var(--primary);
  margin-top: 0.3rem;
  padding-top: 0.45rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

/* ボタン */
.btn-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.btn-primary {
  flex: 1;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  flex: 0 0 auto;
  background: #f0f0f0;
  color: var(--text-light);
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

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

/* リスト */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.count {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-light);
  margin-left: 0.4rem;
}

.btn-clear {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-clear:hover {
  background: var(--danger);
  color: #fff;
}

.empty-msg {
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
  padding: 2rem 0;
  line-height: 1.7;
}

/* アイテムカード */
.item-card {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 0.7rem;
  background: #fff;
  transition: box-shadow 0.2s;
}

.item-card:hover {
  box-shadow: var(--shadow);
}

.item-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.item-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 0.5rem;
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: 0.6rem;
}

.item-price {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 0.5rem;
}

.item-price-label {
  font-size: 0.78rem;
  color: var(--text-light);
  font-weight: 400;
}

.item-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn-edit {
  background: none;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-edit:hover {
  background: var(--primary);
  color: #fff;
}

.btn-delete {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-delete:hover {
  background: var(--danger);
  color: #fff;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #333;
  color: #fff;
  padding: 0.65rem 1.2rem;
  border-radius: 20px;
  font-size: 0.9rem;
  opacity: 0;
  transition: all 0.3s;
  z-index: 100;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 480px) {
  header h1 { font-size: 1.25rem; }
  .form-row { grid-template-columns: 1fr 1fr; }
  .item-details { grid-template-columns: 1fr; }
}
