:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #2b2420;
  --muted: #7a7168;
  --accent: #e0672c;
  --accent-dark: #c14f1c;
  --border: #e7ddd0;
  --danger: #c0392b;
  --radius: 14px;
  font-family: "Hiragino Sans", "Noto Sans JP", -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.app-header {
  text-align: center;
  margin-bottom: 20px;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.voice-panel {
  text-align: center;
}

.voice-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 14px 28px;
  font-size: 1.05rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

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

.voice-btn:active {
  transform: scale(0.97);
}

.voice-btn.recording {
  background: var(--danger);
  animation: pulse 1.2s infinite;
}

.voice-btn.ready {
  background: #2f9e58;
}

.voice-btn.ready:hover {
  background: #257d45;
}

.voice-btn-icon {
  font-size: 1.3rem;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(192, 57, 43, 0); }
  100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0); }
}

.voice-status {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.voice-unsupported {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--danger);
}

.transcript {
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.95rem;
  resize: vertical;
  font-family: inherit;
  background: var(--bg);
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.field-row label {
  font-size: 0.8rem;
  color: var(--muted);
}

.field-row input,
.field-row select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.primary-btn {
  flex: 1;
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 12px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

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

.ghost-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
}

.summary-panel {
  display: flex;
  gap: 10px;
  padding: 12px;
}

.summary-card {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
}

.summary-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.summary-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 4px;
}

.backup-desc {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.backup-actions .ghost-btn {
  flex: 1;
  min-width: 150px;
  padding: 10px 12px;
  font-size: 0.88rem;
}

.history-toolbar {
  margin-bottom: 12px;
}

#searchInput {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.history-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-store {
  font-weight: 700;
  font-size: 1rem;
}

.history-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.history-genre {
  display: inline-block;
  background: #f4e6da;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.72rem;
  margin-right: 6px;
}

.history-mealtype {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.72rem;
  margin-right: 6px;
  font-weight: 700;
}

.history-mealtype.breakfast {
  background: #fdf0c9;
  color: #8a6b00;
}

.history-mealtype.lunch {
  background: #dcefe0;
  color: #2f7a45;
}

.history-mealtype.dinner {
  background: #e2e0fb;
  color: #4b3fb0;
}

.history-mealtype.snack {
  background: #fce3ec;
  color: #b23a6a;
}

.history-memo {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}

.history-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.history-amount {
  font-weight: 700;
  font-size: 1.05rem;
}

.history-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--muted);
  padding: 2px 4px;
}

.icon-btn:hover {
  color: var(--text);
}

.icon-btn.delete:hover {
  color: var(--danger);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 12px 0;
}
