:root {
  color-scheme: light;
  --bg: #f7f2f3;
  --paper: #fffbfc;
  --ink: #44383e;
  --muted: #74616b;
  --line: #e5d9de;
  --primary: #925e73;
  --accent: #a5677e;
  --error: #a33831;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}
button,
input {
  font: inherit;
}
button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: wait;
  opacity: 0.58;
}
a {
  color: inherit;
  text-decoration: none;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid #925e73;
  outline-offset: 4px;
}
button {
  border: 0;
}
svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}
.hidden {
  display: none !important;
}
.header {
  max-width: 1304px;
  margin: auto;
  height: 100px;
  padding: 0 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  font-size: 25px;
  font-weight: 650;
  letter-spacing: 3px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  background: var(--primary);
  color: var(--bg);
  font:
    30px Georgia,
    serif;
  border-radius: 12px;
}
.brand-sub {
  font-size: 14px;
  letter-spacing: 1px;
  font-weight: 400;
  margin-left: 10px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}
.connection {
  font-size: 12px;
  color: var(--muted);
}
.connection:before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #aa7b8e;
  border-radius: 50%;
  margin-right: 7px;
}
.text-button {
  min-width: 44px;
  min-height: 44px;
  background: none;
  color: var(--muted);
  padding: 12px 0;
  font-size: 13px;
}
main {
  max-width: 1208px;
  margin: auto;
  padding: 0 32px;
  min-height: calc(100vh - 190px);
}
.tabs {
  display: flex;
  gap: 30px;
  margin: 24px 0 0;
  border-bottom: 1px solid var(--line);
}
.tab {
  padding: 16px 2px;
  background: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-size: 14px;
}
.tab.active {
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
}
.intro {
  min-height: 375px;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  align-items: center;
  gap: 40px;
  padding: 32px 0;
}
.eyebrow,
.small-number {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  font-weight: 600;
}
.small-number {
  letter-spacing: 1.2px;
}
h1 {
  font-size: clamp(31px, 3.6vw, 49px);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 1px;
  margin: 18px 0 20px;
}
h1 em {
  font-style: normal;
  color: var(--accent);
}
.lead {
  font-size: 14px;
  line-height: 1.9;
  color: var(--muted);
  margin: 0;
}
.fabric-art {
  height: 300px;
  position: relative;
  overflow: hidden;
  background: #eedfe5;
  border-radius: 48% 48% 8px 8px;
}
.fabric-piece {
  position: absolute;
  width: 40%;
  height: 350px;
  top: 5px;
  border-radius: 40px 40px 0 0;
  box-shadow: 9px 5px 16px #44383e25;
  background-size: 40px 40px;
}
.piece-one {
  left: 4%;
  transform: rotate(-13deg);
  background-color: #cbbbc2;
  background-image:
    radial-gradient(
      ellipse at 50% 0,
      transparent 10px,
      #f1e6ea 11px,
      #f1e6ea 14px,
      transparent 15px
    ),
    radial-gradient(
      ellipse at 50% 100%,
      transparent 10px,
      #f1e6ea 11px,
      #f1e6ea 14px,
      transparent 15px
    );
}
.piece-two {
  left: 31%;
  transform: rotate(2deg);
  background-color: #b68f9f;
  background-image:
    radial-gradient(
      ellipse at 0 0,
      transparent 10px,
      #ead7df 11px,
      #ead7df 12px,
      transparent 13px
    ),
    radial-gradient(
      ellipse at 100% 100%,
      transparent 10px,
      #ead7df 11px,
      #ead7df 12px,
      transparent 13px
    );
}
.piece-three {
  left: 66%;
  top: 38px;
  transform: rotate(13deg);
  background-color: #d1aeb7;
  background-image: radial-gradient(
    ellipse at center,
    transparent 5px,
    #f2dfe4 6px,
    #f2dfe4 8px,
    transparent 9px
  );
}
.art-caption {
  position: absolute;
  bottom: 15px;
  left: 0;
  right: 0;
  text-align: center;
  letter-spacing: 5px;
  color: #fff5f8;
  font-size: 11px;
  text-shadow: 0 1px 5px #0009;
}
.entry-card {
  padding: 30px 32px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.entry-copy h2 {
  font-weight: 500;
  font-size: 23px;
  margin: 14px 0 10px;
}
.entry-copy p,
.query-copy > p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
}
.entry-actions {
  display: grid;
  gap: 10px;
  width: 230px;
  flex-shrink: 0;
}
.primary,
.secondary {
  min-height: 48px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  border-radius: 6px;
  padding: 13px 22px;
  font-size: 14px;
  line-height: 1.5;
}
.primary {
  background: var(--primary);
  color: #fffbfc;
}
.primary:hover {
  background: #7c4d61;
}
.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.secondary:hover {
  background: #efe4e9;
}
.primary span,
.secondary span {
  margin-left: 18px;
}
.trust-strip {
  display: flex;
  gap: 35px;
  justify-content: center;
  padding: 25px 0;
  color: var(--muted);
  font-size: 12px;
}
.trust-strip b {
  font-weight: 600;
  color: var(--ink);
}
.trust-strip span + span:before {
  content: "·";
  margin-right: 35px;
}
.query-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 44px;
  padding: 38px 0;
}
.query-preview {
  height: 360px;
  background: #eee7ea;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
}
.query-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.query-copy {
  align-self: center;
}
.query-copy h2 {
  font-weight: 500;
  font-size: 27px;
  line-height: 1.4;
}
.query-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}
.image-action {
  position: absolute;
  right: 12px;
  bottom: 12px;
  border-radius: 6px;
  padding: 10px 15px;
  background: #fffbfce8;
  color: var(--ink);
  font-size: 12px;
  min-height: 42px;
}
.error {
  color: var(--error) !important;
  font-size: 13px;
  line-height: 1.7;
}
.progress-track {
  height: 3px;
  background: var(--line);
  overflow: hidden;
  margin-top: 25px;
}
.progress-track span {
  display: block;
  width: 35%;
  height: 100%;
  background: var(--primary);
  animation: scan 1.8s ease-in-out infinite;
}
.progress-track + p {
  font-size: 14px;
}
#progress {
  margin: 18px 0;
}
#progress .quiet {
  font-size: 12px;
}
@keyframes scan {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 35px 0 18px;
}
.section-heading h2 {
  font-size: 27px;
  font-weight: 500;
  margin: 10px 0;
}
.section-heading h1 {
  font-size: 35px;
}
.quiet {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.notice {
  padding: 14px 18px;
  border-left: 3px solid #b8879b;
  background: #f0e4e9;
  color: #725462;
  font-size: 13px;
  line-height: 1.7;
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  margin: 22px 0;
}
.result-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  text-align: left;
  padding: 0;
  color: var(--ink);
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}
.result-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 24px #44383e0c;
}
.result-photo {
  aspect-ratio: 1.18;
  background: #eee7ea;
  position: relative;
  overflow: hidden;
}
.result-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rank-badge {
  position: absolute;
  left: 12px;
  top: 12px;
  background: #fffbfceb;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  letter-spacing: 1px;
}
.result-info {
  padding: 17px 18px;
}
.result-info h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.4px;
}
.result-info p {
  font-size: 11px;
  color: var(--muted);
  margin: 9px 0 0;
  line-height: 1.6;
}
.no-match {
  margin: 30px 0 40px;
  padding: 22px 26px;
  border: 1px dashed #cbb4bf;
  border-radius: 8px;
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}
.no-match h3 {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}
.no-match p {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  line-height: 1.7;
}
.no-match button {
  font-size: 12px;
  min-height: 42px;
}
.library-search {
  display: flex;
  gap: 12px;
  max-width: 570px;
}
.library-search input,
.login-panel input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  padding: 13px 16px;
  color: var(--ink);
  font-size: 16px;
}
.library-search button {
  flex-shrink: 0;
}
.load-more {
  display: flex;
  margin: 30px auto 50px;
  min-width: 180px;
}
.login-panel {
  max-width: 440px;
  margin: 80px auto;
  padding-bottom: 60px;
}
.login-panel h1 {
  font-size: 43px;
}
.login-panel > p {
  line-height: 1.8;
  color: var(--muted);
  font-size: 14px;
}
.login-panel form {
  margin-top: 33px;
}
.login-panel label {
  display: block;
  font-size: 13px;
  margin-bottom: 12px;
}
.login-panel .primary {
  width: 100%;
  margin-top: 15px;
}
.login-panel .quiet {
  display: block;
  margin-top: 30px;
}
footer {
  max-width: 1208px;
  padding: 28px 32px;
  margin: 30px auto 0;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}
