:root {
  --bg: #f3f7f8;
  --surface: #ffffff;
  --text: #10282d;
  --muted: #5b7176;
  --border: #d5e0e2;
  --accent: #0e7490;
  --accent-text: #ffffff;
  --danger: #b42318;
  --input-bg: #ffffff;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1416;
    --surface: #142226;
    --text: #e6f1f3;
    --muted: #93aab0;
    --border: #26393e;
    --accent: #22a6c3;
    --accent-text: #04191e;
    --danger: #ff8a80;
    --input-bg: #0f1b1e;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding:
    env(safe-area-inset-top)
    calc(16px + env(safe-area-inset-right))
    calc(32px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
}

.app-header h1 {
  margin: 16px 0 12px;
  font-size: 30px;
  letter-spacing: -0.02em;
}

main {
  max-width: 560px;
  margin: 0 auto;
}
.app-header { max-width: 560px; margin: 0 auto; }

h2 {
  font-size: 20px;
  margin: 28px 0 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* Totals */
.totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.total {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}
.total-label { font-size: 14px; color: var(--muted); }
.total-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.total-sub { font-size: 14px; color: var(--muted); }

/* Form */
form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  min-width: 0;
}
form label > span { font-size: 15px; font-weight: 600; color: var(--muted); }
form label em { font-weight: 400; font-style: normal; }

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input, textarea {
  /* 16px+ prevents iOS from zooming on focus */
  font: inherit;
  font-size: 18px;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  min-height: 50px;
  width: 100%;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}
/* iOS renders date/time inputs oddly without these */
input[type="date"], input[type="time"] {
  display: block;
  text-align: left;
}
input::-webkit-date-and-time-value { text-align: left; }
textarea { resize: vertical; }

input:focus, textarea:focus, button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.error {
  color: var(--danger);
  margin: 0 0 12px;
  font-weight: 600;
}

.log-button {
  width: 100%;
  min-height: 60px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 21px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.log-button:active { transform: scale(0.985); filter: brightness(0.95); }

/* History */
.empty { color: var(--muted); }

.soak-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.soak {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.soak-body { flex: 1; min-width: 0; }
.soak-when { font-weight: 600; }
.soak-stats { color: var(--muted); font-variant-numeric: tabular-nums; }
.soak-notes {
  margin-top: 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.delete-button {
  flex: none;
  min-width: 48px;
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--danger);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.delete-button:active { background: color-mix(in srgb, var(--danger) 12%, transparent); }
