/* PTS-CSS-TOKENS: design variables and base theme tokens */
:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #fbfdff;
  --header-bg: rgba(255, 255, 255, 0.92);
  --control-bg: #fbfdff;
  --control-hover: #f3f7ff;
  --button-soft: #eff5ff;
  --button-soft-hover: #e3ecff;
  --button-soft-border: #c9d9ff;
  --ink: #121826;
  --label: #334155;
  --muted: #657084;
  --line: #dfe5ef;
  --line-strong: #c9d3e2;
  --accent: #2368f2;
  --accent-dark: #174fc1;
  --accent-soft: #e8f0ff;
  --success: #168a55;
  --danger: #ba2d2d;
  --success-soft: #e8f7ee;
  --danger-soft: #fff0f0;
  --checker-a: #f8fafc;
  --checker-b: #ffffff;
  --empty: #8a96aa;
  --crop-shade: rgba(15, 23, 42, 0.34);
  --crop-stripe: rgba(255, 255, 255, 0.28);
  --blur-mask: rgba(35, 104, 242, 0.36);
  --focus-ring: rgba(35, 104, 242, 0.12);
  --shadow: 0 18px 48px rgba(28, 39, 58, 0.11);
  --radius: 8px;
}

/* PTS-CSS-THEMES: light/dark theme token overrides */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10141d;
  --panel: #171d29;
  --panel-soft: #1d2533;
  --header-bg: rgba(16, 20, 29, 0.94);
  --control-bg: #111827;
  --control-hover: #202b3c;
  --button-soft: #1f2d44;
  --button-soft-hover: #263957;
  --button-soft-border: #39506f;
  --ink: #edf3ff;
  --label: #d6e0ef;
  --muted: #9eacc0;
  --line: #2a3547;
  --line-strong: #3a4a62;
  --accent: #6ea0ff;
  --accent-dark: #9bbcff;
  --accent-soft: #1f2d44;
  --success: #5fd19a;
  --danger: #ff7a7a;
  --success-soft: #173526;
  --danger-soft: #3a1d22;
  --checker-a: #202838;
  --checker-b: #151b27;
  --empty: #8796ad;
  --crop-shade: rgba(0, 0, 0, 0.58);
  --crop-stripe: rgba(110, 160, 255, 0.26);
  --blur-mask: rgba(110, 160, 255, 0.42);
  --focus-ring: rgba(110, 160, 255, 0.18);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
}

/* PTS-CSS-LAYOUT: global page layout, header, workspace, and access shell */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
}

.brand,
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.brand {
  font-size: 18px;
  font-weight: 760;
  letter-spacing: 0;
}

.brand-logo {
  width: 28px;
  height: 28px;
  display: block;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
}

.theme-toggle {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--panel-soft);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--line-strong);
  background: var(--control-hover);
}

.theme-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset -5px -4px 0 rgba(255, 255, 255, 0.72);
}

.kofi-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--button-soft-border);
  border-radius: 999px;
  background: var(--button-soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 780;
  text-decoration: none;
}

.kofi-button:hover {
  background: var(--button-soft-hover);
}

.kofi-button img {
  width: 22px;
  height: 22px;
  display: block;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(420px, 1fr) minmax(250px, 310px);
  gap: 22px;
  padding: 28px;
  max-width: 1440px;
  margin: 0 auto;
}

.access-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 28px 0;
}

.optional-access summary {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--panel-soft);
  font-size: 13px;
  font-weight: 780;
  cursor: pointer;
}

.optional-access:not([open]) {
  padding-bottom: 0;
}

.access-wide {
  grid-template-columns: minmax(190px, 1fr) auto minmax(280px, 420px);
  align-items: center;
  margin-bottom: 0;
}

/* PTS-CSS-CARDS: home screen tool cards and speed badges */
.tool-home {
  max-width: 1120px;
  margin: 0 auto;
  padding: 42px 28px 52px;
}

.tool-intro {
  max-width: 620px;
  margin-bottom: 22px;
}

.tool-intro h1 {
  margin: 0;
  color: var(--ink);
  font-size: 38px;
  line-height: 1.08;
  letter-spacing: 0;
}

.tool-intro p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.tool-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.tool-card {
  position: relative;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  color: var(--ink);
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 22px 56px rgba(28, 39, 58, 0.14);
}

.tool-card strong {
  display: block;
  font-size: 20px;
  line-height: 1.2;
}

.tool-card small {
  display: block;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.tool-card-copy {
  display: grid;
  gap: 10px;
  width: 100%;
}

.tool-card-notes {
  display: grid;
  gap: 7px;
  width: 100%;
  margin-top: 2px;
}

.tool-card-note {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.tool-card-note-label {
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.tool-card-note--speed {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  display: inline-flex;
  grid-template-columns: none;
  gap: 8px;
  width: auto;
  max-width: calc(100% - 112px);
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
}

.tool-speed {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-weight: 700;
}

.tool-speed-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.tool-speed--fast {
  color: #16a86a;
}

.tool-speed--medium {
  color: #bf8b00;
}

.tool-speed--slow {
  color: #d9485f;
}

@media (max-width: 420px) {
  .tool-card-note--speed {
    top: 14px;
    right: 14px;
    max-width: calc(100% - 104px);
  }
}

.tool-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel-soft);
  position: relative;
}

.tool-icon img {
  display: block;
  width: 100%;
  height: 100%;
  padding: 7px;
}

.editor-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(420px, 1fr);
  gap: 22px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px;
}

