:root {
  color-scheme: light;
  --ink: #132231;
  --muted: #5f7080;
  --line: #d7e6f2;
  --paper: #fbfcfa;
  --panel: #ffffff;
  --accent: #5caee8;
  --accent-strong: #2f7fbd;
  --accent-soft: #dceffc;
  --rose: #c05c72;
  --gold: #a86d15;
  --blue: #386ca8;
  --shadow: 0 18px 45px rgba(28, 57, 82, 0.12);
  --topbar-height: 128px;
  --pane-top-gap: 12px;
  --bottom-nav-height: 76px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  overscroll-behavior-y: none;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #e8f4ff;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(47, 127, 189, 0.14);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  touch-action: pan-y;
}

body, html {
  height: 100%;
  min-height: 100%;
  overscroll-behavior-y: none;
}

#pull-indicator {
  display: none;
}

.pull-spinner {
  display: none;
}

@keyframes pull-spin {
  to {
    transform: rotate(360deg);
  }
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}

.app-shell {
  display: block;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
}

.app-shell > .sidebar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
}

.app-shell > .workspace {
  position: relative;
  min-width: 0;
  min-height: 100svh;
  min-height: 100dvh;
}

.sidebar {
  border-top: 1px solid rgba(179, 208, 230, 0.86);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 -12px 32px rgba(28, 57, 82, 0.12);
  padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.brand {
  display: none;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: white;
  font-weight: 800;
  background: var(--accent);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.1rem;
}

.brand p,
.eyebrow,
.item-meta,
.people-list span,
.empty-state {
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin: 0;
}

.tab-button,
.primary-button,
.secondary-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 44px;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.tab-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 52px;
  padding: 0 4px;
  text-align: center;
  color: var(--ink);
  background: transparent;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.1;
}

.tab-button.active,
.tab-button:focus-visible {
  background: var(--accent-soft);
  border-color: #c5e2f7;
}

.people-panel,
.workspace section {
  min-width: 0;
}

.people-panel {
  display: none;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2,
.section-heading h3 {
  font-size: 0.98rem;
}

.people-list {
  display: grid;
  gap: 8px;
}

.person-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.workspace {
  padding: calc(var(--topbar-height) + var(--pane-top-gap)) max(14px, env(safe-area-inset-right)) 18px max(14px, env(safe-area-inset-left));
  min-width: 0;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 35;
  display: grid;
  gap: 10px;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: calc(10px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left));
  background: rgba(232, 244, 255, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(215, 230, 242, 0.72);
  box-shadow: 0 8px 24px rgba(28, 57, 82, 0.08);
}

.topbar-left {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar h2 {
  font-size: 1.55rem;
  line-height: 1.08;
}

.refresh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  transition: background 140ms ease, transform 140ms ease;
}

.refresh-button:active {
  background: var(--accent-soft);
  transform: rotate(45deg);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
}

.primary-button {
  padding: 0 16px;
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.primary-button:active {
  background: var(--accent-strong);
}

.secondary-button:active,
.icon-button:active {
  background: var(--accent-soft);
}

.secondary-button {
  padding: 0 16px;
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}

.icon-button {
  width: 44px;
  min-width: 44px;
  background: var(--panel);
  border-color: var(--line);
}

.close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.close-button span {
  display: block;
  transform: translateY(-1px);
}

.view {
  display: none;
  transition: transform 120ms ease-out;
  will-change: transform;
}

.active-view {
  display: block;
}

body.is-edge-pulling .active-view {
  transition: none;
}

.date-sections {
  display: grid;
  gap: 16px;
}

.date-section {
  min-width: 0;
}

.item-list {
  display: grid;
  gap: 10px;
}

.item-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 22px rgba(26, 40, 34, 0.07);
}

.item-card.completed {
  opacity: 0.62;
}

.item-card.completed h3 {
  text-decoration: line-through;
}

.item-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.item-card h3 {
  font-size: 0.98rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.item-card p {
  color: var(--muted);
  line-height: 1.36;
  overflow-wrap: anywhere;
}

.item-meta,
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef6fb;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.1;
}

.pill.task {
  background: #dceffc;
  color: var(--accent-strong);
}

.pill.activity {
  background: #e8eef8;
  color: var(--blue);
}

.pill.idea {
  background: #f6e8ec;
  color: var(--rose);
}

.pill.tentative {
  background: #fbefd8;
  color: var(--gold);
}

.pill.overdue {
  background: #fde7ec;
  color: #a9384e;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #bfcfc5;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  line-height: 1.38;
}

.item-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.item-actions button {
  width: 100%;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.calendar-toolbar h3 {
  min-width: 0;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.2;
}

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

.calendar-weekdays {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-align: center;
}

.calendar-weekdays span {
  padding: 0;
}

.calendar-day {
  aspect-ratio: 1 / 1;
  min-height: 44px;
  height: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  overflow: hidden;
}

.calendar-day:focus-visible,
.calendar-day.selected {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.96);
}

.calendar-day.outside {
  opacity: 0.48;
}

.calendar-day.outside.selected {
  opacity: 1;
}

.date-number {
  display: block;
  margin-bottom: 3px;
  font-weight: 800;
  font-size: 0.8rem;
  line-height: 1;
}

.calendar-event {
  display: block;
  width: 100%;
  min-height: 15px;
  margin-bottom: 2px;
  padding: 1px 2px;
  border: 0;
  border-radius: 999px;
  text-align: center;
  color: var(--ink);
  background: #eef6fb;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: normal;
  white-space: nowrap;
}

.calendar-day-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 26px rgba(28, 57, 82, 0.08);
}

.calendar-day-panel-header,
.calendar-day-actions {
  display: grid;
  align-items: center;
  gap: 10px;
  grid-template-columns: 1fr;
}

.calendar-day-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

dialog {
  width: min(430px, calc(100vw - 20px));
  max-width: 100%;
  max-height: calc(100vh - 20px);
  max-height: calc(100svh - 20px);
  max-height: calc(100dvh - 20px);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}

#entry-dialog {
  position: fixed;
  inset: 50% auto auto 50%;
  margin: 0;
  transform: translate(-50%, -50%);
  overflow: auto;
}

dialog::backdrop {
  background: rgba(20, 29, 25, 0.36);
}

#entry-form {
  display: grid;
  gap: 14px;
}

#confirm-form {
  display: grid;
  gap: 14px;
}

#confirm-message {
  color: var(--muted);
  line-height: 1.45;
}

.dialog-header,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dialog-header h2 {
  font-size: 1.15rem;
  line-height: 1.2;
}

.dialog-actions {
  justify-content: flex-end;
  padding-top: 2px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

input,
select,
textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
  font-size: 16px;
  line-height: 1.25;
}

textarea {
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.hidden {
  display: none !important;
}

@media (max-width: 380px) {
  .tab-button {
    font-size: 0.68rem;
  }

  .topbar h2 {
    font-size: 1.38rem;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .item-actions,
  .calendar-day-actions {
    grid-template-columns: 1fr;
  }

  .calendar-weekdays {
    font-size: 0.62rem;
  }

  .calendar-day {
    padding: 3px;
  }

  .calendar-event {
    font-size: 0.52rem;
  }
}

@media (min-width: 560px) {
  .app-shell {
    max-width: 520px;
    margin: 0 auto;
  }

  .app-shell > .sidebar {
    left: 50%;
    width: min(520px, 100%);
    transform: translateX(-50%);
  }

  .topbar {
    left: 50%;
    width: min(520px, 100%);
    transform: translateX(-50%);
  }
}
