.tower-content-status {
  margin: -4px 0 16px;
  padding: 10px 12px;
  border: 1px solid #e0b24f;
  border-radius: var(--radius);
  background: #fff9e8;
  color: #6f5315;
  font-size: .78rem;
  line-height: 1.5;
}

.tower-admin-entry {
  border: 1px solid var(--tp);
  border-radius: 4px;
  background: var(--tp);
  color: #fff;
  padding: 5px 9px;
  font: 600 .72rem var(--ft);
  cursor: pointer;
  white-space: nowrap;
}

.tower-admin-entry:hover {
  background: #fff;
  color: var(--tp);
}

.tower-admin-entry:focus-visible {
  outline: 3px solid rgba(54, 111, 157, .38);
  outline-offset: 3px;
}

html.tower-editor-open,
html.tower-editor-open body {
  overflow: hidden;
}

.tower-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 18px;
  background: rgba(20, 23, 28, .58);
  backdrop-filter: blur(3px);
}

.tower-editor-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  max-height: 100%;
  overflow: hidden;
  border: 1px solid #d7dbe0;
  border-radius: 10px;
  background: #f7f8fa;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .22);
  color: #292d33;
}

.tower-editor-header,
.tower-editor-toolbar,
.tower-editor-footer,
.tower-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tower-editor-header {
  padding: 14px 18px;
  border-bottom: 1px solid #dde1e6;
  background: #fff;
}

.tower-editor-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.tower-editor-heading h2 {
  font-size: 1rem;
  line-height: 1.3;
}

.tower-editor-revision {
  color: #777e88;
  font-size: .72rem;
  white-space: nowrap;
}

.tower-editor-draft-state {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: #edf1f4;
  color: #59616b;
  font-size: .67rem;
  font-weight: 700;
  white-space: nowrap;
}

.tower-editor-draft-state.dirty {
  background: #fff1c8;
  color: #765513;
}

.tower-editor-draft-state.publishing {
  background: #e7f1ff;
  color: #245d91;
}

.tower-editor-draft-state.published {
  background: #e6f5ea;
  color: #287948;
}

.tower-editor-draft-state.conflict,
.tower-editor-draft-state.readonly {
  background: #ffe6e6;
  color: #932f2f;
}

.tower-editor-close,
.tower-editor-action,
.tower-editor-mini,
.tower-editor-submit,
.tower-editor-tab {
  border: 1px solid #cfd4da;
  border-radius: 5px;
  background: #fff;
  color: #30343a;
  font-family: var(--ft);
  font-weight: 600;
  cursor: pointer;
}

.tower-editor-close,
.tower-editor-action {
  padding: 6px 10px;
  font-size: .75rem;
}

.tower-editor-action:hover,
.tower-editor-close:hover,
.tower-editor-mini:hover:not(:disabled) {
  border-color: #707780;
  background: #f1f3f5;
}

.tower-editor-close:focus-visible,
.tower-editor-action:focus-visible,
.tower-editor-mini:focus-visible,
.tower-editor-submit:focus-visible,
.tower-editor-tab:focus-visible,
.tower-editor-input:focus-visible,
.tower-editor-note:focus-visible,
.tower-editor-url-preview:focus-visible {
  outline: 3px solid rgba(54, 111, 157, .34);
  outline-offset: 2px;
}

.tower-editor-action.primary,
.tower-editor-submit {
  border-color: #24282d;
  background: #24282d;
  color: #fff;
}

.tower-editor-warning,
.tower-editor-conflict {
  margin: 10px 18px 0;
  padding: 9px 11px;
  border-radius: 5px;
  font-size: .76rem;
  line-height: 1.45;
}

.tower-editor-warning {
  border: 1px solid #e0b24f;
  background: #fff8df;
  color: #6f5315;
}

.tower-editor-conflict {
  border: 1px solid #d77a7a;
  background: #fff0f0;
  color: #8c2929;
}

.tower-editor-warning[hidden],
.tower-editor-conflict[hidden],
.tower-history-panel[hidden] {
  display: none;
}

.tower-editor-toolbar {
  flex: none;
  padding: 10px 18px;
  border-bottom: 1px solid #dde1e6;
  background: #fff;
}

.tower-editor-tabs,
.tower-editor-toolbar-actions,
.tower-editor-card-tools,
.tower-editor-submit-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.tower-editor-tabs {
  overflow: hidden;
  gap: 0;
  border: 1px solid #cfd4da;
  border-radius: 5px;
}

.tower-editor-tab {
  min-width: 88px;
  padding: 6px 13px;
  border: 0;
  border-radius: 0;
  font-size: .76rem;
}

.tower-editor-tab + .tower-editor-tab {
  border-left: 1px solid #cfd4da;
}

.tower-editor-tab.active {
  background: #292d33;
  color: #fff;
}

.tower-editor-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px 24px;
  overscroll-behavior: contain;
}

.tower-editor-card {
  padding: 13px;
  border: 1px solid #d9dde2;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.tower-editor-card.dragging {
  opacity: .5;
  border-style: dashed;
}

.tower-editor-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.tower-editor-drag {
  color: #7e858e;
  font-size: .7rem;
  cursor: grab;
  user-select: none;
}

