/* ---------- Portal (js/portal.js): the marked thing and the list of all sides ---------- */
:root { --rp-bg: #fff; --rp-fg: #111; --rp-mute: #444; --rp-line: #c9c9d1; --rp-hover: #eef1f6; }
html[data-mode="dark"] { --rp-bg: #1c1c22; --rp-fg: #f2f2f2; --rp-mute: #c8c8d0; --rp-line: #3a3a44; --rp-hover: #2a2a33; }
html[data-mode="black"] { --rp-bg: #000; --rp-fg: #fff; --rp-mute: #ddd; --rp-line: #888; --rp-hover: #1a1a1a; }

.rp-hit { cursor: pointer; }
.rp-hit:focus-visible { outline: 3px solid #4da3ff; outline-offset: 3px; box-shadow: 0 0 0 6px #fff; }
html.rp-show [data-rp] { outline: 2px solid #f0f; outline-offset: 2px; }

.rp-dlg {
  box-sizing: border-box; width: min(420px, calc(100vw - 24px)); max-height: min(640px, 86dvh);
  margin: auto; padding: 0; overflow: hidden; flex-direction: column;
  color: var(--rp-fg); background: var(--rp-bg); border: 1px solid var(--rp-line); border-radius: 10px;
  font: 400 15px/1.4 system-ui, sans-serif; box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.rp-dlg[open] { display: flex; }
.rp-dlg::backdrop { background: rgba(0, 0, 0, .55); }
.rp-bar { flex: none; height: 4px; background: var(--rp-accent, #4da3ff); }
.rp-bar.rp-gold { background: #e8b923; height: 6px; }
.rp-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 14px 4px; }
.rp-head h2 { flex: 1; margin: 0; font-size: 18px; }
.rp-dlg button, .rp-dlg input { font: inherit; color: inherit; }
.rp-close, .rp-reset, .rp-go {
  min-height: 44px; padding: 6px 14px; cursor: pointer; background: var(--rp-bg); border: 1px solid var(--rp-line); border-radius: 8px;
}
.rp-dlg p { flex: none; margin: 0; padding: 2px 14px; }
.rp-found { font-weight: 600; }
.rp-badge { color: var(--rp-fg); font-weight: 700; }
.rp-badge::before { content: "★ "; color: #b8860b; }
.rp-again, .rp-count, .rp-test, .rp-none { color: var(--rp-mute); }
.rp-test { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.rp-all { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 14px; padding: 10px; border: 2px solid #e8b923; border-radius: 8px; }
.rp-all .rp-photo { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.rp-all .rp-note { flex: 1; min-width: 160px; }
.rp-all .rp-note p { padding: 0; }
.rp-date { color: var(--rp-mute); font-size: 13px; }
.rp-dlg .rp-search {
  flex: none; box-sizing: border-box; width: calc(100% - 28px); margin: 8px 14px; min-height: 44px; padding: 6px 10px;
  font-size: 16px; background: var(--rp-bg); border: 1px solid var(--rp-line); border-radius: 8px;
}
.rp-list { flex: 1 1 auto; min-height: 120px; margin: 0; padding: 0 6px; overflow-y: auto; overflow-x: hidden; list-style: none; overscroll-behavior: contain; }
.rp-list li[hidden], .rp-none[hidden] { display: none; }
.rp-item {
  display: flex; align-items: center; gap: 10px; box-sizing: border-box; width: 100%; min-height: 44px; padding: 6px 8px;
  text-align: left; cursor: pointer; background: none; border: 0; border-radius: 6px;
}
.rp-item:hover { background: var(--rp-hover); }
.rp-item:disabled { cursor: default; opacity: 1; color: var(--rp-mute); }
.rp-n { flex: none; min-width: 2em; color: var(--rp-mute); font-variant-numeric: tabular-nums; text-align: right; }
.rp-nm { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rp-here { flex: none; font-size: 12px; font-style: italic; }
.rp-st { flex: none; color: #1a7f37; font-weight: 700; }
html[data-mode="dark"] .rp-st, html[data-mode="black"] .rp-st { color: #5fd47f; }
.rp-foot { flex: none; padding: 8px 14px 12px; border-top: 1px solid var(--rp-line); }
.rp-dlg button:focus-visible, .rp-dlg input:focus-visible { outline: 3px solid #4da3ff; outline-offset: 2px; }

@media (max-width: 480px) {
  .rp-dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 14px 14px 0 0; max-height: 80dvh; }
}
@media (prefers-reduced-motion: no-preference) {
  .rp-dlg[open] { animation: rp-in .18s ease-out; }
  @keyframes rp-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
}