.footer-dot {
  margin: 0 10px;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
  padding: 26px;
  width: min(920px, 94vw);
  max-height: 92dvh;
  overflow: auto;
}
dialog::backdrop {
  background: #30232ba6;
  backdrop-filter: blur(4px);
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}
.dialog-head h2 {
  font-size: 26px;
  margin: 9px 0 0;
  font-weight: 500;
}
.icon-button {
  background: #ecdee4;
  color: var(--ink);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 29px;
  flex-shrink: 0;
}
.comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.comparison.single {
  grid-template-columns: 1fr;
}
.comparison figure {
  margin: 0;
  min-width: 0;
}
.comparison img {
  width: 100%;
  height: 400px;
  object-fit: contain;
  background: #eee7ea;
  cursor: zoom-in;
  border-radius: 7px;
}
.comparison figcaption {
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
  text-align: center;
}
.dialog-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 20px;
}
.image-dialog {
  width: 98vw;
  height: 96dvh;
  padding: 10px;
  background: #292027ee;
  border: 0;
  text-align: center;
}
.image-dialog img {
  max-width: 100%;
  height: 100%;
  object-fit: contain;
}
.image-close {
  position: fixed;
  right: 24px;
  top: 22px;
  width: 44px;
  height: 44px;
  background: #fffbfce8;
  border-radius: 50%;
  font-size: 28px;
  color: var(--ink);
  z-index: 2;
}
.toast {
  position: fixed;
  bottom: 35px;
  left: 50%;
  transform: translateX(-50%);
  background: #754f61;
  color: #fff;
  padding: 13px 24px;
  border-radius: 8px;
  z-index: 5;
  font-size: 14px;
  box-shadow: 0 3px 15px #0002;
}
.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;
}
@media (max-width: 760px) {
  .header {
    height: 78px;
    padding: 0 22px;
  }
  .brand {
    font-size: 22px;
  }
  .brand-mark {
    width: 37px;
    height: 37px;
    font-size: 26px;
  }
  .header-right {
    gap: 14px;
  }
  .connection {
    font-size: 10px;
  }
  main {
    padding: 0 22px;
  }
  .tabs {
    margin-top: 12px;
  }
  .intro {
    grid-template-columns: 1.1fr 0.8fr;
    gap: 15px;
    min-height: 320px;
    padding: 25px 0;
  }
  .intro h1 {
    font-size: 31px;
    letter-spacing: 0;
  }
  .intro .eyebrow {
    font-size: 8px;
    letter-spacing: 1.2px;
  }
  .lead {
    font-size: 12px;
    line-height: 1.85;
  }
  .fabric-art {
    height: 240px;
  }
  .fabric-piece {
    height: 290px;
    width: 45%;
    background-size: 30px 30px;
  }
  .art-caption {
    font-size: 8px;
    letter-spacing: 2px;
  }
  .entry-card {
    padding: 24px;
    display: block;
  }
  .entry-copy h2 {
    font-size: 21px;
  }
  .entry-copy p {
    font-size: 12px;
  }
  .entry-actions {
    margin-top: 22px;
    display: flex;
    width: 100%;
    gap: 10px;
  }
  .entry-actions button {
    flex: 1;
    padding: 12px 8px;
    font-size: 13px;
  }
  .secondary span {
    margin-left: 2px;
  }
  .trust-strip {
    gap: 13px;
    justify-content: space-between;
    font-size: 10px;
    flex-wrap: wrap;
    line-height: 1.6;
  }
  .trust-strip span + span:before {
    display: none;
  }
  .query-panel {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 25px 0;
  }
  .query-preview {
    height: 340px;
  }
  .query-copy h2 {
    font-size: 24px;
    margin: 13px 0;
  }
  .query-copy .small-number {
    font-size: 9px;
  }
  .query-actions {
    margin-top: 16px;
  }
  .query-actions button {
    flex: 1;
  }
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .result-info {
    padding: 13px 12px;
  }
  .result-info h3 {
    font-size: 17px;
  }
  .result-info p {
    font-size: 10px;
  }
  .result-photo {
    aspect-ratio: 0.95;
  }
  .rank-badge {
    font-size: 9px;
    left: 8px;
    top: 8px;
  }
  .section-heading {
    margin-top: 25px;
  }
  .section-heading h2 {
    font-size: 24px;
  }
  .section-heading h1 {
    font-size: 29px;
  }
  .section-heading .quiet {
    font-size: 10px;
    max-width: 110px;
  }
  .notice {
    font-size: 12px;
    padding: 12px;
  }
  .no-match {
    padding: 20px;
    display: block;
  }
  .no-match h3 {
    font-size: 15px;
  }
  .no-match p {
    font-size: 12px;
  }
  .no-match button {
    margin-top: 8px;
  }
  footer {
    padding: 23px 22px;
    font-size: 10px;
  }
  .footer-dot {
    margin: 0 5px;
  }
  dialog {
    padding: 20px;
    width: 96vw;
    border-radius: 13px;
  }
  .dialog-head h2 {
    font-size: 23px;
  }
  .comparison {
    gap: 10px;
  }
  .comparison img {
    height: 280px;
  }
  .comparison figcaption {
    font-size: 10px;
  }
  .dialog-bottom {
    display: block;
  }
  .dialog-bottom button {
    width: 100%;
    margin-top: 14px;
  }
  .login-panel {
    margin: 60px auto;
  }
  .login-panel h1 {
    font-size: 37px;
  }
  .image-close {
    right: 18px;
    top: 18px;
  }
}
@media (max-width: 390px) {
  .intro {
    grid-template-columns: 1fr 0.65fr;
  }
  .intro h1 {
    font-size: 27px;
  }
  .brand-sub {
    display: none;
  }
  .fabric-art {
    height: 218px;
  }
  .entry-card {
    padding: 19px;
  }
  .entry-actions {
    flex-direction: column;
  }
  .trust-strip {
    gap: 7px;
  }
  .comparison img {
    height: 220px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
  .progress-track span {
    width: 100%;
    opacity: 0.4;
  }
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #261f24;
    --paper: #32282f;
    --ink: #f0e5eb;
    --muted: #c0aeb8;
    --line: #53414b;
    --primary: #d9b4c5;
    --accent: #d8a6bc;
    --error: #ffa397;
  }
  .brand-mark,
  .primary {
    background: #d9b4c5;
    color: #35242e;
  }
  .primary:hover {
    background: #edcedc;
  }
  .tab.active {
    color: #edcedc;
  }
  .fabric-art {
    opacity: 0.75;
  }
  .notice {
    background: #3e3038;
    color: #e5cbd7;
  }
  .secondary:hover {
    background: #47333e;
  }
  .result-photo,
  .query-preview,
  .comparison img {
    background: #241b21;
  }
  .rank-badge {
    background: #382a33e8;
    color: #f0e5eb;
  }
  .image-action {
    background: #382a33e8;
    color: #f5e8ef;
  }
  .icon-button {
    background: #503b47;
    color: #f0e5eb;
  }
  .image-close {
    background: #f5e8ef;
    color: #35242e;
  }
  .toast {
    background: #d9b4c5;
    color: #35242e;
  }
}

.zoom-photo {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.zoom-photo img {
  display: block;
  width: 100%;
}
.cloth-detail-preview {
  display: block;
  max-width: 100%;
  max-height: 250px;
  object-fit: contain;
  margin: 16px auto;
}
#crop-canvas {
  display: block;
  max-width: 100%;
  max-height: 55vh;
  width: auto;
  height: auto;
  margin: auto;
  touch-action: none;
  background: var(--paper);
}
.crop-coordinates {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.crop-coordinates input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 6px;
}
.crop-coordinates label {
  font-size: 12px;
}
#ingest-form {
  display: grid;
  gap: 12px;
}
#ingest-form input,
#ingest-form textarea {
  font: inherit;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  width: 100%;
}
#ingest-preview {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  margin: auto;
}