.editor-panel {
  align-self: start;
}

.panel,
.preview-area {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-heading h1,
.panel-heading h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.18;
  letter-spacing: 0;
}

.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.api-key-field {
  display: grid;
  gap: 8px;
  color: var(--label);
  font-size: 13px;
  font-weight: 720;
}

.access-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.access-card h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.access-card p,
.access-card small {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.api-key-field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--control-bg);
  outline: none;
}

.api-key-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.api-key-remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  user-select: none;
}

.api-key-remember input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.small-button,
.key-row button {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 7px;
  background: var(--button-soft);
  color: var(--accent-dark);
  border: 1px solid var(--button-soft-border);
  font-size: 13px;
  font-weight: 780;
  cursor: pointer;
}

.small-button:hover,
.key-row button:hover {
  background: var(--button-soft-hover);
}

.small-button:disabled,
.key-row button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* PTS-CSS-UPLOAD: drop zones, file rows, and selected file metadata */
.drop-zone {
  min-height: 218px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragover {
  border-color: var(--accent);
  background: var(--control-hover);
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-zone strong {
  font-size: 17px;
}

.drop-zone small,
.file-row small {
  color: var(--muted);
  font-size: 13px;
}

.drop-zone small {
  max-width: min(100%, 34ch);
  text-align: center;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.drop-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--button-soft-border);
  position: relative;
}

.drop-icon::before,
.drop-icon::after {
  content: "";
  position: absolute;
  background: var(--accent);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.drop-icon::before {
  width: 18px;
  height: 2px;
}

.drop-icon::after {
  width: 2px;
  height: 18px;
}

.file-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  min-width: 0;
}

.file-row > div {
  min-width: 0;
  flex: 1 1 auto;
}

/* PTS-CSS-QUEUE: queue lists, queue states, and per-file download links */
.queue-block {
  margin: 18px 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.queue-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--label);
  font-size: 14px;
  font-weight: 780;
}

.queue-heading button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 720;
  cursor: pointer;
}

.queue-file {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  min-width: 0;
}

.queue-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}

.queue-file:not(.is-empty) {
  border-color: var(--accent);
  background: var(--panel-soft);
}

.queue-file.is-processing,
.queue-file.is-uploading {
  border-color: var(--accent);
}

.queue-file.is-done {
  border-color: var(--success);
}

.queue-file.is-failed {
  border-color: var(--danger);
}

.queue-file strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-file small {
  color: var(--muted);
  font-size: 13px;
}

.queue-file-meta {
  min-width: 0;
  flex: 1 1 auto;
}

.queue-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 7px;
  background: var(--button-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 780;
  white-space: nowrap;
}

.queue-status.is-waiting {
  color: var(--muted);
}

.queue-status.is-processing,
.queue-status.is-uploading {
  color: var(--accent-dark);
}

.queue-status.is-done {
  color: var(--success);
  background: var(--success-soft);
}

.queue-status.is-failed {
  color: var(--danger);
  background: var(--danger-soft);
}

.queue-download {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--button-soft-border);
  border-radius: 7px;
  background: var(--button-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 780;
  text-decoration: none;
  white-space: nowrap;
}

.queue-help {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.archive-inline-note {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.thumb-placeholder {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent-soft), var(--panel));
  border: 1px solid var(--line);
}

.queue-file:not(.is-empty) .thumb-placeholder {
  background-size: cover;
  background-position: center;
}

.local-note {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.local-note span {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  position: relative;
}

.local-note span::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 5px;
  left: 4px;
  top: 5px;
  border-left: 2px solid var(--success);
  border-bottom: 2px solid var(--success);
  transform: rotate(-45deg);
}

.local-note p {
  margin: 0;
}

.file-row strong {
  display: block;
  max-width: 210px;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--line-strong);
}

.file-row:not(.is-empty) .file-dot {
  background: var(--success);
}

/* PTS-CSS-CONTROLS: buttons and bulk download controls */
.primary-button,
.secondary-button {
  width: 100%;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 780;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(35, 104, 242, 0.24);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.primary-button:disabled,
.secondary-button.is-disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary-button {
  margin-top: 18px;
  background: var(--button-soft);
  color: var(--accent-dark);
  border-color: var(--button-soft-border);
}

.bulk-download-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.bulk-download-actions .secondary-button {
  margin-top: 0;
}

.editor-reset-button {
  margin-top: 10px;
}

.process-action {
  margin-top: 18px;
}

/* PTS-CSS-PREVIEW: image preview, result frames, and empty states */
.preview-area {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px;
}

.preview-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.preview-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-title {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--label);
  font-size: 14px;
  font-weight: 780;
}

.metadata-preview-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.metadata-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.metadata-preview-header > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.metadata-preview-header strong {
  color: var(--ink);
  font-size: 15px;
}

.metadata-preview-header small,
.metadata-copy-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.metadata-copy-button {
  min-height: 32px;
  flex: 0 0 auto;
  padding: 0 10px;
}

