/* ==========================================================================
   Snaptask — neomorphic design system
   Mobile-first, portrait. Soft-UI surfaces cast from the page background.
   ========================================================================== */

:root {
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;
  --r-pill: 999px;

  --gap: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Light theme (default) ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #E7E2D8;
  --text-primary: #2E2B27;
  --text-secondary: #746E60;
  --text-faint: #A29C8C;

  --shadow-dark: #C3BDAE;
  --shadow-light: #FFFFFF;
  --shadow-dark-soft: rgba(195, 189, 174, .6);
  --shadow-light-soft: rgba(255, 255, 255, .7);

  --accent-teal: #3E7C79;
  --accent-teal-bg: #DCE7E3;
  --accent-amber: #d2a228;
  --accent-amber-bg: #ECE0CC;
  --accent-green: #3F7A57;
  --accent-green-bg: #DCE7DE;
  --accent-brick: #A9522F;
  --accent-brick-bg: #EBDBCF;
  --accent-purple: #6C5A99;
  --accent-purple-bg: #E1DCEE;

  --border-hair: rgba(46, 43, 39, .06);
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #24272C;
  --text-primary: #ECE9E2;
  --text-secondary: #9B9890;
  --text-faint: #6D6A64;

  --shadow-dark: #16181B;
  --shadow-light: #313539;
  --shadow-dark-soft: rgba(0, 0, 0, .45);
  --shadow-light-soft: rgba(255, 255, 255, .05);

  --accent-teal: #6FB6B1;
  --accent-teal-bg: #2B3B3A;
  --accent-amber: #E0AA5C;
  --accent-amber-bg: #3A3327;
  --accent-green: #7FC199;
  --accent-green-bg: #2A3B31;
  --accent-brick: #E08C67;
  --accent-brick-bg: #3B2E28;
  --accent-purple: #B6A6E0;
  --accent-purple-bg: #322C42;

  --border-hair: rgba(255, 255, 255, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  scrollbar-width: none;      /* Firefox */
  -ms-overflow-style: none;   /* old Edge / IE */
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;              /* Chrome, Safari, new Edge, Opera */
}

body {
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

h1, h2, h3 {
  font-family: var(--font-display);
  margin: 0;
  letter-spacing: -.01em;
}

p { margin: 0; }

a { color: inherit; text-decoration: none; }

button { font-family: inherit; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: calc(96px + var(--safe-bottom));
}

/* ---------- Neomorphic surface mixins (via utility classes) ---------- */

.raised {
  background: var(--bg);
  border-radius: var(--r-md);
  /* box-shadow: 7px 7px 14px var(--shadow-dark-soft),
              -7px -7px 14px var(--shadow-light-soft); */
  box-shadow:  2px 2px 5px var(--shadow-dark-soft), inset              -2px -2px 5px var(--shadow-light-soft)
}

.pressed {
  background: var(--bg);
  border-radius: var(--r-sm);
  box-shadow: inset 4px 4px 9px var(--shadow-dark-soft),
              inset -4px -4px 9px var(--shadow-light-soft);
}

/* ==========================================================================
   Top bar
   ========================================================================== */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: calc(18px + var(--safe-top)) 20px 14px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
}

.topbar-title {
  flex: 1;
  font-size: 19px;
  font-weight: 700;
}

.topbar-mark, .icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-teal);
  background: var(--bg);
  box-shadow: 5px 5px 10px var(--shadow-dark-soft), -5px -5px 10px var(--shadow-light-soft);
  flex-shrink: 0;
}

.icon-btn { border: none; cursor: pointer; }
.icon-btn:active { box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft); }

.theme-toggle {
  width: 54px;
  height: 30px;
  border-radius: var(--r-pill);
  border: none;
  padding: 3px;
  background: var(--bg);
  box-shadow: inset 4px 4px 8px var(--shadow-dark-soft), inset -4px -4px 8px var(--shadow-light-soft);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.theme-toggle-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 3px 3px 6px var(--shadow-dark-soft), -3px -3px 6px var(--shadow-light-soft);
  color: var(--accent-amber);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .25s ease;
}

