#media {
  --viewer-side: 336px;
  --viewer-width: 340px;
  --viewer-height: 604px;
  position: fixed;
  width: max-content;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 20px 88px #120d116b;
}
#media::backdrop { background: #171316b8; }
#media [hidden] { display: none !important; }
#media svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.viewer-layout {
  display: grid;
  grid-template-columns: var(--viewer-width) var(--viewer-side);
  height: var(--viewer-height);
}
.viewer-stage { position: relative; min-width: 0; overflow: hidden; background: #30292d; }
.viewer-player, #media .viewer-player video, .viewer-player iframe {
  width: 100%;
  height: 100%;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
}
#media .viewer-player video { object-fit: cover; background: transparent; }
.viewer-media-status {
  position: absolute;
  inset-inline: 10px;
  bottom: 52px;
  width: fit-content;
  max-width: calc(100% - 20px);
  margin: auto;
  padding: 6px 9px;
  border-radius: 6px;
  background: #231f20dd;
  color: white;
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}
.viewer-close {
  position: absolute;
  z-index: 2;
  right: 12px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f1eeee;
  color: #3c3439;
}
.viewer-close:hover { background: #e7e1e4; }
.viewer-panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: white; }
.viewer-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; overscroll-behavior: contain; }
.viewer-header { padding: 24px 23px 18px; }
.viewer-locale {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 1px 32px 9px 0;
  color: #8c3a56;
  font-size: 11px;
  font-weight: 680;
  letter-spacing: .015em;
}
#media .viewer-locale svg { width: 13px; height: 13px; }
#video-title { margin: 0; font-size: clamp(21px,2.1vw,29px); line-height: 1.1; letter-spacing: -.045em; overflow-wrap: anywhere; }
.viewer-locale[hidden] + #video-title { margin-right: 25px; }
.viewer-description { margin: 10px 0 0; font-size: 13px; line-height: 1.5; color: #585156; }
.viewer-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 15px; }
.viewer-like, .viewer-source { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 660; }
.viewer-like {
  min-height: 35px;
  padding: 6px 10px;
  border: 1px solid #ddd7da;
  border-radius: 10px;
  background: white;
  font-variant-numeric: tabular-nums;
}
.viewer-like:hover { border-color: #ce6d8b; }
.viewer-like[aria-pressed=true] { border-color: #f0bfd0; background: #fff0f5; color: #a52d52; }
.viewer-like[aria-pressed=true] svg { fill: var(--accent); stroke: var(--accent); }
.viewer-like:disabled { opacity: .65; }
.viewer-source { color: #635b60; text-decoration: none; text-underline-offset: 3px; }
.viewer-source:hover { color: var(--berry); text-decoration: underline; }
#media .viewer-source svg { width: 13px; height: 13px; }
.viewer-thread { margin-inline: 23px; padding: 16px 0 22px; border-top: 1px solid #eee9eb; }
.viewer-thread-title { display: flex; gap: 7px; align-items: baseline; }
.viewer-thread-title h3 { margin: 0; font-size: 15px; line-height: 1.35; letter-spacing: -.025em; }
.viewer-count, .viewer-thread-status, .viewer-feedback { color: #756d72; font-size: 12px; }
.viewer-count { font-variant-numeric: tabular-nums; }
.viewer-thread-status { margin: 9px 0 0; line-height: 1.5; }
.viewer-thread-status:empty, .viewer-comments:empty { display: none; }
.viewer-retry, .viewer-older { padding: 0; margin-top: 4px; border: 0; color: var(--berry); background: none; text-decoration: underline; font-size: 12px; }
.viewer-comments { list-style: none; margin: 13px 0 0; padding: 0; }
.viewer-comments li { margin: 0 0 12px; }
.viewer-comment-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 7px; }
.viewer-comment-head strong { font-size: 12px; color: #3b3539; }
.viewer-comment-head time { font-size: 10px; color: #776f75; }
.viewer-comments p { margin: 2px 0 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.viewer-feedback { padding: 6px 20px 0; margin: 0; color: #8c2547; }
.viewer-feedback.success { color: #315b49; }
.viewer-compose { display: flex; align-items: center; gap: 6px; padding: 12px 16px; border-top: 1px solid #eee9eb; }
.viewer-input { flex: 1; min-width: 0; }
.viewer-input input { box-sizing: border-box; width: 100%; min-height: 38px; border: 1px solid #e4dde0; border-radius: 11px; padding: 7px 11px; background: #faf9f8; font-size: 13px; color: var(--ink); }
.viewer-input input:focus { outline: 2px solid #d63c6866; outline-offset: 0; border-color: #c96182; }
.viewer-send { display: grid; place-items: center; flex: none; width: 37px; height: 37px; border: 0; border-radius: 11px; background: var(--accent); color: white; }
.viewer-send:disabled { background: #f1e9ec; color: #947d87; }
@media (max-width:700px) {
  #media { max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; border-radius: 15px; overscroll-behavior: contain; scrollbar-width: thin; }
  .viewer-layout { display: flex; flex-direction: column; width: var(--viewer-width); height: auto; }
  .viewer-stage { width: 100%; height: var(--viewer-height); flex: none; }
  .viewer-panel, .viewer-scroll { display: block; overflow: visible; }
  .viewer-header { padding: 16px 17px 13px; }
  #video-title { font-size: 23px; }
  .viewer-locale { margin: 0 0 5px; }
  .viewer-description { margin-top: 6px; }
  .viewer-actions { margin-top: 11px; }
  .viewer-thread { margin-inline: 17px; padding: 13px 0; }
  .viewer-compose { padding: 10px 12px; }
  .viewer-close { position: sticky; display: grid; top: 8px; float: right; margin: 8px 8px -40px 0; width: 32px; height: 32px; background: #231f20d9; color: white; box-shadow: 0 0 0 1px #ffffff77; }
  .viewer-close:hover { background: #231f20; }
}
@media (prefers-reduced-motion:no-preference) {
  #media[open] { animation: viewer-show .16s ease-out; }
  @keyframes viewer-show { from { opacity: .6; } to { opacity: 1; } }
}
