.af-feedback,
.otto-3d-toggle {
  --af-paper: var(--workspace-paper, var(--white));
  --af-ink: var(--ink);
  --af-green: var(--workspace-accent);
  --af-action: var(--workspace-action);
  --af-on-action: var(--workspace-on-action);
  --af-hover: var(--workspace-action-hover);
  --af-line: var(--line);
  --af-sage: var(--workspace-selected);
  --af-error: var(--theme-danger);
  --af-muted: var(--muted);
  --af-shadow: var(--shadow);
  --af-backdrop: var(--workspace-backdrop);
  --af-1: 4px;
  --af-2: 8px;
  --af-3: 12px;
  --af-4: 16px;
  --af-6: 24px;
  --af-8: 32px;
  --af-touch: var(--theme-touch);
  --af-control: var(--theme-control);
  --af-radius: var(--ui-radius);
  --af-small: 0.8125rem;
  --af-body: 0.875rem;
  --af-heading: 1.25rem;
  box-sizing: border-box;
  font-family: var(--ui-font);
  font-size: var(--af-body);
  line-height: 1.5;
  color: var(--af-ink);
}
/* The launcher's footprint in the bottom-right corner of the viewport
   (#feedback-button below), along each axis: its size, a gap, and its
   offset from the edge or the device's safe area. They are the one measure
   every page keeps its controls clear of the launcher with: a bar that
   reaches the corner insets its inline end by the inline footprint; a
   dialog, a bottom-anchored panel and the end of a scrolling page or panel
   lift by the block footprint, so the last control scrolls clear. With its
   label the launcher is a control high and at most 7.5rem wide; as an icon
   (below) it is a touch-sized square. An open dialog declares them again,
   so a page that keeps no room for the corner (the apps' workspace,
   styles.css) cannot pass its zeros into a modal holding the launcher. */
:root,
dialog[open] {
  --feedback-clearance-inline: calc(
    7.5rem +
    var(--theme-gap, 8px) +
    max(16px, env(safe-area-inset-right))
  );
  --feedback-clearance-block: calc(
    var(--theme-control, 32px) +
    var(--theme-gap, 8px) +
    max(16px, env(safe-area-inset-bottom))
  );
}
/* Otto's 3D toggle (public/otto-toggle.js) shares the corner: feedback.js
   keeps it immediately before the launcher, so the corner holds
   [toggle][launcher] in one row with the same gap. Each is a fixed width
   there (a touch square on phones, below) and, only while the toggle shows,
   the inline footprint grows by the toggle and a gap; every page without it
   keeps the footprint above. */
:root {
  --feedback-launcher-inline: 7.5rem;
  --feedback-toggle-inline: 4.5rem;
}
:root:has(#otto-3d-toggle:not([hidden])),
:root:has(#otto-3d-toggle:not([hidden])) dialog[open] {
  --feedback-clearance-inline: calc(
    var(--feedback-launcher-inline) +
    var(--feedback-toggle-inline) +
    2 *
    var(--theme-gap, 8px) +
    max(16px, env(safe-area-inset-right))
  );
}
/* An open modal holds the launcher in its top layer (feedback.js), in the
   same corner, at every width: it ends above the launcher, centred in the
   room left, so its own Save, Send and close controls stay uncovered.
   Payday's and a celebration's overlays keep the whole screen; nothing of
   theirs is in the corner. (Job Nuke's overlay withholds the launcher.) */
dialog[open]:not(#feedback-dialog, .a-payday, .celebration-dialog):has(
    > #feedback-button.af-feedback-launcher
  ) {
  box-sizing: border-box;
  inset-block-end: var(--feedback-clearance-block);
  max-height: calc(
    100dvh -
    var(--feedback-clearance-block) -
    2 *
    var(--af-4, 16px)
  );
  margin-block: auto;
}
.af-feedback[hidden],
.af-feedback [hidden],
.otto-3d-toggle[hidden] {
  display: none !important;
}
#feedback-button.af-feedback-launcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--af-2);
  position: fixed;
  inset: auto max(var(--af-4), env(safe-area-inset-right))
    max(var(--af-4), env(safe-area-inset-bottom)) auto;
  margin: 0;
  min-height: var(--af-control);
  min-width: var(--af-control);
  width: auto;
  max-width: calc(100vw - var(--af-8));
  padding: var(--af-1) var(--af-3);
  border: 1px solid var(--af-line);
  border-radius: var(--af-radius);
  background: var(--af-paper);
  color: var(--af-ink);
  font-weight: 600;
  box-shadow: var(--af-shadow);
  z-index: 2147483647;
  cursor: pointer;
}
/* In the corner beside the launcher the launcher is exactly its footprint's
   width, so the toggle ends one gap before it. */
