/* Feedback tab — colours mapped to Cord of Three's tokens (dark default, body.light for the light theme).
   --fb-attention carries white text: #cc4e00 passes 4.5:1. */
body {
  --fb-paper: var(--bg2);
  --fb-card: var(--surface);
  --fb-ink: var(--text);
  --fb-ink-2: var(--muted);
  --fb-line: var(--line);
  --fb-accent: #f4a259;
  --fb-accent-ink: #1b1016;
  --fb-accent-soft: rgba(244, 162, 89, 0.16);
  --fb-attention: #cc4e00;
  --fb-good: var(--sage);
  --fb-error: #ff8a78;
  --fb-radius: 14px;
}
body.light {
  --fb-accent: #a8521a;
  --fb-accent-ink: #ffffff;
  --fb-accent-soft: #f6e3d3;
  --fb-good: #2f8a55;
  --fb-error: #b0302a;
}

.fb-tab {
  position: fixed;
  right: 0;
  top: 50%;
  z-index: 20;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  padding: 12px 8px;
  border: 1px solid var(--fb-line);
  border-right: 0;
  border-radius: 0 var(--fb-radius) var(--fb-radius) 0;
  background: var(--fb-card);
  color: var(--fb-ink-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 18px -10px rgba(0, 0, 0, 0.35);
  margin-right: env(safe-area-inset-right, 0);
}
.fb-tab:hover { color: var(--fb-accent); }

.fb-dialog {
  border: 0;
  border-radius: 20px;
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  background: var(--fb-card);
  color: var(--fb-ink);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.5);
}
.fb-dialog::backdrop { background: rgba(10, 18, 15, 0.45); }
@media (max-width: 520px) {
  .fb-dialog {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
    max-height: 92dvh;
  }
}

.fb-form, .fb-sent { display: grid; gap: 14px; padding: 20px; }
.fb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fb-form h2, .fb-sent h2 { font-size: 22px; }
.fb-sent p { margin: 0; color: var(--fb-ink-2); }
.fb-close {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--fb-line); background: transparent; color: var(--fb-ink-2);
  font-size: 22px; line-height: 1; cursor: pointer;
}

.fb-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-chip {
  padding: 6px 12px; border-radius: 999px; font-size: 14px; cursor: pointer;
  border: 1px solid var(--fb-line); background: var(--fb-paper); color: var(--fb-ink);
}
.fb-chip[aria-checked="true"] { background: var(--fb-accent); border-color: var(--fb-accent); color: var(--fb-accent-ink); }

.fb-field { display: grid; gap: 6px; }
.fb-label { font-size: 13px; color: var(--fb-ink-2); font-weight: 600; }
.fb-field textarea, .fb-field input {
  font: inherit; color: var(--fb-ink); background: var(--fb-paper);
  border: 1px solid var(--fb-line); border-radius: 10px; padding: 10px 12px; width: 100%;
  resize: vertical;
}
.fb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.fb-error { margin: 0; color: var(--fb-error); font-size: 14px; }
.fb-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fb-context { font-size: 12px; color: var(--fb-ink-2); }
.fb-btn {
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--fb-line);
  background: var(--fb-paper); color: var(--fb-ink); font-weight: 600; cursor: pointer;
}
.fb-btn--primary { background: var(--fb-accent); border-color: var(--fb-accent); color: var(--fb-accent-ink); }
.fb-btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- replies ---------- */

/* The bright orange tab that appears above Feedback when there's a reply. */
.fb-tab--replied {
  transform: translateY(calc(-50% - 118px)) rotate(180deg);
  background: var(--fb-attention);
  border-color: var(--fb-attention);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 22px -8px color-mix(in srgb, var(--fb-attention) 70%, transparent);
}
.fb-tab--replied:hover { color: #fff; background: color-mix(in srgb, var(--fb-attention) 85%, black); }
@media (prefers-reduced-motion: no-preference) {
  .fb-tab--replied { animation: replied-in 0.5s ease-out both, replied-nudge 2.4s ease-in-out 0.6s 3; }
}
@keyframes replied-in { from { opacity: 0; transform: translate(12px, calc(-50% - 118px)) rotate(180deg); } }
@keyframes replied-nudge {
  0%, 100% { transform: translateY(calc(-50% - 118px)) rotate(180deg); }
  50% { transform: translate(-4px, calc(-50% - 118px)) rotate(180deg); }
}

.fb-sheet { display: grid; gap: 14px; padding: 20px; max-height: 88dvh; overflow-y: auto; }
.fb-sheet .fb-form, .fb-sheet .fb-sent { padding: 0; }
.fb-views { display: inline-flex; gap: 4px; background: var(--fb-paper); border: 1px solid var(--fb-line); border-radius: 999px; padding: 3px; }
.fb-view { border: 0; background: transparent; color: var(--fb-ink-2); font-weight: 600; font-size: 14px; padding: 6px 12px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.fb-view[aria-selected="true"] { background: var(--fb-accent); color: var(--fb-accent-ink); }
.fb-dot { min-width: 18px; height: 18px; border-radius: 999px; background: var(--fb-attention); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; padding: 0 5px; }

.fb-empty { margin: 0; color: var(--fb-ink-2); }
.fb-threads { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.fb-thread { display: grid; gap: 8px; padding: 12px; border-radius: 14px; border: 1px solid var(--fb-line); background: var(--fb-paper); }
.fb-thread--new { border-color: var(--fb-attention); box-shadow: 0 0 0 1px var(--fb-attention); }
.fb-thread__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fb-done { font-size: 12px; font-weight: 700; color: var(--fb-good); }
.fb-bubble { margin: 0; padding: 8px 12px; border-radius: 14px; max-width: 88%; white-space: pre-wrap; font-size: 15px; }
.fb-bubble--me { justify-self: end; background: var(--fb-accent); color: var(--fb-accent-ink); border-bottom-right-radius: 4px; }
.fb-bubble--them { justify-self: start; background: var(--fb-card); border: 1px solid var(--fb-line); border-bottom-left-radius: 4px; }
.fb-from { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fb-ink-2); margin-bottom: 2px; }
.fb-system { margin: 0; text-align: center; font-size: 12px; color: var(--fb-ink-2); }
.fb-reply { display: flex; gap: 8px; }
.fb-reply__input { flex: 1 1 auto; min-width: 0; font: inherit; font-size: 15px; color: var(--fb-ink); background: var(--fb-card); border: 1px solid var(--fb-line); border-radius: 999px; padding: 8px 14px; }

/* Cord of Three: fonts, a slimmer tab so it never covers the cards, and quiet mode while a round is in play
   (feedback stays reachable from the ⋯ menu; the Replied tab still shows). */
.fb-tab { font-family: var(--sans); padding: 12px 6px; font-size: 12px; z-index: 30; }
.fb-dialog { font-family: var(--sans); }
.fb-dialog h2 { font-family: var(--serif); font-weight: 600; margin: 0; }
.fb-dialog textarea, .fb-dialog input { font-size: 16px; } /* 16px stops iOS zooming into the field */
body.fb-quiet .fb-tab:not(.fb-tab--replied) { display: none; }
body.tv .fb-tab { display: none; }
