/* ============================================================
   ipzom · App-specific styles
   ============================================================
   The shell (header, tabs, sidebar, content) comes from
   ui.mullmania.com. This file only has styles for app-specific
   elements: asset table, thumbnails, pager, edit form.
   ============================================================ */

/* ===== Browse toolbar (inside tab content) ===== */

/* The shared shell locks body scrolling, so this app's content pane must scroll. */
#content-container {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

.browse-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  grid-auto-flow: column;
  gap: var(--space-sm);
  align-items: center;
  padding: var(--space-sm) 0;
}

.mirror-note {
  grid-column: 1 / -1;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: var(--text-xs, 12px);
}

.mirror-note a {
  color: var(--color-primary);
  overflow-wrap: anywhere;
}

.browse-toolbar .browse-shuffle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 2px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-primary);
  color: var(--text-primary);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
}

.browse-toolbar .browse-shuffle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.browse-toolbar .browse-shuffle.is-active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--text-on-primary);
}

.browse-toolbar .browse-field {
  display: inline-grid;
  grid-auto-flow: column;
}

.browse-search {
  width: 100%;
  min-height: 34px;
  padding: 5px var(--space-sm);
  font-size: var(--text-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.browse-search:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }

.browse-field {
  display: grid;
  grid-auto-flow: column;
  gap: 6px;
  align-items: center;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.browse-field select {
  min-height: 30px;
  padding: 2px 8px;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--text-sm);
}

/* ===== Asset table ===== */

.browse-table-container {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md, 10px) var(--radius-md, 10px) 0 0;
  background: var(--bg-primary);
  -webkit-overflow-scrolling: touch;
}

.asset-table { width: 100%; font-size: var(--text-sm); }

.asset-table thead {
  background: var(--bg-primary);
  border-bottom: 2px solid var(--color-primary);
}

.asset-table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-primary);
  white-space: nowrap;
}

.asset-table td {
  padding: var(--space-xs) var(--space-sm);
  vertical-align: middle;
}

.table-empty-cell { padding: var(--space-lg); color: var(--text-secondary); text-align: center; }

.asset-row { cursor: pointer; }

.col-preview { width: 140px; }
.col-tags { width: 180px; }
.col-size { width: 100px; text-align: right; white-space: nowrap; }

.asset-preview-slot { display: flex; align-items: center; }
.asset-preview { vertical-align: middle; }

.asset-cell { display: grid; gap: 2px; min-width: 0; }
.asset-cell__title { font-weight: var(--weight-semibold); color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-cell__file { color: var(--text-muted); font-size: 11px; font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-cell__tags { display: flex; flex-wrap: wrap; gap: 4px; }
.asset-cell__size { color: var(--text-secondary); font-family: var(--font-mono); font-size: 12px; }

.tag-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-secondary); color: var(--text-secondary);
  font-size: 11px; font-weight: var(--weight-semibold); white-space: nowrap;
}
.tag-pill.is-primary { background: var(--color-primary); color: var(--text-on-primary); }

/* ===== Tags tab ===== */

.tags-sidebar {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 260px;
  max-width: 360px;
  padding: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(223, 247, 234, 0.66), rgba(255, 253, 247, 0.88)),
    var(--bg-secondary);
  border-right: 1px solid var(--border-medium);
}

