/* Posting Center · Templates Editor (Phase 0)
   Achievements-class visuals: animated brand glow, gradient hero number,
   pulsing dot, mono digits, card-grid with hover lift.

   Accessible from:
     • Unit Detail page  (per-unit edit button)
     • Posting Center    (cadence flow)
   Entry: openPostingTemplates(unitId) in js/pages/posting-templates.js
*/

/* ────────────────────────────────────────────────────────────────────
   Modal scrim + frame
   ──────────────────────────────────────────────────────────────────── */
.pt-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 5, 0.78);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.pt-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.pt-modal {
  position: relative;
  width: min(1320px, 100%);
  height: min(900px, calc(100vh - 48px));
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  isolation: isolate;
  transform: translateY(8px) scale(0.985);
  transition: transform 220ms cubic-bezier(.34,1.56,.64,1);
}
.pt-overlay.is-open .pt-modal { transform: translateY(0) scale(1); }

/* ────────────────────────────────────────────────────────────────────
   Hero strip — same visual language as Achievements hero
   ──────────────────────────────────────────────────────────────────── */
.pt-hero {
  position: relative;
  overflow: hidden;
  padding: 26px 32px 24px;
  border-bottom: 1px solid var(--border-light);
  isolation: isolate;
}
.pt-hero-glow {
  position: absolute;
  inset: -50% -10% auto auto;
  width: 55%;
  height: 220%;
  background: radial-gradient(closest-side, rgba(232,97,58,0.50), rgba(232,97,58,0.15) 35%, transparent 70%);
  filter: blur(40px);
  pointer-events: none;
  z-index: 0;
  animation: pt-glow-drift 18s ease-in-out infinite alternate;
}
@keyframes pt-glow-drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-6%, 4%) scale(1.08); }
}
.pt-hero-grain {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(232,97,58,0.06) 0, transparent 40%),
    radial-gradient(circle at 82% 78%, rgba(232,97,58,0.04) 0, transparent 35%);
  pointer-events: none;
  z-index: 0;
}
.pt-hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.pt-hero-left { min-width: 0; }
.pt-hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.18em;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
}
.pt-hero-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 12px rgba(232,97,58,0.85);
  animation: pt-pulse 2s ease-in-out infinite;
}
@keyframes pt-pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%     { opacity: 0.45; transform: scale(0.85); }
}
.pt-hero-title {
  display: flex;
  align-items: baseline;
  gap: 14px;
  line-height: 1.05;
  margin: 0 0 6px;
}
.pt-hero-num {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-weight: 600;
  font-size: clamp(38px, 5vw, 60px);
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff 0%, #FBE9E1 60%, var(--brand) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 60px rgba(232,97,58,0.20);
}
.pt-hero-num-suffix {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--brand);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pt-hero-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  max-width: 540px;
}
.pt-hero-meta {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}
.pt-hero-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
}
.pt-hero-meta-val {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.pt-hero-meta-lab {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.pt-hero-close {
  position: absolute;
  top: 18px; right: 18px;
  z-index: 2;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 160ms ease;
}
.pt-hero-close:hover {
  border-color: var(--brand);
  color: var(--brand);
  transform: rotate(90deg);
}

/* ────────────────────────────────────────────────────────────────────
   Body — split into [unit rail | editor]
   ──────────────────────────────────────────────────────────────────── */
.pt-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 0;
  overflow: hidden;
}

/* Unit rail */
.pt-rail {
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(0,0,0,0.10);
}
.pt-rail-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-light);
}
.pt-rail-search {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 160ms ease, background 160ms ease;
}
.pt-rail-search:focus {
  border-color: var(--brand);
  background: rgba(232,97,58,0.06);
}
.pt-rail-list {
  overflow-y: auto;
  padding: 8px;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.10) transparent;
}
.pt-rail-list::-webkit-scrollbar { width: 6px; }
.pt-rail-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); border-radius: 3px; }

.pt-rail-grp {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 14px 12px 6px;
}