:root:has(#otto-3d-toggle:not([hidden]))
  :is(body, dialog)
  > #feedback-button.af-feedback-launcher {
  width: var(--feedback-launcher-inline);
}
/* The 3D toggle: the launcher's family, a cube and "3D". On its own (a page
   without the launcher) it keeps the corner itself. */
#otto-3d-toggle.otto-3d-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--af-2);
  position: fixed;
  inset: auto max(var(--af-4), env(safe-area-inset-right))
    max(var(--af-4), env(safe-area-inset-bottom)) auto;
  margin: 0;
  width: var(--feedback-toggle-inline);
  min-width: var(--af-control);
  min-height: var(--af-control);
  padding: var(--af-1) var(--af-3);
  border: 1px solid var(--af-line);
  border-radius: var(--af-radius);
  background: var(--af-paper);
  color: var(--af-ink);
  font-weight: 600;
  box-shadow: var(--af-shadow);
  z-index: 2147483647;
  cursor: pointer;
}
:root:has(#feedback-button.af-feedback-launcher)
  :is(body, dialog)
  > #otto-3d-toggle.otto-3d-toggle {
  inset: auto
    calc(
      max(var(--af-4), env(safe-area-inset-right)) +
      var(--feedback-launcher-inline) +
      var(--theme-gap, 8px)
    )
    max(var(--af-4), env(safe-area-inset-bottom)) auto;
}
#feedback-dialog.af-feedback-dialog {
  width: min(560px, calc(100vw - var(--af-8)));
  max-width: calc(100vw - var(--af-8));
  max-height: calc(100dvh - var(--af-8));
  margin: auto;
  padding: var(--af-6);
  padding-bottom: calc(var(--af-touch) + var(--af-8));
  overflow: auto;
  border: 1px solid var(--af-line);
  border-radius: var(--af-radius);
  background: var(--af-paper);
  box-shadow: var(--af-shadow);
}
.af-feedback-dialog::backdrop {
  background: var(--af-backdrop);
}
.af-feedback-dialog h2 {
  margin: 0 0 var(--af-2);
  font-size: var(--af-heading);
  padding: 0;
}
.af-feedback-dialog p {
  margin: 0 0 var(--af-4);
}
.af-feedback-dialog form {
  display: grid;
  gap: var(--af-3);
}
.af-feedback-dialog label {
  margin: 0;
  font-weight: 600;
  font-size: var(--af-small);
}
.af-feedback-dialog textarea {
  box-sizing: border-box;
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: var(--af-control);
  padding: var(--af-1) var(--af-3);
  margin: 0;
  border: 1px solid var(--af-muted);
  border-radius: var(--ui-radius);
  color: var(--af-ink);
  background: var(--af-paper);
  font: inherit;
  resize: vertical;
}
.af-feedback-dialog button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--af-2);
  min-height: var(--af-control);
  padding: var(--af-1) var(--af-3);
  border: 1px solid var(--af-line);
  border-radius: var(--ui-radius);
  background: var(--af-paper);
  color: var(--af-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.af-feedback-dialog button.af-feedback-primary {
  background: var(--af-action);
  color: var(--af-on-action);
  border-color: var(--af-action);
}
.af-feedback-dialog button:hover:not(:disabled) {
  background: var(--af-sage);
}
.af-feedback-dialog button.af-feedback-primary:hover:not(:disabled) {
  background: var(--af-hover);
}
#feedback-button.af-feedback-launcher:hover,
#otto-3d-toggle.otto-3d-toggle:hover {
  background: var(--af-sage);
}
/* Pressed (3D on): the selected tint, an accent edge and a filled cube, in
   either theme. */