.tags-sidebar__header {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px 8px;
  background: linear-gradient(180deg, var(--bg-secondary), rgba(255, 253, 247, 0.86));
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tag-sidebar-item {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm, 7px);
  background: rgba(255, 255, 255, 0.74);
  color: var(--text-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

.tag-sidebar-item:hover,
.tag-sidebar-item:focus-visible {
  border-color: var(--border-color);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(47, 143, 91, 0.12);
  outline: none;
}

.tag-sidebar-item.active {
  border-color: var(--color-primary);
  background: linear-gradient(135deg, rgba(47, 143, 91, 0.18), rgba(255, 217, 232, 0.34));
  color: var(--color-primary);
}

.tag-sidebar-item__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.tag-sidebar-item__count {
  display: inline-grid;
  min-width: 54px;
  height: 24px;
  place-items: center;
  padding: 0 8px;
  border-radius: var(--radius-pill, 999px);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tag-sidebar-item.active .tag-sidebar-item__count {
  background: var(--color-primary);
  color: var(--text-on-primary);
}

.tags-content {
  min-width: 0;
  background: var(--bg-primary);
}

.tags-content__inner {
  display: grid;
  gap: var(--space-md);
}

.tags-content__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
}

.tags-content__header h2 {
  margin: 0;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: clamp(22px, 2.2vw, 34px);
  line-height: 1.05;
}

.tags-content__header span {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* ===== Text engine tab ===== */

.text-engine-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  min-height: calc(100vh - 220px);
  background: var(--bg-primary);
}

.text-engine-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-width: 0;
  padding: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  border-right: 1px solid var(--border-medium);
  background: var(--bg-secondary);
}

.text-engine-sidebar__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.text-engine-sidebar__header i {
  color: var(--color-primary);
  font-size: 18px;
}

.text-engine-control {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm, 7px);
  background: var(--bg-primary);
}

.text-control-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
}

.text-engine-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.text-engine-button {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-primary);
  color: var(--text-primary);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  text-decoration: none;
}

.text-engine-button:hover,
.text-engine-button:focus-visible {
  border-color: var(--color-primary);
  color: var(--color-primary);
  outline: none;
}

.text-engine-button--small {
  justify-content: center;
  min-height: 32px;
  width: 100%;
  font-size: 12px;
}

.text-icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
}

.text-icon-button:hover,
.text-icon-button:focus-visible {
  border-color: var(--color-primary);
  color: var(--color-primary);
  outline: none;
}

.text-length-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.text-length-options button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-primary);
  color: var(--text-primary);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}

.text-length-options button:hover,
.text-length-options button:focus-visible {
  border-color: var(--color-primary);
  outline: none;
}

.text-length-options button.active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--text-on-primary);
}

.text-seed-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.text-toggle-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm, 7px);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
}

.text-toggle-row input {
  margin-top: 3px;
  accent-color: var(--color-primary);
}

.text-toggle-row span {
  display: grid;
  gap: 2px;
}

.text-toggle-row small {
  color: var(--text-muted);
  line-height: 1.35;
}

.text-endpoint-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 7px);
  background: var(--bg-primary);
}

.text-endpoint-card__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.text-endpoint-card a {
  min-width: 0;
  overflow: hidden;
  color: var(--color-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-endpoint-card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.text-engine-api-notes {
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--border-light);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.text-engine-api-notes code {
  display: block;
  padding: 4px 0;
  color: inherit;
}

.text-engine-content {
  min-width: 0;
  padding: 28px;
  overflow: auto;
}

.text-engine-hero {
  display: grid;
  gap: 8px;
  max-width: 980px;
  margin-bottom: var(--space-lg);
}

.text-engine-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.text-engine-kicker span,
.text-panel-meta {
  display: inline-grid;
  min-height: 24px;
  place-items: center;
  padding: 0 8px;
  border-radius: var(--radius-pill, 999px);
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.text-engine-hero h2 {
  margin: 0;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 36px;
  line-height: 1.1;
}

.text-engine-hero p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.35;
}

.text-output-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: var(--space-md);
  align-items: start;
}

.text-output-panel,
.text-pack-image {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md, 8px);
  background: var(--bg-primary);
}

.text-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.text-panel-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 16px;
}

.text-output-stack {
  display: grid;
  gap: var(--space-sm);
}

.text-field {
  display: grid;
  gap: 6px;
}

.text-field__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.text-copy-btn {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 6px);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.text-copy-btn:hover,
.text-copy-btn:focus-visible {
  border-color: var(--color-primary);
  color: var(--color-primary);
  outline: none;
}

.text-field__body {
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 7px);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.55;
}

.text-field__body.is-multiline {
  white-space: pre-wrap;
}

.text-json-panel pre {
  max-height: 560px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
}

.text-pack-image {
  margin-top: var(--space-md);
}