.icon-moon { display: none; }
[data-theme="dark"] .theme-toggle-thumb { transform: translateX(24px); color: var(--accent-teal); }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ---------- Header stats (criteria completion + done-as-owner count) ---------- */
.header-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.header-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width:50px;
}
.header-stat svg { flex-shrink: 0; }
.header-stat-star svg { color: var(--accent-amber); }
.header-stat-trophy svg { color: var(--accent-green); }
.header-stat span {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ---------- Settings toggle (header avatar button) ---------- */
.settings-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-teal);
  background: var(--bg);
  box-shadow: 5px 5px 10px var(--shadow-dark-soft), -5px -5px 10px var(--shadow-light-soft);
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  transition: box-shadow .12s ease;
}
.settings-toggle:active,
.settings-toggle[aria-pressed="true"] {
  box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft);
}

/* ---------- Settings page ---------- */
.settings-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 4px 4px;
}
.settings-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent-teal);
  background: var(--bg);
  box-shadow: 5px 5px 10px var(--shadow-dark-soft), -5px -5px 10px var(--shadow-light-soft);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
}
.settings-identity-name { font-weight: 700; font-size: 16px; }
.settings-identity-sub { font-size: 12.5px; color: var(--text-secondary); }

/* ==========================================================================
   Content
   ========================================================================== */

.content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.section-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 4px 2px;
}

/* ---------- Filter comboboxes ---------- */

.filter-row {
  display: flex;
  gap: 10px;
  padding: 2px 2px 4px;
}

/* Inside .topbar (index.php only), always force it onto its own line below
   the title/avatar row, rather than competing for space in that row. */
.topbar .filter-row {
  flex-basis: 100%;
  margin-top: 4px;
  padding: 0;
}

.select-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.select-input {
  width: 100%;
  height: 50px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border: none;
  border-radius: var(--r-pill);
  padding: 11px 32px 11px 16px;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  box-shadow: inset 4px 4px 9px var(--shadow-dark-soft), inset -4px -4px 9px var(--shadow-light-soft);
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.select-input:focus {
  outline: none;
  box-shadow: inset 4px 4px 9px var(--shadow-dark-soft), inset -4px -4px 9px var(--shadow-light-soft), 0 0 0 2px var(--accent-teal);
}

.select-chevron {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-faint);
}

/* ==========================================================================
   Task card — instant-photo signature element
   ========================================================================== */

.task-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

.task-card {
  display: flex;
  flex-direction: column;
  padding: 12px 12px 14px;
  position: relative;
}

.task-photo-frame {
  border-radius: var(--r-sm);
  padding: 6px;
  background: var(--bg);
  box-shadow: inset 2px 2px 5px var(--shadow-dark-soft), inset -2px -2px 5px var(--shadow-light-soft);
  margin-bottom: 6px;
}

.task-photo-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
}

.task-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 0;
}

.task-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.28;
  padding: 2px 8px 2px;
}

.task-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
  flex-wrap: wrap;
  margin-top: auto;
}

.category-chip {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--r-pill);
}

.status-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .02em;
  padding: 3px 7px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.status-badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.tone-teal   { color: var(--accent-teal);   background: var(--accent-teal-bg); }
.tone-amber  { color: var(--accent-amber);  background: var(--accent-amber-bg); }
.tone-green  { color: var(--accent-green);  background: var(--accent-green-bg); }
.tone-brick  { color: var(--accent-brick);  background: var(--accent-brick-bg); }
.tone-purple { color: var(--accent-purple); background: var(--accent-purple-bg); }

.criteria-progress {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--accent-teal);
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* ---------- Empty state ---------- */


.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-secondary);
}
.empty-state svg { color: var(--text-faint); margin-bottom: 14px; }
.empty-state h2 { font-size: 17px; margin-bottom: 6px; color: var(--text-primary); }
.empty-state p { font-size: 14px; line-height: 1.5; }

/* ==========================================================================
   FAB — aperture button (signature action)
   ========================================================================== */

.fab {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(24px + var(--safe-bottom));
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  border: 3px solid var(--accent-teal);
  border-radius: 50%;
  background: none;
  padding: 0px;
}

.fab-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--shadow-dark);
  opacity: .5;
}
.fab-ring-1 { inset: -8px; }
.fab-ring-2 { inset: -16px; opacity: .25; }

.fab-core {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg);
  color: var(--accent-teal);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 8px 8px 16px var(--shadow-dark-soft), -8px -8px 16px var(--shadow-light-soft);
  transition: box-shadow .12s ease;
}