#otto-3d-toggle.otto-3d-toggle[aria-pressed="true"] {
  border-color: var(--af-green);
  background: var(--af-sage);
  color: var(--af-green);
  box-shadow:
    var(--af-shadow),
    inset 0 0 0 1px var(--af-green);
}
#otto-3d-toggle.otto-3d-toggle[aria-pressed="true"] .ui-icon {
  fill: color-mix(in srgb, currentColor 24%, transparent);
}
.af-feedback-dialog :disabled {
  opacity: 0.65;
  cursor: wait;
}
.af-feedback-dialog :focus-visible,
#feedback-button.af-feedback-launcher:focus-visible,
#otto-3d-toggle.otto-3d-toggle:focus-visible {
  outline: 3px solid var(--af-green);
  outline-offset: var(--af-1);
}
.af-feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--af-2);
}
.af-feedback-context {
  padding-block: var(--af-3);
  border-block: 1px solid var(--af-line);
  overflow-wrap: anywhere;
}
.af-feedback-dialog :is(#feedback-privacy, #feedback-status, #feedback-target) {
  font-size: var(--af-small);
  color: var(--af-muted);
}
.af-feedback-dialog #feedback-error {
  color: var(--af-error);
}
.af-feedback-dialog :is(#feedback-error, #feedback-status):empty {
  display: none;
}
.af-feedback-hint {
  position: fixed;
  inset: auto var(--af-4) var(--feedback-clearance-block) auto;
  max-width: min(400px, calc(100vw - var(--af-8)));
  padding: var(--af-3) var(--af-4);
  border: 1px solid var(--af-line);
  border-radius: var(--af-radius);
  background: var(--af-paper);
  box-shadow: var(--af-shadow);
  font-size: var(--af-small);
  pointer-events: none;
  z-index: 2147483646;
}
.af-feedback-highlight {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 0;
  border: 2px solid var(--af-green);
  background: transparent;
  pointer-events: none;
  z-index: 2147483645;
}
.af-feedback .ui-icon,
.af-feedback-launcher .ui-icon,
.otto-3d-toggle .ui-icon {
  width: var(--theme-icon);
  height: var(--theme-icon);
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
}
.af-feedback-dialog .af-feedback-actions:last-child {
  padding-top: var(--af-3);
  border-top: 1px solid var(--af-line);
}
.af-feedback-dialog #feedback-retry {
  justify-self: start;
}
@media (max-width: 700px), (pointer: coarse) {
  :root,
  dialog[open] {
    --feedback-clearance-inline: calc(
      var(--theme-touch, 44px) +
      var(--theme-gap, 8px) +
      max(16px, env(safe-area-inset-right))
    );
    --feedback-clearance-block: calc(
      var(--theme-touch, 44px) +
      var(--theme-gap, 8px) +
      max(16px, env(safe-area-inset-bottom))
    );
  }
  :root {
    --feedback-launcher-inline: var(--theme-touch, 44px);
    --feedback-toggle-inline: var(--theme-touch, 44px);
  }
  .af-feedback,
  .otto-3d-toggle {
    --af-control: var(--theme-touch);
  }
  #feedback-button.af-feedback-launcher,
  #otto-3d-toggle.otto-3d-toggle {
    width: var(--af-touch);
    height: var(--af-touch);
    padding: var(--af-2);
  }
  #feedback-button.af-feedback-launcher > span,
  #otto-3d-toggle.otto-3d-toggle > span {
    display: none;
  }
  .af-feedback-dialog textarea {
    font-size: 1rem;
  }
  #feedback-dialog.af-feedback-dialog {
    padding-inline: var(--af-4);
  }
}
/* The iOS and Android apps keep a slot for the launcher beside their bell
   ([data-feedback-slot], public/app.js), where the corner would cover job
   rows; their stylesheet shapes it to that place. In the flow it stacks
   like its neighbours: the slot is `display: contents`, so the launcher is
   a flex or grid item, and the corner's z-index would still lift it over a
   sticky bar or panel that the page draws above that row. */