.reference-editor {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.reference-editor label {
  display: block;
  font-size: 13px;
  margin: 14px 0 8px;
}
.reference-editor input:not([type="checkbox"]),
.reference-editor textarea {
  width: 100%;
  min-height: 48px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  font: inherit;
  font-size: 16px;
}
.reference-editor textarea {
  resize: vertical;
}
.reference-editor .manual-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.6;
}
.manual-choice input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}
#similar-section {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 24px;
}
textarea:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}
.region-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.region-actions label {
  font-size: 13px;
}
.region-actions select {
  flex: 1;
  min-width: 150px;
}
.region-actions select,
.region-fields input:not([type="checkbox"]) {
  font: inherit;
  font-size: 16px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  min-height: 46px;
}
.region-fields {
  display: grid;
  gap: 10px;
  margin: 20px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.region-fields legend {
  font-size: 14px;
  padding: 0 6px;
}
.region-fields label {
  font-size: 13px;
}
.region-fields .manual-choice {
  display: flex;
  gap: 10px;
  align-items: center;
  line-height: 1.6;
}
.region-fields input[type="checkbox"] {
  flex-shrink: 0;
}
.region-fields input:not([type="checkbox"]) {
  width: 100%;
}
.region-fields .quiet {
  margin: 0;
}
.cloth-detail {
  margin: 18px 0;
  text-align: center;
}
.cloth-detail figcaption {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.cloth-detail-preview {
  margin: 0 auto 10px;
}
.job-panel {
  border-top: 1px solid var(--line);
  margin-top: 36px;
  padding-top: 8px;
}
.job-panel .section-heading {
  margin: 16px 0;
}
.job-panel h2 {
  font-size: 22px;
}
.job-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 15px;
  margin: 10px 0;
}
.job-row > div {
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
}
.job-row strong {
  font-size: 13px;
}
.job-row p {
  font-size: 12px;
  color: var(--muted);
  margin: 7px 0 0;
  line-height: 1.6;
}
.job-row button {
  flex-shrink: 0;
}
.region-actions button:disabled {
  cursor: default;
}
select:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}
@media (max-width: 760px) {
  .region-actions {
    gap: 8px;
  }
  .region-actions label {
    width: 100%;
  }
  .region-actions select {
    width: 100%;
    flex-basis: 100%;
  }
  .region-actions button {
    flex: 1;
    padding: 10px;
  }
  .region-fields {
    padding: 12px;
  }
  .job-row {
    gap: 10px;
    align-items: flex-start;
  }
  .job-row button {
    padding: 10px 12px;
    font-size: 12px;
  }
  .crop-coordinates {
    gap: 7px;
  }
  .crop-coordinates input {
    font-size: 16px;
    padding: 10px 5px;
  }
  .cloth-detail-preview {
    max-height: 220px;
  }
}
/* Image-first cloth editing; the same controls work with touch and a mouse. */
.cloth-editor {
  padding: 0;
  width: min(1240px, 98vw);
  height: min(900px, 96dvh);
  max-height: 96dvh;
  overflow: hidden;
}
.cloth-editor[open] {
  display: flex;
  flex-direction: column;
}
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.editor-head > div {
  text-align: center;
  min-width: 0;
}
.editor-head h2 {
  font-size: 20px;
  margin: 0;
}
.editor-head p {
  margin: 4px 0 0;
  max-width: 55vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor-head .text-button {
  padding: 10px;
  min-width: 58px;
  font-size: 14px;
}
.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 285px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.editor-image-column {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 8px;
}
.crop-viewport {
  position: relative;
  flex: 1;
  min-height: 260px;
  background: #211b20;
  overflow: hidden;
  border-radius: 10px;
}
#crop-canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  background: transparent;
  touch-action: none;
}
.canvas-zoom {
  position: static;
  align-self: flex-end;
  flex-shrink: 0;
  display: flex;
  gap: 1px;
  border-radius: 8px;
  overflow: hidden;
  background: #30252dde;
  box-shadow: 0 2px 8px #0003;
}
.canvas-zoom button {
  min-width: 44px;
  min-height: 44px;
  background: none;
  color: #fff;
  padding: 8px;
  font: inherit;
  font-size: 13px;
}
.editor-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.editor-tools button {
  flex: 1;
  padding: 10px 9px;
  min-height: 46px;
}
.editor-tools button[aria-pressed="true"] {
  background: var(--primary);
  color: var(--bg);
  border-color: var(--primary);
}
.editor-image-column > .quiet {
  margin: 0;
}
#crop-help {
  font-size: 12px;
  min-height: 18px;
}
#crop-ai-status:empty {
  display: none;
}
.editor-sidebar {
  padding: 16px;
  border-left: 1px solid var(--line);
  overflow: auto;
  min-width: 0;
}
.editor-sidebar select {
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  min-height: 44px;
  border-radius: 6px;
  font: inherit;
  padding: 8px;
  margin-bottom: 12px;
}
#region-preview {
  display: block;
  max-height: 240px;
  max-width: 100%;
  width: auto;
  height: auto;
  margin: auto;
}
.region-quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.region-quick-actions button {
  flex: 1;
  min-width: 65px;
  padding: 10px 8px;
}
.region-quick-actions .text-button {
  flex: 0;
}
.editor-sidebar details {
  margin-top: 14px;
}
.editor-sidebar summary {
  min-height: 44px;
  cursor: pointer;
  padding: 12px 0;
  color: var(--muted);
  font-size: 14px;
}
.editor-sidebar .region-fields {
  border: 0;
  padding: 0;
  margin: 0;
}
.editor-sidebar .crop-coordinates {
  grid-template-columns: 1fr 1fr;
}
.editor-footer {
  display: block;
  flex-shrink: 0;
  max-width: none;
  margin: 0;
  padding: 10px 20px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.editor-footer > div {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
.editor-footer .primary {
  min-width: 230px;
}
.editor-footer .error {
  margin: 0 0 6px;
  font-size: 13px;
}
.editor-footer .error:empty {
  display: none;
}
.editor-footer .secondary {
  min-width: 130px;
}
.crop-review-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.review-piece {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  overflow: hidden;
}
.review-piece.excluded {
  border-style: dashed;
}
.review-piece.excluded canvas {
  opacity: 0.5;
}
.review-piece canvas {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: contain;
}
.review-piece label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px;
  min-height: 48px;
  font-size: 13px;
  cursor: pointer;
}
.review-piece input {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  accent-color: var(--primary);
}
#crop-review-stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 24px;
}
.point-ranges {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.point-ranges button {
  padding: 9px;
  min-height: 44px;
  flex: 1;
}
.point-ranges span {
  white-space: nowrap;
}
.region-inspect-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.region-inspect-images figure {
  margin: 0;
  min-width: 0;
}
.region-inspect-images img,
.region-inspect-images canvas {
  display: block;
  width: 100%;
  max-height: 65dvh;
  object-fit: contain;
}
.region-inspect-images figcaption {
  font-size: 12px;
  text-align: center;
  margin: 10px 0;
  color: var(--muted);
}
#region-inspect-adjust {
  margin-top: 15px;
}
#crop-restore-note {
  margin: 0;
  border-radius: 0;
  font-size: 12px;
  padding: 10px 18px;
  flex-shrink: 0;
}
.leave-actions {
  display: grid;
  gap: 10px;
}
.draft-panel {
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  margin: 16px 0;
}
.draft-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.draft-row + .draft-row {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}
.draft-row span {
  flex: 1;
  min-width: 160px;
  font-size: 13px;
}
.query-crop .editor-layout {
  grid-template-columns: 1fr;
}
.query-crop .editor-sidebar {
  display: none;
}
.query-crop #region-summary,
.query-crop #crop-ai-status {
  display: none;
}
.query-crop .crop-viewport {
  min-height: 260px;
}
#crop-confirm:disabled {
  cursor: default;
}
@media (max-width: 760px) {
  .cloth-editor {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    max-width: 100vw;
    border: 0;
    border-radius: 0;
    margin: 0;
  }
  .editor-head {
    padding: 8px 8px max(8px, env(safe-area-inset-top));
    gap: 6px;
  }
  .editor-head h2 {
    font-size: 18px;
  }
  .editor-head p {
    font-size: 11px;
  }
  .editor-layout {
    display: block;
    overflow: auto;
  }
  .editor-image-column {
    height: calc(64dvh - 20px);
    min-height: 360px;
    padding: 10px;
    gap: 6px;
  }
  .crop-viewport {
    min-height: 220px;
    flex: 1;
  }
  .editor-sidebar {
    padding: 6px 12px 14px;
    border-left: 0;
    border-top: 1px solid var(--line);
    overflow: visible;
  }
  .editor-sidebar #region-selected {
    display: grid;
    grid-template-columns: 95px minmax(0, 1fr);
    gap: 8px 12px;
    align-items: center;
  }
  .editor-sidebar #region-select {
    grid-column: 1/-1;
    margin: 0;
  }
  .editor-sidebar #region-preview-zoom {
    grid-row: 2/4;
    grid-column: 1;
  }
  .editor-sidebar #region-status {
    grid-column: 2;
    margin: 0;
    font-size: 11px;
  }
  .editor-sidebar .region-quick-actions {
    grid-column: 2;
    gap: 5px;
  }
  .editor-sidebar .region-quick-actions button {
    font-size: 12px;
    min-width: 0;
    min-height: 44px;
    padding: 8px 6px;
  }
  .editor-sidebar #region-more,
  .editor-sidebar #point-ranges {
    grid-column: 1/-1;
    margin: 0;
  }
  #region-preview {
    max-height: 105px;
  }
  .editor-sidebar .region-fields {
    grid-template-columns: 1fr;
  }
  .editor-sidebar .crop-coordinates {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .editor-tools {
    gap: 6px;
  }
  .editor-tools button {
    font-size: 12px;
    min-height: 44px;
    padding: 8px 6px;
  }
  .editor-footer {
    padding: 8px 12px max(10px, env(safe-area-inset-bottom));
  }
  .editor-footer > div {
    gap: 8px;
  }
  .editor-footer .primary {
    min-width: 0;
    flex: 1;
  }
  .editor-footer .secondary {
    min-width: 0;
    max-width: 120px;
    padding: 10px;
  }
  .editor-footer button {
    font-size: 14px;
  }
  .crop-review-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  #crop-review-stage {
    padding: 10px 12px;
  }
  .review-piece canvas {
    height: 160px;
  }
  .review-piece label {
    padding: 10px;
    font-size: 12px;
  }
  .query-crop .editor-layout {
    display: flex;
  }
  .query-crop .editor-image-column {
    height: auto;
    flex: 1;
    min-height: 0;
  }
  .region-inspect-images {
    grid-template-columns: 1fr;
  }
  .region-inspect-images img,
  .region-inspect-images canvas {
    max-height: 52dvh;
  }
  .draft-row .secondary {
    padding: 10px;
  }
  .draft-row .text-button {
    padding: 8px;
  }
}
.gallery-modes {
  display: flex;
  gap: 8px;
  margin: 18px 0 8px;
}
.gallery-modes button[aria-pressed="true"] {
  background: var(--primary);
  color: var(--bg);
}
.fabric-thumbs {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.fabric-thumbs img {
  width: calc((100% - 24px) / 5);
  height: 60px;
  object-fit: cover;
  border-radius: 5px;
}
.fabric-card .result-photo img {
  object-fit: contain;
}
.fabric-sources {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(280px, calc((100% - 14px) / 2)), 1fr)
  );
  gap: 14px;
  margin: 16px 0;
}
.fabric-source {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}
.fabric-source > h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}
.fabric-cover {
  display: block;
  width: 100%;
  aspect-ratio: 1.18;
  padding: 0;
  background: var(--bg);
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  margin: 0 0 10px;
  cursor: zoom-in;
}
.fabric-cover img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
}
.fabric-source .region-actions {
  gap: 8px;
}
.fabric-source .region-actions button {
  flex: 1 1 110px;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 12px;
}
.fabric-samples {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 0;
}
.fabric-samples > p.quiet {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
}
.fabric-dialog > .secondary {
  margin: 4px 0 16px;
}
.model-photos-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(220px, calc((100% - 12px) / 2)), 1fr)
  );
  gap: 12px;
  margin: 14px 0 20px;
}
.model-photo-card {
  display: block;
  width: 100%;
  aspect-ratio: 1.18;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  overflow: hidden;
  cursor: zoom-in;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}
.model-photo-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px #44383e12;
}
.model-photo-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.fabric-view {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
}
.fabric-view img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}
.fabric-view span {
  display: block;
  padding: 10px;
  font-size: 12px;
}
.fabric-sample-piece details {
  font-size: 12px;
  margin-top: 10px;
}
.fabric-sample-piece summary {
  min-height: 44px;
  cursor: pointer;
  line-height: 1.6;
}
.fabric-sample-piece details .fabric-view {
  margin-top: 8px;
}
.fabric-origin {
  position: relative;
  align-self: start;
}
.comparison .fabric-origin img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: initial;
}
.region-origin-box {
  position: absolute;
  border: 3px solid var(--primary);
  box-shadow: 0 0 0 1px #fff9;
  pointer-events: none;
}
.fabric-dialog .dialog-bottom {
  position: sticky;
  bottom: -26px;
  padding: 14px 0;
  background: var(--bg);
  z-index: 1;
}
@media (max-width: 760px) {
  .fabric-samples {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .fabric-view img {
    height: 150px;
  }
  .fabric-thumbs img {
    height: 50px;
  }
  #library-grid {
    grid-template-columns: 1fr;
  }
  .fabric-card .result-photo {
    aspect-ratio: 1.35;
  }
  #region-origin-dialog .comparison {
    grid-template-columns: 1fr;
  }
  .fabric-dialog .dialog-bottom {
    bottom: -20px;
  }
}
@media (max-width: 600px) {
  .fabric-sources {
    grid-template-columns: repeat(
      auto-fill,
      minmax(min(280px, calc((100% - 10px) / 2)), 1fr)
    );
    gap: 10px;
  }
  .fabric-source {
    padding: 10px;
    border-radius: 10px;
  }
  .fabric-source > h3 {
    font-size: 12px;
    margin-bottom: 6px;
  }
  .fabric-source .region-actions {
    gap: 6px;
  }
  .fabric-source .region-actions button {
    flex: 1 1 100%;
    min-height: 36px;
    padding: 6px 8px;
    font-size: 12px;
  }
  .model-photos-grid {
    grid-template-columns: repeat(
      auto-fill,
      minmax(min(220px, calc((100% - 8px) / 2)), 1fr)
    );
    gap: 8px;
  }
  .model-photo-card {
    border-radius: 8px;
  }
}
@media (max-width: 760px) {
  .editor-sidebar .region-quick-actions .text-button {
    min-width: 44px;
    flex: 0 0 44px;
    white-space: nowrap;
  }
}

/* One photo, one model, with the final retrieval crops visible while editing. */
.gallery-modes {
  align-items: center;
  flex-wrap: wrap;
}
.gallery-modes .text-button {
  margin-left: auto;
  padding: 10px;
}
.gallery-modes .text-button[aria-pressed="true"] {
  background: transparent;
  color: var(--primary);
  text-decoration: underline;
}
.photo-card .result-photo {
  aspect-ratio: 1.25;
}
.photo-card .result-photo img {
  object-fit: contain;
}
.fabric-counts {
  font-size: 14px;
}
.crop-model-fields {
  display: grid;
  grid-template-columns: auto minmax(180px, 360px) 1fr;
  align-items: center;
  gap: 8px 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.crop-model-fields label {
  font-size: 14px;
  font-weight: 600;
}
.crop-model-fields input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.crop-model-fields p {
  margin: 0;
}
.simple-editor .editor-layout {
  grid-template-columns: minmax(0, 1fr) 330px;
}
.simple-editor #crop-kept-section {
  display: block !important;
}
.simple-editor #crop-kept-title {
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 6px;
}
.simple-editor #crop-kept-section > p {
  margin: 0 0 12px;
}
.simple-editor #crop-ai,
.simple-editor #crop-ai-cancel,
.simple-editor #crop-ai-status {
  display: none !important;
}
.simple-editor #region-empty {
  margin: 12px 0;
}
.simple-editor #region-selected {
  padding-top: 16px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
}
.simple-editor #region-preview-zoom {
  display: none;
}
.simple-editor #region-keep {
  display: none;
}
.crop-kept-preview,
.crop-suggestion-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.crop-kept-preview canvas,
.crop-suggestion-list canvas {
  height: 112px;
}
.crop-kept-preview .review-piece label,
.crop-suggestion-list .review-piece label {
  font-size: 12px;
  padding: 8px;
  gap: 6px;
}
.crop-kept-preview button,
.crop-suggestion-list button {
  color: var(--ink);
}
.simple-editor #crop-suggestions {
  border-top: 1px solid var(--line);
  padding-top: 5px;
}
.simple-editor #crop-skip {
  margin-right: auto;
}
.simple-editor .editor-footer .primary {
  min-width: 280px;
}
@media (max-width: 760px) {
  .crop-model-fields {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 10px 12px;
    gap: 5px 10px;
  }
  .crop-model-fields p {
    grid-column: 1/-1;
    font-size: 11px;
  }
  .simple-editor .editor-image-column {
    height: 52dvh;
    min-height: 320px;
  }
  .simple-editor .editor-sidebar #region-selected {
    display: block;
  }
  .simple-editor .editor-sidebar #region-select {
    margin-bottom: 8px;
  }
  .simple-editor .editor-sidebar #region-status {
    margin: 8px 0;
  }
  .simple-editor .editor-sidebar .region-quick-actions {
    display: flex;
  }
  .simple-editor .editor-footer .primary {
    min-width: 0;
    font-size: 12px;
    padding: 10px 8px;
  }
  .simple-editor .editor-footer #crop-skip {
    font-size: 12px;
    white-space: nowrap;
  }
  .crop-kept-preview canvas,
  .crop-suggestion-list canvas {
    height: 130px;
  }
  .gallery-modes {
    gap: 6px;
  }
  .gallery-modes .secondary {
    padding: 10px 12px;
    font-size: 13px;
  }
  .gallery-modes .text-button {
    font-size: 12px;
    padding: 10px 4px;
  }
}

