.tonmio-image-shell {
  display: block;
  width: 100%;
  background: var(--photo-average, var(--surface-muted));
  aspect-ratio: 1;
}
.tonmio-template-frame { --photo-focus-y: 50%; }

body :is(#main,#dialog) .tonmio-image-shell {
  height: auto;
}

.tonmio-image-shell[data-photo-layout="avatar"] { border-radius: 50%; }
.tonmio-image-shell[data-photo-layout="avatar"]:has(> .tonmio-variant-photo:not([src])) {
  background: url('assets/profile-placeholder.svg?v=gold-pin') center / contain no-repeat;
}
.tonmio-image-shell[data-photo-layout="feed"] { aspect-ratio: 4 / 5; max-height: 100%; }
.tonmio-image-shell:is([data-photo-layout="listing"],[data-photo-layout="detail"]) { aspect-ratio: 16 / 9; }

body :is(#main,#dialog) .tonmio-image-shell > .tonmio-photo-image,
.tonmio-image-shell > .tonmio-photo-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--photo-focus-x,50%) var(--photo-focus-y,35%);
  transform-origin: var(--photo-focus-x,50%) var(--photo-focus-y,35%);
  transform: scale(var(--photo-zoom,1));
}

.tonmio-image-shell.show-whole-photo > .tonmio-photo-image,
body :is(#main,#dialog) .tonmio-image-shell.show-whole-photo > .tonmio-photo-image {
  object-fit: contain;
  object-position: center;
  transform: none;
}

.workspace-option-avatar[data-photo-pose="cover"] img {
  object-position: var(--photo-focus-x) var(--photo-focus-y);
  transform-origin: var(--photo-focus-x) var(--photo-focus-y);
  transform: scale(var(--photo-zoom,1));
}
.workspace-option-avatar[data-photo-pose="contain"] img { object-fit: contain; }

.tonmio-image-shell > img:not([src]) { visibility: hidden; }

body :is(#main,#dialog) .tonmio-image-shell[data-photo-layout="thumbnail"] {
  width: 44px;
  margin: 0;
  flex: none;
  border-radius: var(--radius,10px);
}

body :is(#main,#dialog) .tonmio-image-shell[data-photo-layout="thumbnail"] > img { border-radius: inherit; }

.tonmio-profile-gallery, .tonmio-slot-images {
  display: grid;
  gap: var(--space-2);
}

.tonmio-profile-gallery, .tonmio-image-slot:has([data-profile-photo="gallery"]) .tonmio-slot-images {
  grid-template-columns: repeat(auto-fit,minmax(min(120px,100%),1fr));
}

.tonmio-image-slot, .tonmio-listing-photo {
  display: grid;
  gap: var(--space-2);
  padding-block: var(--space-3);
}

.tonmio-image-slot + .tonmio-image-slot,
.tonmio-listing-photo { border-top: 1px solid var(--border-soft); }
.tonmio-image-slot h4, .tonmio-listing-photo h3 { margin: 0; }
.tonmio-listing-photo h3 small { color: var(--text-secondary); font-weight: 400; }
.tonmio-image-slot > button { justify-self: start; }
.tonmio-slot-images:empty { display: none; }
.tonmio-profile-image .tonmio-photo-frame { max-width: 360px; }
body #main .profile-photo-button {
  display: block;
  width: 100%;
  max-width: 360px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-ui);
  background: transparent;
  cursor: pointer;
}
.tonmio-profile-image .tonmio-photo-frame[data-photo-layout="avatar"] { width: min(100%,110px); }
[data-draft-avatar-preview] .tonmio-photo-frame[data-photo-layout="avatar"] { width: min(100%,110px); }
.tonmio-photo-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tonmio-photo-actions button { min-height: var(--tap,44px); }
.tonmio-listing-photo [data-listing-photo-status]:empty { display: none; }
.tonmio-listing-photo [data-photo-editor-mount] { width: 100%; min-width: 0; }

