@font-face {
  font-family: "Geist Mono";
  src: url("./fonts/GeistMono-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("./fonts/GeistMono-SemiBold.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: light;
  --app-height: 100vh;
  --keyboard-offset: 0px;
  --bg: #f2f2f7;
  --ios-status-bg: #f2f2f7;
  --surface: #ffffff;
  --surface-alt: #fbfbfd;
  --border: rgba(60, 60, 67, 0.14);
  --separator: rgba(60, 60, 67, 0.12);
  --text: #111111;
  --muted: #6d6d72;
  --blue: #007aff;
  --orange: #ff9500;
  --red: #ff3b30;
  --green: #34c759;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.14);
  --radius-xl: 34px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --select-menu-bg: #f7f8fb;
  --select-menu-text: #111111;
  --select-menu-selected-bg: rgba(0, 122, 255, 0.2);
  --select-menu-selected-text: #111111;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  touch-action: manipulation;
}

html[data-theme-boot="pending"] body {
  visibility: hidden;
}

html[data-theme-boot="ready"] body {
  visibility: visible;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
  touch-action: manipulation;
}

button {
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.9), transparent 24%),
    linear-gradient(180deg, #f8f8fa 0%, var(--bg) 100%);
  padding:
    calc(24px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
}

.desktop-titlebar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: max(44px, var(--desktop-titlebar-height, 0px));
  padding: 8px 14px 6px;
  z-index: 30;
  pointer-events: none;
}

body[data-desktop-window-frame="overlay"] .desktop-titlebar {
  display: flex;
  align-items: center;
}

.desktop-titlebar-drag {
  width: min(360px, calc(100vw - 188px));
  max-width: calc(100vw - 188px);
  min-width: 180px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0.24));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.44),
    0 10px 22px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(18px) saturate(118%);
  -webkit-backdrop-filter: blur(18px) saturate(118%);
  app-region: drag;
  -webkit-app-region: drag;
  pointer-events: auto;
}

.desktop-titlebar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.desktop-titlebar-logo {
  width: 18px;
  height: 18px;
  display: block;
  border-radius: 6px;
  flex-shrink: 0;
}

.desktop-titlebar-label {
  min-width: 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

body[data-desktop-window-frame="overlay"] .app-shell {
  padding-top: calc(max(18px, var(--desktop-titlebar-height, 0px)) + 18px);
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--custom-translucence-background-image, none);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0;
  pointer-events: none;
  filter: none;
  transform: scale(1);
  transition: opacity 180ms ease, filter 220ms ease, transform 220ms ease;
  z-index: 0;
}

body[data-ui-mode="translucence-custom"][data-ui-custom-background="on"] .app-shell::before {
  opacity: 1;
  filter: blur(var(--custom-translucence-blur, 10px)) saturate(112%);
  transform: scale(var(--custom-translucence-scale, 1.04));
}

.app-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, background-color 180ms ease;
  z-index: 4;
}

