/* ============================================
   RULE FORM (new/edit) — mirrors the schedule
   column's task form so both read as one UI
   ============================================ */

.rule-form-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  max-width: 520px;
  margin: 0 auto;
}

.rule-form {
  display: flex;
  flex-direction: column;
}

.rule-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--recess);
  border-bottom: 1px solid var(--border-panel);
}

.rule-form-title {
  color: var(--text-1);
  font-weight: 600;
  font-size: var(--fs-14);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rule-form-title i { color: var(--accent); }

.rule-form-close {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: #a1a1aa;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur-base) ease;
  font-size: var(--fs-14);
}

.rule-form-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.rule-form-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rule-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rule-form-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rule-form-label i {
  font-size: var(--fs-11);
  opacity: 0.7;
}

/* A label with a link at its far end — "Score the value of … Open tracker →". */
.rule-form-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rule-form-tracker-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-11); font-weight: 600; color: var(--accent); text-decoration: none;
}
.rule-form-tracker-link:hover { text-decoration: underline; }
.rule-form-tracker-link[hidden] { display: none; }
.rule-form-tracker-link i { font-size: var(--fs-10); }

/* Why a gallery rule's Auto-Status reads None: the tracker it scores from isn't there yet. */
.rule-form-missing-tracker {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 8px 0 2px; padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--warn-bright) 45%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn-bright) 9%, transparent);
  color: var(--text-1); font-size: var(--fs-12); line-height: 1.45;
}
.rule-form-missing-tracker > i { margin-top: 2px; color: var(--warn-bright); }
.rule-form-missing-tracker p { margin: 0 0 8px; }
.rule-form-missing-tracker-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  color: var(--text-1); font-weight: 600; text-decoration: none;
}
.rule-form-missing-tracker-btn:hover { background: var(--surface-3); }
.rule-form-hint {
  font-size: var(--fs-11);
  color: #5a5a63;
  margin: 0;
  line-height: 1.35;
}

.rule-form-input,
.rule-form-select,
.rule-form-textarea {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: #e0e0e0;
  font-size: var(--fs-14);
  font-family: inherit;
  transition: all var(--dur-base) ease;
  width: 100%;
  box-sizing: border-box;
}

.rule-form-textarea {
  min-height: 66px;
  resize: vertical;
  line-height: 1.4;
}

.rule-form-input::placeholder,
.rule-form-textarea::placeholder {
  color: #555;
}

.rule-form-input:focus,
.rule-form-select:focus,
.rule-form-textarea:focus {
  outline: none;
  border-color: var(--field-optional-border);
  background-color: rgba(255, 255, 255, 0.1);
  box-shadow: var(--field-optional-ring);
}

.rule-form-input-title {
  font-size: var(--fs-16);
  font-weight: 500;
  padding: 11px 12px;
}

.rule-form-input-title:focus {
  border-color: rgba(34, 197, 94, 0.6);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.13);
}

.rule-form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0aec0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.rule-form-input[type="date"] {
  color: #e0e0e0;
  -webkit-text-fill-color: #e0e0e0;
}

.rule-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.rule-form-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

/* Two fields side by side where the second one comes and goes (start date +
   day-of-month): flex rather than the grid, so the survivor fills the row. */
.rule-form-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.rule-form-row > .rule-form-field {
  flex: 1 1 0;
  min-width: 0;
}

/* One line inside a field: the day number keeps its own width, the toggle takes
   the rest — and the whole line once "last day" hides the number. */
.rule-form-inline {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.rule-form-inline .rule-form-input-day {
  flex: 0 0 72px;
  width: 72px;
}

/* The toggle has to line up with the date field in the column beside it, and font
   trackers alone won't do that (a date input's intrinsic content height isn't the
   label's line box), so both ends of the row are pinned to one height. The
   .rule-form-inline prefix is load-bearing: it outranks .rule-form-toggle's own
   padding, which is declared later in this file. */
.rule-form-row .rule-form-input,
.rule-form-inline .rule-form-toggle-fill {
  height: 40px;
}

.rule-form-inline .rule-form-toggle-fill {
  flex: 1 1 auto;
  justify-content: center;
  padding: 0 12px;
  font-size: var(--fs-14);
  box-sizing: border-box;
}

.rule-form-inline .rule-form-toggle-fill i { font-size: var(--fs-14); }

/* Grouped block (Auto-Status) — keeps its own fields visually together instead of
   reading as more loose rows in the body's single column. */
.rule-form-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
}

