/* Workframe – Zeiterfassung */

:root {
  --bg: #f3f4f9;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --text: #14161f;
  --muted: #6b7280;
  --line: #e5e7ef;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef2ff;
  --green: #059669;
  --green-bright: #10b981;
  --green-soft: #ecfdf5;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 12px 32px -18px rgba(16, 24, 40, .28);
  --radius: 18px;
  --radius-sm: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c11;
    --surface: #14161e;
    --surface-2: #1b1e28;
    --text: #eef0f6;
    --muted: #9aa1b1;
    --line: #262a36;
    --accent: #8b87f8;
    --accent-strong: #a5a1fb;
    --accent-soft: #211f3d;
    --green: #34d399;
    --green-soft: #0d2b23;
    --red: #f87171;
    --red-soft: #2c1518;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 40px -24px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
h1 { font-size: 26px; }
h2 { font-size: 16px; }

.container {
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 20px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }

.brand__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--accent);
  flex: none;
}
.brand__mark svg { width: 34px; height: 34px; }

.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__name { font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand__sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  font-weight: 600;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.nav a {
  padding: 7px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .12);
}

/* The bottom tab bar is only rendered for logged-in users on small screens. */
.mobile-nav { display: none; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted);
  padding-left: 4px;
  text-decoration: none;
}
.user-chip:hover { color: var(--text); text-decoration: none; }
.logout-form { margin: 0; }
.logout-form .link { font-size: 13px; color: var(--muted); }
.logout-form .link:hover { color: var(--red); }
.avatar {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 13px;
}

/* ---------- Layout ---------- */

.main { padding-top: 28px; padding-bottom: 8px; }

.flashes { display: grid; gap: 10px; margin-bottom: 18px; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
}
.flash--success { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 30%, transparent); color: var(--green); }
.flash--error { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 30%, transparent); color: var(--red); }
.flash--info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 26%, transparent); color: var(--accent-strong); }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 { margin-bottom: 4px; }
.muted { color: var(--muted); margin: 0; font-size: 14px; }

.month-nav { display: flex; gap: 8px; align-items: center; }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 28px;
  padding: 34px 36px;
  border-radius: 26px;
  color: #fff;
  background: linear-gradient(135deg, #1b1f3b 0%, #312e81 55%, #4338ca 100%);
  box-shadow: 0 24px 48px -30px rgba(49, 46, 129, .9);
}
.hero::after {
  content: "";
  position: absolute;
  width: 340px; height: 340px;
  right: -120px; top: -160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .16), transparent 68%);
  pointer-events: none;
}
.hero--running {
  background: linear-gradient(135deg, #052e2b 0%, #065f46 55%, #059669 100%);
  box-shadow: 0 24px 48px -30px rgba(5, 150, 105, .9);
}

.hero__eyebrow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
}
.hero__date {
  font-size: 13px;
  color: rgba(255, 255, 255, .72);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .18);
}
.status--live { background: rgba(16, 185, 129, .22); border-color: rgba(52, 211, 153, .45); }
.status__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, .2);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
  50% { box-shadow: 0 0 0 7px rgba(52, 211, 153, .06); }
}

.hero__time {
  font-size: clamp(44px, 8vw, 68px);
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.hero__unit { font-size: .38em; font-weight: 500; opacity: .65; margin-left: 6px; }
.hero__hint { margin: 12px 0 0; font-size: 14px; color: rgba(255, 255, 255, .78); }
.hero__hint strong { color: #fff; font-weight: 600; }
.hero__meta { margin: 10px 0 0; font-size: 12.5px; color: rgba(255, 255, 255, .66); text-align: center; }

.hero__action { position: relative; z-index: 1; }
.stamp-form { display: flex; flex-direction: column; gap: 10px; width: 250px; }

/* ---------- Buttons & inputs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }

.btn--start {
  width: 100%;
  padding: 16px 24px;
  background: #10b981;
  color: #04231a;
  box-shadow: 0 10px 24px -12px rgba(16, 185, 129, .9);
}
.btn--start:hover { background: #34d399; }

.btn--stop {
  width: 100%;
  padding: 16px 24px;
  background: #ef4444;
  color: #fff;
  box-shadow: 0 10px 24px -12px rgba(239, 68, 68, .9);
}
.btn--stop:hover { background: #f87171; }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-strong); }

.btn--ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
  padding: 9px 16px;
  font-size: 14px;
}
.btn--ghost:hover { background: var(--surface-2); text-decoration: none; }

.btn--icon { padding: 8px 14px; font-size: 18px; line-height: 1; }

.btn--danger { background: var(--red); color: #fff; }
.btn--danger:hover { filter: brightness(1.08); }

.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--muted); }
.input[data-format] { font-variant-numeric: tabular-nums; }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.stamp-form .input {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .22);
  color: #fff;
}
.stamp-form .input::placeholder { color: rgba(255, 255, 255, .6); }
.stamp-form .input:focus { border-color: rgba(255, 255, 255, .7); box-shadow: 0 0 0 4px rgba(255, 255, 255, .12); }

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

/* ---------- Stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin: 18px 0 22px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat__label {
  display: block;
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
}
.stat__value {
  display: block;
  margin: 6px 0 2px;
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat__value small { font-size: .5em; font-weight: 500; color: var(--muted); margin-left: 4px; }
.stat__value--action { font-size: 24px; }
.stat__sub { font-size: 12.5px; color: var(--muted); }

/* ---------- Cards ---------- */

.columns {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card--flush { padding: 10px 12px; }
.card--danger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-color: color-mix(in srgb, var(--red) 26%, var(--line));
}
.card--danger h2 { font-size: 15px; margin-bottom: 2px; }

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 4px 14px;
}
.link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--accent);
  cursor: pointer;
}
.link:hover { text-decoration: underline; }
.link--danger { color: var(--red); }