.metadata-summary-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.metadata-summary-list div {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(82px, max-content) minmax(0, 1fr);
  align-items: start;
  gap: 6px 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.metadata-summary-list dt {
  color: var(--label);
  font-size: 12px;
  font-weight: 780;
}

.metadata-summary-list dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: normal;
}

.metadata-details {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.metadata-details summary {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 13px;
  font-weight: 780;
}

.metadata-details pre {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  padding: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.metadata-copy-status {
  min-height: 16px;
  color: var(--success);
}

#metadataWorkspace .preview-grid {
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
}

#metadataWorkspace .metadata-photo-column {
  min-width: 0;
}

.image-frame {
  position: relative;
  flex: 1;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, var(--checker-a) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-a) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-a) 75%),
    var(--checker-b);
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

#backgroundWorkspace .preview-grid {
  min-height: clamp(360px, 50vh, 560px);
}

#backgroundWorkspace .image-frame {
  min-height: clamp(280px, 40vh, 460px);
}

.square-frame {
  aspect-ratio: 1 / 1;
  flex: 0 1 auto;
  max-height: 620px;
  align-self: center;
  width: 100%;
  background: var(--checker-b);
}

/* PTS-CSS-STATUS: status cards, queue position cards, and progress bars */
.status-card {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.status-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.status-card-header strong {
  font-size: 15px;
}

#statusPill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 780;
}

#statusPill.is-ready {
  background: var(--success-soft);
  color: var(--success);
}

#statusPill.is-processing {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

#statusPill.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-log {
  min-height: 150px;
  list-style: none;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.status-log li::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--line-strong);
}

.status-log li.is-active {
  color: var(--accent-dark);
}

.status-log li.is-active::before {
  background: var(--accent);
}

.status-log li.is-done {
  color: var(--success);
}

.status-log li.is-done::before {
  background: var(--success);
}

.status-log li.is-error {
  color: var(--danger);
}

.status-log li.is-error::before {
  background: var(--danger);
}

.queue-position-card {
  display: grid;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.queue-position-card[hidden] {
  display: none;
}

.queue-position-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.queue-position-header strong {
  color: var(--ink);
  font-size: 15px;
}

#queuePositionPill,
.queue-position-header [data-queue-pill] {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 780;
  white-space: nowrap;
}

#queuePositionPill.is-processing,
.queue-position-header [data-queue-pill].is-processing {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

#queuePositionPill.is-error,
.queue-position-header [data-queue-pill].is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.queue-position-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.queue-position-grid div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.queue-position-grid span,
.queue-position-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.queue-position-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
}

.queue-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--button-soft);
}

#queueProgressFill,
.queue-progress-track [data-queue-progress] {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.image-frame img {
  display: none;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.image-frame.has-image img {
  display: block;
}

.empty-preview {
  position: absolute;
  color: var(--empty);
  font-size: 14px;
  font-weight: 720;
}

.image-frame.has-image .empty-preview {
  display: none;
}

/* PTS-CSS-FORM-CONTROLS: sliders, selects, color fields, and editor inputs */
.range-control,
.select-control {
  display: grid;
  gap: 8px;
  margin: 20px 0;
}

.toggle-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.toggle-control > span {
  display: grid;
  gap: 4px;
}

.toggle-control strong {
  color: var(--label);
  font-size: 14px;
}

.toggle-control small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.toggle-control input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.settings-group {
  margin: -6px 0 18px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
}

.settings-group[hidden] {
  display: none;
}

.range-control span,
.select-control span {
  display: flex;
  justify-content: space-between;
  color: var(--label);
  font-size: 14px;
  font-weight: 720;
}

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

.range-action-row .small-button {
  min-height: 34px;
  white-space: nowrap;
}

#compressWorkspace .range-action-row {
  grid-template-columns: minmax(220px, 1fr) max-content;
  gap: 8px;
}

#compressWithoutCompressionButton {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
  line-height: 1;
}

.range-control strong {
  color: var(--ink);
  font-size: 13px;
}

.range-control input {
  width: 100%;
  accent-color: var(--accent);
}

.select-control select,
.custom-size-fields input,
.crop-input-grid input {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) calc(50% - 3px) / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 13px) calc(50% - 3px) / 6px 6px no-repeat,
    var(--panel-soft);
  color: var(--ink);
  outline: none;
}

.select-control select:focus,
.custom-size-fields input:focus,
.crop-input-grid input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.custom-select {
  display: none;
}

.themed-select.is-disabled .themed-select-button {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.range-control small,
.select-control small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.custom-size-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: -4px 0 18px;
}

.custom-size-fields[hidden],
.is-hidden {
  display: none;
}

.custom-size-fields label {
  display: grid;
  gap: 7px;
  color: var(--label);
  font-size: 13px;
  font-weight: 720;
}

.color-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(104px, 0.65fr);
  align-items: end;
  gap: 10px;
  margin: 0 0 18px;
}

.color-fields label,
.file-control {
  display: grid;
  gap: 8px;
  color: var(--label);
  font-size: 13px;
  font-weight: 720;
}

.color-fields input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--control-bg);
}

.color-fields input[type="text"],
.file-control input {
  width: 100%;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--control-bg);
  color: var(--ink);
  outline: none;
}