.pt-rail-item {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  transition: all 140ms ease;
  position: relative;
}
.pt-rail-item:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border-light);
}
.pt-rail-item.is-active {
  background: rgba(232,97,58,0.10);
  border-color: rgba(232,97,58,0.35);
  color: var(--text);
}
.pt-rail-item.is-active::before {
  content: "";
  position: absolute;
  left: -8px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 22px;
  background: var(--brand);
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(232,97,58,0.7);
}
.pt-rail-item-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.pt-rail-item-cmp {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pt-rail-item-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.05);
  border-radius: 9px;
  padding: 3px 8px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.pt-rail-item.is-active .pt-rail-item-count {
  background: rgba(232,97,58,0.18);
  color: var(--brand);
}
.pt-rail-item-zero .pt-rail-item-count {
  color: var(--warn, #d99);
  background: rgba(217,153,153,0.10);
}

/* ────────────────────────────────────────────────────────────────────
   Editor pane
   ──────────────────────────────────────────────────────────────────── */
.pt-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.pt-editor-head {
  padding: 18px 28px 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.pt-editor-h-left { min-width: 0; }
.pt-editor-h-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 3px;
}
.pt-editor-h-meta {
  font-size: 12px;
  color: var(--text-tertiary);
}
.pt-editor-h-actions { display: flex; gap: 8px; }

.pt-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-light);
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 160ms ease;
  font-family: inherit;
}
.pt-btn:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.18);
}
.pt-btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.pt-btn-primary:hover {
  background: var(--brand);
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(232,97,58,0.25);
}
.pt-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.pt-btn-danger:hover {
  border-color: rgba(217,80,80,0.6);
  color: rgba(255,150,150,1);
  background: rgba(217,80,80,0.08);
}
.pt-btn svg { width: 14px; height: 14px; }

/* Templates list inside editor */
.pt-list {
  overflow-y: auto;
  padding: 18px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}
.pt-list::-webkit-scrollbar { width: 8px; }
.pt-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); border-radius: 4px; }

.pt-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-tertiary);
  gap: 12px;
}
.pt-empty-glow {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(232,97,58,0.30), transparent 70%);
  filter: blur(8px);
  position: absolute;
  pointer-events: none;
}
.pt-empty-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(232,97,58,0.10);
  border: 1px solid rgba(232,97,58,0.30);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  position: relative;
}
.pt-empty-icon svg { width: 24px; height: 24px; }
.pt-empty-msg { font-size: 13px; color: var(--text-secondary); max-width: 360px; line-height: 1.5; }

/* Template card */
.pt-card {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 200ms ease, transform 200ms cubic-bezier(.34,1.56,.64,1), box-shadow 200ms ease;
  position: relative;
  flex-shrink: 0;
}
.pt-card:hover {
  border-color: rgba(232,97,58,0.30);
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.30), 0 0 0 1px rgba(232,97,58,0.05);
}
.pt-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}
.pt-card-flag {
  width: 34px; height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}
.pt-card-flag.pt-ar {
  background: linear-gradient(135deg, rgba(232,97,58,0.15), rgba(232,97,58,0.06));
  color: var(--brand);
  border-color: rgba(232,97,58,0.3);
}
.pt-card-flag.pt-en {
  background: linear-gradient(135deg, rgba(91,162,232,0.15), rgba(91,162,232,0.06));
  color: #5BA2E8;
  border-color: rgba(91,162,232,0.3);
}
.pt-card-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: 6px;
  transition: background 160ms ease;
}
.pt-card-title:focus {
  background: rgba(232,97,58,0.08);
  outline: 1px solid rgba(232,97,58,0.3);
}
.pt-card-title::placeholder { color: var(--text-tertiary); }
.pt-card-actions { display: flex; gap: 4px; }
.pt-icon-btn {
  width: 28px; height: 28px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all 140ms ease;
}
.pt-icon-btn svg { width: 14px; height: 14px; }
.pt-icon-btn:hover {
  background: rgba(255,255,255,0.07);
  color: var(--text);
}
.pt-icon-btn.pt-icon-danger:hover {
  background: rgba(217,80,80,0.10);
  border-color: rgba(217,80,80,0.30);
  color: rgba(255,150,150,1);
}

