:root {
  --bg: #0a0d12;
  --panel: #12161d;
  --panel-alt: #171c24;
  --border: #232a35;
  --track: #1e242e;
  --text: #e7ebf0;
  --muted: #7c8798;
  --danger: #ff5c5c;
  --warn: #f5a524;
  --accent: #00e58f;
  --accent-weak: #00e58f29;
  --accent-glow: #00e58f73;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

#app { position: relative; min-height: 100vh; }

.hidden { display: none !important; }

/* ---- login ---- */
#login-screen {
  max-width: 360px;
  margin: 15vh auto 0;
  padding: 0 16px;
}
.login-logo { display: block; margin: 0 0 12px; border-radius: 16px; }
#login-screen h1 { font-size: 22px; margin-bottom: 4px; }
#login-screen p.sub { color: var(--muted); margin-top: 0; margin-bottom: 24px; }
.profile-picker { display: flex; gap: 12px; margin-bottom: 16px; }
.profile-btn {
  flex: 1;
  padding: 14px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}
.profile-btn.selected { border-color: var(--accent); background: var(--accent-weak); }
input[type="password"], input[type="text"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-body);
  margin-bottom: 12px;
}
input[type="color"] {
  width: 48px; height: 36px; padding: 2px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel-alt); cursor: pointer;
}
button.primary {
  width: 100%;
  padding: 11px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #05100b;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button.primary:disabled { opacity: 0.6; cursor: default; }
.error-text { color: var(--danger); font-size: 13px; margin: -4px 0 12px; }

/* ---- app shell: LHSNB + content ---- */
#app-shell { display: flex; min-height: 100vh; }

#lhsnb {
  width: 220px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 16px;
}
.lhsnb-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; padding: 0 8px; letter-spacing: 0.02em; }
.brand-logo { border-radius: 6px; flex-shrink: 0; }
#lhsnb-items { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; border-radius: 8px; border: none; background: none;
  color: var(--muted); font-size: 14px; text-align: left; cursor: pointer; width: 100%;
  font-family: var(--font-body);
}
.nav-item:hover { background: var(--panel-alt); color: var(--text); }
.nav-item.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.nav-icon { display: inline-flex; flex-shrink: 0; color: var(--muted); }
.nav-item:hover .nav-icon { color: var(--text); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.nav-item[draggable="true"] { cursor: grab; }
.nav-item.dragging { opacity: 0.4; cursor: grabbing; }
.lhsnb-footer { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.lhsnb-footer .who { font-size: 13px; color: var(--muted); }
.lhsnb-footer button.link {
  background: none; border: none; color: var(--muted); font-size: 12px;
  text-decoration: underline; cursor: pointer; padding: 0; text-align: left;
}

#main-content {
  --main-pad: 24px;
  flex: 1;
  min-width: 0;
  padding: var(--main-pad) 24px 64px;
  max-width: 1200px;
  margin-right: 340px;
  transition: margin-right 0.15s ease;
}
#app-shell.calendar-collapsed #main-content { margin-right: 64px; }
/* The Home widget grid should use all the room it has out to the calendar
   panel instead of stopping at the same 1200px cap other, text-heavy views
   (Settings, forms) want so their content doesn't stretch awkwardly wide. */
#main-content:has(.view[data-view="home"]:not(.hidden)) { max-width: none; }
/* Home's pan/zoom canvas fills the window exactly (no page scroll), and
   Settings > Grid Edit gets the same full width to show the whole plane.
   gridCanvas.js's homeViewportSize() mirrors these paddings in JS. */
#main-content:has(.view[data-view="home"]:not(.hidden)),
#main-content:has(.grid-edit) { max-width: none; padding-bottom: var(--main-pad); }

.settings-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.settings-tab {
  padding: 8px 14px; border: none; background: none; color: var(--muted);
  font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

@media (max-width: 720px) {
  #lhsnb { width: 64px; padding: 12px 6px; }
  .lhsnb-brand, .nav-label, .lhsnb-footer .who { display: none; }
  .nav-item { justify-content: center; }
  #main-content { --main-pad: 16px; padding: var(--main-pad) 12px 48px; }
}

/* ---- RHSNB: Calendar panel ----
   Mirror of LHSNB: docked flush to its edge (right, vs. LHSNB's left) and
   taken out of the flex flow so it always sits at the true screen edge
   instead of wherever #main-content's max-width happens to leave it.
   Expanding grows leftward from the fixed right edge; collapsing shrinks
   back toward it. #main-content reserves space via margin-right. */
#rhsnb {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--border);
  width: 340px;
  transition: width 0.15s ease;
  display: flex;
  flex-direction: column;
  z-index: 30;
}
#rhsnb.collapsed { width: 64px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; border: none;
  background: none; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-alt); color: var(--text); }
