:root {
  --bg: #f5f1ea;
  --card: #ffffff;
  --text: #2b2b2b;
  --muted: #6b6b6b;
  --accent: #4a8a7b;
  --accent-dark: #366357;
  --accent-soft: #e3efeb;
  --danger: #b3413a;
  --warn-bg: #fff5d6;
  --warn-border: #e0b94a;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding-bottom: calc(60px + var(--safe-bottom));
}

.app-header {
  background: var(--accent);
  color: #fff;
  padding: calc(20px + var(--safe-top)) 20px 18px;
  text-align: center;
}
.app-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.app-header .subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: 0.85;
}

main {
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; }

/* List header */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.list-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

/* Buttons */
button {
  font-family: inherit;
  font-size: 16px;
  border: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-primary:active { background: var(--accent-dark); }

.btn-large {
  width: 100%;
  padding: 16px;
  font-size: 17px;
  border-radius: 12px;
}

.btn-back {
  background: none;
  color: var(--accent);
  padding: 4px 0;
  margin-bottom: 10px;
  font-size: 16px;
}

.btn-danger {
  background: none;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 12px 16px;
  border-radius: 12px;
  width: 100%;
  font-weight: 600;
}
.btn-danger:active { background: var(--danger); color: #fff; }

.btn-link {
  background: none;
  color: var(--accent);
  font-size: 14px;
  text-decoration: underline;
  padding: 4px 8px;
}

/* Entries list */
.entries-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.entry-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border-left: 4px solid var(--accent);
  transition: transform 0.1s;
}
.entry-card:active { transform: scale(0.98); }
.entry-card.pending { border-left-color: var(--warn-border); }

.entry-card .entry-time {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}
.entry-card .entry-food {
  font-weight: 600;
  font-size: 16px;
  margin: 0 0 6px;
  word-wrap: break-word;
}
.entry-card .entry-meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.entry-card .pending-tag {
  display: inline-block;
  background: var(--warn-bg);
  color: #6b4d00;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
}
.entry-card .done-tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
}

/* Pending banner */
.pending-banner {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 14px;
}
.pending-banner.hidden { display: none; }
.pending-banner button {
  display: block;
  margin-top: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}

/* Notify (enable push) banner */
.notify-banner {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.notify-banner.hidden { display: none; }
.notify-banner .notify-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.notify-banner .notify-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
  line-height: 1.4;
}
.notify-banner button { white-space: nowrap; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty-state.hidden { display: none; }

/* Forms */
form { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.label-title {
  font-weight: 600;
  font-size: 15px;
}
.label-hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 2px;
}

textarea, input[type="text"] {
  font-family: inherit;
  font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
  padding: 12px;
  border: 1px solid #d8d3c8;
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  resize: vertical;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
textarea:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,138,123,0.15);
}

.hint {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 4px;
}

.form-actions { margin-top: 8px; }

/* Detail view */
#detail-content .detail-section {
  background: var(--card);
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
#detail-content h3 {
  margin: 0 0 6px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
#detail-content p {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}
#detail-content .detail-time {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}
#detail-content .followup-cta {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  padding: 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  text-align: center;
}
#detail-content .followup-cta button {
  margin-top: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
}

/* Summary card in follow-up */
.summary-card {
  background: var(--accent-soft);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--accent-dark);
  margin-bottom: 6px;
}
.summary-card strong { color: var(--text); }

/* Auth overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 30, 30, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: calc(20px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
}
.auth-overlay.hidden { display: none; }
.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.25);
}
.auth-card h2 { margin: 0 0 6px; font-size: 20px; }
.auth-card form { margin-top: 16px; }
.auth-card input[type="password"] {
  font-family: inherit;
  font-size: 16px;
  padding: 12px;
  border: 1px solid #d8d3c8;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
.auth-card input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,138,123,0.15);
}
.auth-card label.hidden { display: none; }
.auth-error {
  background: #ffe0dc;
  color: #6b1a16;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.auth-error.hidden { display: none; }

/* Footer */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(245,241,234,0.95);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: 10px 16px calc(10px + var(--safe-bottom));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}
.footer-actions { display: flex; gap: 4px; flex-wrap: wrap; }
#storage-status { flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#storage-status.ok { color: var(--accent-dark); }
#storage-status.warn { color: #b07a00; }
#storage-status.err { color: var(--danger); }

/* Removed legacy storage-warning styles (server handles persistence) */

/* Settings */
.settings-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.settings-section h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}
.settings-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.settings-row input[type="number"] {
  font-family: inherit;
  font-size: 16px;
  padding: 8px 10px;
  border: 1px solid #d8d3c8;
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  width: 90px;
  -webkit-appearance: none;
  appearance: none;
}
.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
}
.btn-secondary:active { background: var(--accent); color: #fff; }
.btn-secondary.hidden { display: none; }
.btn-primary.hidden { display: none; }
#settings-notify-status { font-weight: 600; color: var(--text); }
#settings-notify-status.ok { color: var(--accent-dark); }
#settings-notify-status.warn { color: #b07a00; }
#settings-notify-status.err { color: var(--danger); }
#set-followup-status { color: var(--accent-dark); }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b18;
    --card: #2a2926;
    --text: #f0ede6;
    --muted: #9b9a95;
    --accent: #6bb09e;
    --accent-dark: #4a8a7b;
    --accent-soft: #2e3d39;
    --warn-bg: #3a3220;
    --warn-border: #b08a2a;
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.25);
  }
  textarea, input[type="text"] {
    border-color: #44423d;
  }
  .app-footer { background: rgba(28,27,24,0.95); border-top-color: rgba(255,255,255,0.06); }
}