/* ---------- Entry lists ---------- */

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

.entry {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 13px 6px;
  border-top: 1px solid var(--line);
}
.entries > .entry:first-child { border-top: 0; }
.entry--running { background: color-mix(in srgb, var(--green-soft) 60%, transparent); border-radius: 10px; }
.entry__time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.entry__nextday {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: 1px;
}
.entry__note {
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry__dur {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
}
.entry__actions { display: flex; align-items: center; gap: 12px; }
.entry__actions form { margin: 0; }
.entry__edit {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.entry__edit:hover { color: var(--accent); }

.daygroup { padding: 6px 4px; }
.daygroup + .daygroup { border-top: 1px solid var(--line); }
.daygroup__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.daygroup__total { color: var(--muted); }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini { padding: 11px 4px; border-top: 1px solid var(--line); }
.mini:first-child { border-top: 0; }
.mini__top { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.mini__date { font-weight: 600; }
.mini__dur { color: var(--muted); font-variant-numeric: tabular-nums; }
.mini__meta {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini__note { color: var(--muted); }

.empty {
  margin: 6px 0;
  padding: 30px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}
.empty--small { padding: 18px 12px; }

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--wide { grid-column: span 2; }
.field--full { grid-column: 1 / -1; }
.field label {
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}
.field__hint { font-size: 12px; color: var(--muted); }
.field__optional { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  padding-bottom: 12px;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.form-actions { display: flex; gap: 10px; align-items: center; }

.form-footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px 20px;
  flex-wrap: wrap;
  padding-top: 2px;
}
.form-hint {
  margin: 0;
  max-width: 54ch;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}
.form-hint.is-overnight { color: var(--accent); font-weight: 550; }

/* ---------- Authentication & account ---------- */

.auth-shell { max-width: 440px; margin: 10px auto 40px; }
.auth-card { padding: 28px 28px 24px; }
.auth-card__head { margin-bottom: 22px; }
.auth-card__head h1 { font-size: 24px; margin-bottom: 6px; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form .btn { width: 100%; margin-top: 2px; }

.auth-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.auth-check input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }

.auth-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.auth-links .btn { width: 100%; }
.auth-alt { margin: 0; text-align: center; font-size: 13.5px; color: var(--muted); }

.input--pin {
  max-width: 180px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .35em;
}
.input--pin-large {
  max-width: none;
  padding: 16px 20px;
  text-align: center;
  font-size: 24px;
  letter-spacing: .6em;
  padding-left: calc(20px + .6em);
}

.pin-pad { gap: 12px; }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 2px;
}
.keypad__key {
  min-height: 58px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s ease, transform .08s ease, border-color .12s ease;
}
.keypad__key:hover {
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface-2));
  border-color: color-mix(in srgb, var(--accent) 24%, var(--line));
}
.keypad__key:active {
  transform: scale(.97);
  background: var(--accent-soft);
}
.keypad__key--action { font-size: 17px; color: var(--muted); }
.keypad__key--action[data-key="clear"] {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .06em;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.account-hint { margin: 0 0 18px; font-size: 13px; line-height: 1.55; }

.manual { padding: 0; overflow: hidden; }
.manual summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.manual summary::-webkit-details-marker { display: none; }
.manual summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
}
.manual[open] summary::before { content: "–"; }
.manual summary > span:first-child { flex: 1; }
.manual__hint { font-size: 12.5px; color: var(--muted); font-weight: 450; }
.manual .form-grid { padding: 4px 22px 22px; border-top: 1px solid var(--line); padding-top: 20px; }

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  vertical-align: 1px;
}
.badge--live { background: var(--green-soft); color: var(--green); }
.badge--nextday { background: var(--accent-soft); color: var(--accent); }
.badge--muted { background: var(--surface-2); color: var(--muted); }

/* ---------- Confirmation dialog ---------- */

.confirm {
  width: min(420px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 28px 70px -28px rgba(16, 24, 40, .55);
}
.confirm::backdrop {
  background: rgba(9, 11, 18, .52);
  backdrop-filter: blur(2px);
}
.confirm__inner { padding: 22px 24px 20px; }
.confirm__title { font-size: 17px; margin: 0 0 8px; }
.confirm__text {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}
.confirm__actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.confirm[open] { animation: confirm-in .16s ease-out; }

@keyframes confirm-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}

/* ---------- Footer & errors ---------- */

