/* ===== DOSE OF SPIRIT: share sheet ===== */
.shr-wrap {
  position: fixed; inset: 0; z-index: 93;
  display: grid; place-items: center; padding: 16px;
  visibility: hidden; pointer-events: none;
  transition: visibility 0s linear .4s;
}
.shr-wrap.on { visibility: visible; pointer-events: auto; transition-delay: 0s; }
.shr-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 20, 20, .45);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  opacity: 0; transition: opacity .35s;
}
.shr-wrap.on .shr-backdrop { opacity: 1; }

.shr-sheet {
  position: relative;
  width: min(900px, 100%);
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: var(--wall); color: var(--ink);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35), inset 0 0 0 1px var(--line);
  overflow: hidden; outline: none;
  font-family: var(--f-sans); font-size: 15px; line-height: 1.5;
  opacity: 0; transform: translateY(24px) scale(.98);
  transition: transform .5s var(--ease), opacity .3s;
}
html[data-lang="th"] .shr-sheet { font-family: var(--f-th); }
.shr-wrap.on .shr-sheet { opacity: 1; transform: none; }

.shr-grab { display: none; }
.shr-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--line);
  flex: none;
}
.shr-head-t { min-width: 0; }
.shr-title { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.shr-sub { margin: 2px 0 0; font-size: 13px; color: var(--mute); font-family: var(--f-mono), var(--f-th), monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shr-x {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-size: 24px; line-height: 1;
  color: var(--ink); box-shadow: inset 0 0 0 1px var(--line);
  transition: transform .3s var(--ease), background .25s;
}
.shr-x:hover { transform: rotate(90deg); background: var(--wall-2); }

.shr-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr);
  align-content: start;
}

/* controls */
.shr-top { display: grid; gap: 14px; }
.shr-top:empty { display: none; }
.shr-group { display: grid; gap: 8px; }
.shr-lbl { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
.shr-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.shr-chips .chip small { font-size: 11px; font-family: var(--f-mono), monospace; opacity: .65; letter-spacing: .04em; }
.shr-chips .chip[disabled] { opacity: .45; cursor: not-allowed; }
.shr-hint { margin: 0; font-size: 13px; color: var(--mute); line-height: 1.5; }
.shr-warn { color: var(--ink-2); padding: 8px 12px; border-radius: 10px; background: var(--wall-2); box-shadow: inset 0 0 0 1px var(--line); }

/* preview */
.shr-pv { min-width: 0; }
.shr-stage {
  display: grid; place-items: center;
  min-height: 180px; padding: 12px;
  border-radius: 14px; background: var(--wall-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.shr-stage img, .shr-stage video {
  display: block; width: auto; height: auto;
  max-width: 100%; max-height: min(44vh, 460px);
  border-radius: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  background: #F3F3F1;
}
.shr-ph {
  display: grid; place-items: center;
  height: min(44vh, 460px); max-width: 100%; aspect-ratio: var(--ar, 4 / 5);
  border-radius: 8px; border: 1px dashed var(--line);
  padding: 16px;
}
.shr-prog { display: grid; justify-items: center; gap: 12px; width: 100%; max-width: 280px; text-align: center; }
.shr-prog-t { font-size: 13px; color: var(--mute); line-height: 1.45; }
.shr-bar { width: 100%; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.shr-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--ink); transition: width .12s linear; }
.shr-spin { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink); animation: shr-spin .8s linear infinite; }
@keyframes shr-spin { to { transform: rotate(360deg); } }
.shr-msg { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 28px 12px; max-width: 320px; }
.shr-msg b { font-size: 16px; }
.shr-msg span { color: var(--mute); font-size: 14px; word-break: break-word; }

/* actions */
.shr-act { display: grid; gap: 12px; align-content: start; min-width: 0; }
.shr-act:empty { display: none; }
.shr-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.shr-btns .btn { flex: 1 1 140px; }
.shr-btns .btn-sm { flex: 1 1 90px; }
.shr-btns .btn { text-decoration: none; }
.shr-fb {
  display: grid; gap: 8px; padding: 14px; border-radius: 14px;
  background: var(--paper); box-shadow: inset 0 0 0 1px var(--line);
}
.shr-fb b { font-size: 14px; }
.shr-fb p { margin: 0; font-size: 13px; color: var(--mute); line-height: 1.55; }

/* caption picker */
.shr-cap { display: grid; gap: 8px; min-width: 0; }
.shr-cap:empty { display: none; }
.shr-cap-ta {
  display: block; width: 100%; min-height: 76px; resize: vertical;
  padding: 10px 12px; border-radius: 12px; border: 0;
  background: var(--paper); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  font: inherit; font-size: 14px; line-height: 1.55;
}
.shr-cap-ta:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* desktop: preview left, controls right */
@media (min-width: 780px) {
  .shr-body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    grid-template-rows: auto auto 1fr;
    column-gap: 22px; padding: 20px;
  }
  .shr-pv { grid-column: 1; grid-row: 1 / span 3; position: sticky; top: 0; align-self: start; }
  .shr-top { grid-column: 2; grid-row: 1; }
  .shr-cap { grid-column: 2; grid-row: 2; }
  .shr-act { grid-column: 2; grid-row: 3; }
  .shr-stage img, .shr-stage video { max-height: min(66vh, 620px); }
  .shr-ph { height: min(62vh, 580px); }
  .shr-pv:only-child, .shr-top:empty ~ .shr-pv { grid-column: 1 / -1; }
}

/* mobile: bottom sheet */
@media (max-width: 560px) {
  .shr-wrap { padding: 0; place-items: end center; }
  .shr-sheet {
    width: 100%; max-height: 94vh; max-height: 94dvh;
    border-radius: 22px 22px 0 0;
    transform: translateY(60px);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .shr-grab { display: block; width: 40px; height: 4px; border-radius: 99px; background: var(--line); margin: 8px auto 0; flex: none; }
  .shr-head { padding: 10px 12px 10px 16px; }
  .shr-body { padding: 16px; gap: 14px; }
  .shr-stage img, .shr-stage video { max-height: min(38vh, 380px); }
  .shr-ph { height: min(36vh, 340px); }
}

.shr-nomotion .shr-sheet, .shr-nomotion .shr-backdrop { transition: none; }
.shr-nomotion .shr-spin { animation-duration: 2s; }
@media (prefers-reduced-motion: reduce) {
  .shr-sheet, .shr-backdrop { transition: none; }
}

.shr-ig svg { margin-right: 6px; flex: none; }
.shr-ig:hover { box-shadow: inset 0 0 0 1px var(--line), 0 0 0 3px rgba(214, 41, 118, .14); }
