:root {
  --gallery-control-h: 36px;
  --gallery-auth-column-max: 42rem;
  /* Fixed widths for i18n labels — sized for longest EN/ZH string per control */
  --gallery-btn-w-sign-out: 104px;
  --gallery-btn-w-sign-in: 96px;
  --gallery-btn-w-present: 88px;
  --gallery-btn-w-present-exit: 184px;
  --gallery-btn-w-edit: 56px;
  --gallery-btn-w-save: 56px;
  --gallery-btn-w-cancel: 68px;
  --gallery-btn-w-delete: 60px;
  --gallery-readonly-badge-min-w: 168px;
  --gallery-fill-slot-col-w: 132px;
  --gallery-fill-slot-inner: 120px;
  --gallery-fill-table-min-w: 1496px;
  --gallery-fill-table-min-w-with-delete: 1556px;
}

/* Shell — aligned with superuser report.html + admin-shell.css */
.page.gallery-page {
  max-width: 1100px;
  width: 100%;
  min-width: 0;
  padding-top: 24px;
}

.gallery-page > #authCard,
.gallery-page > .gallery-auth-hint-wrap {
  width: 100%;
  max-width: min(100%, var(--gallery-auth-column-max));
  margin-inline: auto;
  box-sizing: border-box;
}

.gallery-page > .panel {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  border: none;
}

.gallery-page > .panel h2 {
  margin: 0 0 12px;
}

.gallery-header.researcher-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 12px;
}

.gallery-header__status {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  margin: 0;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

.gallery-header__status:empty {
  display: none;
}

.gallery-header__status:not(.error):not(.ok):empty {
  display: none;
}

.gallery-header__lead.researcher-header__lead {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  min-width: 0;
}

.gallery-header.researcher-header h1 {
  margin: 0;
  font-size: clamp(20px, 3vw, 30px);
  min-width: 0;
  line-height: 1.15;
}

.gallery-header__actions.researcher-header__actions {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 10px;
  min-width: 0;
}

body:not(.gallery-page--signed-out) .gallery-header__actions.researcher-header__actions {
  display: flex;
}

.gallery-header__actions #signOutBtn {
  min-height: 44px;
  height: 44px;
  max-height: 44px;
}

.gallery-header__actions #signOutBtn.gallery-btn--sign-out {
  width: var(--gallery-btn-w-sign-out);
  min-width: var(--gallery-btn-w-sign-out);
  max-width: var(--gallery-btn-w-sign-out);
}

.gallery-header__actions .lang-toggle-btn {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
}

.grid-form {
  display: grid;
  gap: 10px;
}

.grid-form label {
  display: grid;
  gap: 6px;
}

.gallery-page .grid-form button.gallery-btn--sign-in {
  width: var(--gallery-btn-w-sign-in);
  min-width: var(--gallery-btn-w-sign-in);
  max-width: var(--gallery-btn-w-sign-in);
  justify-self: start;
}

.gallery-page .grid-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
.gallery-page .grid-form textarea,
.gallery-page .grid-form select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 40px;
  background: var(--surface-2);
  border: 1px solid #4a4a4a;
  color: var(--fg);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}