.icon-btn svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

#rhsnb-collapsed-tile { padding: 16px 0; }
.rhsnb-tile-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 100%; padding: 14px 0; background: none; border: none; cursor: pointer; color: var(--muted);
}
.rhsnb-tile-btn:hover { color: var(--text); }
.rhsnb-tile-icon svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.rhsnb-tile-count { font-size: 20px; font-weight: 700; color: var(--accent); }
.rhsnb-tile-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

#rhsnb-expanded { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.rhsnb-header { display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.rhsnb-tabs { display: flex; gap: 4px; flex: 1; }
.rhsnb-tab {
  flex: 1; padding: 6px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--panel-alt);
  color: var(--muted); font-size: 12px; cursor: pointer; text-transform: capitalize; font-family: var(--font-body);
}
.rhsnb-tab.selected { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
.rhsnb-tab.small { flex: 1; padding: 4px 6px; font-size: 11px; }
.rhsnb-granularity { padding: 0 12px 10px; border-bottom: 1px solid var(--border); }

.rhsnb-body { flex: 1; overflow-y: auto; padding: 12px; min-height: 0; }
.rhsnb-nav-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.rhsnb-nav-label { font-size: 13px; font-weight: 600; }

.rhsnb-week-grid { display: flex; gap: 4px; }
.rhsnb-week-col {
  flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: 6px 4px;
  min-height: 120px; cursor: pointer;
}
.rhsnb-week-col.today { border-color: var(--accent); }
.rhsnb-week-col-head { font-size: 10px; color: var(--muted); text-align: center; margin-bottom: 4px; }
.rhsnb-week-event {
  font-size: 10px; background: var(--accent-weak); color: var(--text); border-radius: 4px;
  padding: 2px 3px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.rhsnb-month-dow { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.rhsnb-month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.rhsnb-month-cell {
  aspect-ratio: 1; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; gap: 2px; font-size: 12px;
}
.rhsnb-month-cell:hover { background: var(--panel-alt); }
.rhsnb-month-cell.muted { color: var(--muted); opacity: 0.4; }
.rhsnb-month-cell.today .rhsnb-month-daynum { color: var(--accent); font-weight: 700; }
.rhsnb-month-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }

.rhsnb-add-event { border-top: 1px solid var(--border); padding: 12px; }
.rhsnb-add-event input, .rhsnb-add-event select { margin-bottom: 8px; font-size: 13px; padding: 8px 10px; }
.rhsnb-add-event .row { display: flex; gap: 6px; }
.rhsnb-add-event button.small {
  padding: 8px 12px; border-radius: 8px; border: none;
  background: var(--accent); color: #05100b; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}

.icon-btn.active { background: var(--accent-weak); color: var(--accent); }

.rhsnb-cal-picker { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.rhsnb-cal-row { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.rhsnb-cal-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }
.rhsnb-cal-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.rhsnb-cal-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rhsnb-event-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.rhsnb-event-row { cursor: pointer; border-radius: 6px; }
.rhsnb-event-row:hover { background: var(--panel-alt); }
.rhsnb-week-event { cursor: pointer; }
.rhsnb-week-event:hover { filter: brightness(1.3); }

/* ---- event detail / edit modal ---- */
#rhsnb-event-modal { position: fixed; inset: 0; z-index: 50; }
.rhsnb-modal-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); }
.rhsnb-modal-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.rhsnb-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.rhsnb-modal-body { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.rhsnb-modal-body input, .rhsnb-modal-body textarea { margin-bottom: 0; }
.rhsnb-modal-body .row { display: flex; gap: 8px; margin-top: 8px; }
.rhsnb-modal-body .row button.small, .rhsnb-modal-body .row a.small {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-alt);
  color: var(--text); font-size: 13px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
}
.rhsnb-modal-body button.primary { width: auto; padding: 8px 16px; }
.rhsnb-modal-title { font-size: 16px; font-weight: 700; }
.rhsnb-modal-when { color: var(--muted); font-size: 13px; margin-top: 2px; }
.rhsnb-modal-location, .rhsnb-modal-description { font-size: 13px; margin-top: 8px; }
.rhsnb-modal-section-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 12px; }

/* ---- shared floating hover-preview popover ----
   Used by the RHSNB month view (a day's events) and the Home Tasking
   card's priority tiles (a tile's items) — same look, positioned next to
   whatever's hovered, non-interactive (just a peek). */
.hover-preview-popover {
  position: fixed; z-index: 40; width: 220px; max-height: 260px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 10px 12px; pointer-events: none;
}
/* Priority Items tiles have many more entries than an RHSNB day, so let this
   variant grow to fit them all instead of the shared 260px cap + scrollbar —
   the viewport itself is still the ceiling, and home.js repositions it above
   the tile when it won't fit below. */
.hover-preview-popover.task-tile-preview-popover { max-height: calc(100vh - 16px); }
.hover-preview-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.hover-preview-popover ul.item-list li { font-size: 12px; padding: 5px 0; }
.rhsnb-day-preview-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }

