/* Faction application form: modern cards + BBCode toolbar */
.faction-app-modern .app-form-progress {
  background: #262a33;
  border-bottom: 1px solid #3a4150;
  padding: 12px 16px 14px;
}
.faction-app-modern .app-form-progress p {
  color: #959fb4;
  margin: 0 0 8px;
  font-size: 13px;
}
.faction-app-modern .app-form-track {
  background: #1c212b;
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}
.faction-app-modern .app-form-track > span {
  background: #4080ff;
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  transition: width .2s ease;
}
.faction-app-modern form.panel {
  overflow: hidden;
}
.faction-app-modern .reg-table {
  display: block;
  width: 100%;
  counter-reset: appq;
}
.faction-app-modern .reg-table tbody { display: block; }
.faction-app-modern .reg-table tr {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  background: #2b2f38;
  border-bottom: 1px solid #3a4150;
  padding: 16px 16px 18px;
}
@media (min-width: 760px) {
  .faction-app-modern .reg-table tr:not(.app-form-section) {
    grid-template-columns: minmax(180px, 32%) minmax(0, 1fr);
    align-items: start;
    gap: 18px;
  }
}
.faction-app-modern .reg-table th,
.faction-app-modern .reg-table td {
  display: block;
  width: auto;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  font-weight: 600;
  color: #e0e6f0;
}
.faction-app-modern .reg-table tr:not(.app-form-section) th::before {
  counter-increment: appq;
  content: "Question " counter(appq);
  display: block;
  color: #97baff;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
}
.faction-app-modern .reg-table tr.app-form-section {
  display: block;
  padding: 0;
}
.faction-app-modern .reg-table tr.app-form-section td {
  text-align: center;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #97baff;
  background: #262a33;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 650;
}
.faction-app-modern .reg-required {
  color: #e8749a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-top: 4px;
}
.faction-app-modern .bbcode-field textarea {
  width: 100%;
  min-height: 148px;
  resize: vertical;
}
.faction-app-modern .bbcode-tools {
  margin-bottom: 6px;
}
.faction-app-modern .bbcode-tools .composer-bar {
  align-items: center;
}
.faction-app-modern .bbcode-tools select {
  background: #252a33;
  color: #e0e6f0;
  border: 1px solid #3a4150;
  border-radius: 4px;
  height: 28px;
  font-size: 12px;
  padding: 0 6px;
}
.faction-app-modern .bbcode-preview-toggle {
  margin-left: auto;
  color: #97baff !important;
  font-weight: 700;
  font-size: 12px;
}
.faction-app-modern .bbcode-preview {
  color: #e0e6f0;
  background: #252a33;
  border: 1px solid #3a4150;
  border-radius: 6px;
  min-height: 148px;
  padding: 10px 12px;
}
.faction-app-modern .bbcode-count {
  color: #959fb4;
  margin: 6px 0 0;
  font-size: 12px;
  text-align: right;
}
.faction-app-modern form.panel > .border-t {
  padding: 16px;
  background: #262a33;
}
.faction-app-modern form.panel button[type="submit"],
.faction-app-modern form.panel .border-t button {
  min-width: 160px;
}
.faction-app-modern .page-wrap > h1 {
  letter-spacing: -0.02em;
}
.faction-app-modern .app-form-lead {
  color: #959fb4;
  margin: 6px 0 0;
  font-size: 14px;
}

.faction-app-modern .bbcode-field textarea.bbcode-source {
  display: none;
  width: 100%;
  min-height: 148px;
  resize: vertical;
}
.faction-app-modern .bbcode-field.is-source textarea.bbcode-source {
  display: block;
}
.faction-app-modern .bbcode-field.is-source .bbcode-visual {
  display: none;
}
.faction-app-modern .bbcode-visual {
  color: #e0e6f0;
  background: #252a33;
  border: 1px solid #3a4150;
  border-radius: 6px;
  min-height: 148px;
  padding: 10px 12px;
  overflow: auto;
  outline: none;
}
.faction-app-modern .bbcode-visual:focus {
  border-color: #4080ff;
  box-shadow: 0 0 0 2px rgba(64, 128, 255, .25);
}
.faction-app-modern .bbcode-visual p { margin: 0 0 .7em; }
.faction-app-modern .bbcode-visual p:last-child { margin-bottom: 0; }
.faction-app-modern .bbcode-visual img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}
.faction-app-modern .bbcode-visual [data-spoiler],
.bbcode-paste-preview [data-spoiler] {
  background: #1c212b;
  border: 1px dashed #3a4150;
  border-radius: 4px;
  padding: 4px 8px;
  display: inline-block;
}
.faction-app-modern .bbcode-paste-btn,
.faction-app-modern .bbcode-source-toggle {
  margin-left: 4px;
  color: #97baff !important;
  font-weight: 700 !important;
  font-size: 12px;
}
.faction-app-modern .bbcode-paste-btn {
  border: 1px solid #4080ff !important;
  border-radius: 4px;
  padding: 0 8px;
  background: rgba(64, 128, 255, .15) !important;
}

