:root {
  --bg: #07131c;
  --bg-rgb: 7, 19, 28;
  --surface: rgba(15, 34, 48, 0.93);
  --surface-rgb: 15, 34, 48;
  --surface-soft: rgba(203, 224, 238, 0.075);
  --surface-strong: rgba(203, 224, 238, 0.12);
  --ink: #f8f4ed;
  --muted: #aab7c1;
  --line: rgba(203, 224, 238, 0.14);
  --accent: #a7c7dc;
  --accent-rgb: 167, 199, 220;
  --accent-soft: rgba(167, 199, 220, 0.18);
  --accent-ink: #0b1b26;
  --cream: #f2e8dc;
  --blush: #efc7ba;
  --danger: #f1a5ad;
  --radius: 8px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  overflow-x: hidden;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 0;
  min-height: 100svh;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.35;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
  font-weight: 760;
  touch-action: manipulation;
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(var(--accent-rgb), 0.25);
  outline-offset: 2px;
}

.app-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(var(--bg-rgb), 0.94);
  backdrop-filter: blur(16px);
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
}

.header-main {
  display: grid;
  min-width: 0;
  gap: 2px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.1;
}

h1 {
  font-size: 1.28rem;
  font-weight: 850;
}

h2 {
  font-size: 1rem;
}

.date-button {
  justify-self: start;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 760;
  padding: 0;
}

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

.sync-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.settings-button {
  display: grid;
  width: 44px;
  height: 44px;
  min-height: 44px;
  place-items: center;
  border-radius: 50%;
  background: var(--cream);
  color: #21394c;
  font-weight: 880;
  padding: 0;
}

.app-shell {
  height: 100svh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(84px + env(safe-area-inset-top)) 12px calc(184px + env(safe-area-inset-bottom));
}

.eyebrow,
.access-copy,
.error-message,
.toast {
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.summary-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 44px;
  align-items: stretch;
  gap: 8px;
  margin: 6px 0 14px;
}

.summary-strip div {
  display: grid;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 8px 10px;
}

.summary-strip span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.summary-strip strong {
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1.1;
}

.icon-button {
  display: grid;
  min-width: 44px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  place-items: center;
  padding: 0 10px;
}

.timeline-section {
  min-height: 0;
}

.timeline-title {
  margin-bottom: 10px;
}

.feed-list {
  display: grid;
  gap: 0;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 8px;
  padding-bottom: 10px;
}

.timeline-item::before {
  position: absolute;
  top: 26px;
  bottom: 0;
  left: 6px;
  width: 1px;
  background: var(--line);
  content: "";
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-marker {
  width: 12px;
  height: 12px;
  margin-top: 20px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.38);
}

.timeline-item.is-other .timeline-marker {
  background: var(--blush);
}

.timeline-card {
  display: grid;
  grid-template-columns: auto 1fr auto 32px;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
}

.timeline-time {
  font-size: 0.96rem;
  font-weight: 780;
}

.timeline-amount {
  justify-self: end;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 790;
}

.timeline-meta {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delete-button {
  display: grid;
  width: 32px;
  min-width: 32px;
  min-height: 44px;
  border-radius: 50%;
  background: transparent;
  color: rgba(248, 244, 237, 0.52);
  font-size: 1.28rem;
  place-items: center;
  padding: 0;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 690;
  padding: 14px;
  text-align: center;
}

.input-dock {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 12;
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: rgba(var(--bg-rgb), 0.96);
  backdrop-filter: blur(18px);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}

.dock-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(104px, 0.62fr);
  gap: 8px;
}

.stepper {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  overflow: hidden;
}

.stepper button {
  min-width: 38px;
  min-height: 44px;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-size: 1.24rem;
  padding: 0;
}

.stepper label {
  display: grid;
  align-content: center;
  min-width: 0;
  gap: 0;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  padding: 3px 5px;
}

.stepper span {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 720;
  text-align: center;
}

.stepper input,
.stepper select {
  width: 100%;
  min-width: 0;
  min-height: 25px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  font-weight: 820;
  text-align: center;
  padding: 0;
}

.stepper select {
  appearance: none;
  -webkit-appearance: none;
  text-align-last: center;
}

.compact-time input {
  font-size: 1.08rem;
}

.dock-actions {
  display: grid;
  grid-template-columns: auto minmax(100px, 1fr);
  gap: 8px;
  align-items: center;
}

.icon-toggle-row {
  display: flex;
  gap: 7px;
}

.icon-toggle {
  display: grid;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  font-size: 1.08rem;
  place-items: center;
  padding: 0;
}

.icon-toggle.is-active {
  border-color: rgba(var(--accent-rgb), 0.48);
  background: var(--accent-soft);
}

.save-compact,
.primary-button {
  min-height: 44px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.98rem;
  padding: 9px 14px;
}

.access-card {
  display: none;
  width: min(calc(100% - 24px), 520px);
  margin: calc(82px + env(safe-area-inset-top)) auto 0;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

body.is-locked .access-card {
  display: grid;
}

body.is-locked .app-shell,
body.is-locked .input-dock {
  display: none;
}

.field {
  display: grid;
  gap: 5px;
  color: var(--ink);
  font-weight: 710;
}

.field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 710;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 16px;
  padding: 9px 10px;
}

.access-copy {
  margin-top: 7px;
  color: var(--muted);
  font-weight: 650;
}

.error-message {
  min-height: 1.35em;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 720;
}

.ghost-button {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
  padding: 9px 12px;
}

.sheet[hidden] {
  display: none;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  min-height: 0;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.38);
}

.sheet-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  width: 100%;
  max-height: calc(86svh - env(safe-area-inset-top));
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  background: #0d1d28;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
}

.sheet-head,
.sheet-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sheet-actions {
  margin-top: 4px;
}

#settingsForm {
  display: grid;
  gap: 12px;
}

.settings-stepper {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: end;
}

.settings-stepper button {
  min-width: 44px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--accent);
  font-size: 1.2rem;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 740;
  text-align: center;
}

.calendar-day {
  min-width: 0;
  min-height: 42px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  padding: 0;
}

.calendar-day.is-outside {
  color: rgba(248, 244, 237, 0.34);
}

.calendar-day.is-today {
  border-color: var(--line);
}

.calendar-day.is-selected {
  background: var(--accent);
  color: var(--accent-ink);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(150px + env(safe-area-inset-bottom));
  left: auto;
  z-index: 40;
  width: auto;
  max-width: min(calc(100% - 32px), 280px);
  margin: 0;
  border-radius: 999px;
  background: rgba(var(--surface-rgb), 0.96);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 780;
  padding: 7px 10px;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: transform 180ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 640px) {
  .app-shell,
  .input-dock,
  .app-header {
    width: min(100%, 640px);
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }

  .sheet-panel {
    width: min(100%, 640px);
    margin: 0 auto;
  }
}