.tonmio-photo-confirm {
 padding: var(--space-2, 8px);
 margin-block: var(--space-1, 4px);
 border: 1px solid var(--border-soft, #e4dfd6);
 border-radius: var(--radius, 12px);
 background: var(--surface-muted, #f2efe8);
}
.tonmio-photo-confirm p { margin: 4px 0 8px; }

/* The same large-image profile sheet is used in Backstage and the community. */
body #dialog[open]:has(.tonmio-profile-card-sheet) {
  height: calc(.9 * var(--sheet-visual-height,var(--app-visible-height,100dvh)));
  max-height: calc(var(--sheet-visual-height,var(--app-visible-height,100dvh)) - env(safe-area-inset-top,0px));
}
body #dialog:has(.tonmio-profile-card-sheet) .dialog-head {
  min-height: 56px;
  padding-block: 6px;
}
body #dialog:has(.tonmio-profile-card-sheet) #dialog-content {
  container-type: size;
  overflow-anchor: none;
  padding-block: 0;
}
body #dialog .tonmio-profile-card-sheet {
  padding-block-start: 12px;
  touch-action: pan-y pinch-zoom;
}
body #dialog .tonmio-profile-preview-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--text-secondary);
  font: 550 .875rem/1.2 var(--font-ui);
}
.tonmio-profile-preview-banner svg { width: 19px; height: 19px; flex: none; }
.tonmio-profile-heading .tonmio-profile-compact-name {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font: 650 .9375rem/1.2 var(--font-ui);
}
.tonmio-profile-preview-banner + .tonmio-profile-compact-name { margin-block-start: 4px; }
body #dialog .tonmio-profile-card-sheet > :is(.tonmio-photo-frame,.tonmio-profile-placeholder) {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background-color: var(--photo-average,var(--surface-muted));
  border-radius: var(--radius-photo,14px);
}
.tonmio-profile-placeholder img { width: 76px; height: 76px; }
body #dialog #dialog-content .tonmio-profile-card-sheet .tonmio-profile-identity { margin: 12px 0 8px; }
body #dialog #dialog-content .tonmio-profile-card-sheet .tonmio-profile-identity h2 {
  font: 750 clamp(1.6rem,7vw,2.15rem)/1.12 var(--font-ui);
  overflow-wrap: anywhere;
  margin-bottom: 4px;
}
body #dialog .tonmio-profile-identity p { color: var(--text-secondary); }
.tonmio-profile-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}
.tonmio-profile-genres li {
  border-radius: 99px;
  background: var(--surface-muted);
  font-size: .8125rem;
  padding: 4px 8px;
}
.tonmio-profile-stats {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 8px;
  margin: 0 0 8px;
}
.tonmio-profile-stats div {
  display: grid;
  grid-template-rows: 18px minmax(1.2em,auto) auto;
  justify-items: center;
  gap: 3px;
  padding: 9px 4px;
  border-radius: var(--radius-ui,12px);
  background: var(--surface-muted);
  text-align: center;
}
.tonmio-profile-stats svg { width: 18px; height: 18px; color: var(--accent-ink); }
.tonmio-profile-stats dt { grid-row: 3; color: var(--text-secondary); font-size: .75rem; }
.tonmio-profile-stats dd {
  grid-row: 2;
  align-self: center;
  margin: 0;
  font-size: .875rem;
  font-weight: 650;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
body #dialog > .tonmio-profile-tabs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 0;
  padding-inline: var(--space-4);
  padding-inline: max(var(--space-4),env(safe-area-inset-left)) max(var(--space-4),env(safe-area-inset-right));
  background: #fff;
  border-bottom: 1px solid var(--border);
}
body #dialog > .tonmio-profile-tabs button {
  min-height: 46px;
  text-align: center;
}
body #dialog .tonmio-profile-card-sheet > .tonmio-profile-panel {
  margin: 0;
  padding: 12px 0 16px;
  min-height: 100cqh;
}
.tonmio-profile-panel > * + * { margin-block-start: 12px; }
.tonmio-profile-panel h3 { margin: 0 0 4px; font-size: .875rem; }
.tonmio-profile-panel .search-description { white-space: pre-line; }
.tonmio-profile-dates { margin: 0; padding-inline-start: 1rem; }
.tonmio-profile-panel:has(.tonmio-profile-dates-empty) {
  display: grid;
  place-items: center;
  text-align: center;
}
.tonmio-profile-dates-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--text-secondary);
}
.tonmio-profile-dates-empty svg { width: 22px; height: 22px; color: var(--accent-ink); }
body #dialog #dialog-footer .tonmio-profile-actions .primary:disabled {
  opacity: 1;
  background: var(--surface-muted);
  color: var(--text-secondary);
  border-color: var(--border);
}
@media (max-height: 740px) {
  body #dialog .tonmio-profile-card-sheet > :is(.tonmio-photo-frame,.tonmio-profile-placeholder) { aspect-ratio: 3 / 2; }
}