.site-footer { padding: 26px 0 44px; color: var(--muted); font-size: 13px; }
.site-footer__inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.error-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 32px 20px;
}
.error-shell .brand { color: var(--text); }

.error-page {
  width: 100%;
  max-width: 460px;
  margin: 0;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 44px 28px;
  box-shadow: var(--shadow);
}
.error-page__code {
  display: block;
  font-size: 52px;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 10px;
}
.error-page h1 { font-size: 19px; margin-bottom: 22px; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .columns { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; padding: 28px 26px; gap: 22px; }
  .stamp-form { width: 100%; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field--wide { grid-column: span 2; }
}

/* Phones: compact single-row header plus a fixed bottom tab bar. */
@media (max-width: 720px) {
  .nav--desktop { display: none; }

  .site-header__inner {
    flex-wrap: nowrap;
    gap: 8px 12px;
    min-height: 0;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .brand { margin-right: auto; }
  .user-chip { padding-left: 0; }
  .logout-form .link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 2px;
  }

  /* Touch-friendly targets and 16px inputs (prevents iOS zoom on focus). */
  .btn { min-height: 46px; }
  .input { min-height: 46px; font-size: 16px; }
  .month-nav { width: 100%; }
  .month-nav .btn { flex: 1 1 0; }
  .month-nav .btn--icon { flex: 0 0 46px; }

  /* Keep the page content clear of the fixed bar, including the iOS safe area. */
  .has-mobile-nav {
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--line);
  }
  .mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    padding: 4px;
    border-radius: 12px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav a:hover { color: var(--text); text-decoration: none; }
  .mobile-nav a.is-active {
    color: var(--accent);
    background: var(--accent-soft);
  }
  .mobile-nav svg { width: 22px; height: 22px; flex: none; }
}

@media (max-width: 640px) {
  .container {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .site-header__inner { min-height: 0; }
  .brand__sub, .user-chip__name { display: none; }
  .nav a { padding: 8px 12px; font-size: 13.5px; }
  .main { padding-top: 18px; }
  h1 { font-size: 22px; }
  .hero { border-radius: 20px; padding: 24px 20px; }
  .hero__time { font-size: clamp(38px, 13vw, 52px); }
  .hero__eyebrow { gap: 10px; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  /* A third summary card spans the full width instead of leaving a gap. */
  .stats > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat { padding: 14px 16px; }
  .stat__value { font-size: 26px; }

  .card { padding: 16px; border-radius: 16px; }
  .card--flush { padding: 8px; }

  /* Two-line entries: time + duration, note, then actions. */
  .entry {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    padding: 12px 6px;
  }
  .entry__time { grid-column: 1; grid-row: 1; }
  .entry__dur { grid-column: 2; grid-row: 1; }
  .entry__note {
    display: block;
    grid-column: 1 / -1;
    grid-row: 2;
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
    font-size: 13px;
    line-height: 1.45;
  }
  .entry__note--empty { display: none; }
  .entry__actions {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-content: flex-start;
    gap: 20px;
    padding-top: 2px;
  }
  .entry__actions .link,
  .entry__edit {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 4px 0;
  }

  .page-head { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .field--wide { grid-column: span 1; }
  .field--full { grid-column: 1 / -1; }
  .form-footer { flex-direction: column; align-items: stretch; }
  .form-footer .form-actions { justify-content: flex-end; }
  .form-footer > .btn { width: 100%; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 auto; }

  .card--danger { flex-direction: column; align-items: flex-start; }
  .card--danger form { width: 100%; }
  .card--danger .btn { width: 100%; }
  .manual summary { padding: 16px; }
  .manual .form-grid { padding: 16px; }

  .auth-shell { margin-top: 0; }
  .auth-card { padding: 22px 18px 20px; }
  .keypad__key { min-height: 62px; }

  .confirm { width: calc(100vw - 24px); }
  .confirm__actions .btn { flex: 1; }
  .error-shell { min-height: 100dvh; }
}

/* Short phones: keep the keypad and submit button visible without scrolling. */
@media (max-width: 720px) and (max-height: 700px) {
  .site-header__inner { padding-top: 6px; padding-bottom: 6px; }
  .main { padding-top: 6px; }
  .flashes { margin-bottom: 8px; }
  .flash { padding: 8px 12px; font-size: 12.5px; }
  .auth-card { padding: 8px 14px 10px; }
  .auth-card__head { margin-bottom: 6px; }
  .auth-card__head h1 { font-size: 19px; margin-bottom: 4px; }
  .auth-card__head .muted { font-size: 12px; line-height: 1.4; }
  .auth-form { gap: 5px; }
  .field { gap: 4px; }
  .input { min-height: 42px; }
  .pin-pad { gap: 5px; }
  .input--pin-large {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 19px;
  }
  .keypad { gap: 4px; }
  .keypad__key { min-height: 44px; font-size: 19px; border-radius: 11px; }
  .auth-check { font-size: 12.5px; }
  .auth-form .btn { min-height: 42px; }
  .auth-links { margin-top: 10px; padding-top: 10px; gap: 6px; }
  .auth-alt { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