.tower-editor-card-title {
  overflow: hidden;
  color: #292d33;
  font-size: .84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tower-editor-mini {
  padding: 4px 7px;
  font-size: .68rem;
}

.tower-editor-mini.danger {
  border-color: #e0b9b9;
  color: #a53232;
}

.tower-editor-mini:disabled,
.tower-editor-action:disabled,
.tower-editor-submit:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.tower-editor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.tower-editor-field,
.tower-editor-note-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  margin-top: 10px;
}

.tower-editor-grid .tower-editor-field {
  margin-top: 0;
}

.tower-editor-field-label,
.tower-editor-note-label > span {
  color: #626973;
  font-size: .7rem;
  font-weight: 600;
}

.tower-editor-input,
.tower-editor-note {
  width: 100%;
  border: 1px solid #ccd2d8;
  border-radius: 5px;
  background: #fff;
  color: #25292e;
  font: .77rem/1.5 var(--ft);
  outline: none;
}

.tower-editor-input {
  padding: 7px 8px;
}

textarea.tower-editor-input {
  min-height: 84px;
  resize: vertical;
  white-space: pre-wrap;
}

.tower-editor-input:focus,
.tower-editor-note:focus {
  border-color: #4e6f8f;
  box-shadow: 0 0 0 2px rgba(78, 111, 143, .12);
}

.tower-editor-url-state {
  font-size: .67rem;
}

.tower-editor-url-state.valid {
  color: #287948;
}

.tower-editor-url-state.invalid,
.tower-editor-validation {
  color: #ad3434;
}

.tower-editor-url-preview {
  width: fit-content;
  color: #24658e;
  font-size: .69rem;
  text-decoration: none;
}

.tower-editor-url-preview:hover {
  text-decoration: underline;
}

.tower-editor-empty {
  padding: 36px 16px;
  color: #7b828b;
  font-size: .8rem;
  text-align: center;
}

.tower-editor-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  flex: none;
  align-items: flex-end;
  padding: 12px 18px;
  border-top: 1px solid #d9dde2;
  background: #fff;
  box-shadow: 0 -8px 18px rgba(30, 35, 42, .06);
}

.tower-editor-footer-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tower-editor-summary {
  font-size: .76rem;
}

.tower-editor-validation {
  font-size: .7rem;
}

.tower-editor-note-label {
  max-width: 520px;
  margin-top: 3px;
}

.tower-editor-note {
  height: 32px;
  padding: 0 8px;
}

.tower-editor-submit {
  min-width: 116px;
  padding: 9px 15px;
  font-size: .8rem;
  white-space: nowrap;
}

.tower-editor-submit-actions {
  flex: 0 0 230px;
  justify-content: flex-end;
}

.tower-editor-submit-hint {
  flex: 1 0 100%;
  color: #777e88;
  font-size: .68rem;
  line-height: 1.35;
  text-align: right;
}

.tower-editor-submit-hint.ready {
  color: #287948;
}

.tower-editor-submit-hint.blocked {
  color: #8a5a25;
}

.tower-history-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #f7f8fa;
}

.tower-history-head {
  padding: 14px 18px;
  border-bottom: 1px solid #d9dde2;
  background: #fff;
}

.tower-history-head h3 {
  font-size: .95rem;
}

.tower-history-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  padding: 14px 18px;
}

.tower-history-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  padding: 11px 12px;
  border: 1px solid #d9dde2;
  border-radius: 6px;
  background: #fff;
}

.tower-history-card strong {
  font-size: .78rem;
}

.tower-history-meta {
  color: #7b828b;
  font-size: .68rem;
}

.tower-history-note {
  grid-column: 1 / 3;
  color: #555c65;
  font-size: .74rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 820px) {
  .tower-editor-overlay {
    padding: 0;
  }

  .tower-editor-shell {
    width: 100%;
    border: 0;
    border-radius: 0;
  }

  .tower-editor-toolbar,
  .tower-editor-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .tower-editor-tabs {
    width: 100%;
  }

  .tower-editor-tab {
    flex: 1;
  }

  .tower-editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tower-editor-submit-actions {
    flex-basis: auto;
    justify-content: flex-end;
  }

  .tower-editor-submit-hint {
    text-align: left;
  }

  .tower-editor-close,
  .tower-editor-action,
  .tower-editor-submit,
  .tower-editor-tab {
    min-height: 44px;
  }
}

@media (max-width: 520px) {
  .tower-admin-entry {
    order: 3;
  }

  .tower-editor-header,
  .tower-editor-toolbar,
  .tower-editor-footer,
  .tower-history-head {
    padding-right: 12px;
    padding-left: 12px;
  }

  .tower-editor-list,
  .tower-history-list {
    padding-right: 10px;
    padding-left: 10px;
  }

  .tower-editor-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .tower-editor-card-head {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .tower-editor-drag {
    display: none;
  }

  .tower-editor-card-tools {
    grid-column: 1 / -1;
  }

  .tower-editor-grid {
    grid-template-columns: 1fr;
  }

  .tower-editor-footer {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    max-height: 42vh;
    overflow: hidden;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .tower-editor-footer-info {
    min-height: 0;
    overflow-y: auto;
  }

  .tower-editor-submit-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    width: 100%;
  }

  .tower-editor-submit-hint {
    grid-column: 1 / -1;
  }

  .tower-editor-submit {
    min-width: 128px;
  }

  .tower-history-card {
    grid-template-columns: 1fr auto;
  }

  .tower-history-meta,
  .tower-history-note {
    grid-column: 1 / -1;
  }
}
