/* ============================================================================
   History of the Letter A — Studio, Interactive Video Player, Provenance Plaque
   & Single-Page Share Drawer Styles (Gallery Minimalism + Burnt Vermilion)
   ============================================================================ */

body.studio-page, body.player-page {
  overflow: auto;
  background: #fff;
  color: var(--ink);
}
body.studio-page .top, body.player-page .top {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid #ececec;
  pointer-events: auto;
}

.studio-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.studio-hero {
  margin-bottom: 22px;
}
.studio-hero h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 4.2vw, 44px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.06;
}
.studio-hero p {
  margin: 0;
  color: var(--grey);
  font-size: 16px;
  max-width: 660px;
  line-height: 1.5;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
@media (max-width: 920px) {
  .studio-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}

/* ---------- Live 3D Interactive Stage ---------- */
.studio-preview-col {
  position: sticky;
  top: 74px;
}
@media (max-width: 920px) {
  .studio-preview-col { position: static; }
}

.stage-frame {
  position: relative;
  width: 100%;
  margin: 0 auto;
  border-radius: 20px;
  border: 1px solid #e4e4e7;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.08);
  aspect-ratio: 9 / 16;
  max-height: 70vh;
}
.stage-frame[data-ratio="16:9"] { aspect-ratio: 16 / 9; max-height: none; }
.stage-frame[data-ratio="1:1"]  { aspect-ratio: 1 / 1; max-height: 62vh; }
.stage-frame[data-theme="dark"] { background: #0e0f12; border-color: #27272a; }
.stage-frame[data-theme="vellum"] { background: #f5f0e6; border-color: #dcd2c0; }

.stage-frame canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  cursor: grab;
  touch-action: none;
}
.stage-frame canvas.is-grabbing { cursor: grabbing; }

.stage-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid #ececec;
  background: #fafafa;
}
.st-icon-btn {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  border: 1px solid #e0e0e0;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.st-icon-btn:hover { border-color: #111; }
.stage-controls input[type="range"] {
  flex: 1;
  accent-color: var(--turn);
  cursor: pointer;
}
.st-time {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--grey);
  min-width: 78px;
  text-align: right;
}
.drag-hint {
  margin: 6px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--grey);
}

