* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  font-family:
    Segoe UI,
    system-ui,
    Arial,
    sans-serif;
  background: #0f1115;
  color: #e6e8eb;
}
.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;
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  left: 12px;
  top: 12px;
  width: auto;
  height: auto;
  padding: 8px 12px;
  background: #6c5cff;
  color: #fff;
  border-radius: 8px;
  z-index: 9999;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: #161a21;
  border-bottom: 1px solid #222836;
  flex-wrap: wrap;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
hgroup.brand {
  margin: 0;
}
.logo {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: #6c5cff;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
}
.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.02em;
}
.sub {
  opacity: 0.7;
  font-size: 13px;
  margin: 0;
}
.hint {
  font-size: 13px;
  opacity: 0.8;
  margin: 0;
}
.hint code {
  background: #1e2330;
  padding: 2px 6px;
  border-radius: 4px;
}
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
form#kaelyForm {
  margin: 0;
}
fieldset.controls {
  border: none;
  padding: 0;
  margin: 0 0 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
}
fieldset.controls legend {
  padding: 0;
}
@media (max-width: 700px) {
  fieldset.controls {
    grid-template-columns: 1fr;
  }
}
.field label {
  font-size: 13px;
  opacity: 0.9;
  display: block;
  margin-bottom: 6px;
}
.field .row {
  display: flex;
  gap: 8px;
}
.field input[type="text"] {
  flex: 1;
  background: #161a21;
  border: 1px solid #2a3142;
  color: #e6e8eb;
  padding: 10px 12px;
  border-radius: 8px;
  outline: none;
}
.field input:focus {
  border-color: #6c5cff;
}
.field button {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #2a3142;
  background: #1e2330;
  color: #e6e8eb;
  cursor: pointer;
  font-weight: 600;
}
.field button:hover {
  background: #252d3e;
}
.field small {
  opacity: 0.6;
  font-size: 11px;
}
.field small code {
  background: #1e2330;
  padding: 1px 4px;
  border-radius: 3px;
}
.field.check {
  grid-column: 1/-1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
}
.field.check label {
  margin: 0;
  opacity: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.field.check input[type="checkbox"] {
  accent-color: #6c5cff;
  width: 16px;
  height: 16px;
}
.drop {
  border: 2px dashed #2a3142;
  border-radius: 14px;
  background: #161a21;
  padding: 28px;
  text-align: center;
  transition: 0.15s;
}
.drop.dragover {
  border-color: #6c5cff;
  background: #1a1f2e;
}
.drop .big {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 6px;
}
.drop p {
  margin: 4px 0;
  opacity: 0.85;
}
.drop .small {
  opacity: 0.6;
  font-size: 12px;
}
.link {
  background: none;
  border: none;
  color: #8b85ff;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font: inherit;
}
output.status {
  display: block;
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
}
output.status.ok {
  background: #12301f;
  border: 1px solid #1e5a33;
  color: #b8f0c9;
}
output.status.err {
  background: #2e1519;
  border: 1px solid #6b2630;
  color: #ffc2c9;
}
output.status.warn {
  background: #2e2612;
  border: 1px solid #6b5a20;
  color: #ffe7a8;
}
.hidden {
  display: none !important;
}
.progress-wrap {
  position: relative;
  height: 24px;
  background: #1e2330;
  border-radius: 8px;
  overflow: hidden;
  margin: 10px 0;
  border: 1px solid #2a3142;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6c5cff, #8b85ff);
  border-radius: 8px;
  transition: width 0.2s ease;
}
.progress-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.preview {
  margin: 18px 0;
  background: #161a21;
  border: 1px solid #222836;
  border-radius: 14px;
  padding: 16px;
}
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}
.preview h2 {
  margin: 0 0 8px;
  font-size: 16px;
}
.legend-sep {
  opacity: 0.4;
  margin: 0 4px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.legend-dot.main {
  background: #4a7cff;
}
.legend-dot.tab {
  background: #e05c5c;
}
.role-selectors {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.role-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.role-field label {
  font-size: 11px;
  opacity: 0.85;
  font-weight: 600;
}
.role-field select {
  background: #0f1115;
  border: 1px solid #2a3142;
  color: #e6e8eb;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}
.role-field select:focus {
  border-color: #6c5cff;
}
.preview-hint {
  font-size: 12px;
  opacity: 0.75;
  margin: 0 0 12px;
  line-height: 1.6;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.legend-sep {
  display: none;
}
.legend-item {
  white-space: nowrap;
}
.grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.cell {
  background: #0a0c10;
  border: 1px solid #222836;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  margin: 0;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.cell.is-main {
  border-color: #4a7cff;
  box-shadow: 0 0 0 1px #4a7cff;
}
.cell.is-tab {
  border-color: #e05c5c;
  box-shadow: 0 0 0 1px #e05c5c;
}
.cell.is-main.is-tab {
  border-color: #4a7cff;
  box-shadow:
    0 0 0 1px #e05c5c,
    0 0 0 3px #4a7cff;
}
.cell img {
  max-width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 370 / 320;
  object-fit: contain;
  image-rendering: auto;
}
.cell figcaption {
  font-size: 11px;
  opacity: 0.7;
  word-break: break-all;
  text-align: center;
}
.cell-actions {
  display: flex;
  gap: 4px;
  width: 100%;
  justify-content: center;
  margin-top: 2px;
}
.pick-btn {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border: 1px solid #2a3142;
  border-radius: 4px;
  background: #1e2330;
  color: #e6e8eb;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  text-align: center;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
.pick-btn:hover {
  background: #252d3e;
  border-color: #6c5cff;
}
.pick-btn.active-main {
  background: #4a7cff;
  border-color: #4a7cff;
  color: #fff;
}
.pick-btn.active-main:hover {
  background: #3a6aee;
}
.pick-btn.active-tab {
  background: #e05c5c;
  border-color: #e05c5c;
  color: #fff;
}
.pick-btn.active-tab:hover {
  background: #cc4a4a;
}
li[draggable="true"] {
  cursor: grab;
}
li[draggable="true"].dragging {
  opacity: 0.4;
}
li[draggable="true"].drag-over {
  border: 2px dashed #6c5cff;
  border-radius: 10px;
}
.actions {
  margin: 18px 0;
}
.actions-menu {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 12px;
}
.actions-menu li {
  margin: 0;
}
.actions-menu button {
  padding: 12px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
#btnProcess {
  background: #6c5cff;
  color: #fff;
}
#btnProcess:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.secondary {
  background: #1e2330;
  color: #e6e8eb;
  border: 1px solid #2a3142 !important;
}
.result {
  margin-top: 18px;
  padding: 16px;
  border-radius: 12px;
  background: #0f1f16;
  border: 1px solid #1e5a33;
}
.result .title {
  font-weight: 700;
  color: #8df0b0;
  margin-bottom: 8px;
}
.result .meta {
  font-size: 13px;
  opacity: 0.9;
  line-height: 1.6;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 10px;
  align-items: baseline;
}
.result .meta dt {
  font-weight: 600;
  color: #a8e6c2;
}
.result .meta dd {
  margin: 0;
  word-break: break-all;
}
.result .meta code {
  background: #132a1c;
  padding: 2px 6px;
  border-radius: 4px;
}
.result .btns {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.result a.btn,
.result button.btn {
  padding: 8px 14px;
  border-radius: 8px;
  background: #6c5cff;
  color: #fff;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.result a.btn.secondary,
.result button.btn.secondary {
  background: #1e2330;
  border: 1px solid #2a3142;
  color: #e6e8eb;
}
.result .file-list {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 8px;
  line-height: 1.6;
}
.result .file-list code {
  background: #132a1c;
  padding: 1px 4px;
  border-radius: 3px;
}
footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid #222836;
  opacity: 0.7;
  font-size: 12px;
  flex-wrap: wrap;
}