.fab:active .fab-core {
  box-shadow: inset 4px 4px 9px var(--shadow-dark-soft), inset -4px -4px 9px var(--shadow-light-soft);
}

/* ---------- Fab side toggles ("mine" filters) ---------- */
/* Smaller siblings flanking the fab. Same neumorphic language, but they
   behave as switches: pressed/released state is driven by aria-pressed,
   set server-side from the current ?mine= filter (see index.php). */

.fab-toggle {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom) + 8px);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--accent-teal);
  box-shadow: 6px 6px 12px var(--shadow-dark-soft), -6px -6px 12px var(--shadow-light-soft);
  transition: box-shadow .12s ease, color .12s ease;
  z-index: 20;
  text-decoration: none;
  cursor: pointer;
}

.fab-toggle-left  { left: calc(50% - 32px - 56px - 46px); }
.fab-toggle-right { left: calc(50% + 32px + 56px); }

.fab-toggle:active {
  box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft);
}

.fab-toggle[aria-pressed="true"] {
  box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft);
}

/* ==========================================================================
   Forms
   ========================================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding-left: 2px;
}

.input, textarea.input {
  width: 100%;
  border: none;
  border-radius: var(--r-sm);
  padding: 14px 16px;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  box-shadow: inset 4px 4px 9px var(--shadow-dark-soft), inset -4px -4px 9px var(--shadow-light-soft);
}

.input::placeholder { color: var(--text-faint); }
.input:focus, textarea.input:focus {
  outline: none;
  box-shadow: inset 4px 4px 9px var(--shadow-dark-soft), inset -4px -4px 9px var(--shadow-light-soft), 0 0 0 2px var(--accent-teal);
}

textarea.input { resize: vertical; min-height: 84px; line-height: 1.5; }

/* Category combobox: tap to open, search to filter, tap an option */
.combobox { position: relative; }

.combobox-list {
  /* Pinned near the top of the screen and centered/width-matched to
     .content (same technique as .footerbar-accent), rather than
     anchored below whichever input opened it - #catFilterCombobox in
     particular is only as wide as its narrow flex:1 slot in the
     topbar's filter row, much narrower than .content itself, and a
     consistent top-of-screen position means every combobox behaves
     like the same familiar search panel, regardless of where the
     trigger input sits on the page. */
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 30;
  max-height: calc(100vh - 24px - var(--safe-top) - var(--safe-bottom));
  overflow-y: auto;
  scrollbar-width: none;      /* Firefox */
  -ms-overflow-style: none;   /* old Edge / IE */
  border-radius: var(--r-md);
  background: var(--bg);
  box-shadow: 7px 7px 14px var(--shadow-dark-soft), -7px -7px 14px var(--shadow-light-soft);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.combobox-list::-webkit-scrollbar {
  display: none;              /* Chrome, Safari, new Edge, Opera */
}

.combobox-list[hidden] {
  display: none;
}

.combobox-search {
  /* Stays visible at the top of the panel while the option list below
     it scrolls - .combobox-list is the scroll container (overflow-y:
     auto above), so a sticky child works here without extra markup. */
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  margin-bottom: 2px;
}

/*
 * Category filter combobox (index.php topbar - see #catFilterCombobox):
 * z-index sits below .topbar (30) and .footerbar/.footerbar-accent (10)
 * so it never covers either, while still painting over the unpositioned
 * .content below it. Width/centering/position come from the shared
 * .combobox-list rules above.
 */
#catFilterInput {
  height: 50px;
  border-radius: var(--r-pill);
}
#catFilterList {
  z-index: 9;
}

.combobox-option {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
}

.combobox-option:hover,
.combobox-option:active,
.combobox-option.is-highlighted {
  box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft);
}

/* Photo capture control */
.photo-picker {
  border-radius: var(--r-md);
  background: var(--bg);
  box-shadow: inset 4px 4px 9px var(--shadow-dark-soft), inset -4px -4px 9px var(--shadow-light-soft);
  padding: 28px 16px;
  text-align: center;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.photo-picker svg { color: var(--accent-teal);}
.photo-picker input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.photo-picker .hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; display: block; }

/* Once a photo is selected/present, switch from the spacious empty-state
   padding to the same tight frame task_view.php uses for .detail-photo,
   so the picture displays in full (no cropping) and consistently
   positioned across new/edit/view. */
