/* ============================================================
   DESIGN TOKENS
   Every color in the app is defined once here as a CSS variable,
   then referenced everywhere else as var(--name).
   Change a value here and the whole app updates.
   These match the zinc palette used by rts.rieselisd.net.
   ============================================================ */

:root {
  --radius: 0.625rem;

  --background:        oklch(1 0 0);
  --foreground:        oklch(0.141 0.005 285.823);
  --card:              oklch(1 0 0);
  --card-foreground:   oklch(0.141 0.005 285.823);
  --muted:             oklch(0.967 0.001 286.375);
  --muted-foreground:  oklch(0.552 0.016 285.938);
  --accent:            oklch(0.967 0.001 286.375);
  --primary:           oklch(0.21 0.006 285.885);
  --primary-foreground:oklch(0.985 0 0);
  --border:            oklch(0.92 0.004 286.32);
  --input:             oklch(0.92 0.004 286.32);
  --ring:              oklch(0.705 0.015 286.067);
  --sidebar:           oklch(0.985 0 0);
  --destructive:       oklch(0.577 0.245 27.325);
  --shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

[data-theme="dark"] {
  --background:        oklch(0.141 0.005 285.823);
  --foreground:        oklch(0.985 0 0);
  --card:              oklch(0.21 0.006 285.885);
  --card-foreground:   oklch(0.985 0 0);
  --muted:             oklch(0.274 0.006 286.033);
  --muted-foreground:  oklch(0.705 0.015 286.067);
  --accent:            oklch(0.274 0.006 286.033);
  --primary:           oklch(0.92 0.004 286.32);
  --primary-foreground:oklch(0.21 0.006 285.885);
  --border:            oklch(1 0 0 / 10%);
  --input:             oklch(1 0 0 / 15%);
  --ring:              oklch(0.552 0.016 285.938);
  --sidebar:           oklch(0.21 0.006 285.885);
  --destructive:       oklch(0.704 0.191 22.216);
  --shadow: 0 1px 2px 0 rgb(0 0 0 / 0.4);
}

/* ============================================================
   RESET + BASE
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

svg { display: block; flex: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ============================================================
   APP SHELL — sidebar on the left, everything else on the right
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
}

.app.sidebar-collapsed { grid-template-columns: 0 1fr; }
.app.sidebar-collapsed .sidebar { overflow: hidden; border-right: none; }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
}

.brand-mark {
  width: 30px; height: 30px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 700;
}

/* The T logo, pinned to the top right of the topbar. */
.topbar-logo {
  width: 28px; height: 28px;
  font-size: 14px;
  border-radius: 8px;
  text-decoration: none;
}

.brand-mark.xl {
  width: 56px; height: 56px;
  border-radius: 16px;
  font-size: 26px;
  margin: 0 auto 18px;
}

.brand-title { font-weight: 600; font-size: 13.5px; }
.brand-sub { font-size: 11px; color: var(--muted-foreground); }

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 16px;
}

.nav-section {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted-foreground);
  padding: 14px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--foreground);
  cursor: pointer;
}

.nav-item:hover { background: var(--accent); }
.nav-item.active { background: var(--accent); font-weight: 500; }
.nav-item svg { width: 16px; height: 16px; opacity: .85; }

.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted-foreground);
}

.nav-dot {
  width: 9px; height: 9px;
  flex: none;
  border-radius: 3px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}

.version { font-size: 10px; color: var(--muted-foreground); }

/* ============================================================
   TOPBAR
   ============================================================ */

.topbar {
  height: 48px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--background);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted-foreground);
  min-width: 0;
}

.crumbs .sep { opacity: .5; }
.crumbs .current { color: var(--foreground); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--muted-foreground);
  cursor: pointer;
}

.icon-btn:hover { background: var(--accent); color: var(--foreground); }
.icon-btn svg { width: 16px; height: 16px; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 8px 0 10px;
  min-width: 190px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 8px;
  color: var(--muted-foreground);
  font-size: 13px;
  cursor: pointer;
}

.search-trigger .si { display: grid; place-items: center; }
.search-trigger svg { width: 14px; height: 14px; }