/* Main task views fill the browser viewport; the draft decision stays a compact dialog. */
dialog:not(#crop-leave-dialog):not(#copy-dialog) {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  overscroll-behavior: contain;
}
body:has(dialog[open]) {
  overflow: hidden;
}
dialog:not(.cloth-editor):not(.image-dialog):not(#crop-leave-dialog):not(
    #copy-dialog
  ) {
  --dialog-padding: clamp(16px, 2.5vw, 32px);
  padding: 0 var(--dialog-padding)
    max(var(--dialog-padding), env(safe-area-inset-bottom));
}
dialog:not(#crop-leave-dialog):not(#copy-dialog) > .dialog-head {
  position: sticky;
  top: 0;
  z-index: 3;
  margin: 0 0 20px;
  padding: max(14px, env(safe-area-inset-top)) 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  gap: 16px;
}
dialog:not(#crop-leave-dialog):not(#copy-dialog) > .dialog-head h2 {
  margin: 0;
}
dialog:not(#crop-leave-dialog):not(#copy-dialog) > .dialog-bottom {
  position: sticky;
  bottom: calc(-1 * max(var(--dialog-padding), env(safe-area-inset-bottom)));
  z-index: 2;
  padding: 14px 0 max(14px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.image-dialog {
  overflow: hidden;
}
.image-dialog img {
  display: block;
  width: 100%;
  max-width: 100%;
}
.image-dialog[open]:has(#save-photo-tip:not(.hidden)) {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  padding: max(72px, calc(env(safe-area-inset-top) + 60px)) 12px
    max(16px, env(safe-area-inset-bottom));
}
.image-dialog:has(#save-photo-tip:not(.hidden)) img {
  min-height: 0;
  -webkit-touch-callout: default;
}
#save-photo-tip {
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
}
.image-close {
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
}
.editor-head {
  padding-top: max(10px, env(safe-area-inset-top));
}
@media (max-width: 760px) {
  .editor-head {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: 8px;
  }
}
@media (max-height: 600px) {
  .editor-image-column {
    overflow: auto;
  }
  .crop-viewport,
  .query-crop .crop-viewport {
    min-height: 140px;
  }
}
.canvas-angle {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  width: min(230px, 42%);
  padding: 7px 10px;
  border-radius: 8px;
  background: #30262cdb;
  color: #fff;
  font-size: 12px;
}
.canvas-angle label {
  display: flex;
  justify-content: space-between;
}
.canvas-angle input {
  display: block;
  width: 100%;
  height: 28px;
  accent-color: #dfafc4;
}
.canvas-angle output {
  font-variant-numeric: tabular-nums;
}
.region-origin-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.region-origin-polygon {
  fill: none;
  stroke: var(--primary);
  stroke-width: 5;
  vector-effect: non-scaling-stroke;
}
@media (max-width: 760px) {
  .canvas-angle {
    left: 6px;
    top: 6px;
    bottom: auto;
    width: min(170px, 48%);
    padding: 4px 7px;
  }
  .canvas-angle input {
    height: 24px;
  }
}

.toast {
  pointer-events: none;
  width: max-content;
  max-width: min(560px, calc(100vw - 32px));
  overflow-wrap: anywhere;
}
.duplicate-panel {
  margin: 16px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}
.duplicate-panel h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 12px;
}
.duplicate-candidate {
  display: flex;
  width: 100%;
  justify-content: space-between;
  text-align: left;
  margin: 8px 0;
  flex-wrap: wrap;
}
.duplicate-candidate span {
  flex: 1;
  min-width: 220px;
  align-self: center;
}
.duplicate-candidate img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-left: 8px;
  border-radius: 4px;
}
#duplicate-review-dialog select {
  min-height: 48px;
  min-width: min(100%, 340px);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.duplicate-photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr));
  gap: 14px;
  margin: 16px 0;
}
.duplicate-photo {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.duplicate-photo img {
  display: block;
  width: 100%;
  height: 240px;
  object-fit: contain;
  cursor: zoom-in;
}
.duplicate-photo p {
  overflow-wrap: anywhere;
  font-size: 13px;
}
.duplicate-photo button {
  width: 100%;
}
.cloth-editor .toast {
  bottom: calc(90px + env(safe-area-inset-bottom));
}

@media (max-width: 760px) {
  .simple-editor .editor-footer > div {
    flex-wrap: wrap;
  }
  .simple-editor #crop-skip,
  .simple-editor #crop-archive {
    flex: 1 1 0;
    min-width: 0;
  }
  .simple-editor #crop-confirm {
    flex: 1 1 100%;
  }
}

.rotation-guides {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.cloth-editor:not(.query-crop)
  .crop-viewport:has(#crop-angle:active)
  .rotation-guides {
  display: block;
}
.rotation-guides span {
  position: absolute;
  filter: drop-shadow(0 0 2px #000);
}
.rotation-guide-horizontal {
  left: 0;
  right: 0;
  border-top: 1px dashed #fffc;
}
.rotation-guide-horizontal:nth-child(1) {
  top: 25%;
}
.rotation-guide-horizontal:nth-child(2) {
  top: 50%;
}
.rotation-guide-horizontal:nth-child(3) {
  top: 75%;
}
.rotation-guide-vertical {
  top: 0;
  bottom: 0;
  border-left: 1px dashed #fffc;
}
.rotation-guide-vertical:nth-child(4) {
  left: 25%;
}
.rotation-guide-vertical:nth-child(5) {
  left: 50%;
}
.rotation-guide-vertical:nth-child(6) {
  left: 75%;
}
.canvas-zoom {
  z-index: 2;
}

/* Show the complete saved cloth crop at its own aspect ratio in model details. */
.fabric-view img {
  height: auto;
  object-fit: contain;
}
.photo-card-shell {
  position: relative;
  min-width: 0;
}
.photo-card-shell > .photo-card {
  display: block;
  width: 100%;
  height: 100%;
}
.photo-card-archive {
  min-height: 44px;
  padding: 9px 14px;
  font-size: 13px;
  background: var(--paper);
  box-shadow: 0 2px 8px #0003;
}

/* Skip layout and painting for off-screen result cards. */
#result-grid > .result-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 380px;
}

.batch-upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}
.batch-upload-actions > button {
  max-width: 100%;
}
.batch-upload-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
}
.batch-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.batch-upload-row p {
  flex: 1 1 240px;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.7;
}
.batch-upload-row button {
  flex: 0 0 auto;
  max-width: 100%;
}
.upload-review-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.upload-review-images figure {
  margin: 0;
  min-width: 0;
}
.upload-review-images img {
  display: block;
  width: 100%;
  height: 55dvh;
  object-fit: contain;
  background: var(--paper);
}
.upload-review-images figcaption {
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
  margin: 12px 0;
  overflow-wrap: anywhere;
}
.upload-review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.upload-review-actions button {
  flex: 1 1 200px;
  min-width: 0;
}
.upload-review-images .zoom-photo {
  font-size: 0;
}
.upload-review-images .zoom-photo img {
  font-size: 14px;
}
@media (max-width: 760px) {
  .batch-upload-row p {
    flex-basis: 100%;
  }
  .batch-upload-row button {
    min-height: 44px;
    padding: 10px 14px;
  }
  .upload-review-images {
    gap: 10px;
  }
  .upload-review-images img {
    height: 38dvh;
  }
  .upload-review-actions button {
    flex-basis: 100%;
  }
  .batch-upload-actions > button {
    padding: 12px 14px;
    font-size: 14px;
  }
}

.feedback-panel {
  margin-top: 24px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.feedback-panel button {
  width: 100%;
}
#feedback-status {
  min-height: 1.5em;
}
#result-feedback {
  margin-bottom: 20px;
}

.clipboard-buffer {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
}
.copy-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
}
.copy-dialog input {
  display: block;
  width: 100%;
  font-size: 20px;
  user-select: text;
  -webkit-user-select: text;
  margin: 12px 0 20px;
}
.copy-dialog button {
  width: 100%;
}

/* Finding and comparing cloth: keep evidence and actions together. */
.compare-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.result-card.last-viewed {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.result-card.last-viewed .rank-badge::after {
  content: " · 刚看过";
}
#detail-dialog .dialog-bottom {
  display: block;
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
}
#detail-dialog .dialog-bottom > .quiet:first-child {
  display: none;
}
.detail-actions-shell {
  width: min(100%, 680px);
  margin: 0 auto;
  display: grid;
  gap: 8px;
}
.detail-actions-shell :is(button, a) {
  min-width: 0;
  width: auto;
  min-height: 46px;
  margin: 0;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
}
.detail-actions-shell button:disabled {
  cursor: default;
  opacity: 0.45;
}
.detail-primary-row {
  display: grid;
  grid-template-columns: minmax(84px, 1fr) minmax(0, 2fr) minmax(84px, 1fr);
  gap: 8px;
}
.detail-primary-row:not(:has(#previous-result:not(.hidden))) {
  grid-template-columns: minmax(0, 1fr);
}
.detail-secondary-row {
  display: flex;
  gap: 8px;
}
.detail-secondary-row > :is(button, a) {
  flex: 1 1 0;
}
.detail-secondary-row:not(:has(> :not(.hidden))) {
  display: none;
}
.detail-actions-shell:not(:has(#previous-result:not(.hidden))):has(
    #view-model-photos:not(.hidden)
  ) {
  display: flex;
  gap: 8px;
}
.detail-actions-shell:not(:has(#previous-result:not(.hidden))):has(
    #view-model-photos:not(.hidden)
  )
  > div {
  display: contents;
}
.detail-actions-shell:not(:has(#previous-result:not(.hidden))):has(
    #view-model-photos:not(.hidden)
  )
  :is(button, a) {
  flex: 1 1 0;
}
#detail-dialog #copy-code {
  font-weight: 600;
  border: 1px solid var(--primary);
}
.archive-undo:empty {
  display: none;
}
.undo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  margin: 10px 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.undo-row span {
  flex: 1;
  min-width: 160px;
}
.job-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.job-row > div {
  flex: 1;
  min-width: 200px;
}
.batch-completed > summary {
  min-height: 44px;
  padding: 12px 0;
  cursor: pointer;
}
@media (max-width: 760px) {
  #detail-dialog .comparison img {
    height: 38dvh;
    object-fit: contain;
  }
  .compare-tools {
    gap: 8px;
  }
  .compare-tools .secondary {
    font-size: 13px;
    padding: 10px;
  }
  .compare-tools span {
    white-space: nowrap;
  }
}
@media (max-width: 600px) {
  #detail-dialog .dialog-bottom {
    padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  }
  .detail-actions-shell,
  .detail-primary-row,
  .detail-secondary-row {
    gap: 7px;
  }
  .detail-primary-row {
    grid-template-columns: minmax(74px, 0.95fr) minmax(0, 1.9fr) minmax(
        74px,
        0.95fr
      );
  }
  .detail-actions-shell :is(button, a) {
    min-height: 44px;
    padding: 9px 10px;
    font-size: 13px;
  }
}
@media (max-width: 380px) {
  #detail-dialog #copy-code::before {
    display: none;
  }
  .detail-actions-shell :is(button, a) {
    font-size: 12px;
    padding: 8px 6px;
  }
}
#detail-dialog .comparison img {
  max-height: 38dvh;
}
/* Keep undo reachable even after archiving a card far down a long gallery. */
.archive-undo:not(:empty) {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(620px, calc(100vw - 24px));
  max-height: 32dvh;
  overflow: auto;
  box-shadow: 0 4px 24px #0002;
  border-radius: 8px;
  background: var(--bg);
}
.archive-undo .undo-row {
  margin: 0;
}
.archive-undo .undo-row + .undo-row {
  margin-top: 6px;
}