.file-control input[type="file"] {
  padding: 0 0 0 10px;
  background: var(--panel-soft);
}

.file-control input[type="file"]::file-selector-button {
  margin-right: 10px;
  height: 30px;
  border: 1px solid var(--button-soft-border);
  border-radius: 999px;
  background: var(--button-soft);
  color: var(--accent-dark);
  font-weight: 720;
  cursor: pointer;
}

.file-control {
  margin: 0 0 18px;
}

.file-control small,
.selection-readout small,
.tool-message {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.compact-drop {
  min-height: 170px;
}

.selection-readout {
  display: grid;
  gap: 4px;
  padding: 12px;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.selection-readout strong {
  color: var(--ink);
  font-size: 14px;
}

.tool-message {
  min-height: 20px;
  margin: 14px 0 0;
}

.tool-message.is-error {
  color: var(--danger);
}

.tool-message.is-success {
  color: var(--success);
}

.crop-input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: -6px 0 18px;
}

.crop-input-grid label {
  display: grid;
  gap: 7px;
  color: var(--label);
  font-size: 13px;
  font-weight: 720;
}

/* PTS-CSS-EDITORS: crop/blur canvas preview and editor-specific layout */
.editor-preview {
  min-height: 560px;
}

.canvas-frame {
  position: relative;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, var(--checker-a) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-a) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-a) 75%),
    var(--checker-b);
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

.canvas-frame canvas {
  display: none;
  max-width: 100%;
  max-height: 680px;
  cursor: crosshair;
  touch-action: none;
}

.canvas-frame.has-image canvas {
  display: block;
}

.canvas-frame.has-image .empty-preview {
  display: none;
}

.privacy-footer {
  max-width: 1440px;
  margin: 0 auto 28px;
  padding: 0 28px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  flex-wrap: wrap;
}

.privacy-footer > span {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--success-soft);
  position: relative;
}

.privacy-footer > span::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 5px;
  left: 4px;
  top: 5px;
  border-left: 2px solid var(--success);
  border-bottom: 2px solid var(--success);
  transform: rotate(-45deg);
}

.privacy-footer p {
  margin: 0;
  flex: 1 1 420px;
  min-width: 0;
}

.privacy-footer strong {
  color: var(--accent-dark);
}

#ptsSettingsButton {
  margin-left: auto;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#ptsSettingsButton svg {
  width: 18px;
  height: 18px;
  display: block;
  flex: 0 0 auto;
}

.download-frame {
  display: none;
}

/* PTS-CSS-RESPONSIVE: media queries and small-screen layout */
@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .access-wide {
    grid-template-columns: 1fr;
  }

  .tool-cards,
  .editor-workspace {
    grid-template-columns: 1fr;
  }

  .upload-panel {
    order: 1;
  }

  .export-panel {
    order: 2;
  }

  .preview-area {
    order: 3;
  }

  .preview-grid {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .app-header {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
    gap: 12px;
  }

  .header-status {
    flex-wrap: wrap;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .kofi-button {
    flex: 1 1 auto;
  }

  .workspace {
    padding: 16px;
    gap: 16px;
  }

  .access-shell,
  .tool-home,
  .editor-workspace {
    padding: 16px;
  }

  .tool-intro h1 {
    font-size: 30px;
  }

  .preview-area,
  .preview-grid {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .preview-grid {
    display: grid;
  }

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

  #metadataWorkspace .metadata-photo-column {
    order: 1;
  }

  #metadataWorkspace .metadata-preview-panel {
    order: 2;
  }

  .image-frame {
    min-height: 320px;
  }

  .panel {
    padding: 18px;
  }

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

  .custom-size-fields {
    grid-template-columns: 1fr;
  }

  .crop-input-grid {
    grid-template-columns: 1fr 1fr;
  }

  .color-fields {
    grid-template-columns: 1fr;
  }

  .bulk-download-actions {
    grid-template-columns: 1fr;
  }

  .queue-position-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  #compressWorkspace .range-action-row {
    grid-template-columns: 1fr;
  }

  .queue-file {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .queue-status,
  .queue-download {
    margin-left: 58px;
  }

  .tool-card {
    min-height: 180px;
  }

  .canvas-frame {
    min-height: 320px;
  }

  .privacy-footer {
    align-items: flex-start;
    flex-direction: row;
    padding: 0 16px 18px;
  }
}

/* Stable UI corrections for the transparent theme layer. */
.tool-card {
  height: 100%;
}

.tool-card > .tool-icon {
  border-color: transparent;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  box-shadow: none;
}

.theme-toggle,
.kofi-button,
.tool-card {
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.theme-toggle:focus-visible,
.kofi-button:focus-visible,
.tool-card:focus-visible,
.queue-download:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

#backgroundWorkspace .queue-file,
#compressWorkspace .queue-file,
#formatWorkspace .queue-file {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) max-content max-content;
  align-items: center;
}

#backgroundWorkspace .queue-download,
#compressWorkspace .queue-download,
#formatWorkspace .queue-download {
  justify-self: end;
  margin-left: 0;
}

body > .privacy-footer {
  width: min(1440px, calc(100% - 56px));
}