.photo-picker.has-photo { padding: 10px; cursor: default; }
.photo-picker.has-photo input[type="file"] { cursor: pointer; }

.photo-picker img.preview {
  display: none;
  width: 100%;
  border-radius: var(--r-sm);
}
.photo-picker img.preview.is-visible { display: block; }

/* Edit button shown over the preview once a photo is present */
.photo-edit-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--accent-teal);
  box-shadow: 5px 5px 10px var(--shadow-dark-soft), -5px -5px 10px var(--shadow-light-soft);
  cursor: pointer;
  z-index: 5;
}
.photo-edit-btn:active {
  box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft);
}
.photo-edit-btn[hidden] { display: none; }

/* ---------- Photo editor overlay (crop + freehand markup) ---------- */
.photo-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 16px;
  background: var(--bg);
  width: 100%;
  height:100%;
}
.photo-editor-overlay[hidden] { display: none; }

.photo-editor-panel {
  width: 100%;
  max-width: 500px;
  max-height: 100vh;
  overflow-y: auto;
  scrollbar-width: none;      /* Firefox */
  -ms-overflow-style: none;   /* old Edge / IE */
  padding: calc(18px + var(--safe-top)) 18px calc(18px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: 0;
  box-shadow: none;
}
.photo-editor-panel::-webkit-scrollbar {
  display: none;              /* Chrome, Safari, new Edge, Opera */
}

.photo-editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.photo-editor-title { font-size: 17px; }

.icon-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
  box-shadow: none;
}

.photo-editor-canvas-wrap {
  padding: 6px;
  touch-action: none;
  overflow: hidden;
}
.photo-editor-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
}

.photo-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.editor-tool-group,
.editor-history-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-tool-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  border: none;
  background: var(--bg);
  color: var(--text-secondary);
  box-shadow: 4px 4px 8px var(--shadow-dark-soft), -4px -4px 8px var(--shadow-light-soft);
  cursor: pointer;
}
.editor-tool-btn.is-active {
  color: var(--accent-teal);
  box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft);
}

.photo-editor-hint {
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.4;
  padding: 0 2px;
}

.photo-editor-actions {
  display: flex;
  align-items: center;
  flex-flow:column;
  gap: 10px;
  height: 43px;
}
.photo-editor-actions .add-row-btn { flex: 1; width: stretch; }
.photo-editor-actions .add-row-btn[hidden] { display: none; }

.editor-draw-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.editor-draw-controls[hidden] { display: none; }

.editor-thickness-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.editor-thickness-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.editor-thickness-slider {
  flex: 1;
  accent-color: var(--accent-teal);
}
.editor-thickness-value {
  font-size: 12px;
  color: var(--text-faint);
  flex-shrink: 0;
  width: 34px;
  text-align: right;
}

.editor-color-swatches {
  display: flex;
  align-items: center;
  gap: 10px;
}

.editor-color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  padding: 0;
  cursor: pointer;
  background: var(--swatch-color, #999);
  box-shadow: 2px 2px 5px var(--shadow-dark-soft), -2px -2px 5px var(--shadow-light-soft);
  flex-shrink: 0;
  position: relative;
}
.editor-color-swatch.is-active {
  box-shadow: 0 0 0 2px var(--swatch-color, #999), 2px 2px 5px var(--shadow-dark-soft), -2px -2px 5px var(--shadow-light-soft);
}

.editor-color-custom {
  background: conic-gradient(from 180deg, #ff595e, #ffca3a, #8ac926, #1982c4, #6a4c93, #ff595e);
  overflow: hidden;
}
.editor-color-custom.has-custom-color { background: var(--swatch-color, #000); }
.editor-color-custom-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* Dynamic acceptance-criteria rows in the form */
.criteria-editor { display: flex; flex-direction: column; gap: 10px; }
.criteria-row { display: flex; gap: 8px; align-items: center; }
.criteria-row .input { flex: 1; }
.row-remove {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  border: none;
  background: var(--bg);
  color: var(--accent-brick);
  box-shadow: 4px 4px 8px var(--shadow-dark-soft), -4px -4px 8px var(--shadow-light-soft);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.row-remove:active { box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft); }

.add-row-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px;
  border-radius: var(--r-sm);
  border: none;
  background: var(--bg);
  color: var(--accent-teal);
  font-weight: 600;
  font-size: 14px;
  box-shadow: 4px 4px 8px var(--shadow-dark-soft), -4px -4px 8px var(--shadow-light-soft);
  cursor: pointer;
}
.add-row-btn:active { box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft); }

.btn-primary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--accent-teal);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15.5px;
  box-shadow: 7px 7px 14px var(--shadow-dark-soft), -7px -7px 14px var(--shadow-light-soft);
  cursor: pointer;
}
.btn-primary:active { box-shadow: inset 4px 4px 9px var(--shadow-dark-soft), inset -4px -4px 9px var(--shadow-light-soft); }
.btn-primary[disabled] { opacity: .5; pointer-events: none; }