@media (max-width: 960px) {
  #rhsnb { display: none; }
  /* #rhsnb is hidden here, not just narrowed, so #main-content shouldn't
     reserve space for it — revisit properly when mobile layout is done. */
  #main-content, #app-shell.calendar-collapsed #main-content { margin-right: 0; }
}

/* Plain CSS grid of fixed square cells, used for simple side-by-side
   layouts (e.g. Itinerary). Home uses the pan/zoom plane below instead. */
.grid {
  --cell: 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--cell));
  grid-auto-rows: var(--cell);
  grid-auto-flow: row dense;
  gap: calc(var(--cell) * 0.2);
  position: relative;
  touch-action: pan-y;
}

/* ---- Home grid plane (see public/js/gridCanvas.js) ----
   .grid-viewport is the window onto a fixed 4000×4000 .grid-world that the
   camera moves with one CSS transform. Cards sit on the world at absolute
   cell-snapped px positions (40px cells + 8px gaps). --zoom is set on the
   viewport so on-screen-constant bits (handles, labels) can divide by it. */
.grid-viewport {
  --zoom: 1;
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  touch-action: none;
  cursor: grab;
  overscroll-behavior: contain;
}
.grid-viewport.panning { cursor: grabbing; user-select: none; }
.grid-world {
  position: absolute;
  left: 0;
  top: 0;
  width: 4000px;
  height: 4000px;
  transform-origin: 0 0;
  /* A dot at every cell corner (centred in the 8px gaps), and the plane's
     edge — both divided by --zoom so they stay visible when zoomed out. */
  background-image: radial-gradient(circle, var(--border) calc(1.5px / var(--zoom)), transparent calc(2px / var(--zoom)));
  background-size: 48px 48px;
  background-position: 20px 20px;
  box-shadow: 0 0 0 calc(1px / var(--zoom)) var(--border);
}
.home-viewport { height: calc(100dvh - 2 * var(--main-pad)); }
.home-viewport .card {
  position: absolute;
  /* One finger drags the plane — unless the card itself has content to
     scroll, in which case a swipe on it scrolls the card. */
  touch-action: none;
}
.home-viewport .card.is-scrollable { touch-action: pan-y; }
.grid-viewport.panning .card { cursor: grabbing; }