@media (min-width: 1281px) {
  #backgroundWorkspace.workspace {
    max-width: 1840px;
    grid-template-columns: minmax(340px, 390px) minmax(760px, 1fr) minmax(300px, 360px);
  }

  #cropWorkspace.editor-workspace,
  #blurWorkspace.editor-workspace,
  #metadataWorkspace.editor-workspace {
    max-width: 1680px;
    grid-template-columns: minmax(320px, 380px) minmax(780px, 1fr);
  }

  #cropWorkspace .preview-grid,
  #blurWorkspace .preview-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  #metadataWorkspace .preview-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #cropWorkspace .canvas-frame,
  #blurWorkspace .canvas-frame,
  #cropWorkspace .image-frame,
  #blurWorkspace .image-frame,
  #metadataWorkspace .image-frame {
    min-height: 560px;
  }
}

@media (max-width: 720px) {
  #backgroundWorkspace .queue-file,
  #compressWorkspace .queue-file,
  #formatWorkspace .queue-file {
    grid-template-columns: 46px minmax(0, 1fr);
    row-gap: 8px;
  }

  #backgroundWorkspace .queue-status,
  #backgroundWorkspace .queue-download,
  #compressWorkspace .queue-status,
  #compressWorkspace .queue-download,
  #formatWorkspace .queue-status,
  #formatWorkspace .queue-download {
    margin-left: 58px;
  }

  body > .privacy-footer {
    width: calc(100% - 32px);
  }
}

/* v1.7.8 batch export tools */
.tool-cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tool-icon-compress {
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.tool-icon-format {
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.range-action-row .small-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

@media (min-width: 1281px) {
  #compressWorkspace.editor-workspace,
  #formatWorkspace.editor-workspace {
    max-width: 1680px;
    grid-template-columns: minmax(320px, 380px) minmax(780px, 1fr);
  }

  #compressWorkspace .preview-grid,
  #formatWorkspace .preview-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  #compressWorkspace .image-frame,
  #formatWorkspace .image-frame {
    min-height: 560px;
  }
}

@media (max-width: 1100px) {
  .tool-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .tool-cards {
    grid-template-columns: 1fr;
  }
}


/* clean icon fallback */
.tool-icon-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* v1.8.1 clean tool icons: one real IMG from /static/icons, no CSS icon backgrounds. */
body .tool-cards .tool-card[data-tool-open] > .tool-icon,
body .tool-cards .tool-card[data-tool-open]:hover > .tool-icon,
body .tool-cards .tool-card[data-tool-open]:focus-visible > .tool-icon {
  width: 56px;
  height: 56px;
  min-width: 56px;
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  position: relative;
  padding: 0;
  margin: 0;
  border: 0;
  outline: 0;
  border-radius: 0;
  background: transparent;
  background-color: transparent;
  background-image: none;
  box-shadow: none;
  filter: none;
  opacity: 1;
  visibility: visible;
  overflow: visible;
  line-height: 0;
}

body .tool-cards .tool-card[data-tool-open] > .tool-icon::before,
body .tool-cards .tool-card[data-tool-open] > .tool-icon::after,
body .tool-cards .tool-card[data-tool-open]:hover > .tool-icon::before,
body .tool-cards .tool-card[data-tool-open]:hover > .tool-icon::after,
body .tool-cards .tool-card[data-tool-open]:focus-visible > .tool-icon::before,
body .tool-cards .tool-card[data-tool-open]:focus-visible > .tool-icon::after {
  content: none;
  display: none;
  width: 0;
  height: 0;
  background: transparent;
  background-image: none;
  box-shadow: none;
  filter: none;
  opacity: 0;
  visibility: hidden;
}

html body .tool-cards .tool-card[data-tool-open] > .tool-icon > img.tool-icon-img,
html body .tool-cards .tool-card[data-tool-open]:hover > .tool-icon > img.tool-icon-img,
html body .tool-cards .tool-card[data-tool-open]:focus-visible > .tool-icon > img.tool-icon-img {
  all: unset;
  box-sizing: border-box;
  display: block;
  width: 56px;
  height: 56px;
  min-width: 56px;
  max-width: 56px;
  padding: 0;
  margin: 0;
  border: 0;
  outline: 0;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  background-color: transparent;
  background-image: none;
  box-shadow: none;
  filter: none;
  opacity: 1;
  visibility: visible;
  transform: none;
}



/* v1.8.2 isolated tool card icons.
   Source of truth: one real <img> loaded from /static/icons/.
   This deliberately avoids the old .tool-icon class so old icon CSS cannot hide, duplicate, or stack icons. */
.tool-card-icon {
  width: 56px;
  height: 56px;
  min-width: 56px;
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  position: relative;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  line-height: 0;
}

.tool-card-icon::before,
.tool-card-icon::after {
  content: none;
  display: none;
}

.tool-card-icon-img {
  width: 56px;
  height: 56px;
  min-width: 56px;
  max-width: 56px;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  box-shadow: none;
  opacity: 1;
  visibility: visible;
}

