:root {
  color-scheme: light dark;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --text: #1c1c1a;
  --text-secondary: #5f5e5a;
  --text-muted: #8a8880;
  --border: #ddd9cf;
  --accent: #185fa5;
  --accent-bg: #e6f1fb;
  --danger: #a32d2d;
  --danger-bg: #fcebeb;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #212126;
    --surface-2: #2a2a30;
    --text: #f0efe9;
    --text-secondary: #b4b2a9;
    --text-muted: #888780;
    --border: #38383e;
    --accent: #85b7eb;
    --accent-bg: #0c447c;
    --danger: #f09595;
    --danger-bg: #501313;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

header .title { font-size: 16px; font-weight: 600; }
header .proceeding { font-size: 12px; color: var(--text-muted); }
header .signed-in { font-size: 13px; color: var(--text-secondary); }
header .signed-in strong { color: var(--text); font-weight: 600; }
header button.link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  padding: 4px;
  cursor: pointer;
}

main { flex: 1; padding: 16px; }

.hidden { display: none !important; }

/* Sign-in screen */
#view-signin {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  min-height: 70vh;
}
#view-signin .icon-circle {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}
#view-signin h1 { font-size: 17px; font-weight: 600; margin: 0; }
#view-signin p { font-size: 13px; color: var(--text-secondary); margin: 0; max-width: 260px; }
#google-btn { min-height: 40px; }

/* Form */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.field-row { display: flex; gap: 10px; min-width: 0; }
.field-row .field { flex: 1; min-width: 0; }

input, select, textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
textarea { resize: vertical; min-height: 70px; }

.date-input-wrap { position: relative; min-width: 0; }
.date-input-wrap input[type="text"] { padding-right: 38px; }
.date-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}
/* Invisible native date input, sized and positioned to exactly cover the
   calendar icon (not the whole field) so tapping it opens the native
   iOS/Android date picker without ever letting the native control render
   at full field width, which is what caused the earlier overlap bug. */
.date-native-trigger {
  position: absolute;
  right: 0;
  top: 0;
  width: 38px;
  height: 100%;
  min-width: 0;
  opacity: 0;
  padding: 0;
  border: none;
  cursor: pointer;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}

button.primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button.primary:disabled { opacity: 0.6; }
button.primary:active { transform: scale(0.99); }

.form-error, .form-toast {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.form-error { background: var(--danger-bg); color: var(--danger); }
.form-toast { background: var(--accent-bg); color: var(--accent); }

/* Entries list */
.list-header { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }
.entry-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.entry-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.entry-row:last-child { border-bottom: none; }
.entry-date { font-size: 13px; font-weight: 600; }
.entry-task { font-weight: 400; color: var(--text-muted); }
.entry-action { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.entry-hours { font-size: 13px; font-weight: 600; white-space: nowrap; }
.entry-flag {
  font-size: 11px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-bg);
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius);
  margin-top: 6px;
}
.empty-state { text-align: center; color: var(--text-muted); font-size: 13px; padding: 40px 0; }

/* Totals */
.year-group { margin-bottom: 20px; }
.year-heading { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.totals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.total-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.total-card .name { font-size: 12px; color: var(--text-secondary); }
.total-card .hours { font-size: 22px; font-weight: 600; margin-top: 2px; }

/* Tab bar */
.tabbar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  bottom: 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
}
.tabbar button.active { color: var(--accent); }
.tabbar svg { width: 22px; height: 22px; }