.text-pack-image[hidden] {
  display: none;
}

.text-pack-card {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: var(--space-md);
  align-items: start;
}

.text-pack-card__media {
  display: block;
  min-width: 0;
}

.text-pack-card__media img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 7px);
  background: var(--bg-secondary);
}

.text-pack-card__body {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.text-pack-card__body strong,
.text-pack-card__body span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.text-pack-card__body > span {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.text-pack-card__tags,
.text-pack-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.text-pack-card__actions a {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 3px 9px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 6px);
  color: var(--text-primary);
  font-size: 12px;
  text-decoration: none;
}

.text-pack-card__actions a:hover,
.text-pack-card__actions a:focus-visible {
  border-color: var(--color-primary);
  color: var(--color-primary);
  outline: none;
}

.text-pack-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.text-loading,
.text-load-error {
  padding: var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 7px);
  background: var(--bg-secondary);
  color: var(--text-muted);
}

/* ===== API docs tab ===== */

.api-docs-shell {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  min-height: calc(100vh - 220px);
  background: var(--bg-primary);
}

.api-docs-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  border-right: 1px solid var(--border-medium);
  background:
    linear-gradient(180deg, rgba(223, 247, 234, 0.68), rgba(255, 253, 247, 0.9)),
    var(--bg-secondary);
}

.api-docs-sidebar__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.api-docs-sidebar__header i {
  color: var(--color-primary);
  font-size: 18px;
}

.api-docs-nav-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm, 7px);
  background: rgba(255, 255, 255, 0.74);
  color: var(--text-primary);
  text-decoration: none;
}

.api-docs-nav-item:hover,
.api-docs-nav-item:focus-visible {
  border-color: var(--border-color);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(47, 143, 91, 0.12);
  outline: none;
}

.api-docs-nav-item.active {
  border-color: var(--color-primary);
  background: linear-gradient(135deg, rgba(47, 143, 91, 0.18), rgba(255, 217, 232, 0.34));
  color: var(--color-primary);
}

.api-docs-nav-item__label {
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-docs-nav-item__meta {
  display: inline-grid;
  min-width: 52px;
  height: 24px;
  place-items: center;
  padding: 0 8px;
  border-radius: var(--radius-pill, 999px);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.api-docs-nav-item.active .api-docs-nav-item__meta {
  background: var(--color-primary);
  color: var(--text-on-primary);
}

.api-docs-content {
  min-width: 0;
  min-height: inherit;
  overflow: hidden;
  background: var(--bg-primary);
}

.api-docs-frame {
  display: block;
  width: 100%;
  min-height: inherit;
  height: calc(100vh - 220px);
  border: 0;
  background: var(--bg-primary);
}

/* ===== Pager ===== */

.table-footer {
  border: 1px solid var(--border-color);
  border-top: 0;
  border-radius: 0 0 var(--radius-md, 10px) var(--radius-md, 10px);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-primary);
}

/* ===== Edit form — extends canon .property-* primitives ===== */

/* Edit form spaces fields with canon's .property-field margin; outer wrapper stays plain block. */
.edit-form .property-field { margin-bottom: var(--space-md); }
.edit-form .property-field:last-of-type { margin-bottom: 0; }

/* Canon's .property-input only styles input[type=text|number]; extend to selects so dropdowns match. */
.property-input select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: inherit;
}

.edit-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.edit-tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-color); background: var(--bg-secondary); color: var(--text-primary); font-size: 12px; font-weight: var(--weight-semibold); }
.edit-tag button { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; padding: 0; line-height: 1; }
.edit-tag.is-primary { background: var(--color-primary); color: var(--text-on-primary); border-color: var(--color-primary); }
.edit-tag.is-primary button { color: var(--text-on-primary); }

