:root {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #131b2e;
  --surface-2: #1b2740;
  --text: #e6ebf5;
  --text-dim: #8f9bb3;
  --accent: #4f8cff;
  --danger: #ff5c5c;
  --border: #253252;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  min-height: 100vh;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 24px);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(env(safe-area-inset-top) + 12px);
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 18px;
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 18px;
  line-height: 1;
}

.back-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 4px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

button.logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  min-height: 40px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 13px;
  color: var(--text-dim);
}

input,
select {
  font-size: 16px; /* keeps iOS Safari from auto-zooming on focus */
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  min-height: 44px;
  width: 100%;
}

/* iOS Safari keeps its own intrinsic sizing for date inputs and can ignore
   width:100% unless the native appearance is reset first, which is what
   was letting this field render wider than its card on an iPhone. */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#weight {
  font-size: 32px; /* twice the base input size, so it stands out from the other fields */
  font-weight: 600;
}

button.primary {
  width: 100%;
  min-height: 48px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
}

button.primary:active {
  opacity: 0.85;
}

.link-btn {
  display: block;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  padding: 4px 0;
  min-height: 32px;
}

.link-btn[hidden] {
  display: none;
}

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.entry-row:last-child {
  border-bottom: none;
}

.entry-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 6px 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.entry-date {
  font-size: 13px;
  color: var(--text-dim);
}

.entry-weight {
  font-size: 17px;
  font-weight: 600;
}

.entry-note {
  font-size: 13px;
  color: var(--text-dim);
}

button.delete {
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: 1px solid var(--border);
  color: var(--danger);
  border-radius: 10px;
  font-size: 18px;
}

.empty {
  color: var(--text-dim);
  text-align: center;
  padding: 24px 0;
  font-size: 14px;
}

.chart-wrap {
  width: 100%;
  overflow: hidden;
}

#chart {
  width: 100%;
  height: 176px;
  display: block;
}

.status {
  font-size: 13px;
  color: var(--text-dim);
  min-height: 18px;
  margin-top: 4px;
}

.status.error {
  color: var(--danger);
}

.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: var(--text-dim);
}

.loading-screen[hidden] {
  display: none;
}