.hint-text {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.gallery-auth-hint-wrap {
  margin: 10px auto 72px;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.gallery-auth-readonly-hint {
  margin: 0;
  padding: 0 14px;
  text-align: center;
  width: auto;
  max-width: 100%;
}

.report-readonly-badge {
  margin: 0;
  padding: 8px 18px;
  border-radius: 999px;
  background: #4a3f28;
  color: #f5e6c4;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  line-height: 1.35;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  flex: 0 0 auto;
  min-width: var(--gallery-readonly-badge-min-w);
  box-sizing: border-box;
  text-align: center;
}

.report-readonly-badge[hidden] {
  display: none !important;
}

.report-readonly-badge .report-readonly-badge__long {
  display: inline !important;
}

.report-readonly-badge .report-readonly-badge__short {
  display: none !important;
}

@media (max-width: 640px) {
  .report-readonly-badge .report-readonly-badge__long {
    display: none !important;
  }

  .report-readonly-badge .report-readonly-badge__short {
    display: inline !important;
  }
}

.gallery-console.stack {
  gap: 8px;
  min-height: 0;
}

/* Signed-in: auth blocks must not reserve space (belt-and-suspenders with [hidden]). */
body:not(.gallery-page--signed-out) #authCard,
body:not(.gallery-page--signed-out) #galleryAuthHintWrap {
  display: none !important;
}

@media (max-width: 720px) {
  .gallery-page .gallery-header__actions .btn:not(.gallery-btn--fixed) {
    width: auto;
  }
}

/* Unified height: table row chrome in Fill & Present (not page shell header) */
.gallery-controls .btn,
.gallery-slide__header .btn {
  box-sizing: border-box;
  height: var(--gallery-control-h);
  min-height: var(--gallery-control-h);
  max-height: var(--gallery-control-h);
}

.gallery-filter-inline select,
.gallery-filter-inline__search,
.gallery-fill__select,
.gallery-slide__user-input,
.gallery-card__user-input {
  box-sizing: border-box;
  height: var(--gallery-control-h);
  min-height: var(--gallery-control-h);
}

.gallery-filter-inline select,
.gallery-filter-inline__search,
.gallery-fill__select,
.gallery-slide__user-input,
.gallery-card__user-input {
  padding: 0 10px;
  font-size: 13px;
  line-height: 1.2;
}

.gallery-controls .btn,
.gallery-slide__header .btn {
  padding: 0 12px;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

/* Fixed-width buttons — prevent layout shift on language toggle */
.gallery-btn--fixed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex-shrink: 0;
  white-space: nowrap;
}

.gallery-btn--sign-out {
  width: var(--gallery-btn-w-sign-out);
  min-width: var(--gallery-btn-w-sign-out);
  max-width: var(--gallery-btn-w-sign-out);
}

.gallery-btn--sign-in {
  width: var(--gallery-btn-w-sign-in);
  min-width: var(--gallery-btn-w-sign-in);
  max-width: var(--gallery-btn-w-sign-in);
}

.gallery-btn--edit {
  width: var(--gallery-btn-w-edit);
  min-width: var(--gallery-btn-w-edit);
  max-width: var(--gallery-btn-w-edit);
}

.gallery-btn--save {
  width: var(--gallery-btn-w-save);
  min-width: var(--gallery-btn-w-save);
  max-width: var(--gallery-btn-w-save);
}

.gallery-btn--cancel {
  width: var(--gallery-btn-w-cancel);
  min-width: var(--gallery-btn-w-cancel);
  max-width: var(--gallery-btn-w-cancel);
}

.gallery-btn--delete {
  width: var(--gallery-btn-w-delete);
  min-width: var(--gallery-btn-w-delete);
  max-width: var(--gallery-btn-w-delete);
}

.gallery-present-tools .lang-toggle-btn {
  width: var(--gallery-control-h);
  min-width: var(--gallery-control-h);
  height: var(--gallery-control-h);
  min-height: var(--gallery-control-h);
  max-height: var(--gallery-control-h);
  padding: 0;
  border: none;
  border-radius: 10px;
  background: var(--surface-2);
  font: inherit;
  font-weight: 700;
}

.gallery-present-tools .lang-toggle-btn:hover {
  background: #424242;
}

.gallery-present-tools .lang-toggle-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.gallery-header__lead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.gallery-page--readonly .gallery-card__user-input,
.gallery-page--readonly .why-textarea {
  pointer-events: none;
  opacity: 0.92;
}

/* Shell header uses .researcher-header grid above */
.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.gallery-toolbar--session {
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
}

.gallery-session-email {
  max-width: min(42vw, 280px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Language toggle — gallery toolbar matches .btn chrome (no border) */
.lang-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--fg);
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.lang-toggle-btn:hover {
  background: #424242;
}

.lang-toggle-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.lang-toggle-mark {
  position: relative;
  display: block;
  width: 24px;
  height: 22px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
}

.lang-toggle-mark::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 1.5px;
  background: currentColor;
  opacity: 0.45;
  transform: translate(-50%, -50%) rotate(-38deg);
}

.lang-toggle-mark__zh {
  position: absolute;
  top: 0;
  left: 0;
  font-size: 11px;
}

.lang-toggle-mark__en {
  position: absolute;
  right: 0;
  bottom: 0;
  font-size: 8px;
  letter-spacing: 0.02em;
}

/* Controls row: filter + layout segment */
.gallery-controls {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

body.gallery-layout-fill {
  --gallery-fill-chrome-h: 152px;
}

body.gallery-layout-fill .page.gallery-page {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  max-width: min(100%, 1680px);
  padding-left: 12px;
  padding-right: 12px;
  overflow-x: clip;
}

body.gallery-layout-fill .gallery-controls {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  min-height: var(--gallery-control-h);
  box-sizing: border-box;
  width: 100%;
  margin: 0 0 8px;
  padding: 10px 0;
  background: transparent;
}

body.gallery-layout-fill #galleryMain.stack {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  min-height: 0;
  width: 100%;
}

body.gallery-layout-fill .gallery-list--fill {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

body.gallery-layout-fill .gallery-fill-wrap {
  flex: 0 1 auto;
  box-sizing: border-box;
  width: 100%;
  max-height: calc(100dvh - var(--gallery-fill-chrome-h));
  min-height: 0;
}

body.gallery-layout-fill .gallery-fill-table {
  height: auto;
}

body.gallery-layout-fill #galleryStatus:not(.error):not(.ok):empty {
  display: none;
}

.gallery-status--controls {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}

.gallery-status--controls:empty {
  display: none;
}

.gallery-filter-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: visible;
}