[data-feedback-slot] {
  display: contents;
}
[data-feedback-slot] > #feedback-button.af-feedback-launcher,
[data-feedback-slot] > #otto-3d-toggle.otto-3d-toggle {
  position: static;
  z-index: auto;
  flex: none;
  width: var(--af-control);
  height: var(--af-control);
  margin-inline-start: auto;
  padding: var(--af-1);
  box-shadow: none;
}
/* The toggle before it takes the slot's leading space. */
[data-feedback-slot]
  > #otto-3d-toggle.otto-3d-toggle
  ~ #feedback-button.af-feedback-launcher {
  margin-inline-start: 0;
}
[data-feedback-slot] > #feedback-button.af-feedback-launcher > span,
[data-feedback-slot] > #otto-3d-toggle.otto-3d-toggle > span {
  display: none;
}
.af-feedback-dialog #feedback-recent {
  padding-top: var(--af-3);
  border-top: 1px solid var(--af-line);
  font-size: var(--af-small);
}
.af-feedback-dialog #feedback-recent h3 {
  margin: 0 0 var(--af-2);
  font-size: var(--af-body);
}
.af-feedback-dialog #feedback-recent ul {
  margin: 0;
  padding-left: var(--af-4);
  color: var(--af-muted);
}
/* The live average from feedback to the team's thank-you: set apart in the
   theme's selected tint, the duration in bold. */
.af-feedback-dialog .af-feedback-turnaround {
  display: flex;
  align-items: flex-start;
  gap: var(--af-2);
  padding: var(--af-3);
  border-radius: var(--af-radius);
  background: var(--af-sage);
  font-size: var(--af-small);
}
.af-feedback-dialog .af-feedback-turnaround strong {
  font-weight: 700;
}
/* The note's kind, as chips: a native radio group under its legend, each
   radio stretched invisibly over its chip, so keyboard and focus keep their
   native behaviour. The chip itself shows which kind is chosen. */
.af-feedback-dialog .af-feedback-categories {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.af-feedback-dialog .af-feedback-categories legend {
  margin: 0 0 var(--af-2);
  padding: 0;
  font-weight: 600;
  font-size: var(--af-small);
}
.af-feedback-dialog .af-feedback-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--af-2);
}
/* The workspace's global label rule (styles.css: a 12px column with a gap)
   would stack and top-align the chip's words: it is a centred row here. */
.af-feedback-dialog .af-feedback-chip {
  position: relative;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: var(--af-control);
  padding: var(--af-1) var(--af-3);
  border: 1px solid var(--af-line);
  border-radius: 999px;
  background: var(--af-paper);
  cursor: pointer;
}
.af-feedback-dialog .af-feedback-chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}
.af-feedback-dialog .af-feedback-chip:hover {
  background: var(--af-sage);
}
.af-feedback-dialog .af-feedback-chip:has(input:checked) {
  border-color: var(--af-action);
  background: var(--af-action);
  color: var(--af-on-action);
}
.af-feedback-dialog .af-feedback-chip:has(input:focus-visible) {
  outline: 3px solid var(--af-green);
  outline-offset: var(--af-1);
}
.af-feedback-dialog .af-feedback-chip:has(input:disabled) {
  opacity: 0.65;
  cursor: wait;
}
/* The note's optional screenshot (feedback.js): an add control shaped like
   the dialog's buttons, its file input stretched invisibly over it as the
   kind chips' radios are, then a small preview with its Remove button. */