/* Keep the indexed original and the matching crop visible together. */
#result-grid .result-photo img {
  object-fit: contain;
}
.comparison.with-match {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.comparison > .cloth-detail {
  margin: 0;
}
.comparison > .cloth-detail .zoom-photo {
  display: block;
  width: 100%;
}
.comparison > .cloth-detail img {
  width: 100%;
  object-fit: contain;
}
@media (max-width: 760px) {
  .comparison.with-match {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .comparison.with-match > .cloth-detail {
    grid-column: 1/-1;
  }
}

.batch-upload-panel > h3 {
  margin: 4px 0 10px;
  font-size: 17px;
}
.batch-upload-panel > button {
  margin: 4px 8px 8px 0;
}
.batch-upload-panel > p {
  line-height: 1.7;
  overflow-wrap: anywhere;
}
#feedback-shared-status,
#detail-shared-status {
  overflow-wrap: anywhere;
}

/* Appearance settings: theme colors never filter or tint fabric photographs. */
.brand-puppy,
.puppy-art {
  display: none;
}
.settings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 36px 0 28px;
}
.settings-heading h1 {
  font-size: clamp(28px, 3.3vw, 40px);
  margin: 12px 0;
}
.settings-tag {
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--muted);
}
.settings-banner {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  align-items: center;
  gap: 24px;
  padding: 24px 48px;
  background: #e9eddf;
  border: 1px solid #d4ddca;
  border-radius: 28px;
  color: #344839;
  overflow: hidden;
  position: relative;
}
.settings-banner h2 {
  font-size: clamp(20px, 2.3vw, 29px);
  font-weight: 600;
  line-height: 1.5;
  margin: 16px 0;
}
.settings-banner p {
  font-size: 14px;
  line-height: 1.9;
  color: #576653;
}
.settings-banner .small-number {
  color: #576653;
}
.settings-banner > .schnauzer-mascot {
  display: block;
  width: 100%;
  height: 265px;
  fill: none;
  stroke: none;
}
.companion-note {
  display: inline-block;
  margin-top: 16px;
  font-size: 12px;
  border-bottom: 1px dashed #80917b;
  padding-bottom: 6px;
  letter-spacing: 1px;
}
.theme-picker {
  padding: 0;
  border: 0;
  margin: 34px 0 0;
  min-width: 0;
}
.theme-picker legend {
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 20px;
  padding: 0;
}
.theme-picker legend > span {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 14px;
}
.theme-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.theme-option {
  position: relative;
  display: block;
  min-width: 0;
  cursor: pointer;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  padding: 6px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.theme-option:hover {
  border-color: var(--muted);
}
.theme-option:has(input:checked) {
  border-color: var(--primary);
  box-shadow:
    0 0 0 3px var(--bg),
    0 0 0 4px var(--primary);
}
.theme-option input {
  position: absolute;
  right: 18px;
  top: 18px;
  z-index: 2;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.theme-option:has(input:focus-visible) {
  outline: 3px solid var(--primary);
  outline-offset: 5px;
}
.theme-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  aspect-ratio: 1.7;
  overflow: hidden;
  border-radius: 13px;
}
.preview-classic {
  background: #eedfe5;
}
.preview-forest {
  background: #e4ebd9;
}
.preview-peach {
  background: #f7dfd0;
}
.theme-preview > .schnauzer-mascot {
  width: 77%;
  height: 100%;
  stroke: none;
  fill: none;
  position: relative;
  padding-bottom: 10px;
}
.preview-word {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  color: #596452;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 2px;
}
.preview-peach .preview-word {
  color: #895b4b;
}
.preview-classic .preview-word {
  color: #78566a;
}
.preview-cloud {
  position: absolute;
  width: 125px;
  height: 125px;
  border-radius: 50%;
  background: #fff9;
  top: 18px;
}
.theme-option-copy {
  display: block;
  padding: 17px 14px 12px;
}
.theme-option-copy > strong {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
}
.theme-option-copy > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.7;
}
.theme-selected {
  visibility: hidden;
  color: var(--primary);
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.theme-option:has(input:checked) .theme-selected {
  visibility: visible;
}
.theme-option-copy .theme-swatches {
  display: flex;
  gap: 7px;
  margin-top: 16px;
}
.theme-swatches i {
  width: 18px;
  height: 18px;
  background: var(--paper);
  border: 1px solid #0002;
  border-radius: 50%;
}
.mini-browser {
  width: 64%;
  height: 60%;
  background: #fffbfc;
  border: 1px solid #d5bdc8;
  border-radius: 6px;
  box-shadow: 5px 8px 0 #925e7320;
  padding: 18px 12px 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  position: relative;
}
.mini-browser i {
  position: absolute;
  top: 6px;
  left: 8px;
  width: 28px;
  height: 3px;
  background: #c6a3b3;
  border-radius: 3px;
}
.mini-browser b {
  grid-column: 1/-1;
  width: 62%;
  height: 5px;
  background: #925e73;
  border-radius: 3px;
}
.mini-browser > span {
  background: #e8d5dd;
  border-radius: 3px;
}
.mini-browser > span:nth-last-child(2) {
  background: #caa7b8;
}
.theme-status {
  font-size: 13px;
  color: var(--primary);
  margin: 26px 0 8px;
  min-height: 1.7em;
  line-height: 1.7;
}
.settings-footnote {
  padding-bottom: 28px;
  margin-top: 0;
}
:root[data-theme^="schnauzer"] {
  --bg: #faf7ef;
  --paper: #fffdf8;
  --ink: #343d35;
  --muted: #64705e;
  --line: #dce0cf;
  --primary: #526c55;
  --accent: #526c55;
  --error: #a33831;
  --theme-soft: #e9eddf;
  --theme-border: #d4ddca;
  --theme-art: #e6ebd9;
}
:root[data-theme="schnauzer-peach"] {
  --bg: #fff7f0;
  --paper: #fffdf9;
  --ink: #513f38;
  --muted: #80685d;
  --line: #e9d9cb;
  --primary: #a15f50;
  --accent: #a15f50;
  --theme-soft: #f7e5d9;
  --theme-border: #ead1bf;
  --theme-art: #f6e2d3;
}
[data-theme^="schnauzer"] body {
  background:
    radial-gradient(circle at 90% 10%, var(--theme-soft), transparent 38%),
    var(--bg);
}
[data-theme^="schnauzer"] .brand-mark {
  display: none;
}
[data-theme^="schnauzer"] .brand-puppy {
  display: block;
  width: 52px;
  height: 52px;
  fill: none;
  stroke: none;
  background: var(--theme-soft);
  border-radius: 18px;
}
[data-theme^="schnauzer"] .brand {
  letter-spacing: 2px;
}
[data-theme^="schnauzer"] h1,
[data-theme^="schnauzer"] h2 {
  font-weight: 650;
}
[data-theme^="schnauzer"] .tabs {
  gap: 10px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  width: max-content;
  max-width: 100%;
}
[data-theme^="schnauzer"] .tab {
  border: 0;
  border-radius: 12px;
  padding: 13px 24px;
}
[data-theme^="schnauzer"] .tab.active {
  background: var(--theme-soft);
  color: var(--primary);
}
[data-theme^="schnauzer"] .fabric-art {
  display: none;
}
[data-theme^="schnauzer"] .puppy-art {
  display: flex;
  position: relative;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--theme-art);
  border: 1px solid var(--theme-border);
  border-radius: 46% 46% 26px 26px;
  padding: 18px 14px 16px;
}
[data-theme^="schnauzer"] .puppy-art > .schnauzer-mascot {
  display: block;
  width: 100%;
  height: 260px;
  fill: none;
  stroke: none;
}
.puppy-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted);
  padding-top: 5px;
}
.puppy-caption {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
}
[data-theme^="schnauzer"] .entry-card {
  border-radius: 24px;
  border-color: var(--theme-border);
  box-shadow: 0 7px 0 var(--theme-soft);
}
[data-theme^="schnauzer"] .primary,
[data-theme^="schnauzer"] .secondary {
  border-radius: 14px;
}
[data-theme^="schnauzer"] .primary:hover {
  background: var(--ink);
}
[data-theme^="schnauzer"] .secondary:hover {
  background: var(--theme-soft);
}
[data-theme^="schnauzer"] :is(button, a, input):focus-visible {
  outline-color: var(--primary);
}
[data-theme^="schnauzer"] .result-card,
[data-theme^="schnauzer"] .photo-card,
[data-theme^="schnauzer"] .batch-upload-panel,
[data-theme^="schnauzer"] .duplicate-panel {
  border-radius: 18px;
}
[data-theme^="schnauzer"] .notice {
  border-color: var(--primary);
  background: var(--theme-soft);
  color: var(--ink);
  border-radius: 0 12px 12px 0;
}
[data-theme^="schnauzer"] .no-match {
  border-color: var(--theme-border);
  border-radius: 18px;
}
[data-theme^="schnauzer"] .icon-button {
  background: var(--theme-soft);
}
[data-theme^="schnauzer"] .connection:before {
  background: var(--primary);
}
[data-theme^="schnauzer"] .toast {
  background: var(--primary);
}
[data-theme^="schnauzer"] .settings-banner {
  background: var(--theme-soft);
  border-color: var(--theme-border);
  color: var(--ink);
}
[data-theme^="schnauzer"] .settings-banner p,
[data-theme^="schnauzer"] .settings-banner .small-number {
  color: var(--muted);
}
[data-theme^="schnauzer"]
  :is(.result-photo, .query-preview, .comparison img, .photo-card img) {
  background: #efefea;
}
@keyframes puppy-hello {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}
@media (prefers-reduced-motion: no-preference) {
  [data-theme^="schnauzer"] .puppy-art > .schnauzer-mascot {
    animation: puppy-hello 4s ease-in-out infinite;
  }
}
@media (max-width: 760px) {
  .tabs {
    gap: 20px;
  }
  .tab {
    white-space: nowrap;
  }
  .settings-heading {
    padding: 26px 0 22px;
  }
  .settings-heading h1 {
    font-size: 27px;
  }
  .settings-heading .lead {
    font-size: 13px;
  }
  .settings-tag {
    display: none;
  }
  .settings-banner {
    grid-template-columns: 1fr;
    padding: 25px 24px 8px;
    gap: 0;
    border-radius: 22px;
  }
  .settings-banner h2 {
    font-size: 22px;
    margin: 12px 0;
  }
  .settings-banner p {
    font-size: 13px;
    margin-bottom: 8px;
  }
  .settings-banner > .schnauzer-mascot {
    height: 225px;
  }
  .companion-note {
    margin-top: 8px;
  }
  .theme-options {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .theme-option {
    display: grid;
    grid-template-columns: 130px 1fr;
    align-items: center;
    border-radius: 16px;
    padding: 5px;
  }
  .theme-preview {
    height: 126px;
    aspect-ratio: auto;
    border-radius: 10px;
  }
  .theme-option input {
    top: 12px;
    right: 12px;
    width: 18px;
    height: 18px;
  }
  .theme-option-copy {
    padding: 12px;
  }
  .theme-option-copy > strong {
    font-size: 15px;
    padding-right: 22px;
    display: block;
  }
  .theme-selected {
    display: block;
    font-size: 10px;
    margin-top: 4px;
  }
  .theme-option-copy > span {
    margin-top: 4px;
    font-size: 11px;
  }
  .theme-option-copy .theme-swatches {
    margin-top: 8px;
  }
  .theme-preview > .schnauzer-mascot {
    width: 100%;
    padding-bottom: 12px;
  }
  .preview-word {
    font-size: 6px;
    letter-spacing: 1px;
    bottom: 10px;
  }
  .preview-cloud {
    width: 80px;
    height: 80px;
  }
  .mini-browser {
    width: 80%;
    height: 60%;
    gap: 4px;
    padding: 18px 7px 8px;
  }
  .theme-picker {
    margin-top: 28px;
  }
  [data-theme^="schnauzer"] .tabs {
    gap: 2px;
    width: 100%;
    padding: 4px;
    border-radius: 15px;
  }
  [data-theme^="schnauzer"] .tab {
    padding: 12px 2px;
    flex: 1;
    font-size: 13px;
  }
  [data-theme^="schnauzer"] .intro {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 30px 0;
  }
  [data-theme^="schnauzer"] .intro h1 {
    font-size: 34px;
    margin: 12px 0;
  }
  [data-theme^="schnauzer"] .intro .lead {
    font-size: 13px;
  }
  [data-theme^="schnauzer"] .puppy-art {
    border-radius: 24px;
    min-height: 210px;
    padding: 10px;
  }
  [data-theme^="schnauzer"] .puppy-art > .schnauzer-mascot {
    height: 190px;
  }
  .puppy-label {
    font-size: 8px;
  }
  [data-theme^="schnauzer"] .entry-card {
    padding: 22px;
  }
  [data-theme^="schnauzer"] .brand-puppy {
    width: 44px;
    height: 44px;
  }
  .settings-footnote {
    font-size: 11px;
  }
}

/* The puppy's little world: decorative ink stays outside fabric photographs. */
[data-theme^="schnauzer"] body {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cg fill='%23818b72' opacity='.085' transform='translate(35 28) rotate(-22 20 20)'%3E%3Cellipse cx='20' cy='28' rx='11' ry='9'/%3E%3Cellipse cx='5' cy='16' rx='4' ry='6' transform='rotate(-25 5 16)'/%3E%3Cellipse cx='15' cy='8' rx='4' ry='6'/%3E%3Cellipse cx='26' cy='8' rx='4' ry='6'/%3E%3Cellipse cx='36' cy='17' rx='4' ry='6' transform='rotate(25 36 17)'/%3E%3C/g%3E%3Cg fill='none' stroke='%23a89475' stroke-width='1.5' opacity='.14'%3E%3Cpath d='M158 155l13 8q10-4 10 4q0 7-7 5l-13-8q-9 4-9-3q0-8 6-6z'/%3E%3Cpath d='M100 204l3 5 6 1-6 2-3 6-2-6-6-2 6-1z'/%3E%3C/g%3E%3C/svg%3E"),
    radial-gradient(ellipse at 90% 10%, var(--theme-soft), transparent 48%);
  background-color: var(--bg);
  background-attachment: scroll, fixed;
}
[data-theme^="schnauzer"] .header {
  background: var(--paper);
  border-radius: 0 0 24px 24px;
  box-shadow: 0 4px 0 #343d3505;
}
[data-theme^="schnauzer"] .primary {
  background: var(--primary);
  color: var(--paper);
  box-shadow: 0 4px 0 var(--theme-border);
  border: 1px solid var(--primary);
  transition:
    transform 0.15s,
    box-shadow 0.15s,
    background 0.15s;
}
[data-theme^="schnauzer"] .primary::before {
  content: "";
  display: inline-block;
  flex: 0 0 16px;
  width: 16px;
  height: 18px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M8 23c0-5 4-10 8-10s8 5 8 10c0 6-6 3-8 3s-8 3-8-3Z'/%3E%3Cellipse cx='5' cy='12' rx='3.5' ry='5' transform='rotate(-25 5 12)'/%3E%3Cellipse cx='12' cy='6' rx='3.5' ry='5'/%3E%3Cellipse cx='21' cy='6' rx='3.5' ry='5'/%3E%3Cellipse cx='28' cy='13' rx='3.5' ry='5' transform='rotate(25 28 13)'/%3E%3C/svg%3E")
    center/contain no-repeat;
}
[data-theme^="schnauzer"] #camera-button > svg {
  display: none;
}
[data-theme^="schnauzer"] .primary:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--theme-border);
}
[data-theme^="schnauzer"] .secondary {
  background: var(--paper);
  border-color: var(--theme-border);
  box-shadow: 0 2px 0 var(--theme-soft);
  transition:
    background 0.15s,
    transform 0.15s;
}
[data-theme^="schnauzer"] .secondary:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: none;
}
[data-theme^="schnauzer"] .tabs .tab::before {
  display: inline-block;
  font-size: 13px;
  margin-right: 7px;
  opacity: 0.75;
}
[data-theme^="schnauzer"] .tab[data-page="search"]::before {
  content: "⌕";
}
[data-theme^="schnauzer"] .tab[data-page="library"]::before {
  content: "▦";
}
[data-theme^="schnauzer"] .tab[data-page="history"]::before {
  content: "◷";
}
[data-theme^="schnauzer"] .tab[data-page="settings"]::before {
  content: "⚙";
}
[data-theme^="schnauzer"] .puppy-art {
  background-image:
    radial-gradient(circle at 18% 23%, #fff9 0 4px, transparent 5px),
    radial-gradient(circle at 85% 72%, #fff9 0 5px, transparent 6px),
    radial-gradient(circle at 80% 16%, #fff7 0 22px, transparent 23px);
}
[data-theme^="schnauzer"] .puppy-caption {
  padding: 7px 16px;
  background: var(--paper);
  border-radius: 20px;
  border: 1px dashed var(--theme-border);
}
[data-theme^="schnauzer"] .puppy-label::before,
[data-theme^="schnauzer"] .puppy-label::after {
  content: "✧";
  margin: 0 8px;
  color: var(--primary);
}
[data-theme^="schnauzer"] .entry-card {
  position: relative;
  border-style: dashed;
  border-width: 2px;
}
[data-theme^="schnauzer"] .entry-copy .small-number {
  display: inline-block;
  padding: 6px 12px;
  background: var(--theme-soft);
  border-radius: 20px;
  color: var(--primary);
}
[data-theme^="schnauzer"] .trust-strip > span {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 7px 13px;
}
[data-theme^="schnauzer"] .trust-strip span + span:before {
  display: none;
}
[data-theme^="schnauzer"] .trust-strip {
  gap: 12px;
  flex-wrap: wrap;
}
[data-theme^="schnauzer"] .settings-banner {
  border-style: dashed;
  border-width: 2px;
  box-shadow: 0 6px 0 var(--theme-soft);
}
[data-theme^="schnauzer"] .settings-tag::before {
  content: "✿";
  margin-right: 7px;
}
[data-theme^="schnauzer"] .theme-picker legend::before {
  content: "✧";
  color: var(--primary);
  margin-right: 9px;
}
[data-theme^="schnauzer"] .theme-option {
  box-shadow: 0 4px 0 var(--theme-soft);
}
[data-theme^="schnauzer"] .query-copy .small-number,
[data-theme^="schnauzer"] .section-heading .eyebrow {
  display: inline-block;
  border-bottom: 2px dotted var(--theme-border);
  padding-bottom: 9px;
}
[data-theme^="schnauzer"] .result-info {
  background: linear-gradient(135deg, var(--paper) 75%, var(--theme-soft));
}
[data-theme^="schnauzer"] .rank-badge {
  border-radius: 12px;
  background: var(--paper);
  color: var(--primary);
  border: 1px solid var(--theme-border);
}
[data-theme^="schnauzer"] footer > span::before {
  content: "♡";
  margin-right: 8px;
  color: var(--primary);
}
@media (max-width: 760px) {
  [data-theme^="schnauzer"] .tabs .tab::before {
    margin-right: 4px;
    font-size: 12px;
  }
  [data-theme^="schnauzer"] .primary {
    gap: 7px;
  }
  [data-theme^="schnauzer"] .trust-strip {
    justify-content: flex-start;
    gap: 7px;
    padding: 24px 0;
  }
  [data-theme^="schnauzer"] .trust-strip > span {
    padding: 6px 10px;
    font-size: 10px;
  }
  [data-theme^="schnauzer"] .entry-actions .primary span {
    margin-left: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  [data-theme^="schnauzer"] .primary,
  [data-theme^="schnauzer"] .secondary {
    transition: none;
  }
}

/* Palette previews use stylesheet rules to respect the production content policy. */
[data-choice="classic"] .theme-swatches i:nth-child(1) {
  background: #f7f2f3;
}
[data-choice="classic"] .theme-swatches i:nth-child(2) {
  background: #925e73;
}
[data-choice="classic"] .theme-swatches i:nth-child(3) {
  background: #44383e;
}
[data-choice="schnauzer"] .theme-swatches i:nth-child(1) {
  background: #faf7ef;
}
[data-choice="schnauzer"] .theme-swatches i:nth-child(2) {
  background: #526c55;
}
[data-choice="schnauzer"] .theme-swatches i:nth-child(3) {
  background: #e2ba88;
}
[data-choice="schnauzer-peach"] .theme-swatches i:nth-child(1) {
  background: #fff7f0;
}
[data-choice="schnauzer-peach"] .theme-swatches i:nth-child(2) {
  background: #a15f50;
}
[data-choice="schnauzer-peach"] .theme-swatches i:nth-child(3) {
  background: #e8c5ab;
}

/* The approved chibi artwork keeps its alpha on either theme background. */
.schnauzer-mascot,
.brand-puppy {
  object-fit: contain;
}
.settings-banner > .schnauzer-mascot {
  justify-self: center;
}
.theme-preview > .schnauzer-mascot {
  padding: 8px 0 24px;
}
.brand-puppy {
  padding: 3px;
}

/* Search eligibility is distinct from manual curation and label confirmation. */
.photo-search-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  margin: 0 0 9px;
  border-radius: 20px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  background: var(--bg);
  color: var(--ink);
}
.photo-search-status.status-searchable {
  color: var(--primary);
  border-color: var(--primary);
}
.photo-search-status.status-unlabelled,
.photo-search-status.status-unavailable {
  border-style: dashed;
}
.photo-search-status.status-archived {
  color: var(--muted);
}
.gallery-modes button {
  white-space: nowrap;
}

/* Explicit query-to-gallery supplement, independent of candidate feedback. */
.known-model {
  flex-basis: 100%;
  min-width: 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.known-model > p:empty {
  display: none;
}
.known-model-form {
  display: grid;
  grid-template-columns: minmax(100px, 160px) minmax(0, 1fr);
  gap: 20px;
  margin-top: 18px;
  text-align: left;
}
.known-model-form figure {
  margin: 0;
}
.known-model-form img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.known-model-form figcaption {
  color: var(--muted);
  font-size: 11px;
  margin-top: 8px;
}
.known-model-fields {
  min-width: 0;
}
.known-model-fields label {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}
.known-model-fields input {
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
}
.known-model-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
#known-model-status,
#known-model-error {
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  .known-model-form {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .known-model-form figure {
    max-width: 140px;
  }
  .known-model-actions button {
    flex: 1 1 auto;
  }
}

/* Clickable text keeps the same visible affordance as the rest of the controls. */
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}
.text-button:hover:not(:disabled) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 7%, var(--paper));
}
.text-button[aria-pressed="true"] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--paper));
  color: var(--primary);
}
.batch-completed > summary {
  min-height: 44px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}
