.tn-ptx-page {
  --ptx-paper: #faf6ee;
  --ptx-wash: #f0e8d7;
  --ptx-ink: #241a0e;
  --ptx-muted: #645139;
  --ptx-line: #b8a888;
  --ptx-soft: #ddd4be;
  --ptx-button: #ede6d4;
  --ptx-button-text: #241a0e;
  --ptx-action-line: #b8a888;
  --ptx-hover: #dfd4bb;
  --ptx-primary: #382311;
  --ptx-primary-hover: #633511;
  --ptx-primary-text: #f7ead1;
  --ptx-focus: #963d0b;
  --ptx-board: #e6dcc6;
  --ptx-sans: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI", system-ui, sans-serif;
  --ptx-mono: "Courier New", Courier, monospace;
  color: var(--ptx-ink);
  -webkit-text-fill-color: var(--ptx-ink);
}
body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-d="dark"], [data-scheme="auto"][data-l="dark"]) .tn-ptx-page,
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-ptx-page {
  --ptx-paper: #241d12;
  --ptx-wash: #322a1a;
  --ptx-ink: #f7ead1;
  --ptx-muted: #c3b492;
  --ptx-line: #826744;
  --ptx-soft: #574a37;
  --ptx-button: #2f2115;
  --ptx-button-text: #f7ead1;
  --ptx-action-line: #826744;
  --ptx-hover: #3a2a1b;
  --ptx-primary: #6a3b1f;
  --ptx-primary-hover: #824826;
  --ptx-primary-text: #f7ead1;
  --ptx-focus: #e8823f;
  --ptx-board: #1b160d;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  body[data-scheme="auto"] .tn-ptx-page {
    --ptx-paper: #241d12;
    --ptx-wash: #322a1a;
    --ptx-ink: #f7ead1;
    --ptx-muted: #c3b492;
    --ptx-line: #826744;
    --ptx-soft: #574a37;
    --ptx-button: #2f2115;
    --ptx-button-text: #f7ead1;
    --ptx-action-line: #826744;
    --ptx-hover: #3a2a1b;
    --ptx-primary: #6a3b1f;
    --ptx-primary-hover: #824826;
    --ptx-primary-text: #f7ead1;
    --ptx-focus: #e8823f;
    --ptx-board: #1b160d;
    color-scheme: dark;
  }
}
.tn-ptx-page [hidden] { display: none !important; }
.tn-ptx-page .tn-ptx-tool {
  width: 100%;
  min-width: 0;
  margin: 0;
  color: var(--ptx-ink);
  -webkit-text-fill-color: var(--ptx-ink);
  font-family: var(--ptx-sans);
  font-size: 14px;
  line-height: 1.6;
}
.tn-ptx-tool,
.tn-ptx-tool *,
.tn-ptx-tool *::before,
.tn-ptx-tool *::after { box-sizing: border-box; }
.tn-ptx-tool :is(p, label, ol, ul, li, details, summary, output, figure) { margin: 0; padding: 0; }
.tn-ptx-tool :is(ol, ul) { list-style: none; }
.tn-ptx-tool :is(code, pre, kbd, samp) {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  background-color: transparent;
  color: inherit;
  -webkit-text-fill-color: inherit;
}

/* ---------------------------------------------------------- workspace ---- */

.tn-ptx-tool .tn-ptx-workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-areas: "source stage" "panel stage";
  align-items: start;
  min-width: 0;
  border: 1px solid var(--ptx-line);
  background: var(--ptx-paper);
}
.tn-ptx-tool .tn-ptx-source { grid-area: source; }
.tn-ptx-tool .tn-ptx-panel { grid-area: panel; }
.tn-ptx-tool .tn-ptx-stage { grid-area: stage; }
.tn-ptx-tool :is(.tn-ptx-source, .tn-ptx-panel, .tn-ptx-stage) {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
  padding: 14px;
}
.tn-ptx-tool :is(.tn-ptx-source, .tn-ptx-panel) { border-right: 1px solid var(--ptx-line); }
.tn-ptx-tool .tn-ptx-source { border-bottom: 1px solid var(--ptx-soft); }