.grid-camera-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: default;
}
.grid-camera-controls .icon-btn { width: 26px; height: 26px; font-size: 15px; }
.grid-zoom-label { min-width: 42px; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- Settings > Grid Edit ---- */
.grid-edit-hint { color: var(--muted); font-size: 12px; margin: 0 0 12px; line-height: 1.5; }
.grid-edit-hint-frame { color: var(--accent); font-weight: 600; }
/* Faint line per cell, a stronger one every 10 cells (kept ~1px on screen
   at any zoom), and a clear edge so the plane's bounds are obvious. */
.grid-edit-world {
  background-color: var(--panel-alt);
  background-image:
    linear-gradient(to right, var(--border) calc(1px / var(--zoom)), transparent 0),
    linear-gradient(to bottom, var(--border) calc(1px / var(--zoom)), transparent 0),
    linear-gradient(to right, var(--track) 1px, transparent 0),
    linear-gradient(to bottom, var(--track) 1px, transparent 0);
  background-size: 480px 480px, 480px 480px, 48px 48px, 48px 48px;
  box-shadow: 0 0 0 calc(2px / var(--zoom)) var(--muted);
}
.grid-edit-card {
  position: absolute;
  box-sizing: border-box;
  border-radius: calc(10px / var(--zoom));
  border: calc(1.5px / var(--zoom)) solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: move;
  touch-action: none;
  overflow: hidden;
  padding: min(calc(8px / var(--zoom)), 24px);
  user-select: none;
}
.grid-edit-card:hover { border-color: var(--muted); }
.grid-edit-card.auto { border-style: dashed; }
.grid-edit-card.overlapping { border-color: var(--danger); }
.grid-edit-viewport.dragging .grid-edit-card { cursor: grabbing; }
.grid-edit-card-label {
  font-size: min(calc(12px / var(--zoom)), 64px);
  line-height: 1.2;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.grid-edit-card-size { font-size: min(calc(11px / var(--zoom)), 56px); color: var(--muted); margin-top: calc(2px / var(--zoom)); }
.grid-edit-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  /* Constant on-screen size, but never more than a corner of a card that's
     tiny because you're zoomed far out. */
  width: min(calc(18px / var(--zoom)), 30%);
  height: min(calc(18px / var(--zoom)), 30%);
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--accent) 50%);
  border-top-left-radius: calc(4px / var(--zoom));
  opacity: 0.7;
}
.grid-edit-card:hover .grid-edit-resize { opacity: 1; }
/* The Home view frame: only its edges and tab take the pointer, so cards
   inside it stay draggable. */
.grid-edit-homeview {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  border: calc(2px / var(--zoom)) dashed var(--accent);
  background: var(--accent-weak);
  box-sizing: border-box;
}
.grid-edit-homeview-edge { position: absolute; pointer-events: auto; cursor: move; touch-action: none; }
.grid-edit-homeview-edge.top,
.grid-edit-homeview-edge.bottom { left: 0; right: 0; height: calc(12px / var(--zoom)); }
.grid-edit-homeview-edge.left,
.grid-edit-homeview-edge.right { top: 0; bottom: 0; width: calc(12px / var(--zoom)); }
.grid-edit-homeview-edge.top { top: calc(-6px / var(--zoom)); }
.grid-edit-homeview-edge.bottom { bottom: calc(-6px / var(--zoom)); }
.grid-edit-homeview-edge.left { left: calc(-6px / var(--zoom)); }
.grid-edit-homeview-edge.right { right: calc(-6px / var(--zoom)); }
.grid-edit-homeview-tab {
  position: absolute;
  left: calc(-2px / var(--zoom));
  bottom: 100%;
  pointer-events: auto;
  cursor: move;
  touch-action: none;
  white-space: nowrap;
  font-size: calc(12px / var(--zoom));
  font-weight: 600;
  color: #05100b;
  background: var(--accent);
  padding: calc(3px / var(--zoom)) calc(8px / var(--zoom));
  border-radius: calc(6px / var(--zoom)) calc(6px / var(--zoom)) 0 0;
  user-select: none;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: auto;
  box-sizing: border-box;
  /* Cards outside Home (Settings, Tasking…) scroll with the page as usual;
     Home's plane overrides this (see .home-viewport .card). */
  touch-action: pan-y;
  scrollbar-width: none;
}
.card::-webkit-scrollbar { display: none; }
/* A card grown by expandCardToFitContent (see home.js) can overlap the
   cards below it on the plane — without this it paints under them (later DOM
   order wins ties) and traps clicks/hover on whatever it's covering. */
.card.content-expanded { z-index: 6; box-shadow: 0 10px 28px rgba(0,0,0,.35); }
/* Replaces the native scrollbar: skinny chevrons that sit pinned to the
   card's scroll edges (position: sticky within the scrolling .card itself,
   so no extra wrapper is needed) and fade in only on the side there's more
   content to reveal. Zero-height boxes so they never add layout space. */
