/* img2threejs — tactile dark product UI, with no external font dependency. */
:root {
  color-scheme: dark;
  --bg: #0e1015;
  --bg-deep: #090b0f;
  --surface: #171a21;
  --surface-raised: #1d2028;
  --surface-soft: #222630;
  --line: #2c313c;
  --line-strong: #3b424f;
  --text: #f0f1f4;
  --muted: #a5abb7;
  --faint: #747c89;
  --accent: #f0a443;
  --accent-bright: #ffc167;
  --accent-ink: #1d1205;
  --success: #69d19b;
  --error: #ff7d7d;
  --warning: #f2c25f;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  --max-width: 1240px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg-deep);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -10%, rgba(240, 164, 67, 0.11), transparent 30rem),
    radial-gradient(circle at 95% 18%, rgba(81, 104, 156, 0.09), transparent 32rem),
    var(--bg);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent-bright);
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}

button:disabled,
.is-disabled {
  cursor: not-allowed !important;
  opacity: 0.48;
}

a.is-disabled {
  pointer-events: none;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.6rem 0.85rem;
  transform: translateY(-160%);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 750;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

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

/* Header */

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 1.25rem;
  padding: 0.8rem max(1.25rem, calc((100vw - var(--max-width)) / 2));
  border-bottom: 1px solid rgba(59, 66, 79, 0.68);
  background: rgba(14, 16, 21, 0.88);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(18px);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  flex: none;
  filter: drop-shadow(0 8px 16px rgba(240, 164, 67, 0.2));
}

.brand span {
  min-width: 0;
  display: grid;
  line-height: 1.15;
}

.brand strong {
  font-size: 1.02rem;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 0.22rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.28rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(23, 26, 33, 0.82);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.46rem 0.82rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.is-active {
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--text);
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(105, 209, 155, 0.12);
}

.badge,
.status-pill {
  width: max-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge {
  justify-self: end;
  padding: 0.35rem 0.7rem;
}

.badge-unknown,
.status-neutral {
  color: var(--muted);
  background: rgba(165, 171, 183, 0.08);
}

.badge-ok,
.status-success {
  border-color: rgba(105, 209, 155, 0.48);
  background: rgba(105, 209, 155, 0.1);
  color: var(--success);
}

.badge-bad,
.status-error {
  border-color: rgba(255, 125, 125, 0.48);
  background: rgba(255, 125, 125, 0.1);
  color: var(--error);
}

.status-working {
  border-color: rgba(240, 164, 67, 0.5);
  background: rgba(240, 164, 67, 0.11);
  color: var(--accent-bright);
}

.status-warning {
  border-color: rgba(242, 194, 95, 0.46);
  background: rgba(242, 194, 95, 0.1);
  color: var(--warning);
}

/* Shared layout */

main {
  width: min(var(--max-width), 100%);
  flex: 1;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2.3rem) clamp(1rem, 3vw, 1.5rem) 3rem;
}

.panel {
  position: relative;
  overflow: hidden;
  padding: clamp(1.15rem, 3.3vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.018), transparent 35%),
    var(--surface);
  box-shadow: var(--shadow);
}

.panel::before {
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
  content: "";
  pointer-events: none;
}

.panel-heading,
.result-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.65rem;
}

.panel-heading > div:first-child,
.result-topline > div:first-child {
  max-width: 780px;
}

.panel-heading.compact {
  margin-bottom: 1.4rem;
}

.panel h1,
.dialog-shell h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.55rem);
  line-height: 1.06;
  letter-spacing: -0.045em;
}

.panel-heading p:not(.eyebrow),
.result-sub,
.detail-heading p,
.detail-rail > p {
  max-width: 740px;
  margin: 0.72rem 0 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent-bright);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.step-chip {
  flex: none;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--faint);
  font: 700 0.7rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.05em;
}

.primary,
.secondary,
.quiet-button,
.button,
.overlay-action {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 150ms ease;
}