.batch-completed > summary:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 7%, var(--paper));
}
.batch-completed > summary:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

/* Gallery-first workspace: summary, new photos, then gallery or server tasks. */
#library-page > .gallery-page-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  margin: 26px 0 20px;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: none;
  min-width: 0;
}
#library-page .gallery-page-heading h1 {
  margin: 0 0 5px;
  font-size: 29px;
  line-height: 1.4;
  font-weight: 600;
}
#library-page .gallery-page-heading .quiet {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
}
#library-page .gallery-page-heading .eyebrow,
#library-page .gallery-page-heading .world-label,
#library-page .gallery-page-heading .world-scene-art > span {
  display: none;
}
#library-page .gallery-page-heading .world-scene-art {
  display: flex;
  margin: 0;
}
#library-page .gallery-page-heading .world-dog {
  width: 88px;
  height: 88px;
}
.gallery-overview,
.library-add-module,
.library-search-module {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.gallery-overview {
  padding: 21px 24px 16px;
}
.gallery-module-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 21px;
}
.gallery-module-heading h2,
.library-add-module h2,
.gallery-data-heading h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.5;
}
.gallery-module-heading .quiet,
.library-add-module .quiet {
  margin: 3px 0 0;
}
.gallery-overview-groups {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr;
  gap: 24px;
}
.gallery-overview-group {
  min-width: 0;
}
.gallery-overview-group + .gallery-overview-group {
  border-left: 1px solid var(--line);
  padding-left: 24px;
}
.gallery-overview-group h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
}
.gallery-total-number {
  margin: 0;
  font-size: clamp(27px, 3.2vw, 37px);
  font-weight: 600;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.gallery-total-number small {
  margin-left: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}
.gallery-photo-breakdown {
  display: flex;
  gap: 24px;
  margin: 20px 0 0;
}
.gallery-photo-breakdown dt {
  color: var(--muted);
  font-size: 12px;
}
.gallery-photo-breakdown dd {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.gallery-overview-metrics {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0;
}
.gallery-overview-metrics > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.gallery-overview-metrics dt {
  color: var(--muted);
}
.gallery-overview-metrics dd {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.gallery-overview-metrics small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}
.gallery-ready-number {
  color: var(--primary);
}
.gallery-submetric dt {
  padding-left: 12px;
  font-size: 12px;
}
.gallery-model-metrics {
  margin-top: 13px;
}
.gallery-summary-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.gallery-summary-feedback .quiet {
  margin: 12px 0 0;
}
.gallery-summary-feedback button {
  margin-top: 12px;
}
.gallery-overview-foot {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin: 17px 0 0;
}
.library-add-module {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin: 18px 0;
  padding: 16px 20px;
}
.library-add-controls,
#library-review-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
#library-page button {
  min-height: 44px;
  white-space: normal;
}
.library-add-menu {
  flex: 1 0 100%;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
#library-add-actions .batch-upload-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  gap: 12px;
}
#library-add-actions .batch-upload-actions > button {
  min-height: 64px;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  gap: 4px;
  padding: 13px 16px;
  text-align: left;
  box-shadow: none;
}
#library-add-actions .batch-upload-actions > button::before {
  display: none;
}
#library-add-actions .batch-upload-actions small {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
}
.gallery-panel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 21px 0 16px;
}
.gallery-panel-tabs .secondary {
  border-radius: 11px;
  min-width: 124px;
  padding: 11px 20px;
  box-shadow: none;
}
.gallery-panel-tabs .secondary[aria-pressed="true"] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--paper));
  color: var(--primary);
  font-weight: 600;
}
#library-gallery-panel,
#library-tasks-panel {
  min-width: 0;
}
.library-search-module {
  padding: 16px;
}
#library-page .library-search {
  display: flex;
  gap: 10px;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}