/* Character Tap Inspection Popover */
.inspect-popover {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid #e5e5e5;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.inspect-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.inspect-left strong { display: block; font-size: 14px; }
.inspect-left small { color: var(--grey); font-size: 12px; font-family: var(--mono); }
.inspect-svg svg { width: 32px; height: 32px; color: var(--turn); }
.inspect-right { display: flex; align-items: center; gap: 8px; flex: none; }
.inspect-x { border: 0; background: transparent; font-size: 18px; color: var(--grey); cursor: pointer; padding: 2px 6px; }

/* Primary Share / Export Actions */
.export-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.export-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.st-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #d4d4d8;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, background .15s, transform .1s;
}
.st-btn:hover { border-color: #111; }
.st-btn:active { transform: translateY(1px); }
.st-btn-primary {
  background: #111;
  color: #fff;
  border-color: #111;
}
.st-btn-primary:hover { background: #262626; }
.st-btn-primary.is-busy { background: var(--turn); border-color: var(--turn); }
.export-status {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--turn);
  font-family: var(--mono);
  text-align: center;
  min-height: 18px;
}

/* ---------- Right Panel: Character Picker & Director Controls ---------- */
.studio-panel {
  border: 1px solid #ececec;
  border-radius: 18px;
  padding: 18px;
  background: #fafafa;
  margin-bottom: 16px;
}
.input-row {
  display: flex;
  gap: 8px;
}
.char-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid #d4d4d8;
  background: #fff;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}
.char-input:focus { outline: none; border-color: #111; }
.input-warn {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 12.5px;
  line-height: 1.45;
}

.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.sel-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 9px;
  border-radius: 99px;
  border: 1px solid #e4e4e7;
  background: #fff;
  font-size: 13px;
}
.sel-chip__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sel-chip small { color: var(--grey); font-size: 11.5px; }
.sel-chip__rm {
  border: 0;
  background: transparent;
  color: var(--grey);
  cursor: pointer;
  font-size: 15px;
  padding: 0 2px;
  line-height: 1;
}
.sel-chip__rm:hover { color: var(--turn); }

.picker-tabs {
  display: flex;
  gap: 6px;
  margin: 14px 0 12px;
  border-bottom: 1px solid #e5e5e5;
  padding-bottom: 10px;
}
.st-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid #e0e0e0;
  background: #fff;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.st-pill:hover { border-color: #111; }
.st-pill.is-active { background: #111; color: #fff; border-color: #111; }

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 8px;
}
.preset-card {
  text-align: left;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid #e5e5e5;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.preset-card:hover { border-color: #111; }
.preset-tag { font-family: var(--mono); font-size: 10.5px; color: var(--turn); font-weight: 600; }
.preset-card b { font-size: 15px; }

.gp-group { margin-bottom: 12px; }
.gp-group h4 {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--grey);
}
.glyph-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 6px;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 2px;
}
.gp-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 4px;
  border-radius: 10px;
  border: 1px solid #e6e6e6;
  background: #fff;
  cursor: pointer;
}
.gp-tile:hover { border-color: #111; background: #fffbf7; }
.gp-svg svg { width: 22px; height: 22px; color: #9a7b55; }
.gp-tile b { font-size: 16px; line-height: 1.1; }
.gp-tile small {
  font-size: 10px;
  color: var(--grey);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Director Option Controls */
.ctrl-grid {
  display: grid;
  gap: 12px;
}
.ctrl-row label.ctrl-lbl {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--grey);
  margin-bottom: 6px;
}
.seg-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ctrl-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  font-weight: 500;
}
.ctrl-toggles label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* ---------- 3D Museum Provenance Plaque ---------- */
.plaque-stage { perspective: 900px; margin: 16px 0 0; }
.plaque-card {
  --px: 50%; --py: 50%; --rx: 0deg; --ry: 0deg; --op: 0.45;
  transform-style: preserve-3d;
  cursor: pointer;
}
.plaque-card__rotator {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  transform: rotateY(var(--rx)) rotateX(var(--ry));
  border: 1px solid #e4e4e7;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}
.plaque-card.is-dark .plaque-card__rotator { background: #14151b; color: #f5f5f7; border-color: #2f313d; }
.plaque-card.is-white .plaque-card__rotator { background: linear-gradient(145deg, #fff 0%, #f8f8fa 100%); color: #111; }
.plaque-card.is-vellum .plaque-card__rotator { background: linear-gradient(145deg, #f8f3e9 0%, #eee5d4 100%); color: #1c1917; border-color: #d6cbb7; }
.plaque-card.has-twin .plaque-card__rotator { border-color: var(--turn); }
.plaque-card__body { position: relative; z-index: 1; padding: 16px 18px; }
.plaque-card__sheen {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: var(--op);
  background: radial-gradient(circle at var(--px) var(--py), rgba(194, 65, 12, 0.16), rgba(255, 255, 255, 0.24) 24%, transparent 65%);
  mix-blend-mode: overlay;
}
.plaque-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
}
.plaque-kicker { color: var(--turn); font-weight: 600; }
.plaque-span { opacity: 0.65; }
.plaque-word { font-size: 28px; font-weight: 700; letter-spacing: 0.06em; margin: 8px 0 4px; }
.plaque-totem { font-size: 14px; opacity: 0.78; line-height: 1.45; }
.plaque-twin-seal {
  margin-top: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(194, 65, 12, 0.12);
  color: var(--turn);
  font-size: 12px;
  font-weight: 600;
}
.plaque-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.plaque-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 99px;
  border: 1px solid rgba(128, 128, 128, 0.25);
  background: rgba(128, 128, 128, 0.07);
  color: inherit;
  font-size: 12px;
  cursor: pointer;
}
.plaque-dot { width: 8px; height: 8px; border-radius: 50%; }
.plaque-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(128, 128, 128, 0.18);
  font-family: var(--mono);
  font-size: 10.5px;
  opacity: 0.6;
}

/* ---------- /r/:id Interactive Player Layout ---------- */
.player-shell {
  max-width: 540px;
  margin: 0 auto;
  padding: 20px 16px 72px;
}
.player-make-box {
  margin: 18px 0;
  padding: 16px;
  border-radius: 16px;
  border: 1.5px solid #111;
  background: #fafafa;
}
.player-make-box h2 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}
.player-make-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

/* ---------- WebView-Safe Share / Video Preview Modal ---------- */
.hla-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.hla-modal[hidden] { display: none; }
.hla-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 14, 0.72);
  backdrop-filter: blur(6px);
}
.hla-modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 18px;
  background: #fff;
  color: #111;
  border: 1px solid #e4e4e7;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.hla-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #ececec;
  font-weight: 700;
  font-size: 15px;
}
.hla-modal__close {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid #e0e0e0; background: #fafafa; cursor: pointer; font-size: 18px;
}
.hla-modal__body { padding: 14px 16px 18px; text-align: center; }
.hla-modal__video, .hla-modal__img {
  width: 100%;
  max-height: 50vh;
  border-radius: 12px;
  border: 1px solid #e5e5e5;
  background: #0e0f12;
  object-fit: contain;
}
.hla-modal__hint { font-size: 13px; color: var(--grey); margin: 10px 0 12px; }
.hla-modal__actions { display: flex; flex-direction: column; gap: 8px; }
.hla-modal__social { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }

/* ---------- Single-Character Page Share Drawer (Minimal Frosted Sheet) ---------- */
.exp-share-sheet {
  position: fixed;
  right: 18px;
  top: 58px;
  z-index: 20;
  width: min(320px, calc(100vw - 36px));
  padding: 14px;
  border-radius: 16px;
  border: 1px solid #e4e4e7;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
}
.exp-share-sheet[hidden] { display: none; }
.exp-share-sheet h3 { margin: 0 0 10px; font-size: 13px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--grey); display: flex; justify-content: space-between; align-items: center; }
.exp-share-list { display: flex; flex-direction: column; gap: 7px; }
.exp-share-btn {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 9px 12px; border-radius: 10px; border: 1px solid #e5e5e5; background: #fff;
  font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; text-align: left;
}
.exp-share-btn:hover { border-color: #111; }
.exp-share-btn.is-hero { background: #111; color: #fff; border-color: #111; }
.exp-share-socials { display: flex; gap: 6px; margin-top: 6px; }
.exp-share-socials a { flex: 1; text-align: center; padding: 6px; border-radius: 8px; border: 1px solid #e5e5e5; font-size: 12px; font-weight: 600; text-decoration: none; }
.exp-share-socials a:hover { border-color: #111; }
.exp-share-msg { margin: 6px 0 0; font-size: 11.5px; color: var(--turn); font-family: var(--mono); min-height: 15px; }