.primary:hover,
.secondary:hover,
.quiet-button:hover,
.button:hover,
.overlay-action:hover {
  border-color: rgba(240, 164, 67, 0.78);
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

.primary:not(:disabled):hover {
  border-color: var(--accent-bright);
  background: var(--accent-bright);
  transform: translateY(-1px);
}

.secondary,
.quiet-button,
.overlay-action {
  padding: 0.65rem 0.85rem;
  font-weight: 650;
}

.quiet-button {
  background: transparent;
}

.inline-button {
  width: auto;
}

.compact-button {
  flex: none;
  padding-inline: 0.9rem;
}

/* Upload */

.dropzone {
  position: relative;
  min-height: 240px;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 2.4rem 1rem;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    rgba(9, 11, 15, 0.44);
  background-size: 28px 28px;
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.dropzone::after {
  position: absolute;
  width: 260px;
  height: 180px;
  border-radius: 50%;
  background: rgba(240, 164, 67, 0.08);
  filter: blur(60px);
  content: "";
  pointer-events: none;
}

.dropzone:hover,
.dropzone.drag {
  border-color: var(--accent);
  background-color: rgba(240, 164, 67, 0.025);
  transform: translateY(-1px);
}

.upload-mark {
  position: relative;
  z-index: 1;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin-bottom: 0.85rem;
  border: 1px solid rgba(240, 164, 67, 0.45);
  border-radius: 50%;
  background: rgba(240, 164, 67, 0.11);
  color: var(--accent-bright);
  font-size: 1.3rem;
}

.drop-title,
.drop-sub {
  position: relative;
  z-index: 1;
}

.drop-title {
  margin: 0;
  font-size: 1.03rem;
  font-weight: 760;
}

.drop-sub {
  margin: 0.38rem 0 0;
  color: var(--muted);
  font-size: 0.83rem;
}

.share-control {
  margin-top: 0.85rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(34, 38, 48, 0.6);
}

.switch-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.85rem;
  cursor: pointer;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  width: 42px;
  height: 24px;
  display: block;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-deep);
  transition: background 160ms ease, border-color 160ms ease;
}

.switch span {
  width: 16px;
  height: 16px;
  display: block;
  border-radius: 50%;
  background: var(--faint);
  transition: transform 160ms ease, background 160ms ease;
}

.switch-row input:checked + .switch {
  border-color: var(--success);
  background: rgba(105, 209, 155, 0.18);
}

.switch-row input:checked + .switch span {
  transform: translateX(18px);
  background: var(--success);
}

.switch-row input:focus-visible + .switch {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}

.switch-copy {
  display: grid;
  line-height: 1.35;
}

.switch-copy strong {
  font-size: 0.88rem;
}