#library-page .library-search input {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font-size: 16px;
}
#library-page .library-search button {
  flex: 0 0 auto;
  border-radius: 10px;
  padding: 11px 22px;
  box-shadow: none;
}
#library-filter-actions:empty {
  display: none;
}
#library-filter-actions .gallery-modes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 13px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}
#library-filter-actions .gallery-modes button {
  flex: 0 1 auto;
  margin: 0;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  box-shadow: none;
  text-decoration: none;
}
#library-filter-actions .gallery-modes [aria-pressed="true"] {
  background: color-mix(in srgb, var(--primary) 12%, var(--paper));
  border-color: var(--primary);
  color: var(--primary);
}
.library-advanced-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
#library-advanced-filters button {
  margin: 0;
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 13px;
  box-shadow: none;
}
#library-advanced-filters [aria-pressed="true"] {
  background: color-mix(in srgb, var(--primary) 12%, var(--paper));
  border-color: var(--primary);
  color: var(--primary);
}
.gallery-data-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 24px 0 10px;
}
#library-page #library-status {
  margin: 0 0 12px;
}
#library-page #library-grid {
  margin-top: 0;
}
#library-page #library-grid.library-search-results {
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(220px, calc((100% - 12px) / 2)), 1fr)
  );
  gap: 12px;
}
#library-page #library-grid.library-search-results .result-card {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
}
#library-page #library-grid.library-search-results .result-photo {
  width: 100%;
  aspect-ratio: 1.18;
}
#library-page #library-grid.library-search-results .result-photo img {
  object-fit: contain;
}
#library-page #library-grid.library-search-results .result-info {
  padding: 8px 10px;
  min-height: 0;
}
#library-page #library-grid.library-search-results .result-info::after,
#library-page #library-grid.library-search-results .result-info > :not(h3) {
  display: none;
}
#library-page #library-grid.library-search-results .result-info h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  #library-page #library-grid.library-search-results {
    grid-template-columns: repeat(
      auto-fill,
      minmax(min(220px, calc((100% - 8px) / 2)), 1fr)
    );
    gap: 8px;
  }
  #library-page #library-grid.library-search-results .result-card {
    border-radius: 8px;
  }
  #library-page #library-grid.library-search-results .result-info {
    padding: 7px 9px;
  }
  #library-page #library-grid.library-search-results .result-info h3 {
    font-size: 13px;
  }
}
#library-tasks-panel .batch-upload-panel {
  max-height: none;
  margin: 0;
  padding: 20px;
  border-radius: 16px;
  background: var(--paper);
  overflow: visible;
}
#library-tasks-panel .batch-upload-panel h2 {
  margin: 0 0 8px;
  font-size: 19px;
}
#library-tasks-panel .batch-upload-panel > p {
  line-height: 1.7;
  font-size: 12px;
  color: var(--muted);
}
#library-tasks-panel .job-panel {
  margin-top: 18px;
}
.batch-task-tabs,
.batch-task-toolbar,
.batch-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.batch-task-toolbar {
  margin: 14px 0;
}
.batch-task-tabs {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
#library-tasks-panel .batch-task-tabs button,
#library-tasks-panel .batch-task-toolbar button,
#library-tasks-panel .batch-row-actions button {
  padding: 9px 14px;
  border-radius: 10px;
  box-shadow: none;
}
#library-tasks-panel .batch-task-tabs [aria-pressed="true"] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--paper));
  color: var(--primary);
}
#library-tasks-panel .batch-upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 18px;
  padding: 17px 0;
}
.batch-row-copy {
  min-width: 0;
  overflow-wrap: anywhere;
}
.batch-row-copy > strong {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
}
.batch-row-copy > p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
}
.batch-row-copy > .batch-row-time {
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
}
.batch-row-actions {
  justify-content: flex-end;
}
@media (max-width: 760px) {
  #library-page > .gallery-page-heading {
    gap: 10px;
    margin: 21px 0 16px;
  }
  #library-page .gallery-page-heading h1 {
    font-size: 25px;
  }
  #library-page .gallery-page-heading .quiet {
    font-size: 12px;
  }
  #library-page .gallery-page-heading .world-dog {
    width: 70px;
    height: 70px;
  }
  .gallery-overview {
    padding: 17px 16px 14px;
  }
  .gallery-module-heading {
    margin-bottom: 15px;
    gap: 6px;
  }
  .gallery-overview-scope {
    font-size: 11px;
  }
  .gallery-overview-groups {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
  }
  .gallery-overview-group + .gallery-overview-group {
    padding-left: 16px;
  }
  .gallery-photo-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    align-items: center;
    gap: 10px;
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--line);
    padding-bottom: 16px;
  }
  .gallery-photo-breakdown {
    margin: 0;
    justify-content: space-between;
    gap: 12px;
  }
  .gallery-overview-group:nth-child(2) {
    padding-left: 0;
    border-left: 0;
  }
  .gallery-overview-group h3 {
    font-size: 11px;
  }
  .gallery-total-number {
    font-size: 29px;
  }
  .gallery-overview-metrics > div {
    font-size: 12px;
  }
  .gallery-overview-metrics dd {
    font-size: 16px;
  }
  .gallery-overview-foot {
    font-size: 11px;
    line-height: 1.8;
  }
  .library-add-module {
    padding: 15px 16px;
  }
  .library-add-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    align-items: stretch;
  }
  #library-page #library-review-actions {
    display: contents;
  }
  #library-page .library-add-controls > button,
  #library-page #library-review-actions > button {
    min-width: 0;
    width: 100%;
    height: auto;
    min-height: 44px;
    padding: 10px 12px;
    align-self: stretch;
  }
  .library-add-controls > .duplicate-scan-status {
    grid-column: 1 / -1;
    min-width: 0;
    margin: 0;
  }
  #library-add-actions .batch-upload-actions {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .gallery-panel-tabs {
    gap: 8px;
    margin-top: 18px;
  }
  .gallery-panel-tabs .secondary {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
  }
  .library-search-module {
    padding: 12px;
  }
  #library-page .library-search {
    gap: 8px;
  }
  #library-page .library-search input {
    padding: 11px 10px;
  }
  #library-page .library-search button {
    padding: 10px 14px;
  }
  #library-filter-actions .gallery-modes {
    gap: 7px;
    margin-top: 11px;
  }
  #library-filter-actions .gallery-modes button {
    font-size: 12px;
    padding: 9px 10px;
  }
  #library-tasks-panel .batch-upload-panel {
    padding: 16px;
  }
  #library-advanced-filters button {
    font-size: 12px;
    padding: 9px 10px;
  }
  #library-tasks-panel .batch-upload-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 11px;
  }
  .batch-row-actions {
    justify-content: flex-start;
  }
  .batch-task-tabs button {
    flex: 1 1 0;
    min-width: 0;
  }
}
@media (max-width: 420px) {
  .library-add-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #library-page #library-review-actions {
    display: contents;
  }
  #library-page .library-add-controls > button,
  #library-page #library-review-actions > button {
    height: auto;
    padding: 10px;
    font-size: 12px;
  }
}
.photo-curation-status {
  display: inline-block;
  margin: 0 0 7px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
@media (max-width: 360px) {
  .gallery-overview-groups {
    gap: 16px 12px;
  }
  .gallery-overview-group + .gallery-overview-group {
    padding-left: 10px;
  }
  .gallery-overview-group:nth-child(2) {
    padding-left: 0;
  }
  .gallery-total-number {
    font-size: 25px;
  }
  .gallery-total-number small {
    margin-left: 4px;
    font-size: 11px;
  }
  .gallery-overview-metrics > div {
    flex-wrap: wrap;
    gap: 1px 6px;
  }
  .gallery-submetric dt {
    padding-left: 0;
    font-size: 11px;
  }
}

.photo-card-confirm {
  min-height: 44px;
  padding: 9px 14px;
  font-size: 13px;
  background: var(--paper);
  box-shadow: 0 2px 8px #0003;
}
.photo-card-confirm:disabled {
  opacity: 0.85;
}

/* Actions share the text footer and never cover the fabric image. */
.photo-card-actions {
  position: absolute;
  right: 14px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 112px;
  z-index: 2;
}
.photo-card .result-info {
  padding-right: 142px;
  min-height: 158px;
}
.photo-card-actions button {
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  box-shadow: none;
}
.photo-duplicate-status {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.photo-duplicate-status.duplicate-pending,
.photo-duplicate-status.duplicate-failed {
  font-weight: 700;
  color: var(--ink);
}
.photo-card-shell[data-duplicate-state="pending"] .result-info,
.photo-card-shell[data-duplicate-state="failed"] .result-info {
  min-height: 210px;
}
.photo-card-duplicate,
#library-review-actions .has-pending {
  border-width: 2px;
  font-weight: 700;
}
.duplicate-scan-status {
  flex: 1 0 100%;
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
}
.duplicate-group-progress {
  font-weight: 600;
  margin: 10px 0;
}
.duplicate-review-navigation {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.duplicate-review-navigation button {
  min-height: 44px;
}
.photo-card-shell[data-duplicate-state="pending"] > .photo-card {
  height: auto;
}
.photo-card-shell[data-duplicate-state="pending"] .result-info {
  padding: 16px;
  min-height: 0;
}
.photo-card-shell[data-duplicate-state="pending"] .photo-card-actions {
  position: static;
  width: auto;
  padding: 8px 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.inline-duplicate-review {
  margin: 8px 0 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
}
.duplicate-review-group {
  grid-column: 1 / -1;
}
.duplicate-suppressed {
  display: none !important;
}
.duplicate-review-group .inline-duplicate-review .upload-review-images img {
  height: clamp(220px, 38vw, 480px);
  max-height: 480px;
}
.inline-duplicate-review h4 {
  margin: 0 0 10px;
  font-size: 16px;
}
.inline-duplicate-review p {
  font-size: 12px;
  line-height: 1.6;
}
.inline-duplicate-review .upload-review-images {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.inline-duplicate-review .upload-review-images img {
  height: 220px;
  max-height: 220px;
  object-fit: contain;
}
.inline-duplicate-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.inline-duplicate-actions button {
  min-height: 44px;
  padding: 8px;
  font-size: 12px;
}
@media (max-width: 360px) {
  .photo-card-actions {
    width: 98px;
    right: 12px;
  }
  .photo-card .result-info {
    padding-right: 126px;
  }
}
.query-actions #known-model-open {
  flex: 1 1 180px;
}
#query-panel .known-model {
  margin-top: 14px;
  padding-top: 12px;
}

/* Text search shares the same gallery, result cards and immutable history. */
.search-mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 20px;
}
.search-mode-switch button {
  min-height: 44px;
  padding: 9px 22px;
}
.search-mode-switch button[aria-pressed="true"] {
  background: var(--primary);
  color: var(--paper);
  border-color: var(--primary);
}
.text-search-panel {
  padding: 24px;
  margin: 0 0 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}
.text-search-panel h2 {
  margin: 8px 0;
  font-size: 25px;
  font-weight: 500;
}
.text-search-panel p {
  line-height: 1.7;
  overflow-wrap: anywhere;
}
#text-search-query {
  display: block;
  width: 100%;
  min-height: 108px;
  resize: vertical;
  padding: 14px;
  margin-top: 16px;
  font: inherit;
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.text-search-examples,
.text-search-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.text-search-examples button {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 13px;
}
#text-search-coverage,
#text-search-progress {
  margin: 12px 0 0;
}
#text-search-error:empty {
  display: none;
}
.result-info .result-match-reason {
  color: var(--ink);
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.text-history-preview {
  display: flex;
  min-width: 0;
  min-height: 220px;
  padding: 22px;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  text-align: left;
  background: var(--bg);
  color: var(--ink);
}
.text-history-preview p {
  margin: 0;
  line-height: 1.7;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#detail-query-text,
#detail-match-reason {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.comparison.single.with-match {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 760px) {
  .search-mode-switch {
    margin-bottom: 14px;
  }
  .search-mode-switch button {
    flex: 1;
  }
  .text-search-panel {
    padding: 16px;
    margin-bottom: 18px;
  }
  .text-search-panel h2 {
    font-size: 22px;
  }
  .text-search-actions .primary {
    flex: 1;
  }
  [data-theme^="schnauzer"] #history-grid .text-history-preview {
    min-height: 110px;
    padding: 10px;
    gap: 6px;
    font-size: 12px;
  }
  [data-theme^="schnauzer"] #history-grid .text-history-preview .small-number {
    font-size: 10px;
    letter-spacing: 0;
  }
  .comparison.single.with-match > .cloth-detail {
    grid-column: auto;
  }
}
@media (max-width: 600px) {
  .query-actions #known-model-open {
    grid-column: 1 / -1;
  }
}
.text-search-guide {
  margin: 16px 0;
  font-size: 14px;
  line-height: 1.7;
}
.text-search-guide summary {
  cursor: pointer;
  font-weight: 600;
}
.text-search-guide p {
  margin: 10px 0;
}

