.admin-note-form {
  display: grid;
  min-width: 0;
  margin: 0;
}

.admin-note-preview {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-height: 48px;
}

.admin-note-preview[hidden],
.admin-note-editor[hidden] {
  display: none !important;
}

.admin-note-content {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 7px 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-note-content.is-empty {
  color: #8a8179;
}

.admin-note-edit {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #dfc5ae;
  border-radius: 999px;
  background: #fffaf2;
  color: var(--orange-dark);
  font: 700 13px system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", "PingFang TC", sans-serif;
  cursor: pointer;
  transition: border-color .2s, background .2s, color .2s, transform .2s;
}

.admin-note-edit svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.admin-note-edit:hover,
.admin-note-edit:focus-visible {
  border-color: var(--orange);
  background: var(--orange);
  color: #fff;
  transform: translateY(-1px);
}

.admin-note-editor {
  display: grid;
  gap: 10px;
}

.admin-note-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.admin-note-editor textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-height: 112px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid #cfc2b2;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.admin-note-editor textarea:focus {
  outline: 3px solid #c96f3530;
  border-color: var(--orange);
}

.admin-note-editor textarea[aria-invalid=true] {
  border-color: var(--danger);
}

.admin-note-actions {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding-top: 4px;
}

.admin-note-actions small {
  width: 100%;
  color: #776e65;
  font-size: 13px;
  line-height: 1.6;
}

.admin-note-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.admin-note-buttons .primary,
.admin-note-cancel {
  min-width: 118px;
  min-height: 42px;
  font-size: 14px;
}

.admin-note-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border: 1px solid #d7c5b3;
  border-radius: 12px;
  background: transparent;
  color: #765e4c;
  font: 700 14px system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", "PingFang TC", sans-serif;
  cursor: pointer;
}

.admin-note-cancel:hover {
  border-color: var(--orange);
  color: var(--orange-dark);
}

.admin-note-error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
  line-height: 1.6;
}

.admin-cards .device[id] {
  scroll-margin-top: 24px;
}

@media (max-width: 520px) {
  .admin-note-preview {
    align-items: center;
  }

  .admin-note-edit span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .admin-note-edit {
    width: 40px;
    padding: 8px;
  }

  .admin-note-buttons {
    width: 100%;
  }

  .admin-note-buttons .primary,
  .admin-note-cancel {
    flex: 1 1 0;
    min-width: 0;
  }
}