.switch-copy small {
  margin-top: 0.24rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.preview-row {
  display: grid;
  grid-template-columns: minmax(180px, 300px) 1fr;
  gap: clamp(1rem, 3vw, 1.8rem);
  margin-top: 1.2rem;
  padding: clamp(0.8rem, 2vw, 1.15rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.preview-image-wrap {
  position: relative;
  min-height: 210px;
  overflow: hidden;
  border-radius: 10px;
  background:
    linear-gradient(45deg, #151820 25%, transparent 25%),
    linear-gradient(-45deg, #151820 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #151820 75%),
    linear-gradient(-45deg, transparent 75%, #151820 75%),
    #111319;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.preview-image-wrap img {
  width: 100%;
  height: 100%;
  max-height: 310px;
  display: block;
  object-fit: contain;
}

.reference-label {
  position: absolute;
  bottom: 0.55rem;
  left: 0.55rem;
  padding: 0.26rem 0.48rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: rgba(9, 11, 15, 0.76);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.preview-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.82rem;
}

.preview-name {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.82rem;
}

.palette {
  min-height: 24px;
  display: flex;
  gap: 5px;
  margin-top: 0.5rem;
}

.swatch {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.hint-label {
  display: grid;
  font-size: 0.84rem;
  font-weight: 680;
}

.hint-label span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 450;
}

#hint {
  width: 100%;
  padding: 0.7rem 0.78rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #12151b;
  color: var(--text);
}

#hint::placeholder {
  color: var(--faint);
}

.honesty-note {
  margin: 1.1rem 0 0;
  padding: 0.9rem 1rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.honesty-note strong {
  color: var(--text);
}

/* Progress */

.progress-panel .status-pill {
  padding: 0.42rem 0.72rem;
}

.progress-facts {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(260px, 2fr) minmax(130px, 0.8fr) minmax(120px, 0.7fr);
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.fact-card {
  min-width: 0;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.78rem 0.86rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(29, 32, 40, 0.76);
}

.fact-card > span {
  color: var(--faint);
  font-size: 0.65rem;
  font-weight: 780;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fact-card strong {
  margin: 0.2rem 0;
  overflow: hidden;
  font-size: 0.93rem;
  line-height: 1.3;
  text-overflow: ellipsis;
}

.fact-card:first-child strong {
  color: var(--accent-bright);
  font: 760 1.45rem/1.1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.fact-card small {
  color: var(--faint);
  font-size: 0.68rem;
}

.stages {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  list-style: none;
}

.stage {
  min-height: 66px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(80px, 0.7fr);
  align-items: center;
  gap: 0.85rem;
  padding: 0.72rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 19, 25, 0.42);
}

.stage:last-child {
  border-bottom: 0;
}

.stage-dot {
  width: 10px;
  height: 10px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
}

.stage-copy {
  min-width: 0;
  display: grid;
}

.stage-name {
  font-size: 0.86rem;
}

.stage-description,
.stage-note {
  color: var(--faint);
  font-size: 0.69rem;
}

.stage-note {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
}

.stage-pending .stage-copy {
  opacity: 0.62;
}

.stage-active {
  background: linear-gradient(90deg, rgba(240, 164, 67, 0.085), transparent 55%);
}

.stage-active .stage-dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(240, 164, 67, 0.12);
  animation: pulse 1.25s ease-in-out infinite;
}

.stage-done .stage-dot {
  border-color: var(--success);
  background: var(--success);
}

.stage-done .stage-note {
  color: var(--success);
}

.stage-failed .stage-dot {
  border-color: var(--error);
  background: var(--error);
}

.stage-failed .stage-note {
  color: var(--error);
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 9px rgba(240, 164, 67, 0.02); }
}

.log-drawer {
  margin-top: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #0d0f14;
}

.log-drawer summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.85rem;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 650;
}

.log-drawer summary small {
  color: var(--faint);
  font-weight: 450;
}

.log {
  max-height: 280px;
  margin: 0;
  padding: 0.8rem;
  overflow: auto;
  border-top: 1px solid var(--line);
  color: #bac1cd;
  font: 11px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Result and viewers */

.result-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.result-actions .status-pill {
  padding: 0.4rem 0.65rem;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.78fr);
  gap: 1.2rem;
}

.viewer-column,
.detail-grid > div {
  min-width: 0;
}

.viewer-frame-wrap {
  position: relative;
  min-height: 380px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 50% 45%, #242832, #0e1015 68%),
    var(--bg-deep);
  aspect-ratio: 4 / 3;
}

.viewer-frame-wrap iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

.viewer-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(10, 12, 16, 0.88);
  color: var(--muted);
  text-align: center;
  backdrop-filter: blur(7px);
}

.viewer-overlay > div {
  max-width: 520px;
}

.viewer-overlay p {
  margin: 0.7rem 0 0;
}

.viewer-overlay.is-error {
  color: var(--text);
}

.viewer-overlay.is-error .spinner {
  display: none;
}

.overlay-action {
  margin-top: 0.9rem;
}

.spinner {
  width: 28px;
  height: 28px;
  display: inline-block;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.viewer-toolbar {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(17, 19, 25, 0.78);
}

.viewer-toolbar button {
  padding: 0.38rem 0.62rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
}

.viewer-toolbar button:not(:disabled):hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.viewer-toolbar button[aria-pressed="true"] {
  border-color: rgba(240, 164, 67, 0.45);
  background: rgba(240, 164, 67, 0.1);
  color: var(--accent-bright);
}

.viewer-toolbar > span {
  margin-left: auto;
  padding-right: 0.4rem;
  color: var(--faint);
  font-size: 0.68rem;
}

.viewer-toolbar > span.is-error {
  color: var(--error);
}

.viewer-caption {
  min-height: 28px;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0.25rem 0;
  color: var(--faint);
  font-size: 0.69rem;
}

.viewer-caption span:last-child {
  text-align: right;
}

.result-rail {
  display: flex;
  flex-direction: column;
}

.rail-section,
.honesty-box,
.warnings-box {
  padding: 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.rail-section h2,
.honesty-box h2,
.detail-rail h2 {
  margin: 0;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
}

.rail-section > p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.downloads {
  display: grid;
  gap: 0.42rem;
  margin-top: 0.85rem;
}

.download-button,
.detail-downloads .button {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.58rem 0.72rem;
  text-align: left;
}

.download-button > span {
  display: grid;
}

.download-button strong {
  font-size: 0.78rem;
}

.download-button small {
  color: var(--faint);
  font-size: 0.65rem;
}

.download-button b,
.detail-downloads b {
  color: var(--accent-bright);
  font: 750 0.68rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.download-button.is-busy {
  border-color: var(--accent);
}

.is-success {
  color: var(--success) !important;
}

.is-error {
  color: var(--error) !important;
}

.publication-warning,
.warnings-box,
.honesty-box {
  margin-top: 0.65rem;
  font-size: 0.74rem;
}

.publication-warning {
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(242, 194, 95, 0.42);
  border-radius: var(--radius-md);
  background: rgba(242, 194, 95, 0.07);
}

.publication-warning strong {
  color: var(--warning);
}

.publication-warning p {
  margin: 0.28rem 0 0;
  color: var(--muted);
}

.warnings-box summary {
  color: var(--warning);
  cursor: pointer;
  font-weight: 720;
}

.warnings-box ul,
.honesty-box ul {
  margin: 0.55rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.warnings-box li + li,
.honesty-box li + li {
  margin-top: 0.35rem;
}

.result-rail > .secondary {
  width: 100%;
  margin-top: 0.65rem;
}

/* Gallery */

.gallery-panel {
  min-height: 620px;
}

.gallery-disclosure {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(240, 164, 67, 0.24);
  border-radius: var(--radius-md);
  background: rgba(240, 164, 67, 0.055);
}

.gallery-disclosure > span {
  color: var(--accent-bright);
  font-size: 1.08rem;
}

.gallery-disclosure p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.gallery-disclosure strong {
  color: var(--text);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

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

.gallery-card-button {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: border-color 170ms ease, transform 170ms ease, box-shadow 170ms ease;
}

.gallery-card-button:hover {
  border-color: rgba(240, 164, 67, 0.55);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.24);
  transform: translateY(-3px);
}

.gallery-card-visual {
  position: relative;
  grid-column: 1 / -1;
  height: 190px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 45% 40%, #303642, #12151b 72%);
}

.gallery-card-visual::after {
  position: absolute;
  inset: auto 0 0;
  height: 40%;
  background: linear-gradient(transparent, rgba(9, 11, 15, 0.64));
  content: "";
  pointer-events: none;
}

.gallery-card-visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 250ms ease;
}

.gallery-card-button:hover .gallery-card-visual img {
  transform: scale(1.025);
}

.gallery-card-fallback {
  color: rgba(240, 164, 67, 0.65);
  font-size: 3.2rem;
  font-weight: 820;
  letter-spacing: -0.08em;
}

.gallery-card-badge {
  position: absolute;
  z-index: 1;
  right: 0.55rem;
  bottom: 0.55rem;
  padding: 0.25rem 0.45rem;
  border: 1px solid rgba(105, 209, 155, 0.42);
  border-radius: 999px;
  background: rgba(9, 11, 15, 0.76);
  color: var(--success);
  font-size: 0.62rem;
  font-weight: 750;
  backdrop-filter: blur(7px);
}

.gallery-card-body {
  min-width: 0;
  display: grid;
  padding: 0.75rem 0.2rem 0.78rem 0.8rem;
}

.gallery-card-body strong,
.gallery-card-body small,
.gallery-card-body > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card-body strong {
  font-size: 0.86rem;
}

.gallery-card-body small,
.gallery-card-body > span {
  color: var(--faint);
  font-size: 0.66rem;
}

.gallery-card-body small {
  margin-top: 0.18rem;
  color: var(--muted);
}

.gallery-card-arrow {
  align-self: center;
  padding: 0.8rem;
  color: var(--accent-bright);
}

.gallery-more {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.gallery-loading {
  height: 350px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.gallery-loading span {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(105deg, transparent 25%, rgba(255, 255, 255, 0.035) 40%, transparent 55%),
    var(--surface-raised);
  background-size: 250% 100%;
  animation: shimmer 1.5s linear infinite;
}

@keyframes shimmer {
  to { background-position: -250% 0; }
}

.inline-state {
  min-height: 105px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.inline-state strong {
  font-size: 0.88rem;
}

.inline-state p {
  margin: 0.22rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.inline-error {
  margin-bottom: 1rem;
  border-color: rgba(255, 125, 125, 0.44);
  background: rgba(255, 125, 125, 0.055);
}

.gallery-empty {
  min-height: 220px;
}

.gallery-empty > span {
  flex: none;
  color: var(--accent);
  font-size: 2.5rem;
}

/* Gallery detail */

.gallery-dialog {
  width: min(1180px, calc(100vw - 2rem));
  max-width: none;
  max-height: calc(100vh - 2rem);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.68);
}

.gallery-dialog::backdrop {
  background: rgba(5, 6, 8, 0.78);
  backdrop-filter: blur(10px);
}

.dialog-shell {
  position: relative;
  min-height: 340px;
  padding: clamp(1.1rem, 3vw, 2rem);
}

.dialog-close {
  position: sticky;
  z-index: 3;
  top: 0.65rem;
  float: right;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(29, 32, 40, 0.92);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  backdrop-filter: blur(8px);
}

.dialog-close:hover {
  border-color: var(--accent);
  color: var(--text);
}

.detail-loading {
  min-height: 300px;
  display: grid;
  align-content: center;
  justify-items: center;
  color: var(--muted);
}

.detail-heading {
  min-height: 92px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 3rem 1.2rem 0;
}

.detail-heading h1 {
  overflow-wrap: anywhere;
}

.detail-heading p:not(.eyebrow) {
  color: var(--muted);
  font-size: 0.76rem;
}

.detail-heading img {
  width: 120px;
  height: 82px;
  flex: none;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-deep);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(260px, 0.65fr);
  gap: 1.1rem;
}

.gallery-viewer-wrap {
  min-height: 360px;
}

.detail-rail {
  padding: 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.detail-rail > p {
  font-size: 0.72rem;
}

.detail-downloads .button {
  min-height: 44px;
  font-size: 0.75rem;
}

.action-status {
  min-height: 1.2rem;
  margin: 0.55rem 0 0 !important;
  color: var(--faint) !important;
  font-size: 0.67rem !important;
}

.detail-honesty {
  margin-top: 0.8rem !important;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

/* Errors and footer */

.panel-error {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  border-color: rgba(255, 125, 125, 0.48);
}

.error-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 125, 125, 0.5);
  border-radius: 50%;
  background: rgba(255, 125, 125, 0.1);
  color: var(--error);
  font-size: 1.25rem;
  font-weight: 800;
}

.panel-error h1 {
  color: var(--error);
}

#error-message {
  max-width: 820px;
  color: var(--muted);
}

.error-detail {
  max-height: 320px;
  padding: 0.8rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  color: #c4cad4;
  font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.site-footer {
  padding: 1rem;
  border-top: 1px solid rgba(44, 49, 60, 0.72);
  color: var(--faint);
  font-size: 0.7rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--muted);
  text-underline-offset: 3px;
}

.site-footer a:hover {
  color: var(--accent-bright);
}

/* Responsive */

@media (max-width: 980px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .site-nav {
    grid-row: 2;
    grid-column: 1 / -1;
    justify-self: center;
    order: 3;
  }

  .badge {
    grid-column: 2;
  }

  .progress-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .site-header {
    position: relative;
    min-height: auto;
    gap: 0.65rem;
    padding: 0.72rem 0.85rem;
  }

  .brand small {
    display: none;
  }

  .badge {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .site-nav {
    width: 100%;
  }

  .nav-link {
    flex: 1;
    justify-content: center;
  }

  main {
    padding: 0.8rem 0.65rem 2rem;
  }

  .panel {
    padding: 1rem;
    border-radius: 16px;
  }

  .panel-heading,
  .result-topline {
    display: block;
    margin-bottom: 1.1rem;
  }

  .step-chip {
    display: none;
  }

  .panel-heading > .quiet-button {
    margin-top: 0.85rem;
  }

  .result-actions {
    margin-top: 0.8rem;
  }

  .dropzone {
    min-height: 205px;
    padding: 1.5rem 0.8rem;
  }

  .drop-sub {
    max-width: 300px;
  }

  .preview-row {
    grid-template-columns: 1fr;
  }

  .preview-image-wrap {
    min-height: 190px;
  }

  .progress-facts {
    grid-template-columns: 1fr 1fr;
  }

  .fact-wide {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .stage {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .stage-note {
    grid-column: 2;
    text-align: left;
    white-space: normal;
  }

  .viewer-frame-wrap,
  .gallery-viewer-wrap {
    min-height: 300px;
    aspect-ratio: 1 / 1;
  }

  .viewer-toolbar {
    flex-wrap: wrap;
  }

  .viewer-toolbar > span {
    width: 100%;
    margin: 0;
    padding: 0.15rem 0.4rem;
  }

  .viewer-caption {
    display: grid;
    gap: 0.18rem;
  }

  .viewer-caption span:last-child {
    text-align: left;
  }

  .gallery-grid,
  .gallery-loading {
    grid-template-columns: 1fr;
  }

  .gallery-loading {
    height: 700px;
  }

  .gallery-card-visual {
    height: 220px;
  }

  .inline-state {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .gallery-dialog {
    width: calc(100vw - 0.6rem);
    max-height: calc(100vh - 0.6rem);
    border-radius: 15px;
  }

  .dialog-shell {
    padding: 0.85rem;
  }

  .detail-heading {
    min-height: 0;
    display: block;
    margin-right: 2.5rem;
  }

  .detail-heading img {
    width: 100%;
    height: 140px;
    margin-top: 0.75rem;
  }

  .dialog-close {
    top: 0.35rem;
  }

  .panel-error {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .brand strong {
    font-size: 0.9rem;
  }

  .badge {
    font-size: 0.66rem;
  }

  .nav-link {
    padding-inline: 0.45rem;
    font-size: 0.75rem;
  }

  .progress-facts {
    grid-template-columns: 1fr;
  }

  .fact-wide {
    grid-column: auto;
  }

  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