/* ------------------------------------------------------------- upload ---- */

.tn-ptx-tool .tn-ptx-drop {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 108px;
  padding: 10px;
  border: 1px dashed var(--ptx-line);
  background: var(--ptx-wash);
  text-align: center;
  cursor: pointer;
}
.tn-ptx-tool .tn-ptx-drop > p:first-child { font-size: 13px; font-weight: 700; }
.tn-ptx-tool .tn-ptx-drop.is-dragover { border-color: var(--ptx-focus); box-shadow: inset 0 0 0 1px var(--ptx-focus); }
.tn-ptx-tool .tn-ptx-photoname {
  min-width: 0;
  color: var(--ptx-ink);
  -webkit-text-fill-color: var(--ptx-ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------- fields ---- */

.tn-ptx-tool .tn-ptx-field {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.tn-ptx-tool label {
  display: block;
  min-width: 0;
  color: var(--ptx-ink);
  -webkit-text-fill-color: var(--ptx-ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}
.tn-ptx-tool :is(input[type="color"], select, textarea) {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  border: 1px solid var(--ptx-line);
  border-radius: 0;
  background-color: var(--ptx-paper);
  color: var(--ptx-ink);
  -webkit-text-fill-color: var(--ptx-ink);
  font-family: var(--ptx-sans);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
  line-height: normal;
  letter-spacing: normal;
  box-shadow: none;
  outline: none;
}
.tn-ptx-tool :is(input[type="color"], select) {
  height: 38px;
  min-height: 38px;
  padding: 0 9px;
}
.tn-ptx-tool select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 25px;
  background-color: var(--ptx-wash);
  background-image: linear-gradient(45deg, transparent 50%, var(--ptx-ink) 50%), linear-gradient(135deg, var(--ptx-ink) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  font-size: 13px;
  cursor: pointer;
}
.tn-ptx-tool select option { background: var(--ptx-paper); color: var(--ptx-ink); }
.tn-ptx-tool input[type="color"] { padding: 4px; cursor: pointer; }
.tn-ptx-tool input[type="color"]:disabled { opacity: .5; cursor: not-allowed; }
.tn-ptx-tool textarea {
  min-height: 76px;
  padding: 8px 9px;
  /* 16px keeps iOS Safari from zooming the viewport on focus. */
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  resize: vertical;
}
.tn-ptx-tool ::placeholder {
  color: var(--ptx-muted);
  -webkit-text-fill-color: var(--ptx-muted);
  font-family: var(--ptx-sans);
  font-weight: 400;
  opacity: .35;
}
.tn-ptx-tool input[type="range"] {
  display: block;
  width: 100%;
  min-width: 0;
  height: 38px;
  margin: 0;
  padding: 0;
  accent-color: var(--ptx-focus);
  background: transparent;
  cursor: pointer;
}
.tn-ptx-tool .tn-ptx-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.tn-ptx-tool .tn-ptx-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 10px;
  min-width: 0;
}
.tn-ptx-tool .tn-ptx-wide { grid-column: 1 / -1; }
.tn-ptx-page .tn-ptx-tool .tn-ptx-check {
  display: flex !important;
  align-items: center !important;
  gap: 7px;
  min-height: 38px;
  margin-top: 24px;
  cursor: pointer;
}
.tn-ptx-page .tn-ptx-tool .tn-ptx-check.tn-ptx-wide { margin-top: 0; }
.tn-ptx-tool .tn-ptx-check > span { font-size: 13px; font-weight: 700; line-height: 1.5; }
.tn-ptx-tool .tn-ptx-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-content: center;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--ptx-line);
  border-radius: 0;
  background: var(--ptx-paper);
  color: var(--ptx-ink);
  -webkit-text-fill-color: var(--ptx-ink);
  box-shadow: none;
  cursor: pointer;
}
.tn-ptx-tool .tn-ptx-check input:checked::after {
  content: "";
  width: 5px;
  height: 9px;
  margin-top: -2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}
.tn-ptx-tool .tn-ptx-extra {
  min-width: 0;
  border: 0;
  border-top: 1px solid var(--ptx-soft);
  border-bottom: 1px solid var(--ptx-soft);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.tn-ptx-tool .tn-ptx-extra > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  color: var(--ptx-ink);
  -webkit-text-fill-color: var(--ptx-ink);
  font-size: 13px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}
.tn-ptx-tool .tn-ptx-extra > summary::-webkit-details-marker { display: none; }
.tn-ptx-tool .tn-ptx-extra > summary::marker { content: ""; }
.tn-ptx-tool .tn-ptx-extra > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin: -4px 4px 0 0;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
}
.tn-ptx-tool .tn-ptx-extra[open] > summary::after { margin-top: 4px; transform: rotate(225deg); }
.tn-ptx-tool .tn-ptx-extra > .tn-ptx-options { padding: 5px 0 12px; }

