/* pasted-file-editor: the editor shell, the attachment cards, and the
   preview dialog. Adapted from the vendored single-file page's styling
   (site/static/tools/pasted-file-editor.html); class names carry the pfe-
   prefix so nothing leaks into the page's own styles. */
#tool-root { max-width: none; }

.pfe-shell {
  --pfe-ink: #17202a;
  --pfe-muted: #596579;
  --pfe-line: #d8dee8;
  --pfe-accent: #146c94;
  --pfe-accent-soft: #e4f3f8;
  --pfe-danger: #aa2433;
  --pfe-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #ffffff;
  border: 1px solid var(--pfe-line);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(23, 32, 42, 0.06);
  padding: 16px;
  margin: 1rem 0;
  color: var(--pfe-ink);
}

.pfe-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.pfe-name-label { display: flex; align-items: center; gap: 8px; font-weight: 700; flex: 1 1 16rem; }
.pfe-name {
  flex: 1 1 auto;
  min-width: 8rem;
  padding: 6px 8px;
  border: 1px solid #bfc8d7;
  border-radius: 6px;
  font: 14px/1.4 var(--pfe-mono);
  color: var(--pfe-ink);
}
.pfe-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.pfe-actions button {
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid #bfc8d7;
  border-radius: 6px;
  background: #ffffff;
  color: var(--pfe-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.pfe-actions button:hover,
.pfe-actions button:focus-visible,
.pfe-name:focus,
.pfe-text:focus {
  border-color: var(--pfe-accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 148, 0.14);
  outline: none;
}

.pfe-text {
  display: block;
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 14px;
  border: 1px solid #bfc8d7;
  border-radius: 6px;
  color: var(--pfe-ink);
  font: 15px/1.45 var(--pfe-mono);
  background: #fbfcfe;
  box-sizing: border-box;
}
.pfe-shell.is-drop-target .pfe-text {
  border-color: var(--pfe-accent);
  background: #f0fbfd;
  box-shadow: inset 0 0 0 2px rgba(20, 108, 148, 0.2), 0 0 0 4px rgba(20, 108, 148, 0.14);
}

.pfe-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  margin-top: 8px;
  color: var(--pfe-muted);
  font-size: 0.9rem;
}
.pfe-threshold, .pfe-empty { margin: 8px 0 0; color: var(--pfe-muted); font-size: 0.9rem; }

.pfe-files {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.pfe-files:empty { margin-top: 0; }
.pfe-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--pfe-line);
  border-radius: 8px;
  background: #fbfcfe;
  cursor: pointer;
}
.pfe-card:hover, .pfe-card:focus-visible {
  border-color: var(--pfe-accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 148, 0.12);
  outline: none;
}
.pfe-icon { display: inline-flex; width: 32px; height: 38px; color: var(--pfe-accent); }
.pfe-thumb {
  width: 42px; height: 42px; object-fit: cover;
  border: 1px solid #bfc8d7; border-radius: 6px; background: #eef2f6;
}
.pfe-card-body { min-width: 0; }
.pfe-card-name { display: block; margin-bottom: 3px; font-weight: 700; word-break: break-word; }
.pfe-card-preview {
  display: -webkit-box;
  max-height: 2.8em;
  overflow: hidden;
  color: var(--pfe-muted);
  font: 13px/1.4 var(--pfe-mono);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  word-break: break-word;
}
.pfe-remove {
  width: 28px; height: 28px;
  border: 0; border-radius: 50%;
  background: transparent; color: #697589;
  font-size: 14px; cursor: pointer;
}
.pfe-remove:hover, .pfe-remove:focus-visible { background: #fff0f2; color: var(--pfe-danger); outline: none; }

.pfe-modal-backdrop {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 34, 0.52);
}
.pfe-modal-backdrop[hidden] { display: none; }
.pfe-modal {
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border-radius: 8px;
  background: #ffffff;
  color: #17202a;
  box-shadow: 0 18px 45px rgba(23, 32, 42, 0.14);
}
.pfe-modal-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #d8dee8;
  background: #e4f3f8;
}
.pfe-modal-title { min-width: 0; }
.pfe-modal-title h2 { margin: 0; font-size: 1.05rem; word-break: break-word; }
.pfe-modal-title p { margin: 2px 0 0; color: #596579; font-size: 0.9rem; }
.pfe-modal-content {
  margin: 0; overflow: auto; padding: 16px;
  background: #fbfcfe; color: #18212e;
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
}
.pfe-modal-content.has-image { display: grid; place-items: center; padding: 18px; white-space: normal; }
.pfe-modal-image { display: block; max-width: 100%; max-height: calc(100vh - 180px); border-radius: 6px; }

.pfe-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: 620px) {
  .pfe-shell { padding: 12px; }
  .pfe-status { flex-direction: column; }
  .pfe-files { grid-template-columns: 1fr; }
}
