.admin-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 44px) 48px;
}

.admin-topbar,
.admin-heading,
.editor-heading,
.illustration-heading,
.admin-heading-actions,
.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-topbar {
  min-height: 52px;
  margin-bottom: 44px;
}

.admin-brand,
.admin-link {
  color: inherit;
  text-decoration: none;
}

.parent-auth {
  width: min(520px, 100%);
  margin: clamp(50px, 10vh, 110px) auto 0;
}

.parent-form,
.editor-fields {
  display: grid;
  gap: 10px;
}

.parent-form {
  padding: 24px 0;
  border-top: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
}

.parent-form h2,
.editor h2,
.editor h3 {
  margin: 0;
}

.parent-form label,
.editor label {
  font-weight: 800;
}

.field-help {
  margin: -3px 0 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.parent-form input,
.editor input,
.editor select,
.editor textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
}

.editor textarea {
  resize: vertical;
}

.admin-heading h1 {
  margin-bottom: 0;
}

.server-admin {
  display: grid;
  gap: 16px;
  margin: 26px 0 32px;
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.server-admin-heading,
.child-form {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.server-admin-heading h2 {
  margin: 0;
}

.server-key-form,
.child-form {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.server-key-form {
  grid-template-columns: minmax(170px, 0.8fr) minmax(260px, 1fr);
}

.server-key-form label,
.child-form label {
  font-weight: 800;
}

.server-key-form .pin-row {
  grid-column: span 1;
}

.server-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.server-profile-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.server-profile-card h3,
.server-profile-card p {
  margin: 0;
}

.server-profile-card small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.server-profile-card .pin-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.server-profile-card .pin-row input {
  width: 9ch;
  text-align: center;
  letter-spacing: 0.3em;
}

.sets-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
}

.set-item {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.set-item h3,
.set-item p {
  margin: 0;
}

.set-item p {
  color: var(--muted);
}

.status-pill {
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: #e3f3f4;
  font-size: 12px;
  font-weight: 800;
}

.editor {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 4px solid var(--ink);
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  gap: 36px;
  margin-top: 28px;
}

.reference-area {
  padding-left: 28px;
  border-left: 2px solid var(--line);
}

.reference-area h3,
.reference-area p {
  margin-top: 0;
}

.reference-area p,
.illustration-heading p {
  color: var(--muted);
  line-height: 1.5;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 10px 16px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

.reference-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.reference-item {
  position: relative;
  display: grid;
  gap: 6px;
}

.reference-item img {
  aspect-ratio: 1;
}

.reference-item img,
.word-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 2px solid var(--ink);
  border-radius: 6px;
}

.reference-item input {
  min-height: 38px;
  padding: 7px 8px;
  font-size: 13px;
}

.reference-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(23, 48, 66, 0.9);
  font-weight: 900;
}

.illustration-section {
  margin-top: 38px;
}

.word-editor-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.word-editor {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.word-editor.text-only {
  grid-template-columns: 1fr;
}

.word-image-preview {
  width: 96px;
  aspect-ratio: 1;
  background: #edf2f2;
}

.word-image-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.word-editor-fields {
  display: grid;
  align-content: center;
  gap: 8px;
  min-width: 0;
}

.word-editor-fields input[type="text"] {
  min-height: 42px;
  font-weight: 800;
}

.word-upload-label {
  width: fit-content;
  color: var(--blue-dark);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.danger-button {
  min-height: 46px;
  margin-left: auto;
  padding: 10px 16px;
  border: 2px solid var(--red);
  border-radius: 8px;
  color: var(--red);
  background: var(--surface);
  font-weight: 800;
}

@media (max-width: 780px) {
  .sets-list,
  .word-editor-list,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .reference-area {
    padding: 24px 0 0;
    border-top: 2px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 520px) {
  .admin-heading,
  .editor-heading,
  .illustration-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-heading-actions,
  .editor-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .danger-button {
    margin-left: 0;
  }

  .word-editor {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .word-image-preview {
    width: 78px;
  }
}