/* ------------------------------------------------------------ buttons ---- */

.tn-ptx-page .tn-ptx-tool button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
  height: 38px;
  min-height: 38px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--ptx-action-line);
  border-radius: 0;
  background: var(--ptx-button);
  color: var(--ptx-button-text);
  -webkit-text-fill-color: var(--ptx-button-text);
  font-family: var(--ptx-mono);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: normal;
  text-align: center;
  text-transform: none;
  white-space: nowrap;
  box-shadow: none;
  outline: none;
  cursor: pointer;
}
.tn-ptx-page .tn-ptx-tool button:is(:hover, :focus-visible):not(:disabled) { background: var(--ptx-hover); }
.tn-ptx-page .tn-ptx-tool :is(#tnPtxDownload, button[aria-pressed="true"]) {
  background: var(--ptx-primary);
  color: var(--ptx-primary-text);
  -webkit-text-fill-color: var(--ptx-primary-text);
  border-color: var(--ptx-focus);
}
.tn-ptx-page .tn-ptx-tool :is(#tnPtxDownload, button[aria-pressed="true"]):is(:hover, :focus-visible):not(:disabled) { background: var(--ptx-primary-hover); }
.tn-ptx-page .tn-ptx-tool button:disabled { opacity: .55; cursor: not-allowed; }
.tn-ptx-tool :is(button, input, select, textarea, summary, .tn-ptx-drop, #tnPtxCanvas):focus-visible {
  outline: 2px solid var(--ptx-focus);
  outline-offset: 2px;
}
.tn-ptx-tool #tnPtxDownload { width: 100%; }
.tn-ptx-tool .tn-ptx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.tn-ptx-page .tn-ptx-tool .tn-ptx-actions button { padding: 0 18px; }
.tn-ptx-tool .tn-ptx-align {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

/* ------------------------------------------------------- layer chooser --- */

.tn-ptx-tool .tn-ptx-layerbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ptx-soft);
}
.tn-ptx-tool .tn-ptx-layerbar > label { grid-column: 1 / -1; }
.tn-ptx-tool #tnPtxLayers {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tn-ptx-tool #tnPtxLayers li { min-width: 0; margin: 0; padding: 0; list-style: none; }
.tn-ptx-tool #tnPtxLayers li::before { content: none; }
.tn-ptx-page .tn-ptx-tool #tnPtxLayers button {
  height: 30px;
  min-height: 30px;
  max-width: 156px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tn-ptx-page .tn-ptx-tool :is(#tnPtxAddLayer, #tnPtxRemoveLayer) {
  height: 30px;
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

/* -------------------------------------------------------------- stage ---- */

.tn-ptx-tool .tn-ptx-summary {
  display: block;
  min-width: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ptx-soft);
  color: var(--ptx-ink);
  -webkit-text-fill-color: var(--ptx-ink);
  font-family: var(--ptx-sans);
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: lining-nums tabular-nums;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.tn-ptx-tool .tn-ptx-board {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 240px;
  padding: 12px;
  border: 1px solid var(--ptx-soft);
  background: var(--ptx-board);
}
.tn-ptx-tool #tnPtxCanvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 540px;
  margin: 0;
  padding: 0;
  border: 0;
  object-fit: contain;
  touch-action: none;
  cursor: grab;
}
.tn-ptx-tool #tnPtxCanvas[data-dragging="true"] { cursor: grabbing; }
.tn-ptx-tool #tnPtxEmpty {
  max-width: 300px;
  padding: 12px;
  background: var(--ptx-paper);
  text-align: center;
}
.tn-ptx-tool .tn-ptx-saverow {
  display: grid;
  grid-template-columns: minmax(0, 150px) minmax(0, 1fr);
  align-items: end;
  gap: 10px;
  min-width: 0;
}
.tn-ptx-tool .tn-ptx-saverow > .tn-ptx-primaryfield { align-self: end; }
.tn-ptx-tool :is(.tn-ptx-hint, .tn-ptx-count) {
  color: var(--ptx-muted);
  -webkit-text-fill-color: var(--ptx-muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.tn-ptx-tool .tn-ptx-count {
  font-family: var(--ptx-sans);
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
}
.tn-ptx-tool :is(#tnPtxSizeValue, #tnPtxStrokeValue, #tnPtxOpacityValue, #tnPtxQualityValue) {
  color: var(--ptx-ink);
  -webkit-text-fill-color: var(--ptx-ink);
  font-family: var(--ptx-sans);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: lining-nums tabular-nums;
}
.tn-ptx-tool #tnPtxError {
  color: var(--ptx-focus);
  -webkit-text-fill-color: var(--ptx-focus);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.tn-ptx-tool :is(#tnPtxError, #tnPtxStatus, #tnPtxFontNote):empty { display: none; }
.tn-ptx-tool #tnPtxFontNote {
  color: var(--ptx-muted);
  -webkit-text-fill-color: var(--ptx-muted);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.tn-ptx-tool :is(.tn-ptx-note, noscript p) {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--ptx-line);
  color: var(--ptx-muted);
  -webkit-text-fill-color: var(--ptx-muted);
  font-size: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

/* ----------------------------------------------------------------- ad ---- */

.tn-ptx-page .tn-ptx-ad {
  width: 100%;
  max-width: 900px;
  min-height: 90px;
  height: auto;
  max-height: none;
  margin: 24px auto;
  border: 0;
  background: transparent;
  overflow: visible;
}
.tn-ptx-page .tn-ptx-ad--top { margin-top: 0; }

/* --------------------------------------------------------- responsive ---- */

@media (max-width: 1100px) {
  .tn-ptx-tool .tn-ptx-workspace { grid-template-columns: 272px minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .tn-ptx-tool .tn-ptx-workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "source" "stage" "panel";
  }
  .tn-ptx-tool :is(.tn-ptx-source, .tn-ptx-panel) { border-right: 0; }
  .tn-ptx-tool .tn-ptx-stage { border-bottom: 1px solid var(--ptx-soft); }
  .tn-ptx-tool .tn-ptx-drop {
    grid-template-columns: minmax(0, 1fr) auto;
    justify-items: start;
    align-items: center;
    min-height: 96px;
    text-align: left;
  }
  .tn-ptx-tool .tn-ptx-drop > .tn-ptx-hint { grid-column: 1 / -1; }
  .tn-ptx-tool #tnPtxCanvas { max-height: 46vh; }
  .tn-ptx-tool .tn-ptx-board { min-height: 180px; }
  .tn-ptx-tool .tn-ptx-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .tn-ptx-tool :is(.tn-ptx-source, .tn-ptx-panel, .tn-ptx-stage) { padding: 12px; }
  .tn-ptx-tool .tn-ptx-saverow { grid-template-columns: minmax(0, 1fr); }
  .tn-ptx-page .tn-ptx-tool #tnPtxLayers button { max-width: 124px; }
}
@media (prefers-reduced-motion: reduce) {
  .tn-ptx-tool,
  .tn-ptx-tool *,
  .tn-ptx-tool *::before,
  .tn-ptx-tool *::after { animation: none; transition: none; scroll-behavior: auto; }
}