.tool-card:hover .tool-card-icon-img,
.tool-card:focus-visible .tool-card-icon-img {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.tool-card:hover .tool-card-icon,
.tool-card:focus-visible .tool-card-icon {
  transform: translateY(-1px) scale(1.025);
}

/* v1.8.3 tool card icons (light/dark pairs).
   Each tool card contains two <img> elements: one with .icon-light and one with .icon-dark.
   We hide all images by default, then show the appropriate one based on the document's theme attribute. */
.tool-card-icon img {
  /* Hide all icon images by default. The correct one will be revealed via theme rules below. */
  display: none;
  width: 56px;
  height: 56px;
  min-width: 56px;
  max-width: 56px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  object-fit: contain;
}

/* Show light version by default and when theme is explicitly light. */
html:not([data-theme="dark"]) .tool-card-icon img.icon-light,
html[data-theme="light"] .tool-card-icon img.icon-light {
  display: block;
}

/* Show dark version when theme is dark. */
html[data-theme="dark"] .tool-card-icon img.icon-dark {
  display: block;
}

/* v1.8.4 final tool card icons: one span, one background image, no IMG artifacts. */
.tool-card-icon {
  width: 56px;
  height: 56px;
  min-width: 56px;
  flex: 0 0 56px;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  box-shadow: none;
  overflow: visible;
}

.tool-card-icon::before,
.tool-card-icon::after {
  content: none;
  display: none;
}

.tool-card-icon img,
.tool-card-icon-img {
  display: none;
}







.tool-card:hover .tool-card-icon,
.tool-card:focus-visible .tool-card-icon {
  opacity: 1;
  visibility: visible;
  transform: translateY(-1px) scale(1.025);
}

/* v1.8.5 final visible tool icons: one IMG per card, loaded directly from /static/icons/. */
.pts-tool-card-icon {
  width: 56px;
  height: 56px;
  min-width: 56px;
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  line-height: 0;
}

.pts-tool-card-icon::before,
.pts-tool-card-icon::after {
  content: none;
  display: none;
}

.pts-tool-card-icon__img {
  display: block;
  width: 56px;
  height: 56px;
  min-width: 56px;
  max-width: 56px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  box-shadow: none;
  opacity: 1;
  visibility: visible;
  pointer-events: none;
  transform: none;
}

.tool-card:hover .pts-tool-card-icon,
.tool-card:focus-visible .pts-tool-card-icon {
  transform: translateY(-1px) scale(1.025);
}

.tool-card:hover .pts-tool-card-icon__img,
.tool-card:focus-visible .pts-tool-card-icon__img {
  opacity: 1;
  visibility: visible;
  transform: none;
}


/* v2.1-icons: generic two-file tool card icons.
   Each tool uses /static/icons/{tool-name}-light.svg and /static/icons/{tool-name}-dark.svg.
   CSS decides which image is visible. Icon paths do not use ?v=. */
.pts-tool-card-icon {
  width: 56px;
  height: 56px;
  min-width: 56px;
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  position: relative;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  line-height: 0;
}

.pts-tool-card-icon::before,
.pts-tool-card-icon::after {
  content: none;
  display: none;
}

.pts-tool-card-icon__img {
  grid-area: 1 / 1;
  display: none;
  width: 56px;
  height: 56px;
  min-width: 56px;
  max-width: 56px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  box-shadow: none;
  opacity: 1;
  visibility: visible;
  pointer-events: none;
  transform: none;
}

html:not([data-theme="dark"]) .pts-tool-card-icon__img--light,
html[data-theme="light"] .pts-tool-card-icon__img--light {
  display: block;
}

html[data-theme="dark"] .pts-tool-card-icon__img--dark {
  display: block;
}

html[data-theme="dark"] .pts-tool-card-icon__img--light {
  display: none;
}

.tool-card:hover .pts-tool-card-icon,
.tool-card:focus-visible .pts-tool-card-icon {
  transform: translateY(-1px) scale(1.025);
}

.tool-card:hover .pts-tool-card-icon__img,
.tool-card:focus-visible .pts-tool-card-icon__img {
  opacity: 1;
  visibility: visible;
  transform: none;
}


/* v2.0-bg-icon: final source of truth for visible tool card icons.
   Icons are real <img> files. The wrapper has no background image, so old CSS icon layers cannot appear. */
.pts-tool-card-icon {
  background: transparent;
  background-image: none;
}

.pts-tool-card-icon__img {
  grid-area: 1 / 1;
  display: none;
  width: 56px;
  height: 56px;
  min-width: 56px;
  max-width: 56px;
  object-fit: contain;
  opacity: 1;
  visibility: visible;
}

html:not([data-theme="dark"]) .pts-tool-card-icon__img--light,
html[data-theme="light"] .pts-tool-card-icon__img--light {
  display: block;
}

html[data-theme="dark"] .pts-tool-card-icon__img--dark {
  display: block;
}

html[data-theme="dark"] .pts-tool-card-icon__img--light {
  display: none;
}

/* v1.8.0-file-export-ui:
   Wider preview for Compress / Convert and inline status/queue cards under preview. */
#compressWorkspace,
#formatWorkspace {
  grid-template-columns: minmax(280px, 320px) minmax(640px, 1fr);
}

#compressWorkspace .preview-grid,
#formatWorkspace .preview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#compressWorkspace .image-frame,
#formatWorkspace .image-frame {
  min-height: 440px;
}

