.photo-tool-page {
  --photo-paper: #f2f5fb;
  --photo-card: #fff;
  --photo-ink: #0f172a;
  --photo-muted: #475569;
  --photo-line: #64748b;
  --photo-edge: #e3e7ef;
  --photo-soft: #e8f0ff;
  --photo-accent: #245ce8;
  --photo-button: #2f6df6;
  --photo-button-text: #fff;
  --photo-shadow: 0 8px 24px rgba(15, 23, 42, .08);
  background: var(--photo-paper);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .photo-tool-page {
    --photo-paper: #11161f; --photo-card: #171e2b; --photo-ink: #e5e7eb; --photo-muted: #9ca3af;
    --photo-line: #8492a6; --photo-edge: #202a3f; --photo-soft: #1b2436; --photo-accent: #60a5fa;
    --photo-button: #60a5fa; --photo-button-text: #0f172a; --photo-shadow: 0 12px 40px rgba(0, 0, 0, .45);
  }
}
html[data-theme="dark"] .photo-tool-page {
  --photo-paper: #11161f; --photo-card: #171e2b; --photo-ink: #e5e7eb; --photo-muted: #9ca3af;
  --photo-line: #8492a6; --photo-edge: #202a3f; --photo-soft: #1b2436; --photo-accent: #60a5fa;
  --photo-button: #60a5fa; --photo-button-text: #0f172a; --photo-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
.photo-tool {
  box-sizing: border-box; max-width: 71rem; margin: 0 auto; padding: 6.5rem 2rem 4rem;
  font: 400 1rem/1.5 Inter, "Segoe UI", system-ui, sans-serif; color: var(--photo-ink); overflow-wrap: anywhere;
}
.photo-tool *, .photo-tool *::before, .photo-tool *::after {box-sizing: border-box;}
.photo-tool [hidden] {display: none !important;}
/* The shared no-JS notice stays in the footer so it cannot cover the working forms. */
.photo-tool-page .ns-wrap {position: static; display: block; width: fit-content; max-width: 92%; margin: .75rem auto;}
.photo-tool h1, .photo-tool h2, .photo-tool p, .photo-tool legend, .photo-tool label {color: inherit; margin: 0;}
.photo-tool h1, .photo-tool h2 {font-family: inherit; text-wrap: balance;}
.photo-tool h1 {font-size: clamp(2rem, 1.35rem + 2.9vw, 3.55rem); line-height: 1.08; letter-spacing: -.045em; font-weight: 750;}
.photo-tool .photo-back {display: inline-flex; align-items: center; gap: .3em; margin-bottom: .65rem; font-size: .94rem; color: var(--photo-accent); font-weight: 650; text-decoration: underline; text-underline-offset: .18em;}
.photo-tool .photo-intro {margin: .55rem 0 .95rem; max-width: 64ch; color: var(--photo-muted);}
.photo-library {max-width: 48rem; margin: 0 0 1.45rem; scroll-margin-top: 5rem;}
.photo-searchbar {display: flex; align-items: center; gap: .55rem; min-width: 0; padding: .25rem .3rem .25rem .85rem; background: var(--photo-card); border: 1px solid var(--photo-line); border-radius: .75rem; box-shadow: var(--photo-shadow);}
.photo-searchbar > span {color: var(--photo-accent);}
.photo-searchbar:focus-within {outline: 2px solid var(--photo-accent); outline-offset: 2px;}
.photo-tool .photo-searchbar input {flex: 1; min-width: 0; width: 100%; padding: .35rem 0; border: 0; background: transparent; color: var(--photo-ink); font: inherit; appearance: none;}
.photo-tool .photo-searchbar input:focus-visible {outline: 0;}
.photo-searchbar button, .photo-search-actions button, .photo-filter-submit {
  min-height: 2.75rem; padding: .35rem .8rem; border: 1px solid var(--photo-edge); border-radius: .5rem;
  background: var(--photo-soft); color: var(--photo-accent); font: inherit; font-size: .95rem; font-weight: 650; cursor: pointer;
}
.photo-searchbar button {flex: none;}
.photo-searchbar button:hover, .photo-search-actions button:hover {border-color: var(--photo-accent);}
.photo-library-panel {margin: 0 0 1.8rem; scroll-margin-top: 5rem;}
.photo-gallery-heading {display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem .75rem; margin-bottom: .7rem;}
.photo-tool .photo-library-panel h2 {margin: 0; font-size: clamp(1.3rem, 1rem + 1.2vw, 1.85rem); line-height: 1.2; letter-spacing: -.025em;}
#photo-gallery-search {display: none; color: var(--photo-accent); font-weight: 650; text-decoration: underline; text-underline-offset: .18em;}
#photo-gallery-home #photo-gallery-search {display: inline-flex; align-items: center; min-height: 2.75rem;}
#photo-search {scroll-margin-top: 6rem;}
#photo-gallery-home:not(:empty) {margin-top: 2.25rem; border-top: 1px solid var(--photo-edge); padding-top: 1.65rem;}
.photo-library-panel .photo-search-filters {display: flex; flex-wrap: wrap; gap: .4rem;}
.photo-filter-submit {margin-top: .6rem;}
.photo-search-filters label {position: relative; cursor: pointer;}
.photo-search-filters label span {display: inline-flex; align-items: center; min-height: 2.5rem; padding: .3rem .68rem; border: 1px solid var(--photo-line); border-radius: 1.5rem; font-size: .92rem; font-weight: 600;}
.photo-search-filters input:checked + span {background: var(--photo-button); color: var(--photo-button-text); border-color: var(--photo-button);}
.photo-tool .photo-search-count {color: var(--photo-muted); margin: .6rem 0 .65rem; font-size: .9rem;}
.photo-search-results {display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); list-style: none; padding: 0; margin: 0; gap: 1rem;}
.photo-search-results li {min-width: 0; margin: 0;}
.photo-search-results a {display: flex; flex-direction: column; height: 100%; overflow: hidden; border: 1px solid var(--photo-edge); border-radius: .75rem; background: var(--photo-card); color: var(--photo-ink); text-decoration: none;}
.photo-card-image {display: block; width: 100%; height: auto; aspect-ratio: 1; background: var(--photo-soft);}
.photo-card-caption {display: flex; align-items: center; justify-content: space-between; flex: 1; gap: .5rem; padding: .65rem .8rem;}
.photo-search-results a:hover, .photo-search-results a:focus-visible, .photo-search-results a[aria-current="true"] {border-color: var(--photo-accent); color: var(--photo-accent);}
.photo-search-results a[aria-current="true"] .photo-result-arrow {font-size: 0;}
.photo-search-results a[aria-current="true"] .photo-result-arrow::after {content: '✓'; font-size: 1.1rem;}
.photo-search-results strong, .photo-search-results small {display: block; line-height: 1.35;}
.photo-search-results small {margin-top: .1rem; color: var(--photo-muted); font-size: .85rem;}
.photo-result-arrow {color: var(--photo-accent); font-size: 1.2rem;}
.photo-search-actions {display: flex; flex-wrap: wrap; gap: .5rem;}
.photo-search-actions button {margin-top: .65rem;}
.photo-workbench {display: grid; grid-template-columns: minmax(0, 1.24fr) minmax(0, 1fr); gap: clamp(1.2rem, 3vw, 2.3rem); align-items: start; margin: 0;}
.photo-tool fieldset {min-width: 0; padding: 0; margin: 0; border: 0;}
.photo-tool legend, .photo-result h2 {float: none; width: auto; margin: 0 0 .65rem; font-size: 1.18rem; font-weight: 720; line-height: 1.3; letter-spacing: -.02em;}
.photo-look-grid, .photo-format-grid {display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 5.4rem), 1fr)); gap: .6rem;}
.photo-look, .photo-format {display: block; position: relative; cursor: pointer;}
.photo-look input, .photo-format input, .photo-search-filters input, .photo-sr {position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;}
.photo-look-face {display: block; position: relative; overflow: hidden; background: var(--photo-card); border: 2px solid var(--photo-edge); border-radius: .72rem;}
.photo-look img {display: block; width: 100%; height: auto; aspect-ratio: 16/15; object-fit: cover;}
.photo-look strong {display: block; padding: .5rem .55rem; font-size: 1rem; line-height: 1.35;}
.photo-tick {position: absolute; inset: .4rem .4rem auto auto; display: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 1px solid #fff; color: #fff; background: #4633af; text-align: center; font: 700 1rem/1.4 system-ui;}
.photo-look input:checked + span {border-color: var(--photo-accent); color: var(--photo-accent);}
.photo-look input:checked + span .photo-tick {display: block;}
.photo-tool .photo-formats {margin-top: 1.35rem;}
.photo-format > span {min-height: 2.8rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .3em; padding: .35rem; border: 1px solid var(--photo-line); border-radius: .5rem; background: var(--photo-card); font-weight: 650;}
.photo-format input:checked + span {border-color: var(--photo-accent); box-shadow: inset 0 0 0 1px var(--photo-accent); color: var(--photo-accent); background: var(--photo-soft);}
.photo-format small {font-size: .81rem; font-weight: 500;}
.photo-frame {display: inline-block; height: .84em; width: .84em; border: 1.7px solid currentColor; border-radius: 2px;}
.photo-frame-feed {width: .69em;} .photo-frame-story {width: .52em;}
.photo-details {margin-top: 1rem; border-top: 1px solid var(--photo-edge);}
.photo-details summary {padding: .65rem 0; min-height: 2.75rem; color: var(--photo-accent); font-weight: 660; cursor: pointer;}
.photo-detail-body {display: grid; gap: .9rem; padding-bottom: .3rem;}
.photo-tool input[type="text"], .photo-tool select, .photo-tool textarea {
  display: block; width: 100%; min-width: 0; min-height: 2.75rem; border: 1px solid var(--photo-line); border-radius: .45rem;
  padding: .52rem .65rem; color: var(--photo-ink); background: var(--photo-card); font-family: inherit; font-size: 1rem; font-weight: 400; line-height: 1.45;
}
.photo-tool textarea {resize: vertical;}
.photo-tool input::placeholder, .photo-tool textarea::placeholder {color: var(--photo-muted); opacity: 1;}
.photo-detail-body label, .photo-provider label {display: block; font-size: .95rem; font-weight: 650;}
.photo-selects, .photo-input-row {display: flex; align-items: end; gap: .55rem;}
.photo-selects label {flex: 1; min-width: 0;}
.photo-detail-body select, .photo-input-row, .photo-notes textarea {margin-top: .25rem;}
.photo-idea button, .photo-privacy {background: var(--photo-card); color: var(--photo-accent); border: 1px solid var(--photo-line); border-radius: .45rem; min-height: 2.75rem; padding: .48rem .7rem; font: inherit; font-weight: 630; cursor: pointer;}
.photo-input-row button {flex-shrink: 0;}
.photo-idea p:not(:empty), .photo-idea #photo-options:not(:empty) {margin-top: .45rem;}
.photo-idea #photo-options {display: flex; flex-wrap: wrap; gap: .4rem;}
.photo-tool .photo-result {min-width: 0; padding: clamp(1rem, 2.4vw, 1.65rem); border: 1px solid var(--photo-edge); border-radius: .9rem; background: var(--photo-card); box-shadow: var(--photo-shadow);}
.photo-result-heading {display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .25rem .6rem; margin-bottom: .65rem;}
.photo-result h2 {margin: 0;}
.photo-result-heading span {color: var(--photo-muted); font-size: .875rem;}
.photo-tool #photo-output {font-family: inherit; background: var(--photo-soft); line-height: 1.48; height: 10.8rem; padding: .7rem .85rem;}
.photo-copy {width: 100%; min-height: 2.95rem; margin-top: .75rem; border: 0; border-radius: .5rem; background: var(--photo-button); color: var(--photo-button-text); font: inherit; font-weight: 700; cursor: pointer;}
.photo-copy:disabled {opacity: .65; cursor: default;}
.photo-tool .photo-status:not(:empty) {margin-top: .3rem; color: var(--photo-accent);}
.photo-provider {display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; margin: .9rem 0 .35rem;}
.photo-provider select {width: auto; max-width: 100%; min-height: 2.55rem;}
.photo-provider a {margin-inline-start: auto;}
.photo-provider a, .photo-idea a {color: var(--photo-accent); text-underline-offset: .2em; text-decoration: underline; font-weight: 650;}
.photo-tool .photo-how {color: var(--photo-muted); font-size: .93rem; line-height: 1.5;}
.photo-guide {margin: 2rem 0 0; max-width: 64ch;}
.photo-guide h2 {font-size: 1.2rem;}
.photo-tool .photo-guide p {margin-block: .45rem; color: var(--photo-muted);}
.photo-guide a {color: var(--photo-accent); text-underline-offset: .2em;}
.photo-tool {text-align: start;}
.photo-tool [name="prompt_lang"] {margin-block-start: .25rem;}
html[dir="rtl"] .photo-tool {letter-spacing: normal;}
html[dir="rtl"] .photo-tool h1, html[dir="rtl"] .photo-tool h2 {letter-spacing: normal; line-height: 1.35;}
html[dir="rtl"] .photo-result-arrow, html[dir="rtl"] .photo-back > span {display: inline-block; transform: scaleX(-1);}
html[dir="rtl"] .photo-search-results a[aria-current="true"] .photo-result-arrow {transform: none;}
.photo-tool #photo-output {text-align: start;}
.photo-example {margin: 1rem 0 0; padding-top: .8rem; border-top: 1px solid var(--photo-edge);}
.photo-example figcaption {display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .15rem .55rem; margin: 0 0 .45rem; color: var(--photo-muted); font-size: .86rem;}
.photo-example figcaption strong {color: var(--photo-ink); font-weight: 650;}
.photo-example img {display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: .55rem; background: var(--photo-soft);}
.photo-privacy {margin-top: 1.4rem; font-size: .9rem;}
.photo-tool :focus-visible, .photo-look input:focus-visible + span, .photo-format input:focus-visible + span, .photo-search-filters input:focus-visible + span {outline: 3px solid var(--photo-accent); outline-offset: 3px;}
@media (max-width: 48rem) {
  .photo-tool {padding: 5.1rem 1rem 2.5rem;}
  .photo-tool .photo-intro {margin: .45rem 0 .6rem;}
  .photo-library {margin-bottom: .8rem;}
  .photo-library-panel {margin-bottom: 1.35rem;}
  .photo-library-panel .photo-search-filters {gap: .3rem;}
  .photo-search-results {grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem;}
  .photo-card-caption {padding: .45rem .55rem; font-size: .94rem;}
  .photo-search-filters label span {padding-inline: .55rem; font-size: .875rem;}
  .photo-workbench {grid-template-columns: minmax(0, 1fr); gap: .45rem;}
  .photo-look img {aspect-ratio: 1.55;}
  .photo-tool .photo-formats {margin-top: .85rem;}
  .photo-details {margin-top: .65rem;}
  .photo-tool #photo-output {height: 6.1rem;}
  .photo-result-heading {margin-bottom: .4rem;}
  .photo-look-grid, .photo-format-grid {gap: .4rem;}
}
@media (max-width: 24rem) {
  .photo-tool {padding-inline: .75rem;}
  .photo-look strong {font-size: .9rem; padding: .4rem;}
  .photo-frame {display: none;}
  .photo-input-row {align-items: stretch; flex-direction: column;}
}
@media (max-width: 21rem) {
  .photo-searchbar {gap: .35rem; padding-inline-start: .6rem;}
  .photo-searchbar button {padding-inline: .55rem;}
  .photo-library-panel .photo-search-filters {display: grid; grid-template-columns: 1fr 1fr;}
  .photo-search-filters label span {width: 100%; justify-content: center;}
}
@media (max-width: 48rem) and (max-height: 48rem) {
  .photo-tool {padding-top: 4.25rem;}
  .photo-tool .photo-back {margin-bottom: .25rem;}
  .photo-tool .photo-intro {display: none;}
  .photo-library {margin: .45rem 0 .55rem;}
  .photo-look img {aspect-ratio: 2;}
  .photo-tool .photo-formats {margin-top: .55rem;}
  .photo-details {margin-top: .35rem;}
  .photo-result-heading + .photo-copy {margin: 0 0 .55rem;}
}
@media (max-width: 24rem) and (max-height: 38rem) {
  .photo-tool .photo-back {display: none;}
  .photo-tool h1 {font-size: 1.8rem;}
}
