/* Feedback bar and pins. Uses the page's color tokens. */
:root { --fb-note: #FCE98A; --fb-note-fg: #3D3207; --fb-shadow: 0 6px 20px rgb(0 0 0 / 0.16); }
@media (prefers-color-scheme: dark) { :root { --fb-note: #E8CF5E; --fb-shadow: 0 6px 20px rgb(0 0 0 / 0.5); } }

body { padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }
[data-fb] { position: relative; }

.fb-bar {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 70;
  display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--fb-shadow);
  font-family: var(--font-body); max-width: calc(100vw - 24px);
}
.fb-bar-label { font: 500 10.5px var(--font-mono); text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); padding: 0 8px 0 10px; }
.fb-bar button {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--fg);
  font: 600 13px var(--font-body); padding: 8px 11px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.fb-bar button:hover { background: var(--bg); }
.fb-bar button svg { width: 17px; height: 17px; flex-shrink: 0; }
.fb-tool-up svg { color: var(--blue); }
.fb-tool-down svg { color: var(--red); }
.fb-tool-question svg { color: var(--gold); }
.fb-tool-note svg { color: var(--gold); }
.fb-bar button[aria-pressed="true"] { background: var(--blue); color: var(--on-blue); }
.fb-bar button[aria-pressed="true"] svg { color: currentColor; }
.fb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.fb-count { font: 600 11px var(--font-mono); background: var(--bg); border-radius: 999px; padding: 1px 7px; }
@media (max-width: 620px) {
  .fb-bar-label, .fb-text { display: none; }
  .fb-bar button { padding: 9px; }
}

.fb-hint {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 70;
  max-width: min(520px, calc(100vw - 32px)); background: var(--fg); color: var(--bg); font-size: 13px; line-height: 1.4;
  padding: 8px 14px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s ease; text-align: center;
}
.fb-hint.show { opacity: 1; }

body.fb-placing, body.fb-placing * { cursor: crosshair !important; }
body.fb-placing .fb-ui, body.fb-placing .fb-ui * { cursor: auto !important; }
body.fb-placing .card:hover, body.fb-placing .section-head:hover { outline: 2px dashed var(--blue-edge); outline-offset: 4px; border-radius: 10px; }

/* Pins */
.fb-pin { position: absolute; z-index: 20; transform: translate(-50%, -50%); }
body.fb-hide .fb-pin { display: none; }
.fb-marker {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.22); cursor: pointer; padding: 0; font: 600 11px var(--font-mono); letter-spacing: 0.02em;
}
.fb-marker svg { width: 15px; height: 15px; }
.fb-kind-up .fb-marker { background: #0568B3; color: #fff; }
.fb-kind-down .fb-marker { background: #B45340; color: #fff; }
.fb-kind-question .fb-marker { background: #E5B53B; color: #1C1B19; }
.fb-kind-note .fb-marker { background: var(--fb-note); color: var(--fb-note-fg); border-radius: 4px; transform: rotate(-4deg); width: 28px; height: 28px; }
.fb-new .fb-marker { animation: fb-pop 420ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes fb-pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
.fb-kind-note.fb-new .fb-marker { animation-name: fb-pop-note; }
@keyframes fb-pop-note { 0% { transform: scale(0) rotate(-20deg); } 100% { transform: scale(1) rotate(-4deg); } }
.fb-flash .fb-marker { animation: fb-flash 1200ms ease-out both; }
@keyframes fb-flash { 0% { box-shadow: 0 0 0 0 rgb(7 119 207 / 0.7); } 100% { box-shadow: 0 0 0 18px rgb(7 119 207 / 0); } }

.fb-card {
  display: none; position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%); z-index: 30;
  width: min(240px, 70vw); background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--fb-shadow); padding: 10px 12px; font-size: 13px; line-height: 1.45; text-align: left;
}
.fb-card::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 12px; }
.fb-kind-note .fb-card { background: var(--fb-note); color: var(--fb-note-fg); border-color: transparent; }
.fb-pin:hover .fb-card, .fb-pin:focus-within .fb-card, .fb-pin.open .fb-card { display: block; }
.fb-pin:hover, .fb-pin:focus-within, .fb-pin.open { z-index: 40; }
.fb-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.fb-card-head span { font-size: 11.5px; opacity: 0.75; }
.fb-card p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: inherit; font-size: 13px; }

.fb-link { border: 0; background: none; padding: 0; margin-top: 6px; color: var(--blue); font: 600 12.5px var(--font-body); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.fb-kind-note .fb-card .fb-link { color: var(--fb-note-fg); }

/* Note editor */
.fb-editor {
  position: absolute; z-index: 45; transform: translate(-50%, 12px); width: min(260px, 80vw);
  background: var(--fb-note); color: var(--fb-note-fg); border-radius: 8px; box-shadow: var(--fb-shadow);
  padding: 10px; display: flex; flex-direction: column; gap: 6px;
}
.fb-editor label { font: 600 12px var(--font-body); }
.fb-editor textarea, .fb-general textarea, .fb-dialog input {
  width: 100%; font: 14px var(--font-body); color: var(--fg); background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; resize: vertical;
}
.fb-editor textarea { color: #1C1B19; background: #FFFDF2; border-color: rgb(0 0 0 / 0.15); }
.fb-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fb-primary { border: 0; border-radius: 6px; background: var(--blue); color: var(--on-blue); font: 600 13px var(--font-body); padding: 7px 12px; cursor: pointer; }
.fb-secondary { border: 0; background: none; color: inherit; font: 600 13px var(--font-body); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* List panel */
.fb-panel {
  position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 70;
  width: min(380px, calc(100vw - 32px)); max-height: min(70vh, 640px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--fb-shadow);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.fb-panel[hidden] { display: none; }
.fb-panel-head { display: flex; justify-content: space-between; align-items: center; }
.fb-panel-head h2 { font-size: 1.05rem; }
.fb-icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; display: grid; }
.fb-icon-btn svg { width: 18px; height: 18px; }
.fb-panel-note { font-size: 12.5px; color: var(--muted); }
.fb-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.fb-item { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: start; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.fb-item .fb-link { margin-top: 0; }
.fb-badge { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; }
.fb-badge svg { width: 14px; height: 14px; }
.fb-item.fb-kind-up .fb-badge { background: #0568B3; color: #fff; }
.fb-item.fb-kind-down .fb-badge { background: #B45340; color: #fff; }
.fb-item.fb-kind-question .fb-badge { background: #E5B53B; color: #1C1B19; }
.fb-item.fb-kind-note .fb-badge { background: var(--fb-note); color: var(--fb-note-fg); border-radius: 4px; }
.fb-item-text { min-width: 0; font-size: 13.5px; }
.fb-where { font: 500 10.5px var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.fb-item-text p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--fg); font-size: 13.5px; }
.fb-empty { font-size: 13.5px; color: var(--muted); }
.fb-general { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 12px; }
.fb-general label { font: 600 13px var(--font-body); }
.fb-as { font-size: 12.5px; color: var(--muted); }
.fb-as .fb-link { margin: 0; }

/* Name dialog */
.fb-dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); padding: 20px; width: min(380px, calc(100vw - 32px)); box-shadow: var(--fb-shadow); }
.fb-dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.fb-name-form { display: flex; flex-direction: column; gap: 10px; }
.fb-name-form h2 { font-size: 1.15rem; }
.fb-name-form p { font-size: 13.5px; color: var(--muted); }
.fb-name-form label { font: 600 13px var(--font-body); }
.fb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .fb-new .fb-marker, .fb-flash .fb-marker { animation: none; }
}