body :is(#main,#dialog) .tonmio-photo-expand {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 0;
  padding: 0;
  background: transparent;
  color: white;
  cursor: zoom-in;
}
.tonmio-photo-expand span {
  position: absolute;
  top: var(--photo-expand-top,8px);
  right: 8px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(25,22,18,.76);
}
body #main .discover-slide:has(.discover-bookmark) .tonmio-photo-expand { --photo-expand-top: 61px; }
body :is(#main,#dialog) .tonmio-photo-expand:focus-visible {
  outline: 2px solid white;
  outline-offset: -4px;
}
dialog.tonmio-photo-viewer[open] {
  position: fixed;
  inset: env(safe-area-inset-top,0px) 0 var(--app-visible-bottom-inset,0px);
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  padding: 0;
  margin: auto;
  width: min(calc(100% - 16px),980px);
  max-width: none;
  height: calc(.94 * var(--app-visible-height,100dvh));
  max-height: calc(var(--app-visible-height,100dvh) - env(safe-area-inset-top,0px));
  overflow: hidden;
  border: 1px solid #3a3834;
  border-radius: 16px;
  background: #191713;
  color: #fff;
}
.tonmio-photo-viewer::backdrop {
  background: rgba(0,0,0,.8);
  clip-path: inset(env(safe-area-inset-top,0px) 0 0);
}
.tonmio-photo-viewer header {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 8px;
}
.tonmio-photo-viewer header button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  background: #312e29;
  color: white;
  border-radius: 50%;
  font-size: 1.3rem;
}
.tonmio-photo-viewer-stage {
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}
.tonmio-photo-viewer-stage > div {
  min-width: 100%;
  min-height: 100%;
  width: max-content;
  display: grid;
  place-items: center;
}
.tonmio-photo-viewer-stage img { display: block; max-width: none; max-height: none; }
.tonmio-photo-viewer [hidden] { display: none !important; }

body #dialog .tonmio-profile-card-sheet > .tonmio-profile-panel:not(#tonmio-profile-dates) {
  min-height: 0;
  border-bottom: 1px solid var(--line);
}

#event-template-grid { margin-block-start: var(--space-3); }
#event-template-grid[hidden],
body #dialog .tonmio-listing-photo select[hidden] { display: none; }
.tonmio-template-group + .tonmio-template-group { margin-block-start: var(--space-4); }
.tonmio-template-group h4 { margin: 0 0 var(--space-2); }
.tonmio-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 76px), 1fr));
  gap: var(--space-2);
}
body #dialog #event-template-grid .tonmio-template-option {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: start;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--ink);
  text-align: left;
}
body #dialog #event-template-grid .tonmio-template-option[aria-pressed="true"] {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px var(--gold);
}
.tonmio-template-option img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 9px 9px 0 0;
}
.tonmio-template-option span {
  display: block;
  padding: 6px;
  font-size: .75rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.tonmio-template-option small {
  display: block;
  margin-block-start: 4px;
  font-weight: 700;
}

.tonmio-channel-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-block: var(--space-3);
}
body #dialog a.tonmio-channel-link {
  display: inline-grid;
  flex: none;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 2px 8px rgb(23 20 17 / .08);
  color: var(--ink);
  text-decoration: none;
}
body #dialog a.tonmio-channel-link:active { transform: scale(.95); }
body #dialog a.tonmio-channel-link:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.tonmio-channel-fields {
  display: grid;
  gap: var(--space-3);
}
.tonmio-channel-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}
.tonmio-channel-input [data-channel-prefix] {
  flex: none;
  color: var(--text-secondary);
  font-size: .75rem;
}
.tonmio-channel-input input { flex: 1; min-width: 0; }
.tonmio-channel-error { color: var(--danger, var(--ink)); }