.edit-actions { display: grid; grid-auto-flow: column; grid-auto-columns: max-content; gap: var(--space-sm); }
.edit-actions button { display: grid; grid-auto-flow: column; grid-auto-columns: max-content; gap: 6px; place-items: center; height: 34px; padding: 0 14px; border-radius: var(--radius-sm, 6px); border: 1px solid var(--border-color); background: var(--bg-primary); color: var(--text-primary); font-size: var(--text-sm); font-weight: var(--weight-semibold); cursor: pointer; }
.edit-actions button:hover { background: var(--bg-hover, rgba(0, 0, 0, 0.04)); }
.edit-actions .btn-primary { background: var(--color-primary); color: var(--text-on-primary); border-color: var(--color-primary); }

.edit-raw { max-height: 240px; overflow: auto; padding: var(--space-sm); border: 1px solid var(--border-color); border-radius: var(--radius-sm, 6px); background: var(--bg-secondary); font-family: var(--font-mono); font-size: 11px; white-space: pre; color: var(--text-primary); }

.edit-history { display: grid; gap: 6px; }
.edit-history__item { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 8px 10px; border: 1px solid var(--border-color); border-radius: var(--radius-sm, 6px); background: var(--bg-secondary); font-size: 12px; }
.edit-history__item time { color: var(--text-muted); display: block; }
.edit-history__preview { font-family: var(--font-mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Viewer modal — extends canon .surface-modal scaffold ===== */

.viewer-shell {
  z-index: 5000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
.viewer-shell.active { opacity: 1; pointer-events: auto; }
.viewer-shell .surface-modal__backdrop { backdrop-filter: blur(8px); }

.viewer-modal__panel {
  --surface-modal-max-width: 1280px;
  --surface-modal-max-height: min(92vh, 980px);
  grid-template-rows: auto minmax(0, 1fr);
}

.viewer-modal__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-modal__header-meta {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
}

.viewer-modal__body {
  min-height: 0;
  overflow: auto;
  padding: 0 var(--space-lg) var(--space-lg);
}

.viewer-modal__content { display: grid; gap: var(--space-md); }

.viewer-modal__media {
  min-height: min(58vh, 760px);
  display: grid;
  place-items: center;
  padding: clamp(12px, 2vw, 18px);
  border-radius: 20px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.12), transparent 48%),
    linear-gradient(180deg, #111c2d, #0b1420);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.viewer-modal__image {
  display: block;
  max-width: 100%;
  max-height: min(72vh, 860px);
  object-fit: contain;
  border-radius: var(--radius-md, 16px);
  background: white;
  box-shadow: 0 28px 60px rgba(2, 6, 23, 0.35);
}

.viewer-modal__audio { width: min(640px, 100%); }

.viewer-modal__meta { display: grid; gap: 6px; padding: 4px 4px 0; }
.viewer-modal__meta-title { color: var(--text-primary); font-size: clamp(18px, 1.6vw, 22px); }
.viewer-modal__meta-dimensions,
.viewer-modal__meta-id { color: var(--text-secondary); }
.viewer-modal__meta-id { font-family: var(--font-mono); font-size: 12px; overflow-wrap: anywhere; }

.viewer-modal__links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}
.viewer-modal__links a {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: 6px;
  align-items: center;
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}
.viewer-modal__links a:hover,
.viewer-modal__links a:focus-visible { text-decoration: underline; }

.viewer-unavailable {
  display: grid;
  gap: 8px;
  padding: var(--space-lg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md, 10px);
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.viewer-unavailable strong,
.viewer-unavailable p { margin: 0; }
.viewer-unavailable p { color: var(--text-secondary); }

/* ===== Tabs container minimum height ===== */

#tabs-container { min-height: 47px; align-content: stretch; overflow-y: hidden; }
#tabs-container .tab { align-self: stretch; }

/* ===== Size column: subtle on desktop, hidden on mobile ===== */

.col-size, .cell-size { color: var(--text-muted); }

.cell-size {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  justify-content: space-between;
  white-space: nowrap;
}

.asset-copy-url {
  appearance: none;
  border: 1px solid var(--border-medium);
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
  opacity: 0.55;
}

.asset-row:hover .asset-copy-url,
.asset-copy-url:focus-visible {
  opacity: 1;
  color: var(--text-primary);
  border-color: var(--color-primary);
  outline: none;
}

.asset-copy-url.is-ok {
  color: var(--color-success, #2ea043);
  border-color: currentColor;
  opacity: 1;
}

.asset-copy-url.is-err {
  color: var(--color-danger, #d1495b);
  border-color: currentColor;
  opacity: 1;
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
  .text-engine-shell {
    grid-template-columns: 1fr;
  }

  .text-engine-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border-medium);
  }

  .text-engine-api-notes {
    margin-top: 0;
  }

  .text-engine-content {
    padding: var(--space-md);
  }

  .text-engine-hero h2 {
    font-size: 28px;
  }

  .text-output-layout,
  .text-pack-card {
    grid-template-columns: 1fr;
  }

  .text-panel-header,
  .text-field__header {
    align-items: flex-start;
  }

  .text-panel-header {
    flex-direction: column;
  }

  .api-docs-shell {
    grid-template-columns: 1fr;
  }

  .api-docs-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border-medium);
  }

  .api-docs-content,
  .api-docs-frame {
    min-height: 720px;
    height: 720px;
  }

  .browse-toolbar { grid-template-columns: 1fr 1fr; }
  .browse-toolbar .browse-search { grid-column: 1 / -1; }
  .pager { grid-template-columns: 1fr; gap: var(--space-sm); }
  /* Hide Tags (col 3) and Size (col 4) on mobile */
  .col-size, .col-tags { display: none; }
  .asset-table td:nth-child(3),
  .asset-table td:nth-child(4),
  .asset-table th:nth-child(3),
  .asset-table th:nth-child(4) { display: none; }

  .viewer-modal__panel { --surface-modal-max-height: 96vh; }
  .viewer-modal__panel .surface-modal__header { grid-template-columns: 1fr; }
  .viewer-modal__panel .surface-modal__actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-flow: row;
  }
  .viewer-modal__panel .surface-modal__actions .btn-secondary {
    justify-content: center;
    width: 100%;
  }
  .viewer-modal__title { white-space: normal; }
  .viewer-modal__body { padding: 0 var(--space-md) var(--space-md); }
  .viewer-modal__media { min-height: 36vh; padding: 10px; }
}