.btn-danger {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--accent-brick);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14.5px;
  box-shadow: 4px 4px 8px var(--shadow-dark-soft), -4px -4px 8px var(--shadow-light-soft);
  cursor: pointer;
}
.btn-danger:active { box-shadow: inset 4px 4px 9px var(--shadow-dark-soft), inset -4px -4px 9px var(--shadow-light-soft); }

.form-error {
  border-radius: var(--r-sm);
  padding: 12px 14px;
  background: var(--accent-brick-bg);
  color: var(--accent-brick);
  font-size: 13.5px;
  font-weight: 500;
}

.form-notice {
  border-radius: var(--r-sm);
  padding: 12px 14px;
  background: var(--accent-green-bg);
  color: var(--accent-green);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 12px;
}

/* ==========================================================================
   Fonts admin page
   ========================================================================== */

.font-preview {
  border-radius: var(--r-md);
  padding: 16px 18px;
  margin-top: 10px;
  margin-bottom: 20px;
  box-shadow: inset 4px 4px 9px var(--shadow-dark-soft), inset -4px -4px 9px var(--shadow-light-soft);
}
.font-preview-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.font-preview-sample-main {
  font-family: var(--font-body);
  font-size: 17px;
  color: var(--text-primary);
}
.font-preview-sample-mono {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
}

/* ==========================================================================
   Task detail
   ========================================================================== */

.detail-photo {
  border-radius: var(--r-lg);
  padding: 10px;
  background: var(--bg);
  box-shadow: inset 8px 8px 16px var(--shadow-dark-soft), inset -8px -8px 16px var(--shadow-light-soft);
}
.detail-photo img {
  width: 100%;
  border-radius: var(--r-lg);
  display: block;
  object-fit: cover;
}

.detail-title { font-size: 22px; padding: 4px 2px; }

.detail-description {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  padding: 0 2px;
  white-space: pre-line;
}

.timestamp {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 0 2px;
}

.criteria-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.criterion {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-sm);
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
  background: var(--bg);
  box-shadow: 7px 7px 14px var(--shadow-dark-soft), -7px -7px 14px var(--shadow-light-soft);
}
.criterion.is-met {
  box-shadow: inset 4px 4px 9px var(--shadow-dark-soft), inset -4px -4px 9px var(--shadow-light-soft);
}

.criterion-check {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 3px 3px 6px var(--shadow-dark-soft), inset -3px -3px 6px var(--shadow-light-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-green);
}
.criterion-check svg { opacity: 0; transition: opacity .15s ease; }
.criterion.is-met .criterion-check svg { opacity: 1; }

.criterion-text {
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--text-primary);
}
.criterion.is-met .criterion-text {
  color: var(--text-faint);
  text-decoration: line-through;
}

.comments-placeholder {
  text-align: center;
  padding: 26px 18px;
  color: var(--text-faint);
  font-size: 13px;
}
.comments-placeholder svg { color: var(--text-faint); margin-bottom: 8px; }

/* ==========================================================================
   Login
   ========================================================================== */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 10vh;
}

.login-card {
  width: 100%;
  padding: 32px 26px;
  text-align: center;
}

.login-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--accent-teal);
  box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft);
  margin-bottom: 16px;
}

.login-title { font-size: 18px; margin-bottom: 6px; }
.login-sub { font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 20px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }

.login-admin-link {
  display: block;
  margin-top: 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-teal);
  text-align: center;
}

/* ==========================================================================
   My devices
   ========================================================================== */

.link-reveal {
  padding: 16px;
  margin-bottom: 4px;
}

