/* PSD to PNG Converter — files, settings, preview and layers.
   Colours come from the shared tokens, so the panel follows the light and dark themes. */
.p2p {
  display: grid;
  gap: 1.25rem;
  padding: clamp(16px, 2.4vw, 32px);
  text-align: left;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--shade);
  min-width: 0;
}
.p2p *, .p2p *::before, .p2p *::after { box-sizing: border-box; }
.p2p [hidden] { display: none !important; }
.p2p h2 { margin: 0 0 .35rem; font-size: 1.45rem; letter-spacing: -.02em; }
.p2p h3 { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.p2p h4 { margin: 0 0 .4rem; font-size: .95rem; }
.p2p p { margin: 0; color: var(--ink-soft); }
.p2p-head p { max-width: 76ch; }
.p2p .p2p-sr { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.p2p label { display: grid; gap: .3rem; min-width: 0; font-size: .85rem; font-weight: 650; }
.p2p select, .p2p input[type="number"] {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: .5rem .6rem;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
}
.p2p input[aria-invalid="true"] { border-color: var(--error); box-shadow: inset 0 0 0 1px var(--error); }
.p2p input[type="color"] { width: 64px; min-height: 42px; padding: 2px; background: var(--field); border: 1.5px solid var(--border-soft); border-radius: 6px; cursor: pointer; }
.p2p :is(input, select, button, [tabindex]):focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.p2p button, .p2p-add {
  min-height: 42px;
  padding: .5rem .95rem;
  font: inherit;
  font-weight: 650;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.p2p button:disabled { opacity: .5; cursor: default; }
.p2p .p2p-primary, .p2p .p2p-add { color: var(--on-action); background: var(--action); box-shadow: 3px 3px 0 var(--shade); }
.p2p .p2p-primary:hover:not(:disabled), .p2p .p2p-add:hover { background: var(--primary-dark); }
.p2p .p2p-check { display: flex; align-items: center; gap: .55rem; min-height: 42px; font-size: .95rem; font-weight: 500; }
.p2p .p2p-check input { flex: none; width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--action); }
.p2p-hint { font-size: .85rem; }
.p2p-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* Adding files */
.p2p-drop { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; padding: 1.4rem; background: var(--blue-tint); border: 2px dashed var(--line); border-radius: 10px; }
.p2p-drop p { flex: 1 1 18rem; font-size: .9rem; }
.p2p-drop.p2p-over { border-style: solid; box-shadow: inset 0 0 0 3px var(--primary); }
.p2p-drop.p2p-drop-small { padding: .9rem 1rem; }
.p2p-add { position: relative; display: inline-flex; align-items: center; font-size: 1rem; }
.p2p-add input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.p2p-add:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Settings */
.p2p-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr)); align-items: end; gap: .9rem 1.2rem; margin: 0; padding: 1rem; background: var(--paper-3); border: 2px solid var(--line); border-radius: 10px; min-width: 0; }
.p2p-settings > legend { padding: 0 .35rem; font-weight: 750; }
.p2p-wide { grid-column: 1 / -1; }
.p2p-pills { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0; padding: 0; border: 0; min-width: 0; }
.p2p-pills > legend { width: 100%; margin-bottom: .4rem; padding: 0; font-size: .85rem; font-weight: 700; }
.p2p-pills > label:not(.p2p-swatch) { position: relative; display: inline-flex; align-items: center; min-height: 42px; padding: .45rem .9rem; font-size: .92rem; font-weight: 600; background: var(--bg-2); border: 2px solid var(--line); border-radius: 999px; cursor: pointer; }
.p2p-pills > label:not(.p2p-swatch) input { position: absolute; opacity: 0; pointer-events: none; }
.p2p-pills > label:not(.p2p-swatch):has(input:checked) { color: var(--on-action); background: var(--action); box-shadow: 2px 2px 0 var(--shade); }
.p2p-pills > label:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.p2p-swatch { display: inline-flex !important; grid-auto-flow: column; align-items: center; gap: .5rem !important; font-weight: 600 !important; }
.p2p-settings .p2p-hint { padding: .45rem .7rem; color: var(--ink); background: var(--warning-soft); border-left: 4px solid var(--warning); border-radius: 6px; }