kbd {
  margin-left: auto;
  font-family: inherit;
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.avatar {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 99px;
  background: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* ============================================================
   VIEW AREA + PAGE HEADER
   ============================================================ */

.view {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 60px;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

h1.page-title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-head .spacer { margin-left: auto; }

.page-sub {
  color: var(--muted-foreground);
  font-size: 13px;
  margin: -10px 0 18px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: var(--accent); }
.btn svg { width: 15px; height: 15px; }

.btn.primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: transparent;
}
.btn.primary:hover { opacity: .9; background: var(--primary); }

.btn.danger { color: var(--destructive); border-color: var(--destructive); }
.btn.danger:hover { background: color-mix(in oklab, var(--destructive) 12%, transparent); }

.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; }

.ghost-btn {
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 6px;
}
.ghost-btn:hover { background: var(--accent); color: var(--foreground); }
.ghost-btn.tiny { font-size: 11px; }

/* ============================================================
   CARDS + TILES
   ============================================================ */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 12px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.tile {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  background: var(--background);
}

.tile:hover { border-color: var(--ring); }
.tile .tile-icon {
  width: 30px; height: 30px;
  margin: 0 auto 8px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--muted);
  color: var(--muted-foreground);
}
.tile .tile-icon svg { width: 15px; height: 15px; }
.tile .tile-label { font-size: 12.5px; color: var(--muted-foreground); }
.tile .tile-value { font-size: 21px; font-weight: 600; margin-top: 2px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 14px;
}

/* ============================================================
   TASK ROWS
   ============================================================ */

.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--accent); }

.task-row.done .task-title {
  text-decoration: line-through;
  color: var(--muted-foreground);
}

.check {
  width: 16px; height: 16px;
  flex: none;
  border: 1.5px solid var(--muted-foreground);
  border-radius: 5px;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.check svg { width: 11px; height: 11px; opacity: 0; color: var(--primary-foreground); }
.check.checked { background: var(--primary); border-color: var(--primary); }
.check.checked svg { opacity: 1; }

.task-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font-size: 12px;
  color: var(--muted-foreground);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.pill .nav-dot { width: 7px; height: 7px; border-radius: 2px; }

.pill.high  { color: #f87171; border-color: color-mix(in oklab, #f87171 45%, transparent); }
.pill.med   { color: #fbbf24; border-color: color-mix(in oklab, #fbbf24 45%, transparent); }
.pill.low   { color: var(--muted-foreground); }
.pill.overdue { color: var(--destructive); border-color: color-mix(in oklab, var(--destructive) 50%, transparent); }

.empty {
  text-align: center;
  color: var(--muted-foreground);
  padding: 34px 10px;
  font-size: 13px;
}

/* ============================================================
   FILTER BAR (Tasks page)
   ============================================================ */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.input, select.input {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--background);
  outline: none;
}

.input:focus { border-color: var(--ring); }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input.grow { flex: 1; min-width: 180px; }

/* ============================================================
   PROJECT CARDS
   ============================================================ */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.project-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.project-card:hover { border-color: var(--ring); }

.project-card .stripe {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}

.project-card h3 { margin: 0 0 2px; font-size: 15px; font-weight: 600; }
.project-card .pc-type { font-size: 11.5px; color: var(--muted-foreground); }

.progress {
  height: 5px;
  border-radius: 99px;
  background: var(--muted);
  overflow: hidden;
  margin-top: 12px;
}
.progress > i { display: block; height: 100%; border-radius: 99px; }

/* ============================================================
   CALENDAR
   ============================================================ */

.cal-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
  align-items: start;
}

/* The "Projects" header doubles as a collapse toggle on phones.
   On wide screens it's hidden and the body is always shown. */
.filters-summary {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  padding: 2px 0;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--foreground);
}

.filters-summary .count { font-size: 11.5px; color: var(--muted-foreground); font-weight: 400; }
.filters-summary .chev { transition: transform .18s ease; color: var(--muted-foreground); }
.filters.open .filters-summary .chev { transform: rotate(90deg); }

.filters .filter-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.filters .filter-row:hover { background: var(--accent); }
.filters input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--foreground); cursor: pointer; }
.filters .filter-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.legend { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.legend .lg-title { font-size: 11px; color: var(--muted-foreground); margin-bottom: 7px; }
.legend .lg-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 2px 0; color: var(--muted-foreground); }
.legend .lg-dot { width: 8px; height: 8px; border-radius: 99px; flex: none; }

.cal-shell {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }

.cal-head > div {
  padding: 8px 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.cal-head > div:last-child { border-right: none; }

.cal-cell {
  min-height: 104px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 5px 6px 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
}

.cal-cell:nth-child(7n) { border-right: none; }
.cal-grid > .cal-cell:nth-last-child(-n+7) { border-bottom: none; }
.cal-cell:hover { background: var(--accent); }
.cal-cell.other-month { background: color-mix(in oklab, var(--muted) 30%, transparent); }
.cal-cell.other-month .cal-day { opacity: .35; }
.cal-cell.today { background: color-mix(in oklab, var(--muted) 55%, transparent); }

.cal-day {
  text-align: right;
  font-size: 12px;
  color: var(--muted-foreground);
  margin-bottom: 1px;
}

.cal-cell.today .cal-day {
  color: var(--primary-foreground);
  background: var(--primary);
  border-radius: 99px;
  width: 20px; height: 20px;
  line-height: 20px;
  text-align: center;
  margin-left: auto;
  font-weight: 600;
}

.chip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chip.is-done { opacity: .45; text-decoration: line-through; }
.chip .chip-text { overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-size: 10.5px; color: var(--muted-foreground); padding-left: 4px; }

.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.seg button {
  border: none;
  background: transparent;
  padding: 0 10px;
  height: 30px;
  cursor: pointer;
  font-size: 13px;
}
.seg button:hover { background: var(--accent); }
.seg button + button { border-left: 1px solid var(--border); }

/* ============================================================
   MODAL
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.55);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgb(0 0 0 / 0.35);
  padding: 18px;
}

.modal h2 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted-foreground);
  margin-bottom: 5px;
}
.field .input { width: 100%; }

.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.modal-actions .left { margin-right: auto; }

.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch {
  width: 24px; height: 24px;
  border-radius: 7px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch.selected { border-color: var(--foreground); }

/* ============================================================
   SYNC BADGE + AUTH
   ============================================================ */

.sync-badge {
  font-size: 11px;
  color: var(--muted-foreground);
  cursor: default;
  user-select: none;
}

.sync-badge.status-idle    { color: #22c55e; border-color: color-mix(in oklab, #22c55e 40%, transparent); }
.sync-badge.status-syncing { color: #3b82f6; border-color: color-mix(in oklab, #3b82f6 40%, transparent); }
.sync-badge.status-offline { color: #fbbf24; border-color: color-mix(in oklab, #fbbf24 40%, transparent); }
.sync-badge.status-error   { color: var(--destructive); border-color: color-mix(in oklab, var(--destructive) 45%, transparent); }

.google-btn {
  width: 100%;
  height: 40px;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
}

.google-btn:disabled { opacity: .6; cursor: default; }

img.avatar { object-fit: cover; }

.auth-error {
  background: color-mix(in oklab, var(--destructive) 12%, transparent);
  border: 1px solid color-mix(in oklab, var(--destructive) 40%, transparent);
  color: var(--destructive);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  margin-bottom: 4px;
}

/* Backdrop behind the sidebar drawer — hidden until the drawer opens */
.nav-backdrop { display: none; }

/* ============================================================
   SAFE AREA — keeping clear of the camera bump

   Installed to a home screen, the app draws under the status bar
   and notch. env(safe-area-inset-top) is the height the system
   reserves there; it is 0 in a normal browser tab, so this costs
   nothing on desktop.

   The padding goes on the sticky topbar (and matching height), not
   on the body, so the bar's background fills the notch area
   instead of leaving a transparent strip above it.
   ============================================================ */

.topbar {
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(48px + env(safe-area-inset-top, 0px));
}

.sidebar { padding-top: env(safe-area-inset-top, 0px); }

.auth-screen {
  padding-top: max(24px, env(safe-area-inset-top, 0px));
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
}

/* ============================================================
   SIGN-IN SCREEN
   ============================================================ */

.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--background);
  padding-left: 20px;
  padding-right: 20px;
  z-index: 100;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.auth-card h1 { margin: 0 0 6px; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.auth-sub { color: var(--muted-foreground); font-size: 14px; margin: 0 0 24px; }

.auth-fine {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  text-align: left;
  font-size: 12px;
  color: var(--muted-foreground);
  margin: 18px 0 0;
  line-height: 1.5;
}
.auth-fine svg { flex: none; margin-top: 2px; }

/* ============================================================
   DETAIL PAGES (task + account)
   ============================================================ */

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

.detail-main, .detail-side { display: flex; flex-direction: column; gap: 14px; }

.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }

.count {
  font-size: 11.5px;
  color: var(--muted-foreground);
  font-weight: 400;
  margin-left: 4px;
}

.hint { font-size: 11.5px; color: var(--muted-foreground); }
.error-hint, .overdue-hint { color: var(--destructive); }

.check.big { width: 22px; height: 22px; border-radius: 7px; margin-top: 4px; }
.check.big svg { width: 14px; height: 14px; }

.task-title-input {
  outline: none;
  border-radius: 6px;
  padding: 1px 4px;
  margin: 0 -4px;
  word-break: break-word;
}
.task-title-input:focus { background: var(--accent); }
.task-title-input.is-done { text-decoration: line-through; color: var(--muted-foreground); }

.parent-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted-foreground);
  margin-bottom: 2px;
}
.parent-link:hover { color: var(--foreground); }

.notes-box { width: 100%; resize: vertical; min-height: 90px; }

.quick-add { margin-top: 10px; }
.quick-add .input { width: 100%; }

.input.is-overdue { border-color: color-mix(in oklab, var(--destructive) 55%, transparent); }

/* ---------- attachments ---------- */

.att-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.att-row:last-of-type { border-bottom: none; }
.att-row:hover { background: var(--accent); }

.att-icon {
  width: 30px; height: 30px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--muted);
  color: var(--muted-foreground);
}

