:root {
  --hour-height: 48px;          /* pixels per hour, drives all positioning */
  --gutter-width: 56px;
  --accent: #1a73e8;
  --grid-line: #e4e6eb;
  --text: #202124;
  --muted: #70757a;
  --bg: #fff;
  --event-bg: #1a73e8;
  --event-text: #fff;
  /* Calendar-item palette (overridable via the Colors settings page; the
     defaults below match the original look). */
  --occ-bg: #188038;
  --occ-text: #fff;
  --task-recur-bg: #e8f0fe;
  --task-recur-text: #174ea6;
  --task-top3-bg: #fde6a8;
  --task-top3-text: #6b4e00;
  --task-deadline-bg: #fce3e1;
  --task-deadline-text: #b3261e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---- Toolbar ---- */
#toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  /* Pad past the status bar / notch when installed as a standalone app. */
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  border-bottom: 1px solid var(--grid-line);
  flex: 0 0 auto;
}
/* The date label is a button that opens a date picker to jump anywhere. */
.date-jump {
  font: inherit; font-size: 1rem; font-weight: 600;
  background: none; border: none; color: var(--text);
  padding: 5px 8px; margin-right: 2px; border-radius: 8px;
  white-space: nowrap; cursor: pointer;
}
.date-jump:hover { background: #f1f3f4; }

/* ---- Hamburger menu (Settings + calendar show/hide toggles) ---- */
.menu-wrap { position: relative; flex: 0 0 auto; }
.app-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 230px; max-width: 86vw; background: #fff;
  border: 1px solid var(--grid-line); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18); padding: 6px;
  max-height: 70vh; overflow-y: auto;
}
.menu-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 7px; color: var(--text); text-decoration: none; font-size: 0.9rem;
}
.menu-item:hover { background: #f1f3f4; }
.menu-sep { height: 1px; background: var(--grid-line); margin: 6px 4px; }
.menu-head {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted);
}
.menu-head-link { margin-left: auto; text-decoration: none; font-size: 0.95rem; }
.menu-cals { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; }
.menu-cals .muted { padding: 6px 10px; font-size: 0.82rem; }
.menu-cal {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border-radius: 7px; cursor: pointer; font-size: 0.9rem; user-select: none;
}
.menu-cal:hover { background: #f1f3f4; }
.menu-cal input { margin: 0; flex: 0 0 auto; }
.menu-cal .mc-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.menu-cal .mc-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-cal.off .mc-name { color: var(--muted); }
/* Hidden field that hosts the native date picker, anchored under the label. */
.date-jump-input {
  position: absolute; left: 10px; top: 44px;
  width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0;
}
.spacer { flex: 1 1 auto; }

/* Offline write-queue indicator + not-yet-synced items. */
.sync-status { font-size: 0.72rem; white-space: nowrap; }
.sync-status:empty { display: none; }
.sync-status.pending { color: #b06000; }
.sync-status.syncing { color: var(--muted); }
.event.pending, .event.task-block.pending { border-style: dashed; border-color: #fff; }

.btn {
  font: inherit;
  border: 1px solid var(--grid-line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
.btn:hover { background: #f1f3f4; }
.btn.icon { padding: 6px 10px; font-size: 1.1rem; line-height: 1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { border-color: #d93025; color: #d93025; }

/* ---- All-day row ---- */
#allday-row {
  display: flex;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--grid-line);
  min-height: 36px;
  overflow: hidden;
  /* Reserve the grid's measured scrollbar width so cells line up with the day
     columns below. */
  padding-right: var(--sbw, 0px);
}
#allday-gutter { width: var(--gutter-width); flex: 0 0 auto; }
/* Grid with minmax(0,1fr) tracks: columns are always equal and never widen to
   fit a long chip (the chip ellipsizes/clips instead). --cols is set in JS. */
#allday-cells {
  display: grid; flex: 1 1 auto;
  grid-template-columns: repeat(var(--cols, 7), minmax(0, 1fr));
}
.allday-cell { min-width: 0; overflow: hidden; border-left: 1px solid var(--grid-line); padding: 2px; }
.allday-chip {
  background: var(--event-bg); color: var(--event-text);
  font-size: 0.72rem; border-radius: 4px; padding: 5px 6px;
  margin-bottom: 2px; cursor: pointer; touch-action: none;
  user-select: none; -webkit-user-select: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.allday-chip.selected { outline: 2px solid #fbbc04; }
.allday-chip.dragging { opacity: 0.8; }
.allday-cell.drop-target { background: rgba(26, 115, 232, 0.12); }

/* ---- Scrolling grid ---- */
/* The vertical scrollbar here narrows the day columns; its width is measured in
   JS (--sbw) and reserved on the rows above so every row's columns line up. */
#grid-scroll { flex: 1 1 auto; overflow-y: auto; }
#grid { position: relative; display: flex; }

#time-gutter {
  width: var(--gutter-width);
  flex: 0 0 auto;
  position: relative;
}
.hour-label {
  position: absolute;
  right: 6px;
  font-size: 0.68rem;
  color: var(--muted);
  transform: translateY(-50%);
}

#day-columns { display: flex; flex: 1 1 auto; position: relative; }
.day-col {
  flex: 1 1 0;
  position: relative;
  border-left: 1px solid var(--grid-line);
}
.hour-line {
  position: absolute;
  left: 0; right: 0;
  border-top: 1px solid var(--grid-line);
  pointer-events: none;
}

/* Sticky day headers */
#day-headers {
  display: flex;
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
  border-bottom: 1px solid var(--grid-line);
  /* Reserve the grid's measured scrollbar width so headers line up with the
     day columns (--sbw is set in JS from the actual grid scrollbar). */
  padding-right: var(--sbw, 0px);
}
#day-headers .corner {
  width: var(--gutter-width); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.nav-arrow {
  border: none; background: none; color: var(--accent);
  font-size: 1.25rem; line-height: 1; padding: 4px 3px; cursor: pointer;
}
.nav-arrow:hover { background: #f1f3f4; border-radius: 6px; }
.day-head {
  flex: 1 1 0;
  text-align: center;
  padding: 4px 0;
  border-left: 1px solid var(--grid-line);
  cursor: pointer;
}
.day-head .dow { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; }
.day-head .dom { font-size: 1.25rem; line-height: 1.1; }
.day-head.today .dom {
  background: var(--accent); color: #fff;
  border-radius: 50%; width: 1.7em; height: 1.7em;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---- Event blocks ---- */
.event {
  position: absolute;
  background: var(--event-bg);
  color: var(--event-text);
  border-radius: 5px;
  padding: 2px 5px;
  font-size: 0.74rem;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.35);
}
.event.selected { outline: 2px solid #fbbc04; z-index: 3; }
.event .ev-title { font-weight: 600; }
.event .ev-time { opacity: 0.85; font-size: 0.68rem; }
/* touch-action: none so a vertical drag on an event is never claimed by the
   browser as page scrolling (which fires pointercancel and freezes the drag).
   Scroll the grid by touching empty space instead. */
.event { touch-action: none; user-select: none; -webkit-user-select: none; }
/* First occurrence of a recurring series — gold left stripe; dragging it moves
   the whole series (other occurrences move only themselves). */
.event.recurring.first { box-shadow: inset 4px 0 0 #fbbc04; }
.event.dragging { z-index: 10; opacity: 0.9; box-shadow: 0 2px 10px rgba(0,0,0,0.3); cursor: grabbing; }

/* Resize grips: the top edge changes the start, the bottom edge changes the end.
   Each strip covers HALF the edge — start at the top-RIGHT, end at the
   bottom-LEFT. The halves keep adjacent stacked events disambiguated (their
   touching handles sit on opposite sides) and dodge the top-left title text.
   On opposite corners they never collide, so even a 15-min block stays
   resizable from both halves. */
.ev-handle {
  position: absolute; width: 50%; height: 14px;
  cursor: ns-resize; touch-action: none; z-index: 2;
}
.ev-handle.start { top: -5px; right: 0; }
.ev-handle.end { bottom: -5px; left: 0; }
/* Visible pill spanning the half-width strip. */
.ev-handle::after {
  content: ""; position: absolute; left: 2px; right: 2px; top: 50%;
  height: 5px; transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px solid var(--accent); border-radius: 999px;
}
/* Active (grabbed) handle: filled, larger — confirms a resize was triggered. */
.ev-handle.active::after {
  background: var(--accent); border-color: #fff; height: 9px;
}

/* Bigger grab strip and pill on touch devices. */
@media (pointer: coarse) {
  .ev-handle { height: 24px; }
  .ev-handle.start { top: -10px; }
  .ev-handle.end { bottom: -10px; }
  .ev-handle::after { height: 7px; }
  .ev-handle.active::after { height: 12px; }
}

/* Ghost preview of an event being created. */
.event.ghost {
  background: rgba(26, 115, 232, 0.22);
  border: 1.5px dashed var(--accent);
  color: var(--accent);
  z-index: 3;
}

/* Current-time line (today only). */
.now-line {
  position: absolute; left: 0; right: 0; height: 0;
  border-top: 2px solid #ea4335; z-index: 4; pointer-events: none;
}
.now-line::before {
  content: ""; position: absolute; left: -1px; top: -4px;
  width: 8px; height: 8px; border-radius: 50%; background: #ea4335;
}

/* Disable native scrolling under an active drag. */
body.dragging-active { overflow: hidden; touch-action: none; }
body.dragging-active #grid-scroll { overflow: hidden; }

.btn:disabled { opacity: 0.4; cursor: default; }

/* ---- Blip overlay (future health records) ---- */
#blip-layer {
  position: absolute;
  left: var(--gutter-width); top: 0; right: 0; bottom: 0;
  pointer-events: none;
}
.blip {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 1.05rem;
  line-height: 1;
  pointer-events: auto;
  cursor: pointer;
  z-index: 5;
  /* White halo so the emoji reads over colored event blocks. */
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff;
}

/* Health panel field groups (shown per kind). */
.hp-group { display: flex; flex-direction: column; gap: 8px; }
.hp-emoji { font-size: 1.4rem; }

/* ---- Detail panels (event + task share .panel) ---- */
.panel {
  position: fixed;
  z-index: 20;
  background: #fff;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
}
.panel.hidden { display: none; }
.panel label { display: flex; flex-direction: column; font-size: 0.78rem; color: var(--muted); gap: 3px; }
.panel label.checkbox { flex-direction: row; align-items: center; gap: 6px; }
.panel input[type=text],
.panel input[type=date],
.panel input[type=datetime-local],
.panel textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--grid-line); border-radius: 6px; padding: 7px;
}
/* Auto-growing free-text fields: JS sizes the height to the content (capped),
   so hide the manual resize grip and the scrollbar until the cap is hit. */
.panel textarea.autogrow { resize: none; overflow-y: auto; line-height: 1.35; }
.panel-head { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; font-weight: 600; }
.panel-head #panel-title-label { font-weight: 600; color: var(--text); }
.tp-score { color: var(--muted); font-weight: 400; font-size: 0.8rem; }
/* Recurring-occurrence scope selector — highlighted so it's not missed. */
.panel .scope-row {
  background: #fff8e1; border: 1px solid #ffe082; border-radius: 6px;
  padding: 7px 9px; color: #7a5900; font-weight: 600;
}
.panel .scope-row select { margin-top: 3px; font-weight: 400; }
.tp-hint { font-size: 0.72rem; color: var(--muted); margin: 0; }
/* Scrollable field area so the header + actions stay pinned and Apply is
   always reachable without scrolling the whole panel. */
.panel-body {
  flex: 1 1 auto; overflow-y: auto; min-height: 0;
  display: flex; flex-direction: column; gap: 8px;
  margin: 0;   /* the event body is a <form>; drop any UA default margin */
}
.row { display: flex; gap: 8px; }
.row label { flex: 1 1 0; }
.panel-actions {
  display: flex; align-items: center; gap: 8px; flex: 0 0 auto; padding-top: 8px;
}

/* Mobile: bottom sheet, capped height so the body scrolls under fixed actions. */
@media (max-width: 767px) {
  .panel {
    left: 0; right: 0; bottom: 0; border-radius: 14px 14px 0 0;
    max-height: 85vh; max-height: 85dvh;
  }
}
/* Desktop: panel docks to the right, full height. */
@media (min-width: 768px) {
  .panel { top: 0; right: 0; bottom: 0; width: 340px; border-radius: 0; }
}

/* ---- Task band + chips + scheduled blocks ---- */
#task-row {
  display: flex; flex: 0 0 auto;
  border-bottom: 1px solid var(--grid-line);
  overflow: hidden;
  /* Reserve the grid's measured scrollbar width so cells line up with the day
     columns below. (Non-scrolling, so the reservation is exact.) */
  padding-right: var(--sbw, 0px);
}
#task-gutter {
  width: var(--gutter-width); flex: 0 0 auto;
  font-size: 0.62rem; color: var(--accent); text-transform: uppercase;
  padding: 3px 4px; text-align: right; text-decoration: none;
  display: flex; align-items: center; justify-content: flex-end; font-weight: 600;
}
#task-gutter:hover { text-decoration: underline; }
#task-cells {
  display: grid; flex: 1 1 auto;
  grid-template-columns: repeat(var(--cols, 7), minmax(0, 1fr));
}
.task-cell { min-width: 0; overflow: hidden; border-left: 1px solid var(--grid-line); padding: 2px; min-height: 18px; }
.task-chip {
  display: flex; align-items: center; gap: 4px;
  background: var(--task-recur-bg); color: var(--task-recur-text); border-radius: 4px;
  padding: 2px 5px; margin-bottom: 2px; font-size: 0.72rem; cursor: grab;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
/* Top-3 by score = gold; deadline-today = red; recurring due = faded blue. */
.task-chip.top3 { background: var(--task-top3-bg); color: var(--task-top3-text); }
.task-chip.deadline { background: var(--task-deadline-bg); color: var(--task-deadline-text); }
.task-chip.dragging { opacity: 0.6; cursor: grabbing; }
.task-chip.done { opacity: 0.5; }
/* Already has a planned block on the grid → faded (needs less attention). */
.task-chip.scheduled { opacity: 0.5; }
.task-chip.done .tc-label { text-decoration: line-through; }
.task-chip input[type=checkbox] { margin: 0; flex: 0 0 auto; }
.task-chip .tc-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-chip .tc-due { flex: 0 0 auto; }
/* Scheduled-task block on the grid: green, distinct from events. */
.event.task-block { background: var(--occ-bg); color: var(--occ-text); border: 1px solid rgba(255,255,255,0.4); }
.event.task-block.done { opacity: 0.55; }
.event.task-block.done .ev-title span { text-decoration: line-through; }
.event.task-block .ev-title { display: flex; align-items: center; gap: 3px; }
.event.task-block .occ-check { flex: 0 0 auto; margin: 0; width: 13px; height: 13px; }
.event.task-block .ev-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Ghost block shown while dragging a task chip onto the grid. */
.event.task-block.sched-ghost {
  opacity: 0.85; border: 1.5px dashed #fff; pointer-events: none; z-index: 6;
}

/* ---- Tasks spreadsheet page ---- */
.task-filter {
  flex: 1 1 160px; min-width: 110px; max-width: 340px;
  font: inherit; padding: 6px 10px;
  border: 1px solid var(--grid-line); border-radius: 8px;
}
.task-filter:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#task-table tr[hidden] { display: none; }
#task-scroll { flex: 1 1 auto; overflow: auto; }
#task-table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 0.82rem; }
#task-table th, #task-table td { border: 1px solid var(--grid-line); padding: 0; }
#task-table th {
  background: #f1f3f4; padding: 5px 6px; position: sticky; top: 0; z-index: 1;
  white-space: nowrap; font-weight: 600;
}
#task-table input {
  border: none; background: transparent; font: inherit;
  padding: 6px; width: 100%; box-sizing: border-box;
}
#task-table input.num { width: 46px; text-align: right; }
#task-table input[type=date] { width: 132px; }
#task-table .task-title { min-width: 180px; }
#task-table .task-details { min-width: 150px; }
#task-table .task-recur { min-width: 110px; font-variant-numeric: tabular-nums; }
#task-table td.score {
  padding: 6px 8px; text-align: right; font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
#task-table td.base-score {
  padding: 6px 8px; text-align: right; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
#task-table input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
#task-table tr.pending td { box-shadow: inset 2px 0 0 #d99000; }
#task-table tr.completed { opacity: 0.5; }
#task-table tr.completed .task-title { text-decoration: line-through; }
/* Recurring task: completing it re-bases the cycle (the row stays active),
   so flash green to confirm the completion was logged. */
@keyframes recur-logged {
  0% { background: #c6f0d0; }
  100% { background: transparent; }
}
#task-table tr.recur-logged td { animation: recur-logged 1.1s ease-out; }
#task-table .btn.icon { border: none; padding: 4px 8px; }
.show-completed { display: flex; align-items: center; gap: 5px; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
#task-empty { color: var(--muted); padding: 16px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* ---- Settings page ---- */
.settings-body { padding: 16px; overflow-y: auto; }
.settings-body .card {
  max-width: 540px; border: 1px solid var(--grid-line); border-radius: 10px;
  padding: 16px; margin-bottom: 16px;
}
.settings-body .card h2 { margin: 0 0 10px; font-size: 1rem; }
.settings-body .muted { color: var(--muted); font-size: 0.85rem; }
.settings-body .btn { margin-top: 8px; }
.gcal-list { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.gcal-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px;
  border: 1px solid var(--grid-line); border-radius: 8px; }
.gcal-main { display: flex; align-items: center; gap: 7px; flex: 1 1 auto; min-width: 0;
  flex-direction: row; cursor: pointer; }
.gcal-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.gcal-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcal-role { flex: 0 0 auto; font-size: 0.72rem; color: var(--muted); }
.gcal-star { border: none; padding: 2px 5px; font-size: 1rem; flex: 0 0 auto; }
/* ---- Colors page ---- */
.color-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.color-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  border: 1px solid var(--grid-line); border-radius: 8px; }
.color-swatch { flex: 0 0 auto; width: 34px; height: 26px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; font-size: 0.72rem;
  font-weight: 600; border: 1px solid rgba(0,0,0,0.12); }
.color-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 0.9rem; }
.color-hex { flex: 0 0 auto; width: 8ch; padding: 4px 6px; border: 1px solid var(--grid-line);
  border-radius: 6px; font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem; text-transform: lowercase; color: var(--text); }
.color-hex.invalid { border-color: #d93025; color: #d93025; }
.color-pick { flex: 0 0 auto; width: 36px; height: 28px; padding: 0; border: 1px solid var(--grid-line);
  border-radius: 6px; background: none; cursor: pointer; }
.color-reset { flex: 0 0 auto; border: none; padding: 2px 6px; font-size: 0.95rem; }
.color-reset:disabled { opacity: 0.3; cursor: default; }

.user-list { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.user-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; border: 1px solid var(--grid-line); border-radius: 8px; }
.add-user { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.add-user input { font: inherit; padding: 7px 10px; border: 1px solid var(--grid-line);
  border-radius: 8px; flex: 1 1 120px; min-width: 0; }

/* ---- Auth (login / setup) ---- */
.auth-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; gap: 12px;
  border: 1px solid var(--grid-line); border-radius: 12px; padding: 22px;
}
.auth-card h1 { margin: 0; font-size: 1.3rem; }
.auth-card .muted { margin: 0; color: var(--muted); font-size: 0.85rem; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.auth-card input {
  font: inherit; font-size: 1rem; padding: 9px 11px;
  border: 1px solid var(--grid-line); border-radius: 8px;
}
.auth-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.auth-card .btn { margin-top: 4px; padding: 9px; }
.auth-error { margin: 0; color: #c5221f; font-size: 0.85rem; }

/* ---- Backups page ---- */
.backup-list { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-width: 640px; }
.backup-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--grid-line); border-radius: 8px;
}
.backup-info { display: flex; flex-direction: column; min-width: 0; }
.backup-info .b-when { font-weight: 600; }
.backup-info .b-meta { font-size: 0.78rem; color: var(--muted); }
.backup-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.backup-actions .btn.icon { border: none; padding: 4px 7px; text-decoration: none; }

/* ---- Search page ---- */
.search-body {
  padding: 12px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; max-width: 720px;
}
.search-input {
  font: inherit; font-size: 1rem; padding: 9px 12px;
  border: 1px solid var(--grid-line); border-radius: 10px;
}
.search-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search-types { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.85rem; }
.search-types label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.search-status { color: var(--muted); font-size: 0.8rem; min-height: 1em; }
.search-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.search-result .sr-link {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border: 1px solid var(--grid-line); border-radius: 8px;
  text-decoration: none; color: var(--text);
}
a.sr-link:hover { background: #f1f3f4; }
.sr-badge { flex: 0 0 auto; font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.sr-title { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.sr-meta { flex: 0 0 auto; font-size: 0.76rem; color: var(--muted); white-space: nowrap; }

/* "New version available" toast (PWA update). */
#update-toast {
  position: fixed; left: 50%; z-index: 100;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  background: #202124; color: #fff;
  padding: 9px 9px 9px 16px; border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); font-size: 0.85rem;
  max-width: calc(100vw - 24px);
}
#update-toast button {
  font: inherit; font-weight: 600; border: none; cursor: pointer;
  background: var(--accent); color: #fff; border-radius: 999px; padding: 6px 14px;
}

.hidden { display: none !important; }