.pt-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.pt-card-edit {
  padding: 14px 18px;
  border-right: 1px solid var(--border-light);
}
.pt-card-edit-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.pt-textarea {
  width: 100%;
  min-height: 200px;
  background: rgba(0,0,0,0.20);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  outline: none;
  resize: vertical;
  transition: border-color 160ms ease;
}
.pt-textarea:focus {
  border-color: var(--brand);
  background: rgba(0,0,0,0.30);
}
.pt-textarea[dir="rtl"] {
  font-family: var(--font-arabic, "IBM Plex Sans Arabic", sans-serif);
  font-size: 14px;
  text-align: right;
}

.pt-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.pt-var-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(232,97,58,0.10);
  border: 1px solid rgba(232,97,58,0.30);
  color: var(--brand);
  border-radius: 14px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 140ms ease;
  font-weight: 500;
}
.pt-var-chip:hover {
  background: rgba(232,97,58,0.20);
  transform: translateY(-1px);
}

.pt-card-preview {
  padding: 14px 18px;
  background: rgba(0,0,0,0.10);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pt-preview-bubble {
  background: linear-gradient(180deg, #2A2624, #1F1B19);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  flex: 1;
  overflow-y: auto;
  position: relative;
  font-family: var(--font-sans);
}
.pt-preview-bubble[dir="rtl"] {
  font-family: var(--font-arabic, "IBM Plex Sans Arabic", sans-serif);
  font-size: 14px;
}
.pt-preview-bubble::before {
  content: "";
  position: absolute;
  bottom: 14px;
  left: -7px;
  width: 14px;
  height: 14px;
  background: linear-gradient(225deg, #2A2624, #1F1B19);
  border-left: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  transform: rotate(45deg);
  border-radius: 0 0 0 4px;
}
.pt-preview-empty {
  color: var(--text-tertiary);
  font-style: italic;
  text-align: center;
  padding: 30px 0;
}

.pt-card-foot {
  padding: 8px 18px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(0,0,0,0.12);
}
.pt-foot-status {
  font-size: 11px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.pt-foot-saving {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--brand);
}
.pt-foot-saving::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brand);
  animation: pt-pulse 1s ease-in-out infinite;
}
.pt-foot-saved {
  color: var(--text-tertiary);
}

.pt-card-add {
  background: transparent;
  border: 1px dashed rgba(255,255,255,0.15);
  border-radius: 14px;
  padding: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 200ms ease;
  font-family: inherit;
  font-weight: 500;
}
.pt-card-add:hover {
  background: rgba(232,97,58,0.05);
  border-color: rgba(232,97,58,0.40);
  color: var(--brand);
}
.pt-card-add svg { width: 16px; height: 16px; }

/* Lang segmented switch on each card head */
.pt-lang-seg {
  display: inline-flex;
  background: rgba(0,0,0,0.20);
  border-radius: 7px;
  padding: 2px;
  border: 1px solid var(--border-light);
}
.pt-lang-seg button {
  background: transparent;
  border: none;
  padding: 4px 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  transition: all 120ms ease;
}
.pt-lang-seg button.is-on {
  background: rgba(232,97,58,0.20);
  color: var(--brand);
}

/* Drag handle on card */
.pt-card-grip {
  cursor: grab;
  color: var(--text-tertiary);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity 140ms ease;
}
.pt-card:hover .pt-card-grip { opacity: 1; }
.pt-card.pt-dragging {
  opacity: 0.5;
}
.pt-card.pt-drag-over {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(232,97,58,0.25) inset;
}

/* AI generation popover (shown from "Generate AI" button) */
.pt-ai-pop {
  position: absolute;
  top: 38px;
  right: 0;
  z-index: 6;
  background: linear-gradient(180deg, #2C2826, #1F1C1A);
  border: 1px solid rgba(232,97,58,0.40);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55), 0 0 24px rgba(232,97,58,0.18);
  padding: 12px;
  width: 380px;
  display: none;
  animation: pt-ai-fade 200ms cubic-bezier(.34,1.56,.64,1);
}
.pt-ai-pop.is-open { display: block; }
@keyframes pt-ai-fade {
  0%   { opacity: 0; transform: translateY(-6px); }
  100% { opacity: 1; transform: translateY(0); }
}
.pt-ai-pop-h {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-tertiary);
  padding: 0 4px 8px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 8px;
}
.pt-ai-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pt-ai-style-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 9px;
  transition: background 140ms ease;
}
.pt-ai-style-row:hover {
  background: rgba(232,97,58,0.08);
}
.pt-ai-style-info { min-width: 0; }
.pt-ai-style-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1px;
}
.pt-ai-style-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pt-ai-pick {
  padding: 5px 10px !important;
  font-size: 11px !important;
  min-width: 38px;
}
.pt-ai-pick:hover {
  background: rgba(232,97,58,0.20) !important;
  border-color: var(--brand) !important;
  color: var(--brand) !important;
}
.pt-ai-pop-foot {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  font-size: 10.5px;
  color: var(--text-tertiary);
  text-align: center;
}

