.pft {
  --pft-bg: var(--pf-surface, #ffffff);
  --pft-soft: var(--pf-surface-2, #fafaf9);
  --pft-soft-2: var(--pf-surface-3, #f5f5f4);
  --pft-ink: var(--pf-ink, #1c1917);
  --pft-muted: var(--pf-muted, #78716c);
  --pft-line: var(--pf-line, #e7e5e4);
  --pft-brand: var(--pf-brand, #f97316);
  --pft-brand-2: var(--pf-brand-2, #c2410c);
  --pft-brand-soft: var(--pf-brand-soft, #ffedd5);
  position: relative;
  width: 100%;
  color: var(--pft-ink);
}

.pft__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin: 0 0 12px;
}
.pft__eyebrow {
  margin: 0;
  color: var(--pft-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.pft h1,
.pft h2 {
  margin: 4px 0 0;
  font-size: 34px;
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: 0;
}
.pft__head p:not(.pft__eyebrow) {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--pft-muted);
  font-size: 15px;
}
.pft__model {
  min-width: 260px;
  display: grid;
  gap: 6px;
  color: var(--pft-muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.pft select,
.pft textarea,
.pft input[type="text"] {
  width: 100%;
  border: 1px solid var(--pft-line);
  border-radius: 10px;
  background: var(--pft-bg);
  color: var(--pft-ink);
}
.pft select {
  min-height: 42px;
  padding: 0 12px;
  text-transform: none;
  font-size: 13px;
  font-weight: 650;
}

.pft__grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
}
.pft__grid::after {
  content: "AI";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: 54px;
  height: 118px;
  display: grid;
  place-items: center;
  border: 1px solid var(--pft-line);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 107, 53, .13), rgba(15, 118, 110, .13)),
    var(--pf-bg, #f8faf7);
  color: var(--pft-brand-2);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .08em;
  box-shadow: var(--pf-shadow-soft, 0 10px 30px rgba(23, 33, 31, .07));
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.pft__grid::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: 1px;
  height: calc(100% - 42px);
  background: var(--pft-line);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.pft__panel {
  min-height: 500px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--pft-line);
  border-radius: 22px;
  background: var(--pft-bg);
  box-shadow: var(--pf-shadow-soft, 0 8px 26px rgba(28, 25, 23, .07));
  transition: border-color .18s ease, box-shadow .18s ease;
}
.pft__panel:focus-within {
  border-color: rgba(249, 115, 22, .45);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .08), var(--pf-shadow-soft, 0 8px 26px rgba(28, 25, 23, .07));
}
.pft__panel--result {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, .08), transparent 44%),
    var(--pft-soft);
  box-shadow: inset 0 2px 18px rgba(28, 25, 23, .04);
}
.pft__bar {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--pft-line);
  background: rgba(245, 245, 244, .72);
  color: var(--pft-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 900;
}
html.pf-dark body .pft__bar,
body.pf-dark .pft__bar { background: rgba(28, 25, 23, .55); }
.pft__bar button {
  border: 0;
  background: transparent;
  color: var(--pft-brand-2);
  font-weight: 900;
  cursor: pointer;
}
.pft__bar button:disabled { opacity: .45; cursor: not-allowed; }
.pft textarea {
  flex: 1;
  min-height: 390px;
  resize: vertical;
  padding: 22px;
  border: 0;
  border-radius: 0;
  background: transparent;
  line-height: 1.65;
  outline: 0;
}
.pft textarea::placeholder,
.pft input::placeholder { color: var(--pf-soft, #a8a29e); }
.pft__actions,
.pft__runline,
.pft__refine {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.pft__actions {
  padding: 12px;
  border-top: 1px solid var(--pft-line);
}
.pft button,
.pft__upload {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--pft-line);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
}
.pft__ghost,
.pft__upload {
  background: var(--pft-bg);
  color: var(--pft-muted);
}
.pft__ghost:hover,
.pft__upload:hover {
  color: var(--pft-brand);
  border-color: var(--pft-brand-soft);
  background: rgba(249, 115, 22, .07);
}
.pft__upload input { display: none; }
.pft__output {
  flex: 1;
  padding: 22px;
  overflow: auto;
  color: var(--pft-ink);
  line-height: 1.7;
  white-space: pre-wrap;
}
.pft__empty {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--pf-soft, #a8a29e);
  text-align: center;
}
.pft__empty::before {
  content: "";
  width: 58px;
  height: 58px;
  display: block;
  margin: 0 auto 12px;
  border: 1px solid var(--pft-line);
  border-radius: 16px;
  background:
    linear-gradient(var(--pft-line), var(--pft-line)) 50% 40% / 26px 2px no-repeat,
    linear-gradient(var(--pft-line), var(--pft-line)) 50% 56% / 26px 2px no-repeat,
    var(--pft-bg);
}
.pft__explanation {
  margin: 0 18px 18px;
  padding: 14px 16px;
  border: 1px solid rgba(249, 115, 22, .18);
  border-radius: 14px;
  background: rgba(255, 237, 213, .42);
  color: var(--pft-muted);
  font-size: 14px;
}
html.pf-dark body .pft__explanation,
body.pf-dark .pft__explanation { background: rgba(124, 45, 18, .12); }
.pft__runline {
  margin-top: 14px;
  justify-content: space-between;
}
.pft__run {
  min-width: 190px;
  background: rgba(249, 115, 22, .94);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 14px 28px rgba(249, 115, 22, .18);
}
.pft__run:hover { background: var(--pft-brand); }
.pft__run[disabled] { opacity: .65; cursor: wait; }
.pft__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pft__chips button {
  min-height: 34px;
  background: var(--pft-bg);
  color: var(--pft-brand-2);
  font-size: 12px;
}
.pft__refine { margin-top: 12px; }
.pft__refine input {
  flex: 1;
  min-height: 42px;
  padding: 0 12px;
}
.pft__refine button {
  background: var(--pft-ink);
  color: var(--pf-bg, #fff);
  border-color: var(--pft-ink);
}
.pft__history {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}
.pft__history-item {
  padding: 10px 12px;
  border: 1px solid var(--pft-line);
  border-radius: 12px;
  background: var(--pft-soft);
  color: var(--pft-muted);
  font-size: 13px;
  cursor: pointer;
}
.pft.is-loading .pft__panel--result { position: relative; }
.pft.is-loading .pft__panel--result::after {
  content: 'Нейросеть думает...';
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(var(--pf-bg-rgb, 253, 251, 247), .82);
  color: var(--pft-brand-2);
  font-weight: 900;
  backdrop-filter: blur(6px);
}

@media (max-width: 920px) {
  .pft__head,
  .pft__grid { display: block; }
  .pft__model { margin-top: 14px; min-width: 0; }
  .pft__grid::before,
  .pft__grid::after { display: none; }
  .pft__panel { min-height: 320px; margin-top: 14px; }
  .pft textarea { min-height: 240px; }
  .pft__run { width: 100%; min-height: 48px; }
}

@media (max-width: 560px) {
  .pft h1,
  .pft h2 { font-size: 24px; }
  .pft__head p:not(.pft__eyebrow) { display: none; }
  .pft__bar { padding: 0 12px; }
  .pft textarea,
  .pft__output { padding: 16px; }
  .pft__actions { gap: 8px; }
  .pft button,
  .pft__upload { flex: 1 1 auto; padding-inline: 10px; }
}