#compressWorkspace .preview-area,
#formatWorkspace .preview-area,
#metadataWorkspace .preview-area {
  gap: 20px;
}

#compressWorkspace .status-card,
#formatWorkspace .status-card,
#metadataWorkspace .status-card,
#compressWorkspace .queue-position-card,
#formatWorkspace .queue-position-card,
#metadataWorkspace .queue-position-card {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

@media (max-width: 920px) {
  #compressWorkspace,
  #formatWorkspace {
    grid-template-columns: 1fr;
  }

  #compressWorkspace .preview-grid,
  #formatWorkspace .preview-grid {
    grid-template-columns: 1fr;
  }

  #compressWorkspace .image-frame,
  #formatWorkspace .image-frame {
    min-height: 360px;
  }
}

/* v1.8.3-tilt-cards-stable-hitbox:
   Pointer tilt for tool cards only. Stable hitbox tracking prevents edge jitter. */
html body .tool-home .tool-cards {
  perspective: 1000px;
  perspective-origin: 50% 45%;
}

html body .tool-home .tool-card[data-tilt-card] {
  --tilt-rx: 0deg;
  --tilt-ry: 0deg;
  --tilt-lift: 0px;
  --tilt-glow: 0;
  transform-style: preserve-3d;
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  transform:
    translate3d(0, var(--tilt-lift), 0)
    rotateX(var(--tilt-rx))
    rotateY(var(--tilt-ry));
  will-change: transform;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

html body .tool-home .tool-card[data-tilt-card]:hover,
html body .tool-home .tool-card[data-tilt-card].is-tilting,
html body .tool-home .tool-card[data-tilt-card]:focus-visible {
  transform:
    translate3d(0, var(--tilt-lift), 0)
    rotateX(var(--tilt-rx))
    rotateY(var(--tilt-ry));
  box-shadow:
    0 22px 56px rgba(28, 39, 58, 0.14),
    0 0 calc(var(--tilt-glow) * 30px) rgba(125, 211, 252, 0.20);
}

html body .tool-home .tool-card[data-tilt-card] > * {
  position: relative;
  z-index: 1;
}

html body .tool-home .tool-card[data-tilt-card] .pts-tool-card-icon {
  transform: translateZ(18px);
  transition: transform 120ms ease;
}

html body .tool-home .tool-card[data-tilt-card]:hover .pts-tool-card-icon,
html body .tool-home .tool-card[data-tilt-card].is-tilting .pts-tool-card-icon,
html body .tool-home .tool-card[data-tilt-card]:focus-visible .pts-tool-card-icon {
  transform: translateZ(22px) scale(1.035);
}

@media (pointer: coarse), (prefers-reduced-motion: reduce) {
  html body .tool-home .tool-card[data-tilt-card] {
    transform: none !important;
    transition:
      border-color 160ms ease,
      box-shadow 160ms ease;
    will-change: auto;
  }

  html body .tool-home .tool-card[data-tilt-card] .pts-tool-card-icon,
  html body .tool-home .tool-card[data-tilt-card]:hover .pts-tool-card-icon,
  html body .tool-home .tool-card[data-tilt-card]:focus-visible .pts-tool-card-icon {
    transform: none;
  }
}

/* v1.8.5-tilt-soft-icon-stability:
   Keep SVG tool icons on the card plane. Separate translateZ/scale layers can make
   browser-rasterized SVG <img> icons look softer during 3D transforms. */
html body .tool-home .tool-card[data-tilt-card] .pts-tool-card-icon,
html body .tool-home .tool-card[data-tilt-card]:hover .pts-tool-card-icon,
html body .tool-home .tool-card[data-tilt-card].is-tilting .pts-tool-card-icon,
html body .tool-home .tool-card[data-tilt-card]:focus-visible .pts-tool-card-icon {
  transform: none;
}

html body .tool-home .tool-card[data-tilt-card] .pts-tool-card-icon__img,
html body .tool-home .tool-card[data-tilt-card]:hover .pts-tool-card-icon__img,
html body .tool-home .tool-card[data-tilt-card].is-tilting .pts-tool-card-icon__img,
html body .tool-home .tool-card[data-tilt-card]:focus-visible .pts-tool-card-icon__img {
  transform: none;
  image-rendering: auto;
  backface-visibility: hidden;
}
/* End v1.8.5-tilt-soft-icon-stability. */

/* v2.2 queue progress and narrow layout stability. */
.panel,
.preview-area,
.upload-panel,
.export-panel,
.status-card,
.queue-position-card,
.queue-list,
.queue-file,
.queue-file-meta {
  min-width: 0;
}

.status-card-header,
.queue-position-header {
  min-height: 32px;
  gap: 12px;
}

.status-card-header strong,
.queue-position-header strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#statusPill,
#queuePositionPill,
.queue-position-header [data-queue-pill] {
  min-width: 104px;
  justify-content: center;
  text-align: center;
}

.status-log {
  min-height: clamp(150px, 18vh, 190px);
}

.status-log li {
  min-height: 23px;
  overflow-wrap: anywhere;
}

.queue-list {
  min-height: clamp(82px, 16vh, 180px);
  align-content: start;
}

.queue-file {
  overflow: hidden;
}

.queue-file small {
  display: block;
  min-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-status,
.queue-download {
  justify-self: end;
}

.queue-position-card {
  min-height: clamp(188px, 22vh, 246px);
  align-content: start;
}

.queue-position-grid {
  grid-template-columns: repeat(4, minmax(64px, 1fr));
}

.queue-position-grid div {
  min-height: 66px;
  display: grid;
  align-content: center;
}

.queue-position-grid strong {
  min-height: 18px;
  font-variant-numeric: tabular-nums;
}

.queue-position-card small {
  min-height: 34px;
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

@media (max-width: 720px) {
  .tool-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  html body .tool-home .tool-card[data-tilt-card],
  .tool-card {
    min-height: 128px;
    gap: 8px;
    padding: 12px;
    overflow: hidden;
    transition:
      min-height 180ms ease,
      padding 180ms ease,
      gap 180ms ease,
      border-color 160ms ease,
      box-shadow 160ms ease,
      transform 160ms ease;
  }

  .pts-tool-card-icon,
  .pts-tool-card-icon__img {
    width: 42px;
    height: 42px;
    min-width: 42px;
    max-width: 42px;
  }

  .tool-card-copy {
    gap: 0;
  }

  .tool-card strong {
    min-height: 34px;
    display: flex;
    align-items: flex-end;
    font-size: 14px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .tool-card-copy > small,
  .tool-card-note:not(.tool-card-note--speed) {
    display: none;
  }

  .tool-card-notes {
    min-height: 0;
    margin: 0;
  }

  .tool-card-note--speed {
    top: 10px;
    right: 10px;
    max-width: calc(100% - 62px);
    padding: 5px 7px;
    gap: 5px;
  }

  .tool-card-note--speed .tool-card-note-label {
    display: none;
  }

  .tool-speed {
    gap: 5px;
    font-size: 11px;
  }

  .tool-speed-dot {
    width: 7px;
    height: 7px;
  }

  .workspace,
  .editor-workspace,
  .preview-area,
  .preview-grid,
  .panel {
    max-width: 100%;
    min-width: 0;
  }

  .status-card-header,
  .queue-position-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .queue-position-card {
    min-height: clamp(210px, 30vh, 270px);
  }

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

  #backgroundWorkspace .queue-file,
  #compressWorkspace .queue-file,
  #formatWorkspace .queue-file {
    grid-template-columns: 42px minmax(0, 1fr);
    column-gap: 10px;
    row-gap: 8px;
  }

  #backgroundWorkspace .queue-status,
  #backgroundWorkspace .queue-download,
  #compressWorkspace .queue-status,
  #compressWorkspace .queue-download,
  #formatWorkspace .queue-status,
  #formatWorkspace .queue-download {
    grid-column: 2;
    justify-self: start;
    margin-left: 0;
  }
}

@media (max-width: 380px) {
  html body .tool-home .tool-card[data-tilt-card],
  .tool-card {
    min-height: 116px;
    padding: 10px;
  }

  .pts-tool-card-icon,
  .pts-tool-card-icon__img {
    width: 36px;
    height: 36px;
    min-width: 36px;
    max-width: 36px;
  }

  .tool-card strong {
    min-height: 32px;
    font-size: 13px;
  }

  .tool-card-note--speed {
    top: 8px;
    right: 8px;
    max-width: calc(100% - 54px);
    padding: 4px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .tool-home .tool-card[data-tilt-card],
  .tool-card,
  .pts-tool-card-icon,
  .pts-tool-card-icon__img,
  #queueProgressFill,
  .queue-progress-track [data-queue-progress] {
    transition: none !important;
  }
}

/* custom-icons-20260516-5: final custom icons */
.brand-logo {
  object-fit: contain;
  background: transparent;
}

.kofi-button::before,
.kofi-button::after {
  content: none !important;
  display: none !important;
}

.kofi-button .kofi-icon {
  width: 22px;
  height: 22px;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
  background: transparent;
  pointer-events: none;
}

#ptsSettingsButton::before,
#ptsSettingsButton::after {
  content: none !important;
  display: none !important;
  background: none !important;
  -webkit-mask-image: none !important;
  mask-image: none !important;
}

#ptsSettingsButton svg {
  display: none !important;
}

#ptsSettingsButton .pts-settings-icon {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

#ptsSettingsButton .pts-settings-icon-light {
  display: none;
}

:root[data-theme="light"] #ptsSettingsButton .pts-settings-icon-dark {
  display: none;
}

:root[data-theme="light"] #ptsSettingsButton .pts-settings-icon-light {
  display: block;
}

/* theme-logo-favicons-20260516-7: dynamic logo only */
.brand-logo {
  object-fit: contain;
  background: transparent;
}

/* theme-logo-favicons-20260516-7: visible CSS theme logo */
.brand-logo {
  display: inline-block !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  flex: 0 0 44px !important;
  background-color: transparent !important;
  background-image: url("/static/icons/logo-light.png?v=theme-logo-favicons-20260516-7") !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: contain !important;
  border-radius: 0 !important;
  overflow: visible !important;
}

:root[data-theme="dark"] .brand-logo {
  background-image: url("/static/icons/logo-dark.png?v=theme-logo-favicons-20260516-7") !important;
}
