.portrait-dialog {
  width: min(510px, calc(100% - 28px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: clamp(18px, 5vw, 28px);
  color: #413224;
  background: #fff9ed;
  border: 1px solid #dbc8a6;
  border-radius: 22px;
  box-shadow: 0 18px 54px #21190d38;
  overflow: auto;
}
.portrait-dialog::backdrop { background: #14223785; }
.portrait-dialog [hidden], .portrait-reaction[hidden] { display: none; }
body.dark .portrait-dialog {
  color: #edf3ff;
  background: #202f47;
  border-color: #526480;
}
.portrait-dialog h2 { margin: 0; font-size: 1.4rem; }
.portrait-dialog p { margin: 0; line-height: 1.65; }
.portrait-dialog p + p { margin-top: 7px; }
.portrait-head, .portrait-actions, .portrait-card { display: flex; align-items: center; gap: 9px; }
.portrait-head { justify-content: space-between; margin-bottom: 14px; }
.portrait-head form { margin: 0; }
.portrait-actions { flex-wrap: wrap; margin-top: 12px; }
.portrait-dialog .sbtn { min-height: 42px; }
.portrait-dialog input:focus-visible, .portrait-dialog .sbtn:focus-visible {
  outline: 2px solid #987337;
  outline-offset: 3px;
}
body.dark .portrait-dialog :is(input, .sbtn):focus-visible { outline-color: #ffda90; }
.portrait-options { display: grid; gap: 8px; margin: 15px 0; }
.portrait-options label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 3px 0;
  line-height: 1.6;
}
.portrait-options input { width: 18px; height: 18px; margin: 4px 0 0; accent-color: #2e654d; }
.portrait-dialog .portrait-note { font-size: .9rem; }
.portrait-dialog :is([data-portrait-content], #portraitDraft) { margin-top: 12px; }
#portraitStatus:not(:empty) { margin-top: 10px; }
.portrait-card img, .portrait-reaction img {
  display: block;
  width: 74px;
  aspect-ratio: 1;
  object-fit: cover;
  border: 2px solid #e8c47f;
  border-radius: 18px;
  background: #fff3dd;
}
.portrait-thumbnail { position: relative; flex: none; margin: 0; }
.portrait-reaction {
  position: fixed;
  z-index: 66;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(86px, calc(68px + env(safe-area-inset-bottom)));
  margin: 0;
  pointer-events: none;
  filter: drop-shadow(0 5px 12px #18243345);
}
.portrait-reaction img { width: clamp(54px, 10vw, 78px); }
.portraitExpression {
  display: none;
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 8px;
  white-space: nowrap;
  background: #fff3dc;
  color: #594024;
  font-size: .78rem;
  border: 1px solid #d8b678;
  border-radius: 12px;
}
[data-reaction] > .portraitExpression { display: block; }
[data-reaction="success"] > img { animation: portraitCelebrate .68s cubic-bezier(.2,.65,.3,1) both; border-color: #88bc92; }
[data-reaction="success"] > .portraitExpression { background: #e1f3dc; color: #245037; border-color: #8ab995; }
[data-reaction="retry"] > img { animation: portraitEncourage .56s ease-out both; }
@keyframes portraitCelebrate {
  28% { transform: translateY(-10px) rotate(-6deg) scale(1.08); }
  57% { transform: translateY(1px) rotate(4deg); }
}
@keyframes portraitEncourage {
  30% { transform: rotate(-8deg); }
  64% { transform: rotate(5deg); }
}
@media (prefers-reduced-motion: reduce) {
  [data-reaction] > img { animation: none; }
}