.inline-duplicate-review.duplicate-saving .upload-review-images,
.inline-duplicate-review.duplicate-saving .inline-duplicate-actions {
  display: none;
}
.duplicate-save-notice {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}
.duplicate-save-notice p {
  margin: 0 0 6px;
  font-size: 13px;
}

.feedback-overview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
}
#feedback-overview-summary {
  margin: 0 0 12px;
  line-height: 1.6;
}
.feedback-overview-toolbar {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) minmax(9rem, 2fr) auto;
  align-items: end;
  gap: 10px;
}
.feedback-overview-field {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.feedback-overview-field :is(input, select) {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.feedback-overview-toolbar :is(select, input):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.feedback-overview-filter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.feedback-overview-filter-actions button {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 10px;
}
.feedback-overview-check {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 6px;
  padding-inline: 4px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.feedback-overview-check input {
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}
.feedback-overview-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
.feedback-overview-record {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.85rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
}
.feedback-overview-record img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
}
.feedback-overview-record p {
  margin: 0.32rem 0 0.55rem;
  overflow-wrap: anywhere;
}
.feedback-overview-record .feedback-overview-actions button {
  min-height: 36px;
}
#feedback-index-dialog {
  max-width: min(480px, 94vw);
}
@media (max-width: 760px) {
  .feedback-overview-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .feedback-overview-filter-actions {
    grid-column: 1 / -1;
  }
  .feedback-overview-check {
    margin-inline-end: auto;
  }
}
@media (max-width: 480px) {
  .feedback-overview-record img {
    width: 52px;
    height: 52px;
  }
}

.text-search-tasks {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.text-search-tasks-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.text-search-tasks-heading h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}
#text-search-task-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 420px;
  overflow-y: auto;
}
.text-search-task {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.text-search-task > div {
  min-width: 0;
}
.text-search-task p {
  margin: 0 0 4px;
}
.text-search-task .quiet {
  font-size: 12px;
  line-height: 1.6;
}
.text-search-task button {
  flex-shrink: 0;
  min-height: 44px;
}
@media (max-width: 520px) {
  .text-search-task {
    flex-wrap: wrap;
    gap: 8px;
  }
  .text-search-task > div {
    width: 100%;
  }
}

#batch-search {margin:22px 0}
#batch-rows {display:grid;gap:8px;margin-top:14px}
.batch-search-row {display:flex;align-items:center;gap:8px;padding:10px;border:1px solid var(--line);background:var(--paper);border-radius:12px;min-height:84px}
.batch-search-row img {width:clamp(40px,12vw,72px);height:60px;object-fit:cover;border-radius:7px}
.batch-search-row div {display:grid;flex:1;min-width:0;overflow-wrap:anywhere}
.batch-search-row small,.batch-search-row span {font-size:12px}
.batch-search-row button {padding:8px}

/* Keep the same touch target in the page and in the modal top layer. */
button.batch-return-float, button.context-return {
  position: fixed;
  left: calc(12px + env(safe-area-inset-left, 0px));
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 12;
  min-height: 56px;
  font-size: 18px;
  line-height: 1.3;
  padding: 12px 22px;
  border-radius: 28px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 3px 14px #0003;
}
#search-page:has(#batch-return:not(.hidden)) { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
dialog#detail-dialog:has(> .batch-return-float:not(.hidden)) > .dialog-bottom {
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}


/* Batch comparisons keep their existing direct route to the batch list. */
#detail-dialog:has(> .batch-return-float:not(.hidden)) > .context-return { display:none; }
#search-page:has(#history-return:not(.hidden)),
dialog.fabric-dialog:has(> .context-return),
dialog#region-inspect-dialog:has(> .context-return),
dialog#image-dialog:has(> .context-return) {
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
}
dialog#detail-dialog:has(> .context-return) > .dialog-bottom {
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
}