.rule-form-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #a1a1aa;
}

.rule-form-section-head i {
  font-size: var(--fs-12);
  color: #6b6b76;
}

.rule-form-day-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rule-form-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  color: #6b6b76;
  font-size: var(--fs-12);
  cursor: pointer;
  user-select: none;
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}

.rule-form-toggle i { font-size: var(--fs-13); }

.rule-form-toggle input[type="checkbox"] { display: none; }

.rule-form-toggle:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: #cbd5e0;
}

.rule-form-toggle:has(input:checked) {
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
}

.rule-form-toggle.is-archive:has(input:checked) {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.rule-form-toggle.is-disabled,
.rule-form-toggle:has(input:disabled) {
  opacity: 0.4;
  cursor: not-allowed;
}

.rule-form-toggle.is-disabled:hover {
  border-color: rgba(255, 255, 255, 0.12);
  color: #6b6b76;
}

.rule-form-errors {
  background: rgba(220, 53, 69, 0.12);
  color: #f88;
  border: 1px solid rgba(220, 53, 69, 0.3);
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: var(--fs-12);
}

.rule-form-errors ul {
  margin: 0.35rem 0 0 1rem;
  padding: 0;
}

.rule-form-footer {
  padding: 12px 16px;
  background: var(--recess);
  border-top: 1px solid var(--border-panel);
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 8px;
}

/* Someday / Archive live down here beside Delete, laid out like the task form's
   footer: square icon-only cards, the label carried by the tooltip. */
.rule-form-footer-left {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

/* Same look as .task-type-card, its own name — see the note in rules/_form.html.erb:
   a global click handler owns that class and preventDefault()s it, which stopped the
   label from ever toggling the checkbox underneath. */
.rule-footer-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

.rule-footer-card i {
  font-size: var(--fs-14);
  color: #555;
  transition: color var(--dur-fast);
}

.rule-footer-card:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
}

.rule-footer-card[data-type="someday"].active {
  border-color: #5eead4;
  background: rgba(94, 234, 212, 0.15);
}

.rule-footer-card[data-type="someday"].active i {
  color: #5eead4;
  text-shadow: 0 0 6px rgba(94, 234, 212, 0.4);
}

.rule-footer-card[data-type="maybe"].active {
  border-color: #a5b4fc;
  background: rgba(165, 180, 252, 0.15);
}

.rule-footer-card[data-type="maybe"].active i {
  color: #a5b4fc;
  text-shadow: 0 0 6px rgba(165, 180, 252, 0.4);
}

.rule-footer-card[data-type="archive"].active {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
}

.rule-footer-card[data-type="archive"].active i {
  color: #fbbf24;
  text-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

/* The archive date, shown beside the archive card while it's on. Compact so the
   footer still fits a phone in one row. */
.rule-footer-archive-date {
  flex: 0 1 auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.rule-footer-archive-date label {
  font-size: var(--fs-12);
  color: #fbbf24;
}

.rule-footer-archive-date .rule-form-input {
  width: 100%;
  max-width: 150px;
  min-width: 0;
  padding: 6px 8px;
  font-size: var(--fs-13);
  border-color: rgba(245, 158, 11, 0.4);
}

/* A phone has no room for the date in the icon row, so it takes a row of its own
   under the icons; the submit arrow keeps its size at the top right. */
@media (max-width: 480px) {
  .rule-form-footer { align-items: flex-start; }
  .rule-form-footer-left { flex-wrap: wrap; row-gap: 8px; }
  .rule-form-footer-left > .rule-form-delete,
  .rule-form-footer-left > .rule-footer-card { height: 38px; box-sizing: border-box; }
  .rule-form-footer-left > .rule-footer-divider { height: 30px; }
  .rule-form-submit { height: 38px; }
  .rule-footer-archive-date { flex-basis: 100%; }
  .rule-footer-archive-date .rule-form-input { max-width: none; flex: 1; }
}

.rule-footer-card.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.rule-footer-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 4px 2px;
  align-self: stretch;
}

.rule-form-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  background: none;
  border: 1px solid rgba(229, 115, 115, 0.4);
  color: #e57373;
  padding: 8px;
  border-radius: var(--radius-md);
  font-size: var(--fs-14);
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}

.rule-form-delete:hover {
  background: rgba(229, 115, 115, 0.12);
  border-color: #e57373;
}

.rule-form-submit {
  background: #22c55e;
  border: none;
  color: #06130a;
  width: 40px;
  padding: 8px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--fs-16);
  font-family: inherit;
  cursor: pointer;
  transition: background-color var(--dur-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.rule-form-submit:hover { background: #4ade80; }

/* ── Value form ──────────────────────────────────────────────────────────────
   Lived in a <style> block inside values/_form.html.erb, which meant the markup
   only looked right when rendered with that partial's own output: the sidebar's
   "Value" link injects the .val-form-card element on its own, and left the styles
   behind — the card came out transparent and unstyled. Global, like .rule-form-*.

   The card used to be tinted with the area of interest's colour, interpolated through
   ERB and then through a --val-accent custom property. It reads as the rule form now —
   the same neutral surface, wells and focus ring — so a value and a rule are visibly
   the same kind of thing, and the tint has gone with it. */
  .val-form-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    max-width: 520px;
    margin: 0 auto;
  }
  .val-form-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 12px 16px;
    background: var(--recess);
    border-bottom: 1px solid var(--border-panel);
  }
  .val-form-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: var(--accent);
    font-size: var(--fs-12);
  }
  .val-form-header-title {
    color: var(--text-1);
    font-weight: 600;
    font-size: var(--fs-14);
    letter-spacing: -0.01em;
  }
  /* Pushed to the far end of the header row — same control as .rule-form-close. */
  .val-form-close {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: #a1a1aa;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--dur-base) ease, color var(--dur-base) ease;
    font-size: var(--fs-14);
  }
  .val-form-close:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
  .val-form-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .val-form-field { display: flex; flex-direction: column; gap: 4px; }
  .val-form-field[hidden] { display: none; }
  .val-form-label {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .val-form-label i { font-size: var(--fs-11); opacity: 0.7; }
  
  .val-form-input,
  .val-form-select,
  .val-form-textarea {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: #e0e0e0;
    font-size: var(--fs-14);
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    transition: all var(--dur-base) ease;
  }

  /* The name field carries the form's title, so it reads a size up with no label
     over it and its own green focus — .rule-form-input-title's arrangement. */
  .val-form-input-title {
    font-size: var(--fs-16);
    font-weight: 500;
    padding: 11px 12px;
  }
  .val-form-input-title:focus {
    border-color: rgba(34, 197, 94, 0.6);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.13);
  }
  .val-form-input:hover,
  .val-form-select:hover,
  .val-form-textarea:hover { border-color: rgba(255, 255, 255, 0.25); }
  .val-form-input:focus,
  .val-form-select:focus,
  .val-form-textarea:focus {
    outline: none;
    border-color: var(--field-optional-border);
    background-color: rgba(255, 255, 255, 0.1);
    box-shadow: var(--field-optional-ring);
  }
  /* A date input paints its own text and calendar glyph from the OS theme. */
  .val-form-input[type="date"] {
    color: #e0e0e0;
    -webkit-text-fill-color: #e0e0e0;
    color-scheme: dark;
  }
  .val-form-input:disabled { opacity: 0.45; cursor: not-allowed; }
  .val-form-input::placeholder,
  .val-form-textarea::placeholder { color: #555; }
  /* Native select chrome is unstyleable, so draw our own chevron and hide theirs. */
  .val-form-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0aec0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
  }
  .val-form-select option { background: #1a1a1a; color: #e2e8f0; }
  .val-form-textarea { min-height: 66px; resize: vertical; line-height: 1.4; }
  .val-form-hint { font-size: var(--fs-12); color: #5a5a63; margin: 0; line-height: 1.35; }

  /* Find More Values' "Add to…": your values as a list to fold a suggestion into. */
  .val-add-to-list { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; }
  .val-add-to-list form { margin: 0; }
  .val-add-to-option {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text-1); font: inherit; font-size: var(--fs-14); text-align: left; cursor: pointer;
  }
  .val-add-to-option:hover { border-color: var(--border-strong); background: var(--surface-3); }
  .val-add-to-area { flex-shrink: 0; color: var(--text-3); font-size: var(--fs-11); }
  .val-add-to-empty { margin: 4px 0 0; color: var(--text-3); font-size: var(--fs-13); }

  /* Area / Do / Review share one line, the way the rule form's Category / Do / Review do. */
  .val-form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  /* Two fields side by side where the second comes and goes (start date + day of
     month): flex rather than the grid, so the survivor fills the row. */
  .val-form-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
  }
  .val-form-row > .val-form-field { flex: 1 1 0; min-width: 0; }

  /* One line inside a field: the day number keeps its own width, the toggle takes the
     rest — and the whole line once "last day" hides the number. */
  .val-form-inline { display: flex; align-items: stretch; gap: 8px; }
  .val-form-inline .val-form-input-day { flex: 0 0 72px; width: 72px; }
  /* The toggle has to line up with the date field in the column beside it, and font
     metrics alone won't do that (a date input's intrinsic height isn't the label's
     line box), so both ends of the row are pinned to one height. */
  .val-form-row .val-form-input,
  .val-form-inline .val-form-toggle-fill { height: 40px; }
  .val-form-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    color: #6b6b76;
    font-size: var(--fs-14);
    cursor: pointer;
    user-select: none;
    transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
  }
  .val-form-toggle input[type="checkbox"] { display: none; }
  .val-form-toggle i { font-size: var(--fs-14); }
  .val-form-toggle:hover { border-color: rgba(255, 255, 255, 0.25); color: #cbd5e0; }
  .val-form-toggle:has(input:checked) {
    border-color: #60a5fa;
    background: rgba(96, 165, 250, 0.15);
    color: #93c5fd;
  }
  .val-form-inline .val-form-toggle-fill { flex: 1 1 auto; }

  .val-name-group { display: flex; align-items: center; gap: 6px; }
  .val-name-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    color: #6b6b76;
    font-size: var(--fs-13);
    cursor: pointer;
    transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast), opacity var(--dur-fast);
  }
  .val-name-remove:hover:not(:disabled) { background: rgba(220,53,69,0.12); border-color: #dc3545; color: #f88; }
  .val-name-btn:disabled { opacity: 0.3; cursor: not-allowed; }
  .val-name-add:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.25); color: #cbd5e0; }

  /* Grouped block (Auto-Rating) — keeps its own fields visually together instead of
     reading as more loose rows in the body's single column. .rule-form-section's shape. */
  .val-form-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
  }
  .val-form-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-12);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-1);
  }
  .val-form-section-head i { color: var(--accent); font-size: var(--fs-12); }

  .val-auto-rule-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-md);
    padding: 12px 6px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .val-auto-rule-box .val-form-hint { margin-bottom: 6px; padding-right: 8px; }
  .val-threshold-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    font-size: var(--fs-13);
    color: #999;
    padding: 4px 8px 4px 0;
    border-radius: var(--radius-sm);
  }
  @media (hover: hover) { .val-threshold-row:hover { background: rgba(255,255,255,0.02); } }
  .val-threshold-row input {
    width: 64px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: #e2e8f0;
    padding: 5px 8px;
    font-size: var(--fs-14);
    text-align: center;
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  }
  .val-threshold-row input:hover { border-color: rgba(255, 255, 255, 0.25); }
  .val-threshold-row input:focus {
    outline: none;
    border-color: var(--field-optional-border);
    background-color: rgba(255, 255, 255, 0.1);
    box-shadow: var(--field-optional-ring);
  }
  .val-threshold-unit { color: #5a5a63; font-size: var(--fs-12); }
  .val-auto-rule-tasks { max-height: 220px; overflow-y: auto; margin-bottom: 6px; }
  .val-auto-rule-tasks .val-threshold-row { cursor: pointer; }
  .val-auto-rule-tasks .val-threshold-row input { width: auto; }

  /* Same pill the rule form's "Review on" picker uses — the checkbox is hidden and
     the pill itself carries the on state. */
  .val-day-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.04);
    font-size: var(--fs-12);
    color: #718096;
    cursor: pointer;
    user-select: none;
    transition: border-color var(--dur-fast) ease, background var(--dur-fast) ease, color var(--dur-fast) ease;
  }
  .val-day-chip input[type="checkbox"] { display: none; }
  .val-day-chip:hover { border-color: rgba(255, 255, 255, 0.25); color: #cbd5e0; }
  .val-day-chip:has(input:checked) {
    border-color: #1da1f2;
    background: rgba(29, 161, 242, 0.18);
    color: #63b3ed;
  }

  .val-form-footer {
    padding: 12px 16px;
    background: var(--recess);
    border-top: 1px solid var(--border-panel);
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 10px;
  }
  /* Delete, Someday and Archive down here beside the submit arrow — the rule footer's
     shape: square icon-only cards, the label carried by the tooltip. */
  .val-form-footer-left { display: flex; align-items: center; gap: 6px; }
  .val-footer-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color var(--dur-fast), background var(--dur-fast);
    width: auto !important;
  }
  .val-footer-card i { font-size: var(--fs-14); color: #555; transition: color var(--dur-fast); }
  .val-footer-card:hover { border-color: rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.08); }
  .val-footer-card[data-type="someday"].active { border-color: #5eead4; background: rgba(94, 234, 212, 0.15); }
  .val-footer-card[data-type="someday"].active i { color: #5eead4; text-shadow: 0 0 6px rgba(94, 234, 212, 0.4); }
  .val-footer-card[data-type="archive"].active { border-color: #f59e0b; background: rgba(245, 158, 11, 0.15); }
  .val-footer-card[data-type="archive"].active i { color: #fbbf24; text-shadow: 0 0 6px rgba(245, 158, 11, 0.4); }
  .val-footer-divider {
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 2px;
    align-self: stretch;
  }
  .val-form-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    background: none;
    border: 1px solid rgba(229, 115, 115, 0.4);
    color: #e57373;
    padding: 8px;
    border-radius: var(--radius-md);
    font-size: var(--fs-14);
    text-decoration: none;
    cursor: pointer;
    transition: background var(--dur-fast), border-color var(--dur-fast);
  }
  .val-form-delete:hover { background: rgba(229, 115, 115, 0.12); border-color: #e57373; }
  /* Same green arrow button the task composer submits with. */
  .val-form-submit {
    background: #22c55e;
    border: none;
    color: #06130a;
    width: 40px;
    padding: 8px;
    border-radius: var(--radius-md);
    font-size: var(--fs-16);
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--dur-fast), transform var(--dur-fast);
  }
  .val-form-submit:hover { background: #4ade80; }
  .val-form-submit:active { transform: scale(0.96); }
  .val-form-errors {
    background: rgba(220,53,69,0.12);
    color: #f88;
    border: 1px solid rgba(220,53,69,0.3);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: var(--fs-14);
  }
  .val-form-errors ul { margin: 0.4rem 0 0 1rem; padding: 0; }

/* Auto-Status, folded under More options (rules/_form). */
.rule-form-more > summary { cursor: pointer; list-style: none; }
.rule-form-more > summary::-webkit-details-marker { display: none; }
.rule-form-more:not([open]) > summary { margin-bottom: 0; }
.rule-form-more-chevron { margin-left: auto; font-size: var(--fs-10); color: var(--text-3); transition: transform var(--dur-fast); }
.rule-form-more[open] .rule-form-more-chevron { transform: rotate(180deg); }

/* ---- The value form ---- */
/* Auto-Rating explains itself only once a source is picked. */
.val-form-section:has(#auto-rule-type option[value=""]:checked) .val-auto-hint { display: none; }
/* A start date fixed by the first rating: read-only, said in words, not faded to nothing. */
.val-form-field.is-locked .val-form-input { opacity: 0.7; cursor: not-allowed; }
/* A start date fixed by the first mark: read-only, said in words. */
.rule-form-field.is-locked .rule-form-input { opacity: 0.7; cursor: not-allowed; }

/* A rule's journal (rules/journal): writing about it, then what's been written. */
.rule-journal-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; }
.rule-journal-head-end { display: inline-flex; align-items: center; gap: 6px; }
.rule-journal-edit { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; color: var(--text-3); font-size: var(--fs-12); }
.rule-journal-edit:hover { color: var(--text-1); background: rgba(255, 255, 255, 0.06); }
.rule-journal-form { display: grid; gap: 8px; }
.rule-journal-input { width: 100%; resize: vertical; }
.rule-journal-form-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rule-journal-date { flex: 0 0 auto; width: 170px; color-scheme: dark; }
.rule-journal-entries { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.rule-journal-entry { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--recess); }
.rule-journal-entry-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: var(--fs-12); }
.rule-journal-day { color: var(--text-2); font-weight: 600; }
.rule-journal-status { padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; font-size: var(--fs-11); }
.rule-journal-status.is-complete { color: var(--accent-bright); }
.rule-journal-status.is-neutral { color: var(--warn-bright); }
.rule-journal-status.is-failed { color: var(--danger-bright); }
.rule-journal-open { margin-left: auto; color: var(--text-3); text-decoration: none; }
.rule-journal-open:hover { color: var(--text-1); }
.rule-journal-text { color: var(--text-1); font-size: var(--fs-13); line-height: 1.5; }
.rule-journal-text p { margin: 0 0 6px; }
.rule-journal-text p:last-child { margin-bottom: 0; }
/* On a rule's row: its journal, the count of entries. */
.ledger-tag.rule-journal-tag { text-decoration: none; }