.gallery-filter-inline__label {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.gallery-filter-inline select,
.gallery-filter-inline__search {
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  outline: none;
  box-shadow: none;
}

.gallery-filter-inline select:focus,
.gallery-filter-inline select:focus-visible,
.gallery-filter-inline__search:focus,
.gallery-filter-inline__search:focus-visible {
  outline: none;
  box-shadow: none;
  border-color: #4a4a4a;
}

.gallery-enter-present {
  flex-shrink: 0;
  margin-left: auto;
  width: var(--gallery-btn-w-present);
  min-width: var(--gallery-btn-w-present);
  max-width: var(--gallery-btn-w-present);
}

.gallery-segment {
  display: inline-flex;
  flex-shrink: 0;
  height: var(--gallery-control-h);
  border-radius: 8px;
}

.gallery-segment__btn {
  appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 0;
  margin-left: -1px;
  padding: 0 14px;
  border: 1px solid #4a4a4a;
  background: #2a2a2a;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}

.gallery-segment__btn:first-child {
  margin-left: 0;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

.gallery-segment__btn:last-child {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

.gallery-segment__btn:hover {
  color: var(--fg);
  background: #333;
  z-index: 1;
}

.gallery-segment__btn--active,
.gallery-segment__btn.is-active {
  color: var(--fg);
  background: #333;
  border-color: var(--primary);
  z-index: 2;
}

.gallery-segment__btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  z-index: 3;
}

/* Present mode: filter row + exit */
.gallery-present-tools {
  display: none;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  margin-left: auto;
}

.gallery-present-exit {
  width: var(--gallery-btn-w-present-exit);
  min-width: var(--gallery-btn-w-present-exit);
  max-width: var(--gallery-btn-w-present-exit);
  padding: 0 12px;
  white-space: nowrap;
}

.gallery-controls--present {
  position: relative;
  flex-wrap: nowrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.gallery-controls--present .gallery-filter-inline {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.gallery-controls--present .gallery-present-tools {
  position: relative;
  z-index: 1;
  display: flex;
  margin-left: auto;
}

.gallery-present-nav {
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

body.gallery-mode-present .gallery-present-nav {
  padding: 0;
  margin: 0;
  border: 0;
}

body.gallery-mode-present .gallery-present-nav .gallery-review-nav {
  padding: 0;
  gap: 12px;
}

body.gallery-mode-present {
  overflow: hidden;
}

body.gallery-mode-present .gallery-header {
  display: none;
}

body.gallery-mode-present .page {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1320px;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  padding: 8px 12px max(28px, calc(12px + env(safe-area-inset-bottom, 0px)));
}

body.gallery-mode-present #galleryMain.stack {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

body.gallery-mode-present #galleryStatus:not(.error):not(.ok):empty {
  display: none;
}

body.gallery-mode-present .gallery-controls {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  box-sizing: border-box;
  width: 100%;
  margin: 0 0 8px;
  padding: 10px 0;
  background: transparent;
}

body.gallery-mode-present .gallery-present-nav {
  display: none;
}

body.gallery-mode-present .gallery-list--detail {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

body.gallery-mode-present .gallery-slide.panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  padding: 8px 12px 16px;
  overflow: hidden;
  border: none;
  background: transparent;
  animation: gallery-present-slide-in 240ms ease-out;
}

body.gallery-mode-present .gallery-slide__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 12px;
  flex-shrink: 0;
  margin-top: 0;
  padding-bottom: 14px;
}

body.gallery-mode-present .gallery-slide__header-lead {
  grid-column: 1;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: initial;
}

body.gallery-mode-present .gallery-slide__nav {
  grid-column: 2;
  justify-self: center;
  min-width: 0;
}

body.gallery-mode-present .gallery-slide__nav .gallery-review-nav {
  gap: 6px;
}

body.gallery-mode-present .gallery-slide__actions {
  grid-column: 3;
  justify-self: end;
  margin-left: 0;
}

body.gallery-mode-present .gallery-slide__header-lead .gallery-slide__user-name,
body.gallery-mode-present .gallery-slide__header-lead .gallery-name-combobox {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}

body.gallery-mode-present .gallery-slide__header-lead .gallery-name-combobox .gallery-slide__user-input {
  width: 100%;
  max-width: none;
}

.gallery-name-combobox {
  position: relative;
  min-width: 0;
}

.gallery-name-combobox__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  margin: 0;
  padding: 4px 0;
  max-height: 220px;
  overflow-y: auto;
  list-style: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.gallery-name-combobox__option {
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
}

.gallery-name-combobox__option:hover,
.gallery-name-combobox__option:focus-visible {
  background: #424242;
  outline: none;
}

body.gallery-mode-present .gallery-slide__actions {
  margin-left: auto;
}

body.gallery-mode-present .gallery-slide__viewport {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

body.gallery-mode-present .gallery-slide__columns {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(300px, 1fr));
  gap: 12px;
  min-height: 0;
  min-width: 920px;
  width: 100%;
  height: 100%;
}

body.gallery-mode-present .gallery-slide__col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  min-width: 0;
  height: 100%;
}

body.gallery-mode-present .gallery-slide__col .gallery-slot {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

body.gallery-mode-present .gallery-slide__col .gallery-slot__label,
body.gallery-mode-present .gallery-slide__col .gallery-slot__filename {
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

body.gallery-mode-present .gallery-slide__col .gallery-slot__filename {
  color: rgba(255, 255, 255, 0.52);
  font-weight: 400;
  word-break: break-all;
}

body.gallery-mode-present .gallery-slide__col .gallery-slot__label {
  color: #fff;
  font-weight: 600;
  padding-bottom: 10px;
}

body.gallery-mode-present .gallery-slide__col .gallery-slot__img-wrap,
body.gallery-mode-present .gallery-slide__col .gallery-slot__empty {
  box-sizing: border-box;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 3 / 4;
  height: auto;
  min-height: 0;
  max-height: none;
}

body.gallery-mode-present .gallery-slide__col .gallery-slot__empty {
  border-width: 1px;
}

body.gallery-mode-present .gallery-slide__col .eval-group {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 0 0 14px 12px;
}

body.gallery-mode-present .gallery-slide__col .eval-group.stack {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  height: 100%;
  align-items: stretch;
}

body.gallery-mode-present .gallery-slide__col .eval-group.stack > .field:not(:has(.why-textarea)) {
  flex: 0 0 auto;
  width: 100%;
}

body.gallery-mode-present .gallery-slide__col .eval-group.stack > .field:has(.why-textarea) {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  width: 100%;
}

body.gallery-mode-present .gallery-slide__col .eval-group .field {
  gap: 6px;
  align-content: start;
}

body.gallery-mode-present .gallery-slide__col .field-label,
body.gallery-mode-present .gallery-slide__col .field-label--compact {
  font-size: 12px;
  line-height: 1.25;
  margin: 0;
  padding: 0;
  overflow: visible;
  white-space: normal;
  word-break: break-word;
}

body.gallery-mode-present .gallery-slide__col .choice-options,
body.gallery-mode-present .gallery-slide__col .choice-options--compact {
  gap: 6px;
  align-items: start;
  grid-auto-rows: min-content;
}

body.gallery-mode-present .gallery-slide__col .choice-option,
body.gallery-mode-present .gallery-slide__col .choice-options--compact .choice-option {
  box-sizing: border-box;
  min-height: 0;
  height: auto;
  padding: 6px 8px;
  border-width: 1px;
  border-radius: 6px;
  align-self: start;
}

body.gallery-mode-present .gallery-slide__col .choice-option input {
  min-height: 0;
  min-width: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  font-size: 0;
}

body.gallery-mode-present .gallery-slide__col .choice-option__emoji {
  font-size: 13px;
}

body.gallery-mode-present .gallery-slide__col .choice-option__text {
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

body.gallery-mode-present .gallery-slide__col .why-textarea,
body.gallery-mode-present .gallery-slide__col .why-textarea--compact {
  flex: 1 1 auto;
  min-height: 48px;
  height: auto;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.35;
  resize: none;
}

.gallery-review-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0;
}

.gallery-review-nav__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  margin: 0;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.gallery-review-nav__btn:hover:not(:disabled) {
  color: var(--fg);
}

.gallery-review-nav__btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.gallery-review-nav__counter {
  min-width: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.gallery-toolbar select {
  min-width: 180px;
}

.gallery-list {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.gallery-list--fill {
  gap: 0;
}

.gallery-fill-wrap {
  overflow: auto;
  scrollbar-gutter: stable;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.gallery-fill-table {
  table-layout: fixed;
  width: 100%;
  min-width: var(--gallery-fill-table-min-w-with-delete);
  border-collapse: collapse;
}

.gallery-page:not(.gallery-page--readonly) .gallery-fill-table {
  min-width: var(--gallery-fill-table-min-w-with-delete);
}

.gallery-fill-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-sizing: border-box;
  height: 36px;
  padding: 0 6px;
  background: #353535;
  font-size: 12px;
  font-weight: 600;
  line-height: 36px;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-fill-table td {
  vertical-align: middle;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-align: center;
}

.gallery-fill-table td.gallery-fill__slot {
  vertical-align: middle;
}

.gallery-fill-table tbody tr:last-child td {
  border-bottom: 0;
}

.gallery-fill__row-tail {
  cursor: pointer;
}

.gallery-fill-table tbody tr.is-row-active td {
  background: rgba(255, 255, 255, 0.045);
}

.gallery-fill__uploaded {
  width: 76px;
  min-width: 76px;
  max-width: 76px;
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-fill__slot {
  width: var(--gallery-fill-slot-col-w);
  min-width: var(--gallery-fill-slot-col-w);
  max-width: var(--gallery-fill-slot-col-w);
}

.gallery-fill-table .gallery-slot--compact .gallery-slot__img-wrap,
.gallery-fill-table .gallery-slot--compact .gallery-slot__empty {
  box-sizing: border-box;
  width: var(--gallery-fill-slot-inner);
  height: var(--gallery-fill-slot-inner);
  max-width: var(--gallery-fill-slot-inner);
  max-height: var(--gallery-fill-slot-inner);
  margin-inline: auto;
  aspect-ratio: 1 / 1;
}

.gallery-fill__user {
  width: 96px;
  min-width: 96px;
  max-width: 96px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-fill__select {
  width: 100%;
  min-width: 108px;
  max-width: 140px;
  font-size: 13px;
}

.gallery-fill__why {
  min-width: 120px;
  max-width: 180px;
}

.gallery-fill__why-input {
  width: 100%;
  min-height: 34px;
  font-size: 12px;
  line-height: 1.35;
  resize: vertical;
}

.gallery-fill__text {
  width: 104px;
  min-width: 104px;
  max-width: 104px;
  line-height: 1.35;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-fill__why-col {
  width: 136px;
  min-width: 136px;
  max-width: 136px;
}

.gallery-fill__actions-col {
  position: sticky;
  right: 0;
  z-index: 1;
  width: var(--gallery-btn-w-delete);
  min-width: var(--gallery-btn-w-delete);
  max-width: var(--gallery-btn-w-delete);
  background: var(--surface);
  box-shadow: -6px 0 10px rgba(0, 0, 0, 0.22);
  vertical-align: middle;
}

.gallery-fill__row-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.gallery-fill__share-btn,
.gallery-fill__delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 2px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  box-sizing: border-box;
  width: var(--gallery-btn-w-delete);
  min-width: var(--gallery-btn-w-delete);
  max-width: var(--gallery-btn-w-delete);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.gallery-fill__share-btn {
  color: var(--primary, #1677ff);
}

.gallery-fill__delete-btn {
  color: #ff4d4f;
}

.gallery-fill-table tbody tr.is-row-active .gallery-fill__share-btn,
.gallery-fill-table tbody tr.is-row-active .gallery-fill__delete-btn {
  opacity: 1;
  pointer-events: auto;
}

.gallery-fill__share-btn:hover {
  color: #4096ff;
  text-decoration: underline;
}

.gallery-fill__delete-btn:hover {
  color: #ff7875;
  text-decoration: underline;
}

.gallery-fill__delete-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  text-decoration: none;
}

body.gallery-layout-fill .gallery-enter-present {
  line-height: 1.2;
}

.gallery-fill-table thead .gallery-fill__actions-col {
  z-index: 4;
  background: #353535;
}

.gallery-fill-table tbody tr.is-row-active td.gallery-fill__actions-col {
  background: #303030;
}

.gallery-page--readonly .gallery-fill__select,
.gallery-page--readonly .gallery-fill__why-input,
.gallery-page--readonly .gallery-fill__user {
  pointer-events: none;
  opacity: 0.92;
}

.gallery-empty {
  padding: 24px;
  text-align: center;
}

.gallery-card {
  min-width: 0;
  gap: 14px;
}

.gallery-card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.gallery-card__no {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.gallery-card__user-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
}

.gallery-card__user-input {
  flex: 1 1 160px;
  min-width: 0;
  max-width: 280px;
}

.gallery-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.gallery-card__photos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.gallery-slot {
  margin: 0;
  min-width: 0;
  display: grid;
  gap: 6px;
}

.gallery-slot__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.gallery-slot__filename {
  display: block;
  min-height: calc(11px * 1.3);
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
  text-align: center;
  word-break: break-all;
}

.gallery-slot__filename--placeholder {
  visibility: hidden;
}

.gallery-slide {
  min-width: 0;
  gap: 12px;
}

.gallery-slide__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.gallery-slide__no {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.gallery-slide__user-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
}

.gallery-slide__user-input {
  flex: 1 1 160px;
  min-width: 0;
  max-width: 280px;
}

.gallery-slide__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.gallery-slide__viewport {
  overflow: hidden;
  width: 100%;
}

.gallery-slide__columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(300px, 1fr));
  gap: 12px;
  min-width: 920px;
}

.gallery-slide__col {
  min-width: 0;
  display: grid;
  gap: 10px;
  align-content: start;
}

.gallery-slot__img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #1e1e1e;
  overflow: hidden;
}

.gallery-slot__img-wrap--peekable {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: grab;
}

.gallery-slot__img-wrap--peekable:active {
  cursor: grabbing;
}

.gallery-slot__img-wrap--peek {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.gallery-slot__img-stack {
  position: relative;
  width: 100%;
  height: 100%;
}

.gallery-slot__img-stack .gallery-slot__img {
  position: absolute;
  inset: 0;
}

.gallery-slot__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.gallery-slot__img--full {
  opacity: 0;
  transition: opacity 320ms ease;
}

.gallery-slot__img--full.is-visible {
  opacity: 1;
}

.gallery-slot__original-loading {
  position: absolute;
  left: 50%;
  bottom: 10px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  transform: translateX(-50%);
  pointer-events: none;
}

.gallery-slot__original-loading__spinner {
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  animation: gallery-original-loading-spin 0.75s linear infinite;
}

@keyframes gallery-original-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes gallery-present-slide-in {
  from {
    opacity: 0.5;
  }

  to {
    opacity: 1;
  }
}

.gallery-slot--compact {
  align-content: start;
}

.gallery-slot--compact .gallery-slot__img-wrap,
.gallery-slot--compact .gallery-slot__empty {
  box-sizing: border-box;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  align-self: start;
  min-height: 0;
}

.gallery-slot--compact .gallery-slot__empty {
  border-width: 1px;
}

.gallery-slot__empty {
  aspect-ratio: 3 / 4;
  border: 2px dashed #666;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  background: var(--surface-2);
}

.gallery-slot__drop {
  transition: border-color 0.15s, background 0.15s;
  cursor: copy;
}

.gallery-slot__drop.is-dragover {
  border-color: var(--primary);
  background: rgba(22, 119, 255, 0.12);
}

.gallery-slot__img-wrap--droppable {
  cursor: copy;
}

.gallery-slot__img-wrap--droppable.is-dragover {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.gallery-slot__drop.is-uploading,
.gallery-slot__img-wrap--uploading {
  opacity: 0.85;
  pointer-events: none;
  cursor: wait;
}

.gallery-slot__upload-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: rgba(0, 0, 0, 0.72);
  color: #f2f2f2;
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
}

.gallery-slot__hover-panel {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 6px;
  background: rgba(0, 0, 0, 0.78);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.gallery-slot__img-wrap--hover-meta:hover .gallery-slot__hover-panel {
  opacity: 1;
  pointer-events: auto;
}

.gallery-slot__hover-meta {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  font-size: 9px;
  line-height: 1.25;
  color: #f2f2f2;
  text-align: center;
}

.gallery-slot__hover-line {
  width: 100%;
  min-width: 0;
}

.gallery-slot__hover-line--device {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 9px;
  font-weight: 600;
}

.gallery-slot__hover-line--time {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 9px;
  font-weight: 500;
  color: rgba(242, 242, 242, 0.92);
}

.gallery-slot__hover-delete {
  flex: 0 0 auto;
  border: 0;
  padding: 0 2px;
  background: transparent;
  color: #ff4d4f;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  box-sizing: border-box;
  width: var(--gallery-btn-w-delete);
  min-width: var(--gallery-btn-w-delete);
  max-width: var(--gallery-btn-w-delete);
  white-space: nowrap;
  text-align: center;
}

.gallery-slot__hover-delete:hover {
  color: #ff7875;
}

.gallery-slot__hover-delete:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.gallery-card__evals {
  min-width: 0;
}

.gallery-card__evals--columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.gallery-card__evals--columns .eval-group + .eval-group {
  margin-top: 0;
  padding-top: 0;
}

.field-label--compact {
  font-size: 12px;
  line-height: 1.3;
}

.field-label {
  color: var(--fg);
  font-size: 14px;
}

.eval-group {
  position: relative;
  min-width: 0;
  padding: 0 0 10px 14px;
}

.eval-group + .eval-group {
  margin-top: 8px;
  padding-top: 10px;
}

.eval-group::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 2px;
  background: var(--eval-accent);
}

.eval-group--orange {
  --eval-accent: #f97316;
}

.eval-group--green {
  --eval-accent: #22c55e;
}

.eval-group--purple {
  --eval-accent: #a855f7;
}

.choice-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.choice-options--count-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 52px;
  padding: 10px 6px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.choice-option__content {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.choice-option__emoji {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

.choice-option__text {
  font-size: 11px;
  line-height: 1.25;
}

.choice-option:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.choice-option input {
  position: absolute;
  min-width: 0;
  min-height: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.choice-options--readonly .choice-option {
  cursor: default;
}

.choice-options--readonly .choice-option:not(:has(input:checked)) {
  opacity: 0.42;
}

.choice-options--compact {
  gap: 4px;
}

.choice-options--compact .choice-option {
  min-height: 36px;
  padding: 6px 4px;
}

.choice-options--compact .choice-option__emoji {
  font-size: 13px;
}

.choice-options--compact .choice-option__text {
  font-size: 10px;
}

.why-textarea--compact {
  min-height: 52px;
}

.why-textarea {
  min-height: 72px;
  font-size: 13px;
  line-height: 1.35;
  resize: vertical;
}

.why-textarea::placeholder {
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-line;
}

.auth-card {
  box-sizing: border-box;
}

.btn-sm {
  padding: 0 12px;
  font-size: 13px;
}

.hint.ok {
  color: #86efac;
}

.hint.error {
  color: #ff9c9c;
}

@media (max-width: 720px) {
  .gallery-controls:not(.gallery-controls--present) {
    flex-direction: column;
    align-items: stretch;
  }

  .gallery-enter-present {
    margin-left: 0;
    align-self: flex-end;
  }

  .gallery-controls--present {
    flex-wrap: wrap;
  }

  .gallery-controls--present .gallery-present-tools {
    margin-left: auto;
  }

  .gallery-filter-inline {
    width: 100%;
  }

  .gallery-controls:not(.gallery-controls--present) .gallery-filter-inline {
    width: 100%;
  }

  .gallery-filter-inline select,
  .gallery-filter-inline__search {
    flex: 1;
    max-width: none;
  }

  .gallery-segment {
    width: 100%;
  }

  .gallery-segment__btn {
    flex: 1;
  }

  .gallery-slide__actions {
    width: 100%;
    margin-left: 0;
  }

  .gallery-slide__user-input {
    max-width: none;
    width: 100%;
  }
}

/* Present eval: must follow base .choice-option / .why-textarea rules above */
body.gallery-mode-present .gallery-slide__col .choice-options--compact .choice-option {
  min-height: 0;
  padding: 6px 8px;
}

body.gallery-mode-present .gallery-slide__col .why-textarea--compact {
  flex: 1 1 auto;
  min-height: 48px;
  resize: none;
}