.bbcode-paste-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(8, 10, 14, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.bbcode-paste-modal-backdrop[hidden] { display: none; }
.bbcode-paste-modal {
  background: #2b2f38;
  border: 1px solid #3a4150;
  border-radius: 12px;
  width: min(960px, 100%);
  max-height: min(90vh, 820px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
  color: #e0e6f0;
}
.bbcode-paste-head { padding: 16px 18px 8px; }
.bbcode-paste-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -.02em;
}
.bbcode-paste-head p {
  margin: 6px 0 0;
  color: #959fb4;
  font-size: 14px;
}
.bbcode-paste-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 8px 18px 12px;
  min-height: 0;
  flex: 1;
}
@media (max-width: 720px) {
  .bbcode-paste-grid { grid-template-columns: 1fr; }
}
.bbcode-paste-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 220px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #97baff;
}
.bbcode-paste-input,
.bbcode-paste-preview {
  flex: 1;
  min-height: 240px;
  max-height: 48vh;
  overflow: auto;
  background: #252a33;
  border: 1px solid #3a4150;
  border-radius: 8px;
  color: #e0e6f0;
  padding: 10px 12px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  font-size: 14px;
}
.bbcode-paste-input {
  width: 100%;
  resize: vertical;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  line-height: 1.45;
}
.bbcode-paste-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}
.bbcode-paste-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid #3a4150;
}
.bbcode-paste-actions button {
  min-width: 110px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #3a4150;
  background: #262a33;
  color: #e0e6f0;
  font-weight: 650;
  cursor: pointer;
}
.bbcode-paste-actions .bbcode-paste-insert {
  background: #4080ff;
  border-color: #4080ff;
  color: #fff;
}
body.bbcode-modal-open { overflow: hidden; }

.faction-post-meta {
  color: #959fb4;
  font-size: 13px;
  margin: 0 0 1em;
  padding-bottom: 10px;
  border-bottom: 1px solid #3a4150;
}
.faction-app-modern .rich-editor .bbcode-paste-btn {
  margin-left: auto;
}
.faction-app-modern .rich-editor.is-source .rich-surface {
  display: none;
}
.faction-app-modern .rich-editor textarea.bbcode-rich-source {
  display: block;
  width: 100%;
  min-height: 180px;
  margin-top: 8px;
  background: #252a33;
  color: #e0e6f0;
  border: 1px solid #3a4150;
  border-radius: 6px;
  padding: 10px 12px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
  resize: vertical;
}

.bbcode-visual.is-drop-target,
.rich-surface.is-drop-target,
.bbcode-image-drop.is-drop-target {
  outline: 2px dashed #4080ff;
  outline-offset: 2px;
  background: rgba(64, 128, 255, 0.08);
}
.prose-pcrp img,
.bbcode-visual img,
.bbcode-paste-preview img {
  cursor: zoom-in;
  max-width: 100%;
  height: auto;
}

