:root {
  color-scheme: light;
  --bg-a: #f5f2ee;
  --bg-b: #eef0ed;
  --ink: #1c1c1e;
  --muted: #747b80;
  --soft: #f8f8f5;
  --line: #deded8;
  --primary: #37474f;
  --primary-dark: #263238;
  --meal: #fafaf8;
  --symptom: #fff4ef;
  --symptom-line: #f2b7aa;
  --green-bg: #eef7ef;
  --green: #2e7d32;
  --amber-bg: #fff7df;
  --amber: #9a5a00;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background: linear-gradient(160deg, var(--bg-a) 0%, var(--bg-b) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
  min-width: 0;
  max-width: 100%;
}

button {
  min-height: 44px;
  cursor: pointer;
}

.app-shell {
  width: 100%;
  max-width: min(500px, 100%);
  min-width: 0;
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 44px;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e2e2dc;
  margin-bottom: 16px;
}

.title {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 750;
  letter-spacing: 0;
}

.subtitle {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid #c8e6c9;
  background: var(--green-bg);
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.sync-pill.waiting {
  border-color: #ffe1a4;
  background: var(--amber-bg);
  color: var(--amber);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.link-button,
.back-button {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #667176;
  text-decoration: underline;
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 750;
  color: #384146;
  white-space: nowrap;
}

.export-back-button {
  margin-top: 1px;
  padding: 0 0 0 16px;
}

.panel,
.export-card {
  background: #fff;
  border: 1px solid #e5e5df;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(34, 36, 38, 0.06);
}

.capture-panel {
  padding: 16px;
  margin-bottom: 16px;
}

.note-input {
  display: block;
  width: 100%;
  min-height: 132px;
  resize: vertical;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.55;
  outline: none;
}

.note-input:focus,
.field:focus {
  border-color: #87979f;
  box-shadow: 0 0 0 3px rgba(55, 71, 79, 0.12);
}

.hint {
  margin: 7px 0 12px;
  color: #8b9296;
  font-size: 12px;
}

.time-preview {
  margin: 0 0 10px;
  color: #556167;
  font-size: 13px;
  font-weight: 650;
}

.primary-button,
.secondary-button,
.danger-button,
.chip {
  border-radius: 8px;
  border: 1.5px solid transparent;
  font-weight: 750;
}

.primary-button {
  width: 100%;
  background: var(--primary);
  color: #fff;
  padding: 12px 18px;
}

.primary-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.secondary-button {
  background: #fff;
  border-color: #d9d9d4;
  color: #384146;
  padding: 8px 13px;
  font-size: 13px;
}

.danger-button {
  width: 100%;
  margin-top: 10px;
  padding: 12px 18px;
  background: #fff;
  border-color: #e7b5ad;
  color: #b33123;
}

.danger-button.compact {
  width: auto;
  min-width: 96px;
  margin-top: 0;
}

.section-label {
  display: block;
  margin: 18px 0 8px;
  color: #828b90;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.chip-group-label {
  margin-top: 22px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.amount-chip-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.amount-chip-row .chip:last-child {
  grid-column: 1 / -1;
}

.chip {
  min-height: 44px;
  padding: 8px 13px;
  background: #f4f4f1;
  border-color: #deded8;
  color: #384146;
  font-size: 14px;
  line-height: 1.25;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.field {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-inline-size: 0;
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input.field[type="date"],
input.field[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
  inline-size: 100%;
  max-inline-size: 100%;
}

.day-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
}

.date-field {
  width: auto;
  max-width: 170px;
}

.timeline-label {
  margin: 0 0 10px;
  color: #626a6f;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.entry-card {
  padding: 13px 14px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 8px;
  background: var(--meal);
}

.entry-card.symptom {
  border-color: var(--symptom-line);
  background: var(--symptom);
}

.entry-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #eef7ef;
  color: #2e7d32;
  font-size: 12px;
  font-weight: 800;
}

.badge.symptom {
  background: #ffe9e4;
  color: #b33123;
}

.badge.note,
.badge.refused {
  background: #eceff1;
  color: #54656d;
}

.badge.snack {
  background: #e6f1fb;
  color: #2367a6;
}

.badge.photo {
  background: #f4edfb;
  color: #6f3fa1;
}

.time-text,
.card-sync {
  color: #6f777b;
  font-size: 13px;
}

.card-sync {
  margin-left: auto;
  font-size: 12px;
  font-weight: 750;
}

.entry-text {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.entry-actions {
  display: flex;
  justify-content: flex-end;
}

.empty-state {
  padding: 42px 16px;
  color: #8b9296;
  text-align: center;
}

.export-screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.export-card {
  padding: 16px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid #e5e5df;
  border-radius: 8px;
}

.export-title {
  margin: 0 0 5px;
  font-size: 17px;
  font-weight: 800;
}

.export-copy {
  margin: 0;
  color: #3f484d;
  font-size: 13px;
  line-height: 1.55;
}

.range-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-top: 12px;
  min-width: 0;
  max-width: 100%;
}

.date-range-field {
  display: grid;
  gap: 7px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.date-range-field .field {
  width: 100%;
  max-width: 100%;
}

.field-label {
  color: #6f777b;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.export-actions {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.export-secondary-button {
  width: 100%;
  min-height: 46px;
  border-color: #cbd2d5;
  background: #fff;
  color: #37474f;
  font-size: 15px;
}

.reminder-list,
.preview-body {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.reminder {
  padding: 10px 11px;
  border: 1px solid #e6d6f1;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  line-height: 1.5;
}

.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-color: #f4dc76;
  background: #fffbe5;
}

.disclaimer .export-copy {
  color: #3f3626;
}

.info-icon {
  flex: 0 0 auto;
  margin-top: 1px;
  font-size: 15px;
  line-height: 1.2;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.42);
  padding: 0 10px;
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.42);
}

.confirm-dialog {
  width: min(100%, 340px);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.24);
}

.confirm-title {
  margin: 0 0 18px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.3;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.sheet {
  width: 100%;
  max-width: 500px;
  max-height: 86vh;
  overflow: auto;
  border-radius: 16px 16px 0 0;
  background: #fafaf8;
  padding: 22px 18px 34px;
  box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.18);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  margin: 0 auto 18px;
  border-radius: 999px;
  background: #d5d5cf;
}

.sheet-title {
  margin: 0 0 15px;
  font-size: 20px;
  font-weight: 800;
}

.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.preview-box {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid #e0e0da;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  color: #263238;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 80;
  transform: translate(-50%, 14px);
  opacity: 0;
  pointer-events: none;
  border-radius: 999px;
  background: var(--primary-dark);
  color: #fff;
  padding: 11px 22px;
  font-weight: 800;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.24);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

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

@media (max-width: 380px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .title {
    font-size: 25px;
  }
}