/* ===== Slideshow tab (canon UI.Screensaver host) ===== */

.slideshow-tab-shell {
  position: relative;
  width: 100%;
  min-height: var(--slideshow-viewport-height, calc(100dvh - 220px));
  height: var(--slideshow-viewport-height, calc(100dvh - 220px));
  border-radius: 0;
  overflow: hidden;
  background: #05070b;
}

.slideshow-tab-shell.screensaver-shell {
  min-height: var(--slideshow-viewport-height, calc(100dvh - 220px));
  height: var(--slideshow-viewport-height, calc(100dvh - 220px));
}

.slideshow-tab-shell .screensaver-stage {
  min-height: 100%;
  height: 100%;
}

.slideshow-tab-shell .screensaver-stage__media {
  object-fit: contain;
  background: #05070b;
  animation: none;
  transform: none;
}

.slideshow-tab-shell .screensaver-stage__layer {
  background: #05070b;
  will-change: opacity;
}

.slideshow-tab-shell .screensaver-stage__title {
  max-width: min(860px, 86vw);
  font-size: clamp(28px, 5vw, 74px);
}

/* Kiosk auto-hide: when the canon controller mirrors `is-chrome-hidden` up to
   <body>, fade out the page header and tabs so a `#slideshow` URL becomes a
   true immersive zombie slideshow. Any pointer/keyboard input restores them. */
body.is-screensaver-chrome-hidden .header,
body.is-screensaver-chrome-hidden .tabs {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 280ms ease, transform 280ms ease;
}

body.is-screensaver-chrome-hidden #content-container {
  /* Let the slideshow stretch into the space the header/tabs vacated */
  padding-top: 0;
}

body.is-screensaver-chrome-hidden .slideshow-tab-shell {
  position: fixed;
  inset: 0;
  z-index: 3000;
  width: 100vw;
  min-height: 100dvh;
  height: 100dvh;
}