.bbcode-image-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 14, 0.72);
  padding: 24px;
}
.bbcode-image-modal-backdrop[hidden] { display: none; }
.bbcode-image-modal {
  width: min(460px, 100%);
  background: #1c2028;
  color: #e0e6f0;
  border: 1px solid #3a4150;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}
.bbcode-image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}
.bbcode-image-head h2 {
  margin: 0;
  font-size: 18px;
}
.bbcode-image-close {
  border: 0;
  background: transparent;
  color: #959fb4;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.bbcode-image-tabs {
  display: flex;
  gap: 6px;
  padding: 0 16px;
}
.bbcode-image-tab {
  flex: 1;
  height: 34px;
  border: 1px solid #3a4150;
  border-radius: 8px 8px 0 0;
  background: #262a33;
  color: #c5cce0;
  font-weight: 650;
  cursor: pointer;
}
.bbcode-image-tab.is-active {
  background: #4080ff;
  border-color: #4080ff;
  color: #fff;
}
.bbcode-image-panel { padding: 14px 16px 16px; }
.bbcode-image-label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #959fb4;
}
.bbcode-image-url {
  height: 38px;
  border-radius: 8px;
  border: 1px solid #3a4150;
  background: #252a33;
  color: #e0e6f0;
  padding: 0 10px;
}
.bbcode-image-preview-wrap {
  margin-top: 12px;
  min-height: 120px;
  border: 1px dashed #3a4150;
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 10px;
  background: #161a22;
}
.bbcode-image-preview {
  max-width: 100%;
  max-height: 180px;
  height: auto;
  border-radius: 4px;
}
.bbcode-image-preview-empty {
  margin: 0;
  color: #959fb4;
  font-size: 13px;
  text-align: center;
}
.bbcode-image-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}
.bbcode-image-insert {
  min-width: 110px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #4080ff;
  background: #4080ff;
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}
.bbcode-image-insert:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.bbcode-image-drop {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 140px;
  border: 1px dashed #3a4150;
  border-radius: 8px;
  background: #161a22;
  color: #c5cce0;
  text-align: center;
  padding: 16px;
  cursor: pointer;
}
.bbcode-image-drop input { display: none; }
.bbcode-image-status {
  margin: 10px 0 0;
  font-size: 13px;
  color: #c5cce0;
}
.bbcode-image-status.is-error { color: #f27d77; }

.bbcode-lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 14, 0.86);
  padding: 32px;
  cursor: zoom-out;
}
.bbcode-lightbox[hidden] { display: none; }
.bbcode-lightbox img {
  max-width: min(1100px, 94vw);
  max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  cursor: default;
}
.bbcode-lightbox-close {
  position: absolute;
  top: 16px;
  right: 18px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
}

.bb-video,
video.bb-video,
.prose-pcrp video,
.bbcode-visual video,
.bbcode-paste-preview video,
.bbcode-image-preview-video {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #111;
}

.prose-pcrp img,
.bb-img,
.bbcode-visual img,
.bbcode-paste-preview img {
  max-width: 100%;
  height: auto;
}
.bb-table,
.prose-pcrp table.bb-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}
.bb-table td,
.bb-table th {
  border: 1px solid #3a4150;
  padding: 6px 8px;
  vertical-align: top;
}
.bb-cite {
  margin: 0 0 0.5em;
  font-weight: 650;
  color: #959fb4;
  font-size: 13px;
}
.bb-youtube {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 16 / 9;
  margin: 8px 0;
  background: #111;
}
.bb-youtube iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 8px;
}
.spoiler-title {
  display: block;
  margin-bottom: 4px;
}

.bb-gif-video {
  max-width: 100%;
  height: auto;
}
details.bb-spoiler,
.prose-pcrp details.bb-spoiler,
.bbcode-visual details.bb-spoiler,
.bbcode-paste-preview details.bb-spoiler {
  display: block;
  margin: 10px 0;
  background: #1c2028;
  border: 1px solid #3a4150;
  border-radius: 8px;
  padding: 0;
}
details.bb-spoiler > summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 12px;
  font-weight: 650;
  color: #e0e6f0;
  background: #262a33;
  border-radius: 8px;
}
details.bb-spoiler[open] > summary {
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid #3a4150;
}
details.bb-spoiler > summary::-webkit-details-marker { display: none; }
details.bb-spoiler > summary::before {
  content: "▸ ";
  color: #97baff;
}
details.bb-spoiler[open] > summary::before { content: "▾ "; }
.bb-spoiler-body { padding: 10px 12px 12px; }
details.bb-ispoiler {
  display: inline;
  margin: 0 0.1em;
}
details.bb-ispoiler > summary {
  display: inline;
  cursor: pointer;
  list-style: none;
  background: #111318;
  color: #111318;
  border-radius: 3px;
  padding: 0 4px;
  font-weight: 650;
}
details.bb-ispoiler > summary::-webkit-details-marker { display: none; }
details.bb-ispoiler[open] > summary { display: none; }
details.bb-ispoiler .bb-ispoiler-body {
  background: #2a3140;
  border-radius: 3px;
  padding: 0 3px;
}
.bb-indent {
  margin: 6px 0 6px 2em;
}
.bbcode-toolbar { flex-wrap: wrap; }