.link-reveal-hint {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.link-reveal-row {
  display: flex;
  gap: 8px;
}

.link-reveal-row .input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.copy-btn {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: var(--r-sm);
  border: none;
  background: var(--bg);
  color: var(--accent-teal);
  box-shadow: 4px 4px 8px var(--shadow-dark-soft), -4px -4px 8px var(--shadow-light-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.copy-btn:active { box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft); }
.copy-btn.is-copied { color: var(--accent-green); }

.device-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.device-info { flex: 1; min-width: 0; }

.device-label {
  font-weight: 600;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-current {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--accent-teal);
  background: var(--accent-teal-bg);
  padding: 3px 8px;
  border-radius: var(--r-pill);
}

.device-meta {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 3px;
}

.device-row form { flex-shrink: 0; }

.device-revoke-btn {
  color: var(--accent-brick);
  border: none;
}

/* ==========================================================================
   Admin: hub, users, groups
   ========================================================================== */

.admin-card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
}

.admin-card-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-teal);
  background: var(--bg);
  box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft);
}

.admin-card-text { display: flex; flex-direction: column; gap: 3px; }
.admin-card-title { font-weight: 700; font-size: 15px; }
.admin-card-sub { font-size: 12.5px; color: var(--text-secondary); line-height: 1.4; }

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.user-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.role-select {
  width: auto;
  padding: 8px 24px 8px 12px;
  font-size: 11.5px;
}

.group-card {
  border-radius: var(--r-md);
  background: var(--bg);
  box-shadow: 7px 7px 14px var(--shadow-dark-soft), -7px -7px 14px var(--shadow-light-soft);
  padding: 16px;
  margin-bottom: 14px;
}

.group-rename-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.group-rename-row .input { flex: 1; font-weight: 600; }
.group-rename-row .icon-btn { flex-shrink: 0; }

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--bg);
  box-shadow: inset 3px 3px 7px var(--shadow-dark-soft), inset -3px -3px 7px var(--shadow-light-soft);
  font-size: 13.5px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   Comments
   ========================================================================== */

.comment-form {
  margin-bottom: 16px;
}

.comment-form textarea.input {
  min-height: 64px;
  resize: vertical;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.comment-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 100%;
}

.comment-row.comment-right {
  flex-direction: row-reverse;
}

.comment-bubble {
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 96px);
  border-radius: var(--r-md);
  padding: 10px 13px;
  background: var(--bg);
  box-shadow: inset 4px 4px 9px var(--shadow-dark-soft), inset -4px -4px 9px var(--shadow-light-soft);
}

.comment-right .comment-bubble { text-align: left; }

.comment-meta {
  display: flex;
  gap: 6px;
  align-items: baseline;
  margin-bottom: 3px;
}

.comment-right .comment-meta { justify-content: flex-start; }

.comment-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.comment-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
}

.comment-body {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

#loadMoreComments {
  margin-bottom: 4px;
}

/* ==========================================================================
   Status switch (open/done filter, index.php) - same mechanic as the
   light/dark theme toggle: a single pill with a sliding thumb.
   ========================================================================== */

.status-switch {
  flex-shrink: 0;
  width: 90px;
  height: 50px;
  border-radius: var(--r-pill);
  border: none;
  padding: 4px;
  background: var(--bg);
  box-shadow: inset 4px 4px 8px var(--shadow-dark-soft), inset -4px -4px 8px var(--shadow-light-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.status-switch-thumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 3px 3px 6px var(--shadow-dark-soft), -3px -3px 6px var(--shadow-light-soft);
  color: var(--accent-teal);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .25s ease;
}

.status-switch .icon-done { display: none; }
.status-switch.is-done .status-switch-thumb { transform: translateX(40px); color: var(--accent-green); }
.status-switch.is-done .icon-open { display: none; }
.status-switch.is-done .icon-done { display: block; }

/* ==========================================================================
   Footer bar
   ========================================================================== */
   .footerbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    height: calc(69px + var(--safe-bottom));
    background:var(--bg);
    border-radius: var(--r-sm) var(--r-sm) 0 0;
   }

   .footerbar-accent {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    /* Sits directly on top of .footerbar, which already reserves the
       safe-area inset - so no separate --safe-bottom handling needed here. */
    bottom: calc(69px + var(--safe-bottom));
    z-index: 10;
    height: 12px;
    background: color-mix(in srgb, var(--accent-teal) 35%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: var(--r-sm) var(--r-sm) 0 0;
   }