.card-scroll-hint {
  position: sticky;
  left: 0; right: 0;
  height: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 3;
}
.card-scroll-hint-up { top: 0; }
.card-scroll-hint-down { bottom: 0; }
.card-scroll-hint svg {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.15s, transform 0.15s;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.5));
}
.card-scroll-hint-down svg { transform: translateY(6px); }
.card-scroll-hint.visible svg { opacity: 0.85; transform: translateY(0); }
.card h2 { font-size: 14px; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.card .stat { font-size: 28px; font-weight: 700; }
.card .stat-label { color: var(--muted); font-size: 13px; margin-top: -4px; }
.card .empty { color: var(--muted); font-size: 14px; }
.card .unavailable { color: var(--muted); font-size: 13px; font-style: italic; }

.card-header-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.card-header-actions .icon-btn { width: 22px; height: 22px; font-size: 13px; flex-shrink: 0; }
.card-refresh-btn { width: 22px; height: 22px; flex-shrink: 0; }
.card-refresh-btn.spinning svg { animation: card-refresh-spin 0.6s linear infinite; }
@keyframes card-refresh-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---- Render services card ---- */
.render-services { display: flex; flex-direction: column; margin-top: 4px; }
.render-service {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 12px 4px;
  border-top: 1px solid var(--border);
}
.render-service:first-child { border-top: none; }
.render-service-status-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); text-transform: capitalize; flex-shrink: 0; width: 110px; }
.render-status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.render-status-dot.status-live { background: var(--accent); box-shadow: 0 0 6px var(--accent-glow); }
.render-status-dot.status-building, .render-status-dot.status-deploying, .render-status-dot.status-update_in_progress { background: var(--warn); }
.render-status-dot.status-build_failed, .render-status-dot.status-update_failed { background: var(--danger); }
.render-status-dot.status-suspended, .render-status-dot.status-unknown, .render-status-dot.status-deactivated, .render-status-dot.status-canceled { background: var(--muted); }
.render-service-name { font-weight: 600; font-size: 14px; flex-shrink: 0; width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.render-service-name a { color: inherit; text-decoration: none; }
.render-service-name a:hover { text-decoration: underline; }
.render-service-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.render-service-meta span { white-space: nowrap; }
.render-service-commit { flex: 1; min-width: 160px; font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.render-service-commit .render-commit-time { color: var(--muted); margin-left: 6px; }

/* ---- History strip (recent deploys / backup runs, oldest → newest) ---- */
.history-strip { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.history-dot { width: 8px; height: 8px; border-radius: 2px; }

/* ---- App Status card: one shared grid so every row's columns (status,
   name, meta, history, commit) line up regardless of how long each row's
   own content is — a per-row flex layout (still used elsewhere, e.g.
   Backup Status) can't do that since each row sizes its own columns
   independently. Rows are `display: contents` so their cells become
   direct children of the grid; a separate full-width divider element
   between rows draws one continuous line instead of border-top on every
   cell (which would show gaps at each column-gap). */
.app-status-grid {
  display: grid;
  grid-template-columns: 110px 180px 70px max-content 1fr;
  column-gap: 16px;
}
.app-status-row { display: contents; }
.app-status-row > * { padding: 10px 0; align-self: center; }
.app-status-divider { grid-column: 1 / -1; height: 1px; background: var(--border); }
.app-status-grid .render-service-commit { text-align: left; }
.commit-sha {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--muted);
  text-decoration: none;
}
.commit-sha:hover { color: var(--text); text-decoration: underline; }

ul.item-list { list-style: none; margin: 8px 0 0; padding: 0; }
ul.item-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px;
}
ul.item-list li:first-child { border-top: none; }
ul.item-list li .title { flex: 1; color: var(--text); }
ul.item-list li .title.done { text-decoration: line-through; color: var(--muted); }
ul.item-list li .amount { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }

/* Important Emails card — each row is subject+time on one line and a
   muted from/snippet preview on the next, unlike the default single-row
   item-list li, so it needs its own column layout instead of the shared
   flex-row one. */
ul.item-list.gmail-item-list li { flex-direction: column; align-items: stretch; gap: 2px; }
.gmail-item-row { display: flex; align-items: center; gap: 8px; }
.gmail-item-row .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gmail-item-preview {
  font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* "What I'm working on" card — wide, easy-to-hit pills instead of thin rows */
ul.item-list.pill-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
ul.item-list.pill-list li {
  border-top: none; padding: 10px 16px; border-radius: 999px;
  background: var(--panel-alt); cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
ul.item-list.pill-list li:hover { transform: translateY(-1px); }
ul.item-list.pill-list li .title { font-weight: 600; }

.trip-row { cursor: pointer; border-radius: 8px; }
.trip-row.selected { background: var(--accent-weak); }

.quick-add { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.quick-add .row { display: flex; gap: 8px; }
.quick-add .row input { margin-bottom: 8px; }
.quick-add button.small {
  padding: 9px 14px; border-radius: 8px; border: none;
  background: var(--accent); color: #05100b; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}

.trip-countdown { display: flex; align-items: baseline; gap: 10px; margin-top: 4px; }
.trip-countdown-num {
  font-size: 56px; font-weight: 800; line-height: 1; color: var(--accent);
  text-shadow: 0 0 18px var(--accent-glow);
}
.trip-countdown-unit { font-size: 15px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.trip-countdown-word {
  font-size: 32px; font-weight: 800; color: var(--accent); text-shadow: 0 0 18px var(--accent-glow);
  text-transform: capitalize;
}

.layout-save-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(12px);
  background: var(--panel-alt); border: 1px solid var(--border); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.layout-save-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- charts ---- */
.chart-card svg { display: block; max-width: 100%; }
.gauge-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.bar-list { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.bar-list-row { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 8px; }
.bar-list-label { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list-track { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar-list-fill { height: 100%; border-radius: 4px; }
.bar-list-value { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.gauge-wrap { position: relative; display: inline-block; }
.gauge-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.gauge-value { font-size: 20px; font-weight: 700; }
.gauge-label { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---- settings: appearance ---- */
.accent-swatches { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.accent-swatch {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0;
}
.accent-swatch.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.custom-accent { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.custom-accent label { font-size: 13px; color: var(--muted); }

button.small {
  padding: 9px 14px; border-radius: 8px; border: none;
  background: var(--accent); color: #05100b; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}

/* ---- Tasking Home card: priority tiles ---- */
.task-tiles { display: flex; gap: 8px; }
.task-tile {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 6px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-alt);
  color: var(--muted); cursor: pointer; font-family: var(--font-body);
}
.task-tile svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.task-tile:hover { color: var(--text); }
.task-tile.open { border-color: var(--accent); background: var(--accent-weak); color: var(--accent); }
.task-tile-count { font-size: 20px; font-weight: 700; }
.task-tile-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
#task-tile-detail:not(:empty) { margin-top: 12px; }
#task-tile-detail .item-list li { cursor: pointer; }

/* ---- item edit modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px; width: 100%; max-width: 420px; max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-type-badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  background: var(--panel-alt); border-radius: 6px; padding: 3px 8px;
}
.modal-box .row { display: flex; gap: 8px; }
.modal-box textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-alt); color: var(--text); font-family: var(--font-body); font-size: 14px; resize: vertical;
}
.modal-done-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 4px 0; }
.modal-children { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.modal-children .item-list li { cursor: pointer; }

/* Scroll chevrons — replaces native scrollbars app-wide with small
   always-visible up/down/left/right buttons, injected by scrollChevrons.js
   onto every scrollable element. */
.dgo-scroll-host {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.dgo-scroll-host::-webkit-scrollbar {
  display: none;
}

.dgo-chevron-wrap {
  position: sticky;
  z-index: 40;
  pointer-events: none;
}
.dgo-chevron-wrap-y-prev,
.dgo-chevron-wrap-y-next {
  height: 0;
  display: flex;
  justify-content: center;
}
.dgo-chevron-wrap-y-prev { top: 0; }
.dgo-chevron-wrap-y-next { bottom: 0; }
.dgo-chevron-wrap-y-prev .dgo-chevron-btn { transform: translateY(4px); }
.dgo-chevron-wrap-y-next .dgo-chevron-btn { transform: translateY(calc(-100% - 4px)); }
.dgo-chevron-wrap-x-prev,
.dgo-chevron-wrap-x-next {
  width: 0;
  display: flex;
  align-items: center;
}
.dgo-chevron-wrap-x-prev { left: 0; }
.dgo-chevron-wrap-x-next { right: 0; }
.dgo-chevron-wrap-x-prev .dgo-chevron-btn { transform: translateX(4px); }
.dgo-chevron-wrap-x-next .dgo-chevron-btn { transform: translateX(calc(-100% - 4px)); }
.dgo-chevron-hidden { display: none; }

.dgo-chevron-btn {
  pointer-events: auto;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  transition: opacity 0.15s ease, background-color 0.15s ease;
}
.dgo-chevron-btn:hover:not(:disabled) {
  background: rgba(15, 23, 42, 0.8);
}
.dgo-chevron-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.dgo-chevron-btn-fixed {
  position: fixed;
  right: 20px;
  width: 36px;
  height: 36px;
  z-index: 100;
}
.dgo-chevron-fixed-up { bottom: 76px; }
.dgo-chevron-fixed-down { bottom: 32px; }