.att-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.att-title { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta { font-size: 11px; color: var(--muted-foreground); }
.att-open { color: var(--muted-foreground); flex: none; }
.att-del { flex: none; opacity: 0; }
.att-row:hover .att-del { opacity: 1; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- account ---------- */

.avatar-editor { display: flex; align-items: center; gap: 16px; }

.avatar-lg {
  width: 72px; height: 72px;
  flex: none;
  border-radius: 99px;
  object-fit: cover;
  background: var(--muted);
}
.avatar-lg.placeholder {
  display: grid; place-items: center;
  font-size: 26px; font-weight: 600;
  color: var(--muted-foreground);
}

.crumb-link:hover { color: var(--foreground); text-decoration: underline; }

/* ============================================================
   RESPONSIVE

   On phones the sidebar stops being a column and becomes a
   drawer that slides over the page. `.nav-open` on .app is what
   opens it — see the toggle-sidebar action in app.js.
   ============================================================ */

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 250px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .22s ease;
  }

  .app.nav-open .sidebar { transform: translateX(0); }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.5);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
  }

  .app.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

  .cal-layout { grid-template-columns: 1fr; }
  .view { padding: 16px 14px 80px; }

  /* Collapsible filter panel */
  .filters-summary { display: flex; }
  .filters { padding: 12px 14px; }
  .filters .filters-body { display: none; padding-top: 10px; }
  .filters.open .filters-body { display: block; }

  /* Month name gets its own line so the controls sit together below it */
  .cal-toolbar { flex-wrap: wrap; gap: 8px; }
  .cal-toolbar .page-title { order: -1; width: 100%; font-size: 19px; }
  .cal-toolbar .spacer { display: none; }
  .cal-toolbar .btn { margin-left: auto; }

  /* Reclaim topbar space */
  .search-trigger { min-width: 0; padding: 0 9px; }
  .search-trigger .st-label, .search-trigger kbd { display: none; }
  .sync-badge { display: none; }

  h1.page-title { font-size: 22px; }
  .page-head { flex-wrap: wrap; }

  /* A month grid needs room — let it scroll sideways rather than crush */
  .cal-shell { overflow-x: auto; }
  .cal-head, .cal-grid { min-width: 620px; }

  .task-meta .pill:not(.overdue):not(.high) { display: none; }

  /* Detail pages stack instead of sitting side by side */
  .detail-grid { grid-template-columns: 1fr; }
  .avatar-editor { flex-direction: column; align-items: flex-start; gap: 12px; }
  .att-del { opacity: 1; }          /* no hover on touch */

  /* The logo stays put on phones; the breadcrumb yields space instead. */
  .crumbs { flex: 1; min-width: 0; overflow: hidden; }
  .crumbs .crumb-link, .crumbs .sep { display: none; }
  .crumbs .current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .topbar-right { gap: 4px; }
}

/* Respect the iPhone home indicator / notch */
@supports (padding: max(0px)) {
  @media (max-width: 820px) {
    .view { padding-bottom: max(80px, env(safe-area-inset-bottom)); }
    .topbar { padding-left: max(14px, env(safe-area-inset-left)); }
  }
}