/* Batch */
.p2p-summary { display: grid; gap: .6rem; padding: .9rem 1rem; border: 2px solid var(--line); border-radius: 10px; }
.p2p-totals { font-weight: 650; color: var(--ink) !important; overflow-wrap: anywhere; }
.p2p-summary progress { width: 100%; height: 10px; accent-color: var(--action); }
.p2p-files { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.p2p-file { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .8rem; align-items: center; padding: .55rem .7rem; background: var(--bg-2); border: 1.5px solid var(--border-soft); border-radius: 8px; }
.p2p-file.p2p-selected { border: 2px solid var(--line); box-shadow: 3px 3px 0 var(--shade); }
.p2p .p2p-file-name { justify-self: start; display: inline-flex; align-items: center; min-height: 38px; padding: .15rem 0; font-weight: 700; text-align: left; background: none; border: 0; border-radius: 4px; overflow-wrap: anywhere; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.p2p-file-meta { grid-column: 1; font-size: .85rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.p2p-file[data-status="error"] .p2p-file-meta { color: var(--error); font-weight: 600; }
.p2p-file-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }
.p2p-file-actions button { min-height: 38px; padding: .35rem .7rem; font-size: .88rem; }

/* Preview and layers */
.p2p-workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.p2p-preview, .p2p-layers { display: grid; gap: .8rem; min-width: 0; padding: 1rem; border: 2px solid var(--line); border-radius: 10px; }
.p2p-preview-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.p2p-zoom > label:not(.p2p-swatch) { min-height: 38px; padding: .3rem .8rem; }
.p2p-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 220px;
  max-height: min(70vh, 760px);
  overflow: auto;
  background-color: var(--field);
  background-image: conic-gradient(var(--border-faint) 25%, transparent 0 50%, var(--border-faint) 0 75%, transparent 0);
  background-size: 20px 20px;
  border: 1.5px solid var(--border-soft);
  border-radius: 8px;
}
.p2p-stage img { display: block; width: auto; height: auto; max-width: 100%; max-height: min(68vh, 740px); object-fit: contain; }
.p2p-stage[data-zoom="actual"] { place-items: start; }
.p2p-stage[data-zoom="actual"] img { max-width: none; max-height: none; }
.p2p-stage-note { position: absolute; inset: auto .6rem .6rem; padding: .4rem .7rem; font-weight: 650; color: var(--ink) !important; background: var(--bg-2); border: 1.5px solid var(--line); border-radius: 6px; overflow-wrap: anywhere; }
.p2p-stage-note[data-error="true"] { background: var(--error-soft); border-color: var(--error); }
.p2p-facts { display: grid; gap: .35rem; margin: 0; font-size: .88rem; }
.p2p-facts div { display: grid; grid-template-columns: minmax(7.5rem, auto) minmax(0, 1fr); gap: .8rem; padding: .3rem 0; border-bottom: 1px solid var(--border-faint); }
.p2p-facts dt { font-weight: 700; }
.p2p-facts dd { margin: 0; color: var(--ink-soft); overflow-wrap: anywhere; }
.p2p-notes { padding: .7rem .9rem; background: var(--warning-soft); border-left: 4px solid var(--warning); border-radius: 6px; }
.p2p-notes ul { display: grid; gap: .35rem; margin: 0; padding-left: 1.1rem; font-size: .88rem; }
.p2p-notes li { overflow-wrap: anywhere; }
.p2p-layer-tools { display: grid; gap: .7rem; }
.p2p-layer-list { display: grid; gap: 2px; max-height: 34rem; margin: 0; padding: 0; overflow: auto; list-style: none; border: 1.5px solid var(--border-soft); border-radius: 8px; }
.p2p-layer { display: grid; grid-template-columns: auto auto 48px minmax(0, 1fr) auto; align-items: center; gap: .5rem; padding: .35rem .5rem .35rem calc(.5rem + var(--depth, 0) * .9rem); background: var(--bg-2); border-bottom: 1px solid var(--border-faint); }
.p2p-layer-off .p2p-thumb, .p2p-layer-off .p2p-layer-text { opacity: .5; }
.p2p-pick { width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--action); }
.p2p .p2p-eye { display: inline-grid; place-items: center; width: 38px; min-height: 38px; padding: 0; border-width: 1.5px; border-radius: 6px; }
.p2p .p2p-eye svg { width: 20px; height: 20px; }
.p2p .p2p-eye[aria-pressed="false"] { color: var(--ink-soft); background: var(--paper-3); }
.p2p-thumb { display: grid; place-items: center; width: 48px; height: 48px; font-weight: 700; color: var(--ink-soft); background-color: var(--field); background-image: conic-gradient(var(--border-faint) 25%, transparent 0 50%, var(--border-faint) 0 75%, transparent 0); background-size: 8px 8px; border: 1px solid var(--border-soft); border-radius: 4px; overflow: hidden; }
.p2p-thumb canvas { max-width: 100%; max-height: 100%; }
.p2p-layer-text { display: grid; min-width: 0; }
.p2p-layer-name { font-weight: 650; overflow-wrap: anywhere; }
.p2p-layer-meta { font-size: .78rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.p2p-flag { padding: .15rem .45rem; font-size: .72rem; font-weight: 700; color: var(--ink); background: var(--warning-soft); border: 1px solid var(--warning); border-radius: 999px; white-space: nowrap; }
.p2p-status { min-height: 1.4em; font-weight: 600; color: var(--ink) !important; overflow-wrap: anywhere; }
.p2p-status[data-error="true"] { padding: .5rem .75rem; background: var(--error-soft); border-left: 4px solid var(--error); border-radius: 6px; }
.p2p-foot { font-size: .85rem; }

@media (max-width: 900px) {
  .p2p-workspace { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .p2p-file { grid-template-columns: minmax(0, 1fr); }
  .p2p-file-actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
  .p2p-layer { grid-template-columns: auto auto 40px minmax(0, 1fr); padding-left: calc(.4rem + min(var(--depth, 0), 4) * .6rem); }
  .p2p-thumb { width: 40px; height: 40px; }
  .p2p-flag { grid-column: 4; justify-self: start; }
  .p2p-facts div { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
}

/* Space the page holds for this view until it mounts (see .tool-view-placeholder in _workspace.css).
   Each height is a little under the space the view takes at that width, measured as how far the
   content below moves when the view replaces the placeholder, so nothing below it moves. Re-measure
   after changing the view's layout: node scripts/measure-tool-views.js --apply psd-to-png. */
.tool-view-placeholder[data-tool="psd-to-png"] { min-height: 609px; }
@media (max-width: 992px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 679px; } }
@media (max-width: 928px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 701px; } }
@media (max-width: 784px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 723px; } }
@media (max-width: 648px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 753px; } }
@media (max-width: 580px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 775px; } }
@media (max-width: 528px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 931px; } }
@media (max-width: 480px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 1005px; } }
@media (max-width: 464px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 1059px; } }
@media (max-width: 448px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 1083px; } }
@media (max-width: 416px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 1129px; } }
@media (max-width: 376px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 1176px; } }
@media (max-width: 344px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 1216px; } }
@media (max-width: 340px) { .tool-view-placeholder[data-tool="psd-to-png"] { min-height: 1237px; } }