/* Duplicate-from-unit picker (small inline modal) */
.pt-dupe-pop {
  position: absolute;
  top: 56px;
  right: 20px;
  z-index: 5;
  background: linear-gradient(180deg, #2C2826, #1F1C1A);
  border: 1px solid rgba(232,97,58,0.35);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
  padding: 14px;
  width: 320px;
  display: none;
}
.pt-dupe-pop.is-open { display: block; }
.pt-dupe-pop h4 {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.pt-dupe-pop .sub {
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}
.pt-dupe-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pt-dupe-item {
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: all 140ms ease;
  font-family: inherit;
}
.pt-dupe-item:hover {
  background: rgba(232,97,58,0.10);
  border-color: rgba(232,97,58,0.40);
}
.pt-dupe-item .cnt {
  float: right;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-tertiary);
}

/* responsive */
@media (max-width: 900px) {
  .pt-body { grid-template-columns: 1fr; }
  .pt-rail { display: none; }
  .pt-card-body { grid-template-columns: 1fr; }
  .pt-card-edit { border-right: none; border-bottom: 1px solid var(--border-light); }
}

/* ────────────────────────────────────────────────────────────────────
   RESPONSIVE — mobile/tablet (additive, behind media queries only)
   Templates: hero → unit rail → editor/preview side-by-side
   ──────────────────────────────────────────────────────────────────── */

/* Tablet (≤1024px) — stack editor over preview, keep rail */
@media (max-width: 1024px) {
  .pt-modal { width: 100%; max-width: none; height: 100vh; max-height: 100vh; border-radius: 0; }
  .pt-overlay { padding: 0; }

  .pt-hero-inner { padding: 14px 16px; }
  .pt-hero-meta { gap: 14px; }

  .pt-body { grid-template-columns: 240px 1fr; }
  .pt-rail { min-width: 0; }

  /* Stack editor & preview at tablet */
  .pt-card-body { grid-template-columns: 1fr; }
  .pt-card-edit { border-right: none; border-bottom: 1px solid var(--border-light); }

  /* Show hover-only affordances by default */
  .pt-rail-item-count,
  .pt-editor-h-actions { opacity: 1; }

  .pt-btn { min-height: 36px; }
  .pt-textarea { min-height: 160px; }
}

/* Phone (≤640px) — fully collapsed, rail becomes top selector */
@media (max-width: 640px) {
  .pt-hero { padding: 0; }
  .pt-hero-inner { flex-wrap: wrap; gap: 12px; padding: 12px 14px; }
  .pt-hero-title { font-size: 18px; }
  .pt-hero-num { font-size: 18px; }
  .pt-hero-meta {
    gap: 12px 18px;
    flex-wrap: wrap;
    width: 100%;
  }
  .pt-hero-close { width: 32px; height: 32px; }

  /* Body becomes single column; rail shown as horizontally scrolling chip strip */
  .pt-body { grid-template-columns: 1fr; }
  .pt-rail {
    display: flex;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    max-height: 120px;
    min-height: 0;
  }
  .pt-rail-head { padding: 8px 10px; flex: 0 0 auto; }
  .pt-rail-search input { font-size: 16px; }
  .pt-rail-list {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: row;
    gap: 6px;
    padding: 6px 8px;
    white-space: nowrap;
    scrollbar-width: none;
  }
  .pt-rail-list::-webkit-scrollbar { display: none; }
  .pt-rail-grp { display: inline-flex; flex-direction: row; gap: 6px; padding: 0; border: 0; }
  .pt-rail-item {
    flex: 0 0 auto;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    background: rgba(255,255,255,0.03);
  }
  .pt-rail-item.is-active { border-color: var(--brand); }
  .pt-rail-item.is-active::before { display: none; }

  /* Editor header */
  .pt-editor-head { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 14px; }
  .pt-editor-h-actions { width: 100%; flex-wrap: wrap; }
  .pt-editor-h-actions .pt-btn { flex: 1 1 auto; }

  /* Editor + preview already stacked at 900px; tighten */
  .pt-card-body { gap: 0; }
  .pt-card-edit,
  .pt-card-preview { padding: 12px 14px; }
  .pt-textarea {
    min-height: 160px;
    font-size: 13px;       /* mono — still readable */
  }
  /* Arabic textarea needs ≥16px to prevent iOS zoom */
  .pt-textarea[dir="rtl"] { font-size: 16px; }

  /* Variable chip rows wrap */
  .pt-vars { gap: 5px; }
  .pt-var-chip { font-size: 11px; padding: 5px 10px; min-height: 30px; }

  /* Duplicate-from popover */
  .pt-dupe-pop {
    width: calc(100% - 24px);
    right: 12px;
    left: 12px;
  }
}

/* Touch tap-target enforcement */
@media (hover: none) and (pointer: coarse) {
  .pt-btn,
  .pt-rail-item,
  .pt-var-chip,
  .pt-hero-close,
  .pt-icon-btn,
  .pt-dupe-item,
  .pt-ai-pick { min-height: 36px; }
  .pt-hero-close { min-width: 36px; }
  .pt-icon-btn { min-width: 36px; }
}

/* ────────────────────────────────────────────────────────────────────
   Additional gap-fills — AI popover, card header, empty state
   ──────────────────────────────────────────────────────────────────── */

/* Tablet (≤1024px) — keep AI popover inside viewport */
@media (max-width: 1024px) {
  .pt-ai-pop {
    width: min(380px, calc(100vw - 32px));
    right: 0;
  }
  .pt-card-head { flex-wrap: wrap; gap: 8px; }
  .pt-card-title { min-width: 140px; }
}

/* Phone (≤640px) — finer tweaks */
@media (max-width: 640px) {
  /* AI popover spans the screen width */
  .pt-ai-pop {
    width: calc(100vw - 24px);
    right: 12px;
    left: 12px;
    top: 44px;
  }
  /* Style row simpler on phone — let title wrap, keep button right */
  .pt-ai-style-row {
    grid-template-columns: 1fr auto;
    gap: 6px;
  }
  .pt-ai-style-desc { white-space: normal; }

  /* Card head wraps; flag + title + lang + actions */
  .pt-card-head { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .pt-card-title { font-size: 13.5px; flex: 1 1 100%; order: 2; }
  .pt-card-flag { order: 1; }
  .pt-lang-seg { order: 3; }
  .pt-card-actions { order: 4; margin-left: auto; }

  /* Card foot stacks meta info if cramped */
  .pt-card-foot { flex-wrap: wrap; gap: 6px; padding: 8px 12px; }

  /* Empty state padding */
  .pt-empty { padding: 32px 16px; }
  .pt-empty-icon { width: 48px; height: 48px; }
  .pt-empty-msg { font-size: 12.5px; }

  /* Rail item count chip tighter */
  .pt-rail-item-count { padding: 2px 7px; font-size: 10.5px; }

  /* List padding */
  .pt-list { padding: 12px 14px 20px; gap: 12px; }

  /* Card add stays tappable */
  .pt-card-add { padding: 16px 12px; min-height: 56px; }
}