.af-feedback-dialog .af-feedback-shot {
  display: grid;
  gap: var(--af-2);
  min-width: 0;
}
.af-feedback-dialog .af-feedback-shot-add {
  position: relative;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  justify-self: start;
  gap: 0;
  max-width: 100%;
  min-height: var(--af-control);
  box-sizing: border-box;
  padding: var(--af-1) var(--af-3);
  border: 1px dashed var(--af-muted);
  border-radius: var(--ui-radius);
  background: var(--af-paper);
  color: var(--af-ink);
  font-size: inherit;
  cursor: pointer;
}
.af-feedback-dialog .af-feedback-shot-add input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}
.af-feedback-dialog .af-feedback-shot-add:hover {
  background: var(--af-sage);
}
.af-feedback-dialog .af-feedback-shot-add:has(input:focus-visible) {
  outline: 3px solid var(--af-green);
  outline-offset: var(--af-1);
}
.af-feedback-dialog .af-feedback-shot-add:has(input:disabled) {
  opacity: 0.65;
  cursor: wait;
}
.af-feedback-dialog .af-feedback-shot-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--af-2);
  min-width: 0;
}
.af-feedback-dialog .af-feedback-shot-preview img {
  display: block;
  box-sizing: border-box;
  width: auto;
  height: auto;
  max-width: min(100%, 220px);
  max-height: 140px;
  border: 1px solid var(--af-line);
  border-radius: var(--ui-radius);
  background: var(--af-paper);
  object-fit: contain;
}
.af-feedback-dialog .af-feedback-shot p {
  margin: 0;
  font-size: var(--af-small);
}
.af-feedback-dialog #feedback-shot-hint {
  color: var(--af-muted);
}
.af-feedback-dialog #feedback-shot-error {
  color: var(--af-error);
}
.af-feedback-dialog #feedback-shot-error:empty {
  display: none;
}
/* Forced colours replace the chosen chip's fill with the system's, which
   would leave nothing to tell it apart: it takes the system's highlight. */
@media (forced-colors: active) {
  .af-feedback-dialog .af-feedback-chip:has(input:checked) {
    forced-color-adjust: none;
    border-color: Highlight;
    background: Highlight;
    color: HighlightText;
  }
  #otto-3d-toggle.otto-3d-toggle[aria-pressed="true"] {
    outline: 2px solid Highlight;
    outline-offset: -3px;
    color: Highlight;
  }
}
.af-feedback-dialog .af-feedback-sent {
  display: grid;
  gap: var(--af-3);
}
.af-feedback-dialog .af-feedback-sent p {
  margin: 0;
}
/* Otto (docs/otto-brand-guide.md). Transparent art sits on a soft plate in
   the dark theme, where his outline would sink into the page. */
.otto-art {
  display: block;
  max-width: 100%;
  height: auto;
}
:root[data-theme="dark"] .otto-plate {
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 55%,
    #f3efe2 0 62%,
    transparent 63%
  );
}
/* The thank-you: Otto above the note, smaller on phones. */
.af-feedback-dialog .af-feedback-otto {
  justify-self: start;
}
@media (max-width: 700px) {
  .af-feedback-dialog .af-feedback-otto {
    width: 64px;
  }
}
.af-feedback-dialog #feedback-receipt {
  font-size: var(--af-small);
  color: var(--af-muted);
  overflow-wrap: anywhere;
  user-select: text;
}
.af-feedback-dialog #feedback-title:focus {
  outline: none;
}
/* public/member-language.js comes with feedback.js to every page this sheet
   styles, and shows a refused field's English message (englishFormControls).
   Its base style, for pages without one of their own (guides, whose inline
   stylesheet is at its first-paint budget); :where() leaves a page's own
   .form-error and .field-invalid-note rules (styles.css) in charge. */
:where(.field-invalid-note) {
  display: block;
  margin: 0 0 8px;
  color: var(--theme-danger, #9c3b43);
  font-size: 0.875rem;
  font-weight: 400;
}