.app-frame {
  width: min(430px, 100%);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  padding: 18px 16px 16px;
  min-height: min(860px, calc(100vh - 48px));
  background: var(--bg);
  border-radius: 42px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.desktop-web-layout {
  display: none;
}

.desktop-context-title,
.desktop-context-subtitle,
.desktop-card-title,
.desktop-card-meta,
.desktop-list-title,
.desktop-list-subtitle,
.desktop-list-meta,
.desktop-list-body,
.desktop-list-empty {
  margin: 0;
}

@media (min-width: 1180px) {
  body[data-web-desktop="true"] {
    overflow: hidden;
  }

  body[data-web-desktop="true"] .app-shell {
    height: 100dvh;
    min-height: 100dvh;
    place-items: stretch;
    overflow: hidden;
    padding: 20px;
  }

  body[data-web-desktop="true"] .app-frame {
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    grid-template-columns: minmax(250px, 280px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 22px;
    padding: 22px;
    border-radius: 32px;
    align-items: stretch;
    overflow: hidden;
  }

  body[data-web-desktop="true"][data-desktop-rail="hidden"] .app-frame {
    grid-template-columns: 1fr;
  }

  body[data-web-desktop="true"] .nav-bar {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
    min-height: 64px;
    padding: 12px 16px;
    border-radius: 24px;
    background: color-mix(in srgb, var(--surface-alt) 78%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 82%, transparent);
  }

  body[data-web-desktop="true"] .nav-button-start {
    display: none;
  }

  body[data-web-desktop="true"] .nav-actions {
    margin-left: 0;
    width: auto;
    max-width: none;
    justify-content: center;
    gap: 14px;
    overflow: visible;
    padding-bottom: 0;
  }

  body[data-web-desktop="true"] .icon-button {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 78%, transparent);
  }

  body[data-web-desktop="true"] .icon-button.is-active {
    background: color-mix(in srgb, var(--blue) 18%, var(--surface) 82%);
    color: var(--blue);
    box-shadow:
      inset 0 0 0 1px color-mix(in srgb, var(--blue) 34%, transparent),
      0 12px 24px rgba(0, 122, 255, 0.12);
  }

  body[data-web-desktop="true"] .desktop-web-layout {
    grid-column: 1;
    grid-row: 1;
    display: flex !important;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    min-height: 0;
  }

  body[data-web-desktop="true"][data-desktop-rail="hidden"] .desktop-web-layout {
    display: none !important;
  }

  body[data-web-desktop="true"] .page-stack {
    display: grid;
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    min-height: 0;
    border-radius: 28px;
    padding: 20px;
    background: color-mix(in srgb, var(--surface-alt) 84%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 84%, transparent);
    overflow: hidden;
  }

  body[data-web-desktop="true"][data-desktop-rail="hidden"] .page-stack {
    grid-column: 1 / -1;
  }

  body[data-web-desktop="true"] .desktop-context-rail {
    background: color-mix(in srgb, var(--surface-alt) 84%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 84%, transparent);
    border-radius: 24px;
  }

  body[data-web-desktop="true"] .desktop-context-rail {
    padding: 18px;
    min-height: 0;
    overflow: hidden;
  }

  body[data-web-desktop="true"] .desktop-context-default {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 16px;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  body[data-web-desktop="true"] .desktop-context-header {
    display: grid;
    gap: 4px;
  }

  body[data-web-desktop="true"] .desktop-context-title {
    font-size: 1.35rem;
    line-height: 1.15;
  }

  body[data-web-desktop="true"] .desktop-context-subtitle,
  body[data-web-desktop="true"] .desktop-list-subtitle,
  body[data-web-desktop="true"] .desktop-list-meta,
  body[data-web-desktop="true"] .desktop-list-body,
  body[data-web-desktop="true"] .desktop-list-empty {
    color: var(--muted);
    line-height: 1.4;
  }

  body[data-web-desktop="true"] .desktop-context-list {
    min-height: 0;
    overflow: auto;
    display: grid;
    gap: 10px;
    align-content: start;
  }

  body[data-web-desktop="true"] .page {
    background: transparent;
    overflow: auto;
  }

  body[data-web-desktop="true"] .desktop-list-item {
    display: grid;
    gap: 4px;
    width: 100%;
    border: 0;
    text-align: left;
    cursor: pointer;
    padding: 12px 14px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 76%, transparent);
  }

  body[data-web-desktop="true"] .desktop-list-title {
    font-weight: 600;
    line-height: 1.25;
  }

  body[data-web-desktop="true"] .desktop-list-item.is-active {
    background: color-mix(in srgb, var(--blue) 14%, var(--surface) 86%);
    box-shadow:
      inset 0 0 0 1px color-mix(in srgb, var(--blue) 32%, var(--border) 68%),
      0 8px 20px rgba(0, 122, 255, 0.08);
  }

  body[data-web-desktop="true"] .content-stack.page>.dashboard-title-row,
  body[data-web-desktop="true"] .content-stack.page>.notes-title-row,
  body[data-web-desktop="true"] .content-stack.page>.quickmail-title-row,
  body[data-web-desktop="true"] .content-stack.page>.calendar-title-row {
    flex-shrink: 0;
    padding-block: 6px 10px;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail-header .group-label {
    margin: 0;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    flex: 0 0 auto;
    flex-shrink: 0;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail-actions>.setting-action-button,
  body[data-web-desktop="true"] .desktop-mailbox-rail-actions>.import-button {
    flex: 0 1 auto;
    min-width: 0;
    justify-content: center;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail-status {
    margin: 0;
    line-height: 1.35;
  }

  body[data-web-desktop="true"] .desktop-mailbox-search {
    width: 100%;
    flex-shrink: 0;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail-folders {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail-folders .setting-title {
    margin: 0;
    flex: 0 0 auto;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail-folders .filter-button {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail-list-wrap {
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail-list {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-right: 2px;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail-list .quickmail-thread-card {
    flex-shrink: 0;
  }

  body[data-web-desktop="true"] .desktop-mailbox-rail-empty {
    margin: 0;
    padding: 8px 4px;
    color: var(--muted);
    line-height: 1.4;
  }

  /* [hidden] must win: layout rules above set display:grid/flex with higher specificity than the UA [hidden] rule */
  body[data-web-desktop="true"] .desktop-context-default[hidden],
  body[data-web-desktop="true"] .desktop-mailbox-rail[hidden] {
    display: none !important;
  }
}

body[data-ui-glass="on"] .app-frame {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--blue) 8%, var(--surface) 54%, transparent),
      color-mix(in srgb, var(--red) 5%, var(--surface-alt) 56%, transparent));
  border-color: color-mix(in srgb, var(--blue) 18%, var(--border) 82%);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 8px 18px rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px) saturate(112%);
  -webkit-backdrop-filter: blur(12px) saturate(112%);
}

@media (display-mode: standalone) and (max-width: 640px) {
  .app-shell {
    place-items: stretch;
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg);
  }

  .app-frame {
    width: 100%;
    min-height: 100vh;
    padding-top: calc(18px + env(safe-area-inset-top));
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }
}

@supports (-webkit-touch-callout: none) {
  @media (display-mode: standalone) and (max-width: 640px) {
    .app-shell {
      background: transparent;
    }

    .app-frame {
      min-height: calc(100vh + env(safe-area-inset-top));
      margin-top: calc(-1 * env(safe-area-inset-top));
      padding-top: calc(18px + env(safe-area-inset-top));
    }
  }
}

.nav-bar {
  display: flex;
  align-items: center;
  min-height: 32px;
  gap: 12px;
  min-width: 0;
}

.nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  justify-content: flex-end;
}

.nav-actions::-webkit-scrollbar {
  display: none;
}

body[data-ui-glass="on"] .nav-bar,
body[data-ui-glass="on"] .pull-refresh,
body[data-ui-glass="on"] .sync-banner {
  backdrop-filter: blur(8px) saturate(108%);
  -webkit-backdrop-filter: blur(8px) saturate(108%);
}

.nav-button {
  min-height: 32px;
  padding: 0 4px;
  background: none;
  color: var(--blue);
  font-size: 1rem;
  border: 0;
  cursor: pointer;
}

.nav-button-start {
  margin-right: auto;
}

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-button:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.icon-button svg {
  width: 24px;
  height: 24px;
}

.nav-button[hidden] {
  display: none;
}

.page-stack {
  display: grid;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.content-stack {
  display: grid;
  gap: 16px;
  align-content: start;
}

.page {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  padding-bottom: 0;
  background: var(--bg);
  transition:
    transform 320ms cubic-bezier(0.32, 0.72, 0, 1),
    opacity 320ms cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
}

.page[aria-hidden="true"] {
  pointer-events: none;
  visibility: hidden;
}

.page[aria-hidden="false"] {
  visibility: visible;
}

.page[data-page-state="active"] {
  transform: translate3d(0, 0, 0);
  opacity: 1;
  z-index: 2;
}

.page[data-page-state="before"] {
  transform: translate3d(-104%, 0, 0);
  opacity: 1;
  z-index: 1;
}

.page[data-page-state="after"] {
  transform: translate3d(104%, 0, 0);
  opacity: 1;
  z-index: 3;
}

.tasks-page {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.tasks-page-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  transition: transform 180ms ease;
  will-change: transform;
}

.tasks-page-content>*:not(.tasks-group),
.tasks-group>*:not(.todo-form) {
  transition:
    opacity 180ms ease,
    filter 180ms ease;
}

body[data-keyboard-open="true"] .tasks-page-content>*:not(.tasks-group),
body[data-keyboard-open="true"] .tasks-group>*:not(.todo-form) {
  opacity: 0.46;
  filter: brightness(0.7);
}

.pull-refresh {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding-top: 2px;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, -18px, 0);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  z-index: 1;
}

.pull-refresh.is-visible {
  opacity: 1;
}

.pull-refresh.is-refreshing .pull-refresh-spinner {
  animation: pull-refresh-spin 800ms linear infinite;
}

.pull-refresh-spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(60, 60, 67, 0.18);
  border-top-color: var(--blue);
}

.pull-refresh-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.page-heading {
  margin: 0;
  padding: 6px 24px 4px;
  font-size: 2rem;
  line-height: 1.2;
  font-family: inherit;
  letter-spacing: 0;
}

.notes-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 24px 10px;
  box-sizing: border-box;
}

/* Headings beside actions (Journal, Notes, Monzo, …): row supplies spacing; drop h1 padding for optical centering */
.notes-title-row .page-heading {
  margin: 0;
  padding: 0;
  line-height: 1.25;
}

.sync-banner {
  margin: 2px 4px 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(0, 122, 255, 0.1);
  color: #0f4c9d;
  font-size: 0.92rem;
  line-height: 1.35;
}

.sync-banner[data-sync-state="offline"] {
  background: rgba(255, 149, 0, 0.14);
  color: #8a4b00;
}

.sync-banner[data-sync-state="issues"] {
  background: rgba(255, 59, 48, 0.12);
  color: #9d1f18;
}

.group-label,
#task-count,
.setting-value {
  margin: 0;
  color: var(--muted);
}

.group {
  display: grid;
  gap: 8px;
}

.tasks-group {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}